@tiledev/sdk-apptile-live-selling 0.10.0 → 0.12.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 +94 -1
- package/dist/auctions.d.ts.map +1 -1
- package/dist/auctions.js +22 -1
- package/dist/auctions.js.map +1 -1
- package/dist/commentLinkCards.d.ts +11 -0
- package/dist/commentLinkCards.d.ts.map +1 -0
- package/dist/commentLinkCards.js +70 -0
- package/dist/commentLinkCards.js.map +1 -0
- package/dist/commentLinks.d.ts +29 -0
- package/dist/commentLinks.d.ts.map +1 -1
- package/dist/commentLinks.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -3
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +21 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.web.d.ts +13 -0
- package/dist/react/index.web.d.ts.map +1 -1
- package/dist/react/index.web.js +35 -1
- package/dist/react/index.web.js.map +1 -1
- package/dist/react/showPages.d.ts +102 -0
- package/dist/react/showPages.d.ts.map +1 -0
- package/dist/react/showPages.js +155 -0
- package/dist/react/showPages.js.map +1 -0
- package/dist/react/showPagesOnDevice.d.ts +18 -0
- package/dist/react/showPagesOnDevice.d.ts.map +1 -0
- package/dist/react/showPagesOnDevice.js +31 -0
- package/dist/react/showPagesOnDevice.js.map +1 -0
- package/dist/react/useCommentLinkCards.d.ts +6 -0
- package/dist/react/useCommentLinkCards.d.ts.map +1 -0
- package/dist/react/useCommentLinkCards.js +67 -0
- package/dist/react/useCommentLinkCards.js.map +1 -0
- package/dist/react/useMySilentAuctionBids.d.ts +29 -0
- package/dist/react/useMySilentAuctionBids.d.ts.map +1 -0
- package/dist/react/useMySilentAuctionBids.js +154 -0
- package/dist/react/useMySilentAuctionBids.js.map +1 -0
- package/dist/react/useSilentAuctionLot.d.ts +42 -0
- package/dist/react/useSilentAuctionLot.d.ts.map +1 -0
- package/dist/react/useSilentAuctionLot.js +147 -0
- package/dist/react/useSilentAuctionLot.js.map +1 -0
- package/dist/react/useSilentAuctionLots.d.ts +39 -0
- package/dist/react/useSilentAuctionLots.d.ts.map +1 -0
- package/dist/react/useSilentAuctionLots.js +59 -0
- package/dist/react/useSilentAuctionLots.js.map +1 -0
- package/dist/react/useSilentAuctionRounds.d.ts +14 -0
- package/dist/react/useSilentAuctionRounds.d.ts.map +1 -0
- package/dist/react/useSilentAuctionRounds.js +40 -0
- package/dist/react/useSilentAuctionRounds.js.map +1 -0
- package/dist/replays.d.ts +7 -0
- package/dist/replays.d.ts.map +1 -1
- package/dist/replays.js +16 -0
- package/dist/replays.js.map +1 -1
- package/dist/sessionTypes.d.ts +9 -0
- package/dist/sessionTypes.d.ts.map +1 -1
- package/dist/sessionTypes.js.map +1 -1
- package/dist/shopifyCommerce.d.ts +43 -1
- package/dist/shopifyCommerce.d.ts.map +1 -1
- package/dist/shopifyCommerce.js +62 -2
- package/dist/shopifyCommerce.js.map +1 -1
- package/dist/showPages.d.ts +44 -0
- package/dist/showPages.d.ts.map +1 -0
- package/dist/showPages.js +38 -0
- package/dist/showPages.js.map +1 -0
- package/dist/silentAuctionFeed.d.ts +47 -0
- package/dist/silentAuctionFeed.d.ts.map +1 -0
- package/dist/silentAuctionFeed.js +232 -0
- package/dist/silentAuctionFeed.js.map +1 -0
- package/dist/silentAuctionRules.d.ts +206 -0
- package/dist/silentAuctionRules.d.ts.map +1 -0
- package/dist/silentAuctionRules.js +424 -0
- package/dist/silentAuctionRules.js.map +1 -0
- package/dist/silentAuctions.d.ts +65 -0
- package/dist/silentAuctions.d.ts.map +1 -0
- package/dist/silentAuctions.js +272 -0
- package/dist/silentAuctions.js.map +1 -0
- package/dist/types.d.ts +40 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMySilentAuctionBids = useMySilentAuctionBids;
|
|
4
|
+
/**
|
|
5
|
+
* My Bids as a page model (0.12.0, moved from Sparkl's `MySilentAuctionBids` on 2026-10-17): the lots
|
|
6
|
+
* this customer bid on, split into active, won and lost (`myBidsTabs`).
|
|
7
|
+
*
|
|
8
|
+
* - **The customer's bid record is the list** (`silentAuctions.bidRecord`): the service keeps no
|
|
9
|
+
* per-bidder index. Read each time the screen shows. A failed read isn't "signed out": the last
|
|
10
|
+
* record stays, and the page is `failed` only with nothing to show.
|
|
11
|
+
* - **90 entries to a page** (`loadMore`), read in one bulk call each; a batch that fails leaves the
|
|
12
|
+
* rest (`incomplete`), and only all of them failing is a failure.
|
|
13
|
+
* - **Products are read once** through the commerce adapter and kept, so a poll (every
|
|
14
|
+
* `pollIntervalMs`, 2 000: an open lot is contested) costs one bulk call. Sold-out lots stay: a won
|
|
15
|
+
* lot usually is.
|
|
16
|
+
* - **Restoring counts as loading,** so the signed-out state doesn't flash on a cold start.
|
|
17
|
+
*/
|
|
18
|
+
const react_1 = require("react");
|
|
19
|
+
const client_1 = require("../client");
|
|
20
|
+
const silentAuctionRules_1 = require("../silentAuctionRules");
|
|
21
|
+
const silentAuctions_1 = require("../silentAuctions");
|
|
22
|
+
function useMySilentAuctionBids(options) {
|
|
23
|
+
var _a, _b, _c;
|
|
24
|
+
const { signedIn, restoring = false, screenOnShow, pollIntervalMs = 2000 } = options;
|
|
25
|
+
const [record, setRecord] = (0, react_1.useState)(null);
|
|
26
|
+
const [recordRead, setRecordRead] = (0, react_1.useState)(false);
|
|
27
|
+
const [recordFailed, setRecordFailed] = (0, react_1.useState)(false);
|
|
28
|
+
const [pages, setPages] = (0, react_1.useState)(1);
|
|
29
|
+
const [items, setItems] = (0, react_1.useState)([]);
|
|
30
|
+
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
31
|
+
const [refreshing, setRefreshing] = (0, react_1.useState)(false);
|
|
32
|
+
const [lotsFailed, setLotsFailed] = (0, react_1.useState)(false);
|
|
33
|
+
const [someBatchesFailed, setSomeBatchesFailed] = (0, react_1.useState)(false);
|
|
34
|
+
/** Products by store id, kept across polls. */
|
|
35
|
+
const products = (0, react_1.useRef)(new Map());
|
|
36
|
+
/** Every read starts a new one; an answer from an older one is dropped. */
|
|
37
|
+
const generation = (0, react_1.useRef)(0);
|
|
38
|
+
const readRecord = (0, react_1.useCallback)(async () => {
|
|
39
|
+
if (!signedIn) {
|
|
40
|
+
setRecord(null);
|
|
41
|
+
setRecordFailed(false);
|
|
42
|
+
setRecordRead(true);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
setRecord(await silentAuctions_1.silentAuctions.bidRecord());
|
|
47
|
+
setRecordFailed(false);
|
|
48
|
+
}
|
|
49
|
+
catch (caught) {
|
|
50
|
+
// Not "signed out": the token may be fine and the network not. Keep what we had.
|
|
51
|
+
(0, client_1.getLogger)().error(caught, { at: 'useMySilentAuctionBids.record' });
|
|
52
|
+
setRecordFailed(true);
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
setRecordRead(true);
|
|
56
|
+
}
|
|
57
|
+
}, [signedIn]);
|
|
58
|
+
(0, react_1.useEffect)(() => {
|
|
59
|
+
if (screenOnShow)
|
|
60
|
+
void readRecord();
|
|
61
|
+
}, [screenOnShow, readRecord]);
|
|
62
|
+
const entries = (_a = record === null || record === void 0 ? void 0 : record.entries) !== null && _a !== void 0 ? _a : [];
|
|
63
|
+
const visible = (0, react_1.useMemo)(() => entries.slice(0, pages * silentAuctions_1.BID_RECORD_BATCH_SIZE), [entries, pages]);
|
|
64
|
+
const visibleKey = visible.join(',');
|
|
65
|
+
const load = (0, react_1.useCallback)(async () => {
|
|
66
|
+
const mine = ++generation.current;
|
|
67
|
+
if (visible.length === 0) {
|
|
68
|
+
setItems([]);
|
|
69
|
+
setLoading(false);
|
|
70
|
+
setRefreshing(false);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const { lots, failedBatches, totalBatches } = await silentAuctions_1.silentAuctions.lotsForBidEntries(visible);
|
|
75
|
+
if (mine !== generation.current)
|
|
76
|
+
return;
|
|
77
|
+
const missing = [...new Set(lots.map((lot) => lot.storeProductId).filter((id) => !!id && !products.current.has(id)))];
|
|
78
|
+
const commerce = (0, client_1.getCommerce)();
|
|
79
|
+
if (missing.length && commerce) {
|
|
80
|
+
const read = await commerce.productsByIds(missing);
|
|
81
|
+
if (mine !== generation.current)
|
|
82
|
+
return;
|
|
83
|
+
for (const product of read)
|
|
84
|
+
products.current.set(product.storeProductId, product);
|
|
85
|
+
}
|
|
86
|
+
const next = [];
|
|
87
|
+
for (const lot of lots) {
|
|
88
|
+
const product = lot.storeProductId ? products.current.get(lot.storeProductId) : undefined;
|
|
89
|
+
if (lot.productGid && product)
|
|
90
|
+
next.push({ lot, product: product });
|
|
91
|
+
}
|
|
92
|
+
setItems(next);
|
|
93
|
+
setLotsFailed(totalBatches > 0 && failedBatches === totalBatches);
|
|
94
|
+
setSomeBatchesFailed(failedBatches > 0 && failedBatches < totalBatches);
|
|
95
|
+
}
|
|
96
|
+
catch (caught) {
|
|
97
|
+
if (mine !== generation.current)
|
|
98
|
+
return;
|
|
99
|
+
(0, client_1.getLogger)().error(caught, { at: 'useMySilentAuctionBids.lots' });
|
|
100
|
+
setLotsFailed(true);
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
if (mine === generation.current) {
|
|
104
|
+
setLoading(false);
|
|
105
|
+
setRefreshing(false);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// The entries by value: `visible` is a new array each render.
|
|
109
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
110
|
+
}, [visibleKey]);
|
|
111
|
+
(0, react_1.useEffect)(() => {
|
|
112
|
+
if (!recordRead)
|
|
113
|
+
return;
|
|
114
|
+
void load();
|
|
115
|
+
}, [recordRead, load]);
|
|
116
|
+
(0, react_1.useEffect)(() => {
|
|
117
|
+
if (!screenOnShow || pollIntervalMs <= 0 || visible.length === 0)
|
|
118
|
+
return undefined;
|
|
119
|
+
const timer = setInterval(() => void load(), pollIntervalMs);
|
|
120
|
+
return () => clearInterval(timer);
|
|
121
|
+
}, [screenOnShow, pollIntervalMs, visible.length, load]);
|
|
122
|
+
const refresh = (0, react_1.useCallback)(() => {
|
|
123
|
+
setRefreshing(true);
|
|
124
|
+
void readRecord();
|
|
125
|
+
void load();
|
|
126
|
+
}, [readRecord, load]);
|
|
127
|
+
const hasMore = entries.length > visible.length;
|
|
128
|
+
const loadMore = (0, react_1.useCallback)(() => {
|
|
129
|
+
if (hasMore)
|
|
130
|
+
setPages((count) => count + 1);
|
|
131
|
+
}, [hasMore]);
|
|
132
|
+
const customerId = (_b = record === null || record === void 0 ? void 0 : record.customerId) !== null && _b !== void 0 ? _b : null;
|
|
133
|
+
const tabs = (0, react_1.useMemo)(() => (0, silentAuctionRules_1.myBidsTabs)(items, customerId, Date.now()), [items, customerId]);
|
|
134
|
+
const status = !signedIn && !restoring
|
|
135
|
+
? 'signedOut'
|
|
136
|
+
: restoring || !recordRead || loading
|
|
137
|
+
? 'loading'
|
|
138
|
+
: (recordFailed || lotsFailed) && items.length === 0
|
|
139
|
+
? 'failed'
|
|
140
|
+
: items.length === 0
|
|
141
|
+
? 'empty'
|
|
142
|
+
: 'ready';
|
|
143
|
+
return {
|
|
144
|
+
status,
|
|
145
|
+
...tabs,
|
|
146
|
+
customerId,
|
|
147
|
+
incomplete: ((_c = record === null || record === void 0 ? void 0 : record.skipped) !== null && _c !== void 0 ? _c : 0) > 0 || someBatchesFailed,
|
|
148
|
+
refreshing,
|
|
149
|
+
refresh,
|
|
150
|
+
hasMore,
|
|
151
|
+
loadMore,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=useMySilentAuctionBids.js.map
|
|
@@ -0,0 +1 @@
|
|
|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AC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAClD,CAAC,CAAC,QAAQ;gBACV,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;oBAClB,CAAC,CAAC,OAAO;oBACT,CAAC,CAAC,OAAO,CAAC;IAEpB,OAAO;QACL,MAAM;QACN,GAAG,IAAI;QACP,UAAU;QACV,UAAU,EAAE,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,mCAAI,CAAC,CAAC,GAAG,CAAC,IAAI,iBAAiB;QAC3D,UAAU;QACV,OAAO;QACP,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type BidCapState, type SilentAuctionLot, type SilentAuctionPhase } from '../silentAuctionRules';
|
|
2
|
+
export interface UseSilentAuctionLotOptions {
|
|
3
|
+
/** The signed-in customer's id (GID or bare), or null. A bid needs it; reading the lot doesn't. */
|
|
4
|
+
customerId: string | null;
|
|
5
|
+
/** Whether the shopper is signed in (the customer id may still be on its way). */
|
|
6
|
+
signedIn: boolean;
|
|
7
|
+
/** Sent with a bid; the service returns it as the winner's contact. */
|
|
8
|
+
email?: string | null;
|
|
9
|
+
/** The variant the shopper has chosen, which a bid is placed on. */
|
|
10
|
+
variantId?: string | null;
|
|
11
|
+
/** The screen is showing: reads only then. */
|
|
12
|
+
screenOnShow: boolean;
|
|
13
|
+
/** How often the lot is read again, ms. Default 4 000; never under 1 000. */
|
|
14
|
+
pollMs?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface SilentAuctionLotConsole {
|
|
17
|
+
/** The product's lot, or null when it isn't in a round. */
|
|
18
|
+
lot: SilentAuctionLot | null;
|
|
19
|
+
/** `failed` only before any answer. */
|
|
20
|
+
status: 'loading' | 'ready' | 'failed';
|
|
21
|
+
phase: SilentAuctionPhase | null;
|
|
22
|
+
timeLeftMs: number;
|
|
23
|
+
/** What the one-tap bid offers. */
|
|
24
|
+
nextBid: number;
|
|
25
|
+
/** The bid cap, against `nextBid`. */
|
|
26
|
+
bidCap: BidCapState;
|
|
27
|
+
/** This customer holds the leading bid. */
|
|
28
|
+
leading: boolean;
|
|
29
|
+
/** For a closed lot: won, lost, or unknown while the signed-in customer's id is on its way. */
|
|
30
|
+
outcome: 'won' | 'lost' | 'unknown';
|
|
31
|
+
/** The close was pushed back by a late bid, or the service flagged a bidding war. */
|
|
32
|
+
extended: boolean;
|
|
33
|
+
/** A bid now would push the close back. */
|
|
34
|
+
inExtensionWindow: boolean;
|
|
35
|
+
/** A bid is on its way. */
|
|
36
|
+
bidding: boolean;
|
|
37
|
+
placeBid(amount?: number): Promise<void>;
|
|
38
|
+
rebidOnVariant(): Promise<void>;
|
|
39
|
+
refresh(): void;
|
|
40
|
+
}
|
|
41
|
+
export declare function useSilentAuctionLot(productId: string | null, options: UseSilentAuctionLotOptions): SilentAuctionLotConsole;
|
|
42
|
+
//# sourceMappingURL=useSilentAuctionLot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSilentAuctionLot.d.ts","sourceRoot":"","sources":["../../src/react/useSilentAuctionLot.ts"],"names":[],"mappings":"AAsBA,OAAO,EAQL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAI/B,MAAM,WAAW,0BAA0B;IACzC,mGAAmG;IACnG,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,kFAAkF;IAClF,QAAQ,EAAE,OAAO,CAAC;IAClB,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,8CAA8C;IAC9C,YAAY,EAAE,OAAO,CAAC;IACtB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,uBAAuB;IACtC,2DAA2D;IAC3D,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC7B,uCAAuC;IACvC,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IACvC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,MAAM,EAAE,WAAW,CAAC;IACpB,2CAA2C;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,+FAA+F;IAC/F,OAAO,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;IACpC,qFAAqF;IACrF,QAAQ,EAAE,OAAO,CAAC;IAClB,2CAA2C;IAC3C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,2BAA2B;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,0BAA0B,GAAG,uBAAuB,CAgH1H"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSilentAuctionLot = useSilentAuctionLot;
|
|
4
|
+
/**
|
|
5
|
+
* One product's silent-auction lot, for its product page's bid console (0.12.0, moved from Sparkl's
|
|
6
|
+
* `useAuctionConsole` on 2026-10-17).
|
|
7
|
+
*
|
|
8
|
+
* - **Reads the lot every `pollMs`** (4 000) on a one-second tick while `screenOnShow`, one read at a
|
|
9
|
+
* time; a failed read keeps the last lot shown (a second stale beats a console that blinks out
|
|
10
|
+
* mid-round) and is `failed` only before any answer.
|
|
11
|
+
* - **A new product starts from nothing:** another product's answer says nothing about this one.
|
|
12
|
+
* - **`extended`:** the close moved later inside the anti-sniping window (`wasExtended`), or the service
|
|
13
|
+
* flagged a bidding war.
|
|
14
|
+
* - **`placeBid(amount?)`:** the one-tap bid (`nextBid`) or a typed amount, to the service; then, not
|
|
15
|
+
* awaited, the customer's bid record (`silentAuctions.recordBid`, which My Bids reads) and the variant
|
|
16
|
+
* it was placed on (`rememberBidVariant`); then a fresh read. Rejects when the service refuses.
|
|
17
|
+
* - **`rebidOnVariant()`:** the leader picked another size: the bid again at the standing amount, never
|
|
18
|
+
* `nextBid`, so changing size doesn't cost more.
|
|
19
|
+
*
|
|
20
|
+
* Which bottom bar the page draws is `productPageBuyBar`; whether this customer may bid (terms, tags,
|
|
21
|
+
* unpaid wins) stays the app's gate. No words or formatting.
|
|
22
|
+
*/
|
|
23
|
+
const react_1 = require("react");
|
|
24
|
+
const shopifyIds_1 = require("../shopifyIds");
|
|
25
|
+
const silentAuctionRules_1 = require("../silentAuctionRules");
|
|
26
|
+
const silentAuctions_1 = require("../silentAuctions");
|
|
27
|
+
const client_1 = require("../client");
|
|
28
|
+
function useSilentAuctionLot(productId, options) {
|
|
29
|
+
var _a;
|
|
30
|
+
const { customerId, signedIn, email = null, variantId = null, screenOnShow, pollMs = 4000 } = options;
|
|
31
|
+
const [lot, setLot] = (0, react_1.useState)(null);
|
|
32
|
+
const [status, setStatus] = (0, react_1.useState)('loading');
|
|
33
|
+
const [extendedSeen, setExtendedSeen] = (0, react_1.useState)(false);
|
|
34
|
+
const [bidding, setBidding] = (0, react_1.useState)(false);
|
|
35
|
+
const [now, setNow] = (0, react_1.useState)(() => Date.now());
|
|
36
|
+
/** When the last answer landed; the tick compares against it. */
|
|
37
|
+
const lastRead = (0, react_1.useRef)(0);
|
|
38
|
+
const reading = (0, react_1.useRef)(false);
|
|
39
|
+
/** The close time last shown, so an extension can be told from a first read. */
|
|
40
|
+
const previousEndsAt = (0, react_1.useRef)(null);
|
|
41
|
+
/** The product the answers are for, so one for a product the page has left is dropped. */
|
|
42
|
+
const forProduct = (0, react_1.useRef)(productId);
|
|
43
|
+
forProduct.current = productId;
|
|
44
|
+
const load = (0, react_1.useCallback)(async () => {
|
|
45
|
+
var _a;
|
|
46
|
+
if (!productId || reading.current)
|
|
47
|
+
return;
|
|
48
|
+
reading.current = true;
|
|
49
|
+
try {
|
|
50
|
+
const next = await silentAuctions_1.silentAuctions.lot(productId);
|
|
51
|
+
if (forProduct.current !== productId)
|
|
52
|
+
return;
|
|
53
|
+
const before = previousEndsAt.current;
|
|
54
|
+
setLot(next);
|
|
55
|
+
previousEndsAt.current = (_a = next === null || next === void 0 ? void 0 : next.endsAt) !== null && _a !== void 0 ? _a : null;
|
|
56
|
+
if (next && (0, silentAuctionRules_1.wasExtended)(before, next, Date.now()))
|
|
57
|
+
setExtendedSeen(true);
|
|
58
|
+
// An answer, so whatever it said is now known, "no round" included.
|
|
59
|
+
setStatus('ready');
|
|
60
|
+
}
|
|
61
|
+
catch (caught) {
|
|
62
|
+
(0, client_1.getLogger)().error(caught, { at: 'useSilentAuctionLot.read', productId });
|
|
63
|
+
if (forProduct.current === productId)
|
|
64
|
+
setStatus((previous) => (previousEndsAt.current === null ? 'failed' : previous));
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
reading.current = false;
|
|
68
|
+
lastRead.current = Date.now();
|
|
69
|
+
}
|
|
70
|
+
}, [productId]);
|
|
71
|
+
// A new product: back to knowing nothing, and read it.
|
|
72
|
+
(0, react_1.useEffect)(() => {
|
|
73
|
+
setLot(null);
|
|
74
|
+
setExtendedSeen(false);
|
|
75
|
+
previousEndsAt.current = null;
|
|
76
|
+
lastRead.current = 0;
|
|
77
|
+
if (!productId) {
|
|
78
|
+
// No product to ask about isn't a failed read.
|
|
79
|
+
setStatus('ready');
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
setStatus('loading');
|
|
83
|
+
void load();
|
|
84
|
+
}, [productId, load]);
|
|
85
|
+
// The tick: the clock moves once a second, and the lot is read again every `pollMs`.
|
|
86
|
+
(0, react_1.useEffect)(() => {
|
|
87
|
+
if (!productId || !screenOnShow)
|
|
88
|
+
return undefined;
|
|
89
|
+
const timer = setInterval(() => setNow(Date.now()), 1000);
|
|
90
|
+
return () => clearInterval(timer);
|
|
91
|
+
}, [productId, screenOnShow]);
|
|
92
|
+
(0, react_1.useEffect)(() => {
|
|
93
|
+
if (!productId || !screenOnShow)
|
|
94
|
+
return;
|
|
95
|
+
if (Date.now() - lastRead.current < Math.max(pollMs, 1000))
|
|
96
|
+
return;
|
|
97
|
+
void load();
|
|
98
|
+
}, [now, productId, screenOnShow, pollMs, load]);
|
|
99
|
+
const submit = (0, react_1.useCallback)(async (amount) => {
|
|
100
|
+
if (!productId || !customerId || bidding)
|
|
101
|
+
return;
|
|
102
|
+
setBidding(true);
|
|
103
|
+
try {
|
|
104
|
+
await silentAuctions_1.silentAuctions.bid({ productId, customerId, amount, variantId, email });
|
|
105
|
+
// The record My Bids reads, and the size to reopen on. Neither holds the bid up or fails it.
|
|
106
|
+
void silentAuctions_1.silentAuctions.recordBid(productId, lot === null || lot === void 0 ? void 0 : lot.auctionId);
|
|
107
|
+
if (variantId)
|
|
108
|
+
void silentAuctions_1.silentAuctions.rememberBidVariant(productId, variantId);
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
setBidding(false);
|
|
112
|
+
lastRead.current = 0;
|
|
113
|
+
void load();
|
|
114
|
+
}
|
|
115
|
+
}, [productId, customerId, bidding, variantId, email, lot === null || lot === void 0 ? void 0 : lot.auctionId, load]);
|
|
116
|
+
const offer = lot ? (0, silentAuctionRules_1.nextBid)(lot) : 0;
|
|
117
|
+
const leading = !!lot && (0, silentAuctionRules_1.isLeading)(lot, customerId);
|
|
118
|
+
const placeBid = (0, react_1.useCallback)((amount) => submit(amount !== null && amount !== void 0 ? amount : offer), [submit, offer]);
|
|
119
|
+
const rebidOnVariant = (0, react_1.useCallback)(async () => {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
if (!lot)
|
|
122
|
+
return;
|
|
123
|
+
await submit(((_a = lot.highestBid) !== null && _a !== void 0 ? _a : 0) > 0 ? lot.highestBid : ((_b = lot.startingPrice) !== null && _b !== void 0 ? _b : 0));
|
|
124
|
+
}, [lot, submit]);
|
|
125
|
+
const refresh = (0, react_1.useCallback)(() => {
|
|
126
|
+
lastRead.current = 0;
|
|
127
|
+
void load();
|
|
128
|
+
}, [load]);
|
|
129
|
+
const phase = lot ? (0, silentAuctionRules_1.lotPhase)(lot, now) : null;
|
|
130
|
+
return {
|
|
131
|
+
lot,
|
|
132
|
+
status,
|
|
133
|
+
phase,
|
|
134
|
+
timeLeftMs: lot ? (0, silentAuctionRules_1.timeLeftMs)(lot, now) : 0,
|
|
135
|
+
nextBid: offer,
|
|
136
|
+
bidCap: (0, silentAuctionRules_1.bidCapState)(offer, (_a = lot === null || lot === void 0 ? void 0 : lot.biddingCap) !== null && _a !== void 0 ? _a : null),
|
|
137
|
+
leading,
|
|
138
|
+
outcome: leading ? 'won' : signedIn && !(customerId && (0, shopifyIds_1.bareId)(customerId)) ? 'unknown' : 'lost',
|
|
139
|
+
extended: extendedSeen || !!(lot === null || lot === void 0 ? void 0 : lot.biddingWarAt),
|
|
140
|
+
inExtensionWindow: lot ? phase === 'live' && (0, silentAuctionRules_1.inExtensionWindow)(lot, now) : false,
|
|
141
|
+
bidding,
|
|
142
|
+
placeBid,
|
|
143
|
+
rebidOnVariant,
|
|
144
|
+
refresh,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=useSilentAuctionLot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSilentAuctionLot.js","sourceRoot":"","sources":["../../src/react/useSilentAuctionLot.ts"],"names":[],"mappings":";;AA8EA,kDAgHC;AA9LD;;;;;;;;;;;;;;;;;;GAkBG;AACH,iCAAiE;AAEjE,8CAAuC;AACvC,8DAW+B;AAC/B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Feed';
|
|
2
|
+
import { type SilentAuctionOrder } from '../silentAuctionRules';
|
|
3
|
+
export interface UseSilentAuctionLotsOptions {
|
|
4
|
+
/** `newest` (default), `endingSoon`, `wishlisted` or `upcoming`: see `orderLots`. */
|
|
5
|
+
order?: SilentAuctionOrder;
|
|
6
|
+
/** The screen is showing: reads and polls only then. */
|
|
7
|
+
screenOnShow: boolean;
|
|
8
|
+
/** Read the shown lots' bids again this often, ms. 0 (default) doesn't poll. */
|
|
9
|
+
pollIntervalMs?: number;
|
|
10
|
+
/** The shopper's wishlisted products (bare ids or GIDs), for `order: 'wishlisted'`. */
|
|
11
|
+
wishlistedProductIds?: string[];
|
|
12
|
+
/** Read past the first page in the background. Default true; false for a rail. */
|
|
13
|
+
readAhead?: boolean;
|
|
14
|
+
/** The order pages are read in. Default the service's. */
|
|
15
|
+
pageOrder?: SilentAuctionFeedOptions['pageOrder'];
|
|
16
|
+
/** Keep sold-out lots. Default false. */
|
|
17
|
+
keepSoldOut?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface SilentAuctionLotsPage<TRaw = unknown> {
|
|
20
|
+
/** `loading` until the first page; `empty` when the order has nothing (and nothing is still being read). */
|
|
21
|
+
status: 'loading' | 'failed' | 'empty' | 'ready';
|
|
22
|
+
/** The lots, in `order`. */
|
|
23
|
+
items: SilentAuctionItem<TRaw>[];
|
|
24
|
+
/** For `order: 'upcoming'`: the lots by round, the soonest first. Empty otherwise. */
|
|
25
|
+
upcoming: {
|
|
26
|
+
auctionId: string;
|
|
27
|
+
startsAt: number | null;
|
|
28
|
+
items: SilentAuctionItem<TRaw>[];
|
|
29
|
+
}[];
|
|
30
|
+
/** A pull to refresh is running. */
|
|
31
|
+
refreshing: boolean;
|
|
32
|
+
/** More lots are being read in the background: a list footer, never the spinner. */
|
|
33
|
+
readingAhead: boolean;
|
|
34
|
+
hasMore: boolean;
|
|
35
|
+
/** Pull to refresh. */
|
|
36
|
+
refresh(): void;
|
|
37
|
+
}
|
|
38
|
+
export declare function useSilentAuctionLots<TRaw = unknown>(options: UseSilentAuctionLotsOptions): SilentAuctionLotsPage<TRaw>;
|
|
39
|
+
//# sourceMappingURL=useSilentAuctionLots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSilentAuctionLots.d.ts","sourceRoot":"","sources":["../../src/react/useSilentAuctionLots.ts"],"names":[],"mappings":"AAWA,OAAO,EAA2B,KAAK,wBAAwB,EAA+B,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACnJ,OAAO,EAA6B,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3F,MAAM,WAAW,2BAA2B;IAC1C,qFAAqF;IACrF,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,wDAAwD;IACxD,YAAY,EAAE,OAAO,CAAC;IACtB,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uFAAuF;IACvF,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,kFAAkF;IAClF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,wBAAwB,CAAC,WAAW,CAAC,CAAC;IAClD,yCAAyC;IACzC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB,CAAC,IAAI,GAAG,OAAO;IACnD,4GAA4G;IAC5G,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;IACjD,4BAA4B;IAC5B,KAAK,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;IACjC,sFAAsF;IACtF,QAAQ,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAA;KAAE,EAAE,CAAC;IAC7F,oCAAoC;IACpC,UAAU,EAAE,OAAO,CAAC;IACpB,oFAAoF;IACpF,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,uBAAuB;IACvB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,oBAAoB,CAAC,IAAI,GAAG,OAAO,EAAE,OAAO,EAAE,2BAA2B,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAmDtH"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSilentAuctionLots = useSilentAuctionLots;
|
|
4
|
+
/**
|
|
5
|
+
* The silent-auction lots page as a page model (0.12.0, moved from Sparkl's `CurrentSilentAuction` and
|
|
6
|
+
* `useAuctionProducts` on 2026-10-17). Also a home rail's (`order: 'upcoming'`, `readAhead: false`).
|
|
7
|
+
*
|
|
8
|
+
* The lots and their products come from `createSilentAuctionFeed`; this orders them (`orderLots`) and
|
|
9
|
+
* groups the upcoming ones by round (`upcomingGroups`). It reads while `screenOnShow`, polls every
|
|
10
|
+
* `pollIntervalMs` (Sparkl's grid: 2 000), and stops when the screen goes. Changing `order` between
|
|
11
|
+
* `upcoming` and the rest reads the other list from scratch, as Sparkl does. No words or formatting.
|
|
12
|
+
*/
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const silentAuctionFeed_1 = require("../silentAuctionFeed");
|
|
15
|
+
const silentAuctionRules_1 = require("../silentAuctionRules");
|
|
16
|
+
function useSilentAuctionLots(options) {
|
|
17
|
+
const { order = 'newest', screenOnShow, pollIntervalMs = 0, wishlistedProductIds, readAhead = true, pageOrder, keepSoldOut = false } = options;
|
|
18
|
+
const filter = order === 'upcoming' ? 'upcoming' : 'current';
|
|
19
|
+
const feed = (0, react_1.useMemo)(() => (0, silentAuctionFeed_1.createSilentAuctionFeed)({ filter, readAhead, pageOrder, keepSoldOut }), [filter, readAhead, pageOrder, keepSoldOut]);
|
|
20
|
+
const [state, setState] = (0, react_1.useState)(feed.getState());
|
|
21
|
+
(0, react_1.useEffect)(() => {
|
|
22
|
+
setState(feed.getState());
|
|
23
|
+
return feed.subscribe(() => setState(feed.getState()));
|
|
24
|
+
}, [feed]);
|
|
25
|
+
(0, react_1.useEffect)(() => {
|
|
26
|
+
if (!screenOnShow)
|
|
27
|
+
return undefined;
|
|
28
|
+
void feed.load();
|
|
29
|
+
const timer = pollIntervalMs > 0 ? setInterval(() => void feed.poll(), pollIntervalMs) : null;
|
|
30
|
+
return () => {
|
|
31
|
+
if (timer)
|
|
32
|
+
clearInterval(timer);
|
|
33
|
+
feed.stop();
|
|
34
|
+
};
|
|
35
|
+
}, [feed, screenOnShow, pollIntervalMs]);
|
|
36
|
+
const wishlistKey = (wishlistedProductIds !== null && wishlistedProductIds !== void 0 ? wishlistedProductIds : []).join(',');
|
|
37
|
+
const items = (0, react_1.useMemo)(() => (0, silentAuctionRules_1.orderLots)(state.items, order, Date.now(), wishlistedProductIds !== null && wishlistedProductIds !== void 0 ? wishlistedProductIds : []),
|
|
38
|
+
// The ids by value: a fresh array each render mustn't reorder the list.
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
[state.items, order, wishlistKey]);
|
|
41
|
+
const upcoming = (0, react_1.useMemo)(() => (order === 'upcoming' ? (0, silentAuctionRules_1.upcomingGroups)(items) : []), [items, order]);
|
|
42
|
+
const status = state.status === 'idle' || state.status === 'loading'
|
|
43
|
+
? 'loading'
|
|
44
|
+
: state.status === 'failed'
|
|
45
|
+
? 'failed'
|
|
46
|
+
: items.length === 0 && !state.readingAhead
|
|
47
|
+
? 'empty'
|
|
48
|
+
: 'ready';
|
|
49
|
+
return {
|
|
50
|
+
status,
|
|
51
|
+
items,
|
|
52
|
+
upcoming,
|
|
53
|
+
refreshing: state.refreshing,
|
|
54
|
+
readingAhead: state.readingAhead,
|
|
55
|
+
hasMore: state.hasMore,
|
|
56
|
+
refresh: () => void feed.load({ userInitiated: true }),
|
|
57
|
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,QAAQ;YACV,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY;gBACzC,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,OAAO,CAAC;IAElB,OAAO;QACL,MAAM;QACN,KAAK;QACL,QAAQ;QACR,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;KACvD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SilentAuctionRound } from '../silentAuctionRules';
|
|
2
|
+
export interface UseSilentAuctionRoundsOptions {
|
|
3
|
+
/** `active` (default) or `upcoming`. */
|
|
4
|
+
filter?: 'active' | 'upcoming';
|
|
5
|
+
/** The screen is showing: reads only then. */
|
|
6
|
+
screenOnShow: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SilentAuctionRounds {
|
|
9
|
+
status: 'loading' | 'failed' | 'empty' | 'ready';
|
|
10
|
+
rounds: SilentAuctionRound[];
|
|
11
|
+
refresh(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function useSilentAuctionRounds(options: UseSilentAuctionRoundsOptions): SilentAuctionRounds;
|
|
14
|
+
//# sourceMappingURL=useSilentAuctionRounds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSilentAuctionRounds.d.ts","sourceRoot":"","sources":["../../src/react/useSilentAuctionRounds.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,MAAM,WAAW,6BAA6B;IAC5C,wCAAwC;IACxC,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC/B,8CAA8C;IAC9C,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;IACjD,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,6BAA6B,GAAG,mBAAmB,CA0BlG"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSilentAuctionRounds = useSilentAuctionRounds;
|
|
4
|
+
/**
|
|
5
|
+
* A store's silent-auction rounds, for the home page's banner and its countdown (0.12.0, moved from
|
|
6
|
+
* Sparkl's Home on 2026-10-17): `active` (bidding open) or `upcoming` rounds, each with its name, times,
|
|
7
|
+
* notification and lots. Read each time the screen shows. No words or formatting.
|
|
8
|
+
*/
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const client_1 = require("../client");
|
|
11
|
+
const silentAuctions_1 = require("../silentAuctions");
|
|
12
|
+
function useSilentAuctionRounds(options) {
|
|
13
|
+
const { filter = 'active', screenOnShow } = options;
|
|
14
|
+
const [rounds, setRounds] = (0, react_1.useState)([]);
|
|
15
|
+
const [status, setStatus] = (0, react_1.useState)('loading');
|
|
16
|
+
const generation = (0, react_1.useRef)(0);
|
|
17
|
+
const load = (0, react_1.useCallback)(async () => {
|
|
18
|
+
const mine = ++generation.current;
|
|
19
|
+
try {
|
|
20
|
+
const next = await silentAuctions_1.silentAuctions.rounds(filter);
|
|
21
|
+
if (mine !== generation.current)
|
|
22
|
+
return;
|
|
23
|
+
setRounds(next);
|
|
24
|
+
setStatus(next.length ? 'ready' : 'empty');
|
|
25
|
+
}
|
|
26
|
+
catch (caught) {
|
|
27
|
+
if (mine !== generation.current)
|
|
28
|
+
return;
|
|
29
|
+
(0, client_1.getLogger)().error(caught, { at: 'useSilentAuctionRounds', filter });
|
|
30
|
+
// A failed read keeps rounds already shown.
|
|
31
|
+
setStatus((previous) => (previous === 'ready' ? previous : 'failed'));
|
|
32
|
+
}
|
|
33
|
+
}, [filter]);
|
|
34
|
+
(0, react_1.useEffect)(() => {
|
|
35
|
+
if (screenOnShow)
|
|
36
|
+
void load();
|
|
37
|
+
}, [screenOnShow, load]);
|
|
38
|
+
return { status, rounds, refresh: () => void load() };
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=useSilentAuctionRounds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSilentAuctionRounds.js","sourceRoot":"","sources":["../../src/react/useSilentAuctionRounds.ts"],"names":[],"mappings":";;AAwBA,wDA0BC;AAlDD;;;;GAIG;AACH,iCAAiE;AAEjE,sCAAsC;AAEtC,sDAAmD;AAenD,SAAgB,sBAAsB,CAAC,OAAsC;IAC3E,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACpD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAuB,EAAE,CAAC,CAAC;IAC/D,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAgC,SAAS,CAAC,CAAC;IAC/E,MAAM,UAAU,GAAG,IAAA,cAAM,EAAC,CAAC,CAAC,CAAC;IAE7B,MAAM,IAAI,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QAClC,MAAM,IAAI,GAAG,EAAE,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,+BAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACjD,IAAI,IAAI,KAAK,UAAU,CAAC,OAAO;gBAAE,OAAO;YACxC,SAAS,CAAC,IAAI,CAAC,CAAC;YAChB,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,IAAI,IAAI,KAAK,UAAU,CAAC,OAAO;gBAAE,OAAO;YACxC,IAAA,kBAAS,GAAE,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,wBAAwB,EAAE,MAAM,EAAE,CAAC,CAAC;YACpE,4CAA4C;YAC5C,SAAS,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxE,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,YAAY;YAAE,KAAK,IAAI,EAAE,CAAC;IAChC,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;AACxD,CAAC"}
|
package/dist/replays.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { ReplaysAPI } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The cover the host chose for the show, or null without one. Shows brought over from another platform
|
|
4
|
+
* carry their cover's query string twice (`…png?fit=bounds&width=450&height=700&…?fit=bounds&width=450&
|
|
5
|
+
* height=450&…`): only the first is kept, which a stricter CDN would still serve, and which asks for the
|
|
6
|
+
* portrait crop a card wants.
|
|
7
|
+
*/
|
|
8
|
+
export declare function coverUrlOf(cover: unknown): string | null;
|
|
2
9
|
/**
|
|
3
10
|
* Where a recording's chat is published: one static file per show, `<streaming id>.json`.
|
|
4
11
|
*
|
package/dist/replays.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replays.d.ts","sourceRoot":"","sources":["../src/replays.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAMV,UAAU,EACX,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"replays.d.ts","sourceRoot":"","sources":["../src/replays.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAMV,UAAU,EACX,MAAM,SAAS,CAAC;AA8CjB;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAMxD;AAgBD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,uDAAuD,CAAC;AA0BxF,eAAO,MAAM,OAAO,EAAE,UA6FrB,CAAC"}
|
package/dist/replays.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.replays = exports.REPLAY_COMMENTS_URL = void 0;
|
|
4
|
+
exports.coverUrlOf = coverUrlOf;
|
|
4
5
|
/**
|
|
5
6
|
* Replays, from the live-selling gateway. A replay is an HLS recording plus stored product windows, so
|
|
6
7
|
* the whole feature works without the live engine — nothing here touches Zego.
|
|
@@ -22,6 +23,20 @@ function toThumbnailUrl(raw) {
|
|
|
22
23
|
(0, wire_1.imageUrl)((_b = (_a = raw.product_info) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.product_thumbnail) ||
|
|
23
24
|
null);
|
|
24
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The cover the host chose for the show, or null without one. Shows brought over from another platform
|
|
28
|
+
* carry their cover's query string twice (`…png?fit=bounds&width=450&height=700&…?fit=bounds&width=450&
|
|
29
|
+
* height=450&…`): only the first is kept, which a stricter CDN would still serve, and which asks for the
|
|
30
|
+
* portrait crop a card wants.
|
|
31
|
+
*/
|
|
32
|
+
function coverUrlOf(cover) {
|
|
33
|
+
const url = (0, wire_1.imageUrl)(cover);
|
|
34
|
+
if (!url)
|
|
35
|
+
return null;
|
|
36
|
+
const firstQuery = url.indexOf('?');
|
|
37
|
+
const secondQuery = firstQuery === -1 ? -1 : url.indexOf('?', firstQuery + 1);
|
|
38
|
+
return secondQuery === -1 ? url : url.slice(0, secondQuery);
|
|
39
|
+
}
|
|
25
40
|
function toReplay(raw) {
|
|
26
41
|
var _a, _b, _c, _d, _e, _f;
|
|
27
42
|
return {
|
|
@@ -30,6 +45,7 @@ function toReplay(raw) {
|
|
|
30
45
|
title: ((_a = raw.title) === null || _a === void 0 ? void 0 : _a.trim()) || ((_b = raw.description) === null || _b === void 0 ? void 0 : _b.trim()) || '',
|
|
31
46
|
videoUrl: raw.streaming_url || raw.url || null,
|
|
32
47
|
thumbnailUrl: toThumbnailUrl(raw),
|
|
48
|
+
coverUrl: coverUrlOf(raw.streaming_thumbnail_image),
|
|
33
49
|
productIds: ((_c = raw.product_ids) !== null && _c !== void 0 ? _c : []).map(client_1.toProductGid),
|
|
34
50
|
viewCount: (_d = raw.watched) !== null && _d !== void 0 ? _d : 0,
|
|
35
51
|
publishedAt: (_f = (_e = raw.published_at) !== null && _e !== void 0 ? _e : raw.created_at) !== null && _f !== void 0 ? _f : null,
|
package/dist/replays.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replays.js","sourceRoot":"","sources":["../src/replays.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"replays.js","sourceRoot":"","sources":["../src/replays.ts"],"names":[],"mappings":";;;AAmEA,gCAMC;AAzED;;;GAGG;AACH,qCAA6G;AAC7G,mCAA0C;AAC1C,2CAAyC;AACzC,iCAAkC;AAUlC,0FAA0F;AAC1F,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,wGAAwG;AACxG,MAAM,cAAc,GAAG,mBAAmB,CAAC;AA6B3C,6FAA6F;AAC7F,SAAS,cAAc,CAAC,GAAqB;;IAC3C,OAAO,CACL,GAAG,CAAC,SAAS;QACb,GAAG,CAAC,eAAe;QACnB,GAAG,CAAC,yB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