@tiledev/sdk-apptile-live-selling 0.1.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 +322 -0
- package/android/build.gradle +33 -0
- package/android/src/main/AndroidManifest.xml +7 -0
- package/android/src/main/java/expo/modules/livepip/LivePipModule.kt +310 -0
- package/app.plugin.js +3 -0
- package/dist/auctions.d.ts +3 -0
- package/dist/auctions.d.ts.map +1 -0
- package/dist/auctions.js +152 -0
- package/dist/auctions.js.map +1 -0
- package/dist/client.d.ts +63 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +154 -0
- package/dist/client.js.map +1 -0
- package/dist/clips.d.ts +3 -0
- package/dist/clips.d.ts.map +1 -0
- package/dist/clips.js +53 -0
- package/dist/clips.js.map +1 -0
- package/dist/commentLinks.d.ts +46 -0
- package/dist/commentLinks.d.ts.map +1 -0
- package/dist/commentLinks.js +120 -0
- package/dist/commentLinks.js.map +1 -0
- package/dist/engine.d.ts +13 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +40 -0
- package/dist/engine.js.map +1 -0
- package/dist/engine.native.d.ts +3 -0
- package/dist/engine.native.d.ts.map +1 -0
- package/dist/engine.native.js +815 -0
- package/dist/engine.native.js.map +1 -0
- package/dist/flags.d.ts +5 -0
- package/dist/flags.d.ts.map +1 -0
- package/dist/flags.js +61 -0
- package/dist/flags.js.map +1 -0
- package/dist/guest.d.ts +5 -0
- package/dist/guest.d.ts.map +1 -0
- package/dist/guest.js +89 -0
- package/dist/guest.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/liveSelling.d.ts +3 -0
- package/dist/liveSelling.d.ts.map +1 -0
- package/dist/liveSelling.js +44 -0
- package/dist/liveSelling.js.map +1 -0
- package/dist/nativeViewTag.d.ts +15 -0
- package/dist/nativeViewTag.d.ts.map +1 -0
- package/dist/nativeViewTag.js +23 -0
- package/dist/nativeViewTag.js.map +1 -0
- package/dist/pip.d.ts +14 -0
- package/dist/pip.d.ts.map +1 -0
- package/dist/pip.js +15 -0
- package/dist/pip.js.map +1 -0
- package/dist/pip.native.d.ts +11 -0
- package/dist/pip.native.d.ts.map +1 -0
- package/dist/pip.native.js +47 -0
- package/dist/pip.native.js.map +1 -0
- package/dist/polls.d.ts +11 -0
- package/dist/polls.d.ts.map +1 -0
- package/dist/polls.js +135 -0
- package/dist/polls.js.map +1 -0
- package/dist/react/LiveSellingProvider.d.ts +16 -0
- package/dist/react/LiveSellingProvider.d.ts.map +1 -0
- package/dist/react/LiveSellingProvider.js +49 -0
- package/dist/react/LiveSellingProvider.js.map +1 -0
- package/dist/react/LiveVideoTarget.d.ts +22 -0
- package/dist/react/LiveVideoTarget.d.ts.map +1 -0
- package/dist/react/LiveVideoTarget.js +73 -0
- package/dist/react/LiveVideoTarget.js.map +1 -0
- package/dist/react/index.d.ts +19 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +43 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/useAuction.d.ts +28 -0
- package/dist/react/useAuction.d.ts.map +1 -0
- package/dist/react/useAuction.js +66 -0
- package/dist/react/useAuction.js.map +1 -0
- package/dist/react/useAuctionBidGate.d.ts +48 -0
- package/dist/react/useAuctionBidGate.d.ts.map +1 -0
- package/dist/react/useAuctionBidGate.js +144 -0
- package/dist/react/useAuctionBidGate.js.map +1 -0
- package/dist/react/useAuctionWins.d.ts +51 -0
- package/dist/react/useAuctionWins.d.ts.map +1 -0
- package/dist/react/useAuctionWins.js +268 -0
- package/dist/react/useAuctionWins.js.map +1 -0
- package/dist/react/useClips.d.ts +9 -0
- package/dist/react/useClips.d.ts.map +1 -0
- package/dist/react/useClips.js +37 -0
- package/dist/react/useClips.js.map +1 -0
- package/dist/react/useLiveSession.d.ts +34 -0
- package/dist/react/useLiveSession.d.ts.map +1 -0
- package/dist/react/useLiveSession.js +876 -0
- package/dist/react/useLiveSession.js.map +1 -0
- package/dist/react/useLiveStreams.d.ts +9 -0
- package/dist/react/useLiveStreams.d.ts.map +1 -0
- package/dist/react/useLiveStreams.js +35 -0
- package/dist/react/useLiveStreams.js.map +1 -0
- package/dist/react/useOngoingLive.d.ts +13 -0
- package/dist/react/useOngoingLive.d.ts.map +1 -0
- package/dist/react/useOngoingLive.js +45 -0
- package/dist/react/useOngoingLive.js.map +1 -0
- package/dist/react/useReplays.d.ts +15 -0
- package/dist/react/useReplays.d.ts.map +1 -0
- package/dist/react/useReplays.js +66 -0
- package/dist/react/useReplays.js.map +1 -0
- package/dist/react/useStreamInfo.d.ts +21 -0
- package/dist/react/useStreamInfo.d.ts.map +1 -0
- package/dist/react/useStreamInfo.js +125 -0
- package/dist/react/useStreamInfo.js.map +1 -0
- package/dist/replays.d.ts +3 -0
- package/dist/replays.d.ts.map +1 -0
- package/dist/replays.js +114 -0
- package/dist/replays.js.map +1 -0
- package/dist/session.d.ts +23 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +464 -0
- package/dist/session.js.map +1 -0
- package/dist/sessionTypes.d.ts +462 -0
- package/dist/sessionTypes.d.ts.map +1 -0
- package/dist/sessionTypes.js +55 -0
- package/dist/sessionTypes.js.map +1 -0
- package/dist/streams.d.ts +67 -0
- package/dist/streams.d.ts.map +1 -0
- package/dist/streams.js +170 -0
- package/dist/streams.js.map +1 -0
- package/dist/types.d.ts +591 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/dist/viewer.d.ts +5 -0
- package/dist/viewer.d.ts.map +1 -0
- package/dist/viewer.js +66 -0
- package/dist/viewer.js.map +1 -0
- package/dist/wire.d.ts +155 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +73 -0
- package/dist/wire.js.map +1 -0
- package/dist/zego.d.ts +83 -0
- package/dist/zego.d.ts.map +1 -0
- package/dist/zego.js +13 -0
- package/dist/zego.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/LivePip.podspec +20 -0
- package/ios/LivePipController.swift +327 -0
- package/ios/LivePipModule.swift +35 -0
- package/package.json +91 -0
- package/plugin/build/index.d.ts +29 -0
- package/plugin/build/index.js +101 -0
- package/react/package.json +6 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session layer's types — the assembled, renderable state.
|
|
3
|
+
*
|
|
4
|
+
* The rest of this package is a data client: it fetches records and forwards a `LiveEvent` stream.
|
|
5
|
+
* This is the layer that folds those two together into something a screen renders directly, so a
|
|
6
|
+
* host app never has to reimplement the auction clock, the "is there a picture" question, or the
|
|
7
|
+
* poll tally merge.
|
|
8
|
+
*
|
|
9
|
+
* Like `types.ts`, nothing here imports React, React Native or Zego.
|
|
10
|
+
*/
|
|
11
|
+
import type { AuctionWin, AuctionWinItem, BidLeader, GuestCredentials, LiveEvent, LiveComment, LiveGiveaway, LivePoll, LivePollOption, LivePollResults, LiveStream, MixerLayout, SoldAnnouncement } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* Where this device stands as a guest.
|
|
14
|
+
*
|
|
15
|
+
* `waiting` is its own state and not a detail: accepting an invite grants publishing rights
|
|
16
|
+
* immediately, but the host still has to admit the guest, so a guest is on camera locally and
|
|
17
|
+
* invisible to viewers until then.
|
|
18
|
+
*/
|
|
19
|
+
export type GuestStatus = 'idle' | 'waiting' | 'live' | 'removed';
|
|
20
|
+
export type LiveSessionStatus = 'loading' | 'connecting'
|
|
21
|
+
/** Connected, but the host's camera is off or they stopped publishing. */
|
|
22
|
+
| 'waitingForHost' | 'playing' | 'ended' | 'error';
|
|
23
|
+
/**
|
|
24
|
+
* Where the video is playing.
|
|
25
|
+
*
|
|
26
|
+
* `inapp` is a surface the host app draws above its own navigator; `system` is the OS
|
|
27
|
+
* picture-in-picture window, which cannot be entered or left programmatically — it is reported by
|
|
28
|
+
* the platform.
|
|
29
|
+
*/
|
|
30
|
+
export type LivePipMode = 'none' | 'inapp' | 'system';
|
|
31
|
+
export type SoldCard = SoldAnnouncement & {
|
|
32
|
+
id: string;
|
|
33
|
+
createdAt: number;
|
|
34
|
+
};
|
|
35
|
+
export interface FloatingReaction {
|
|
36
|
+
id: string;
|
|
37
|
+
reactionUrl: string;
|
|
38
|
+
userName: string;
|
|
39
|
+
createdAt: number;
|
|
40
|
+
}
|
|
41
|
+
export type LivePollChoice = LivePollOption & {
|
|
42
|
+
votes: number;
|
|
43
|
+
/** 0–100, from the raw counts rather than the host's pre-rendered string. */
|
|
44
|
+
percent: number;
|
|
45
|
+
};
|
|
46
|
+
export interface LivePollView {
|
|
47
|
+
pollUuid: string;
|
|
48
|
+
question: string;
|
|
49
|
+
choices: LivePollChoice[];
|
|
50
|
+
/** Already multiplied by the host's view multiplier, like `viewerCount`. */
|
|
51
|
+
totalVotes: number;
|
|
52
|
+
/** Null until this install votes; the tally stays hidden until then, as the host's own UI does. */
|
|
53
|
+
votedOptionId: string | null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The live bidding round.
|
|
57
|
+
*
|
|
58
|
+
* Every number here comes from the host. A viewer never advances its own high bid or shortens its
|
|
59
|
+
* own clock — it offers a bid and waits for the host's broadcast. That is what makes two phones
|
|
60
|
+
* agree on who is leading, and why nothing in this shape is optimistic.
|
|
61
|
+
*/
|
|
62
|
+
export interface AuctionState {
|
|
63
|
+
biddingOpen: boolean;
|
|
64
|
+
/** 0 before the first bid, so a UI can say "Yet to bid" rather than a currency zero. */
|
|
65
|
+
highestBid: number;
|
|
66
|
+
/** The minimum the next bid must beat. Seeded from the lot's opening price. */
|
|
67
|
+
nextBid: number;
|
|
68
|
+
/** Time on the host's clock, not the device's. 0 once the round is over. */
|
|
69
|
+
timeLeftMs: number;
|
|
70
|
+
isLeading: boolean;
|
|
71
|
+
leaderName: string | null;
|
|
72
|
+
/**
|
|
73
|
+
* A bid extended the round past its original deadline — the bidding war. Latches for the rest of
|
|
74
|
+
* the round, so a banner plays once rather than on every subsequent late bid.
|
|
75
|
+
*/
|
|
76
|
+
extended: boolean;
|
|
77
|
+
/** The lot the host named when opening the round, which may lead the featured product. */
|
|
78
|
+
storeProductId: string | null;
|
|
79
|
+
/** The hammer, held until the celebration is dismissed. */
|
|
80
|
+
lastWin: AuctionWin | null;
|
|
81
|
+
bidCap: number | null;
|
|
82
|
+
extendedBiddingMs: number;
|
|
83
|
+
}
|
|
84
|
+
/** No round open, nothing won. For a replay or anything else that cannot bid. */
|
|
85
|
+
export declare const IDLE_AUCTION: AuctionState;
|
|
86
|
+
/**
|
|
87
|
+
* The giveaway running alongside the auction.
|
|
88
|
+
*
|
|
89
|
+
* `active` and `result` are separate because they overlap: the draw for the lot that just closed
|
|
90
|
+
* plays while the host may already have opened the next one.
|
|
91
|
+
*/
|
|
92
|
+
export interface GiveawayState {
|
|
93
|
+
active: LiveGiveaway | null;
|
|
94
|
+
/** Host-authoritative — it arrives with the host's own registration push. */
|
|
95
|
+
entryCount: number;
|
|
96
|
+
registered: boolean;
|
|
97
|
+
/** The finished draw being celebrated, cleared when the animation ends. */
|
|
98
|
+
result: {
|
|
99
|
+
winnerName: string;
|
|
100
|
+
entrantNames: string[];
|
|
101
|
+
} | null;
|
|
102
|
+
}
|
|
103
|
+
export declare const IDLE_GIVEAWAY: GiveawayState;
|
|
104
|
+
/**
|
|
105
|
+
* Where this device stands as a co-host.
|
|
106
|
+
*
|
|
107
|
+
* `mode` is the load-bearing one: while it is true a guest holds the room login, so the viewer
|
|
108
|
+
* session has stood down and nothing else may join.
|
|
109
|
+
*/
|
|
110
|
+
export interface LiveGuestState {
|
|
111
|
+
mode: boolean;
|
|
112
|
+
status: GuestStatus;
|
|
113
|
+
slot: number | null;
|
|
114
|
+
/** Forced by the host; a guest cannot turn its own mic or camera back on against these. */
|
|
115
|
+
mutedByHost: boolean;
|
|
116
|
+
cameraOffByHost: boolean;
|
|
117
|
+
mixerLayout: MixerLayout | null;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A product, as little of one as the session needs. Produced by the commerce adapter.
|
|
121
|
+
*
|
|
122
|
+
* `TRaw` is whatever your catalogue's own product type is: put it on `raw` and it comes back off
|
|
123
|
+
* `session.products` with that type intact, so a call site never has to cast. Defaults to `unknown`,
|
|
124
|
+
* which is what an adapter that sets no `raw` gets.
|
|
125
|
+
*/
|
|
126
|
+
export interface LiveProduct<TRaw = unknown> {
|
|
127
|
+
/** Whatever the adapter's catalogue calls it — a Shopify GID, a SKU, an internal id. */
|
|
128
|
+
id: string;
|
|
129
|
+
/** The bare numeric id the gateway and host dashboard use. How a lot is matched to a product. */
|
|
130
|
+
storeProductId: string;
|
|
131
|
+
title: string;
|
|
132
|
+
price: string | null;
|
|
133
|
+
currencyCode: string | null;
|
|
134
|
+
imageUrl: string | null;
|
|
135
|
+
variants: LiveProductVariant[];
|
|
136
|
+
/** For a share sheet. */
|
|
137
|
+
url?: string | null;
|
|
138
|
+
/** Anything the adapter wants to carry through to its own call sites, untouched. */
|
|
139
|
+
raw?: TRaw;
|
|
140
|
+
}
|
|
141
|
+
export interface LiveProductVariant {
|
|
142
|
+
id: string;
|
|
143
|
+
title: string;
|
|
144
|
+
price: string | null;
|
|
145
|
+
available: boolean;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Everything the session needs from a storefront.
|
|
149
|
+
*
|
|
150
|
+
* The gateway only ever speaks in bare numeric product ids, because that is what the host dashboard
|
|
151
|
+
* records. Turning one into something with a price, an image and variants is the host app's job, and
|
|
152
|
+
* so is selling it — nothing in this package knows what platform is behind this.
|
|
153
|
+
*
|
|
154
|
+
* Only `productsByIds` is required. An unimplemented method disables the feature that needs it
|
|
155
|
+
* rather than throwing.
|
|
156
|
+
*/
|
|
157
|
+
export interface CommerceAdapter<TRaw = unknown> {
|
|
158
|
+
/**
|
|
159
|
+
* Resolve lots to products, in the order asked. Missing ids should be omitted rather than padded
|
|
160
|
+
* with nulls — a host can feature a product that has since been unpublished.
|
|
161
|
+
*/
|
|
162
|
+
productsByIds: (storeProductIds: string[]) => Promise<LiveProduct<TRaw>[]>;
|
|
163
|
+
/**
|
|
164
|
+
* Add one unit to the cart. Return false when the write was *refused* (out of stock, a hold
|
|
165
|
+
* someone else owns) rather than throwing — a refused line must not be announced to the room.
|
|
166
|
+
*/
|
|
167
|
+
addLine?: (variantId: string, quantity: number) => Promise<boolean>;
|
|
168
|
+
/**
|
|
169
|
+
* Build a one-off cart for the lots this customer won and return somewhere to pay.
|
|
170
|
+
*
|
|
171
|
+
* Deliberately not the shopping cart: an auction win is already a commitment at a settled price,
|
|
172
|
+
* and mixing those lines into a browsing cart lets a quantity stepper change it.
|
|
173
|
+
*
|
|
174
|
+
* `cartId` is optional but worth returning: the cart does not exist until this call, so anything the
|
|
175
|
+
* host app applies to it — store credit, a gift card — can only be applied afterwards, and it needs
|
|
176
|
+
* the id to do that. Returning the URL alone means the payment can never be reduced.
|
|
177
|
+
*
|
|
178
|
+
* Whatever the platform needs in order to recognise the resulting order as an auction settlement
|
|
179
|
+
* belongs in here. On Shopify that is cart-level attributes plus the buyer's identity, and it is
|
|
180
|
+
* load-bearing rather than reporting: an order the host cannot match is an order that never clears
|
|
181
|
+
* the customer's `auction.winner` metafield, which leaves them blocked from bidding after paying.
|
|
182
|
+
*/
|
|
183
|
+
createAuctionCheckout?: (wins: AuctionWinItem[], auctionId: string) => Promise<{
|
|
184
|
+
checkoutUrl: string;
|
|
185
|
+
cartId?: string;
|
|
186
|
+
}>;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Who is watching.
|
|
190
|
+
*
|
|
191
|
+
* Two ids, and keeping them apart matters. `viewerId` is the room identity and the unit the host
|
|
192
|
+
* mutes by — per install, never per person. `bidderId` is the customer a win is attributed to and
|
|
193
|
+
* turned into a cart, so it has to be the same id the host's own broadcast echoes back, or
|
|
194
|
+
* `isLeading` compares two different things and nobody is ever leading.
|
|
195
|
+
*/
|
|
196
|
+
export interface IdentityAdapter {
|
|
197
|
+
/**
|
|
198
|
+
* The signed-in customer, bare rather than a GID, or null when signed out. Bidding and giveaway
|
|
199
|
+
* entry are offered only when this is set.
|
|
200
|
+
*/
|
|
201
|
+
bidderId?: () => string | null;
|
|
202
|
+
/** Full customer identifier, when the giveaway endpoint wants one (Shopify: the GID). */
|
|
203
|
+
customerRef?: () => string | null;
|
|
204
|
+
/** The customer's own display name, so a signed-in bidder is never asked to invent one. */
|
|
205
|
+
customerName?: () => string | null;
|
|
206
|
+
customerEmail?: () => string | null;
|
|
207
|
+
}
|
|
208
|
+
export type LivePipEvents = {
|
|
209
|
+
/** The system PIP window is up. */
|
|
210
|
+
onPipStart: () => void;
|
|
211
|
+
/** It came down. `restored` distinguishes the expand button from the close button. */
|
|
212
|
+
onPipStop: (payload: {
|
|
213
|
+
restored: boolean;
|
|
214
|
+
}) => void;
|
|
215
|
+
/** The user asked to come back to the app; navigate to the live screen. */
|
|
216
|
+
onPipRestore: () => void;
|
|
217
|
+
onPipError: (payload: {
|
|
218
|
+
message: string;
|
|
219
|
+
}) => void;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* The picture-in-picture boundary. No-op off-device — see `pip.ts`.
|
|
223
|
+
*
|
|
224
|
+
* `start`/`stop` exist for completeness; nothing in the session calls them, because both platforms
|
|
225
|
+
* reach a window through `setArmed` plus the user's own gesture. Android has no dismiss API at all.
|
|
226
|
+
*/
|
|
227
|
+
export interface LivePipController {
|
|
228
|
+
/** Enable custom rendering. After the engine exists, before anything plays. iOS only in effect. */
|
|
229
|
+
configure(): Promise<void>;
|
|
230
|
+
/** Which stream feeds the window; null when playback stops. No-op on Android. */
|
|
231
|
+
setStream(streamId: string | null): Promise<void>;
|
|
232
|
+
/** Arm to let the OS take over on backgrounding. Also gates the frame copy on iOS. */
|
|
233
|
+
setArmed(armed: boolean): Promise<void>;
|
|
234
|
+
start(): Promise<void>;
|
|
235
|
+
stop(): Promise<void>;
|
|
236
|
+
/** Returns an unsubscribe, or undefined where there is no module to listen to. */
|
|
237
|
+
addListener<K extends keyof LivePipEvents>(event: K, listener: LivePipEvents[K]): (() => void) | undefined;
|
|
238
|
+
}
|
|
239
|
+
export interface LiveSessionCapabilities {
|
|
240
|
+
canComment: boolean;
|
|
241
|
+
canReact: boolean;
|
|
242
|
+
canShop: boolean;
|
|
243
|
+
showLiveBadge: boolean;
|
|
244
|
+
showViewerCount: boolean;
|
|
245
|
+
canPip: boolean;
|
|
246
|
+
/** Auction streams only. */
|
|
247
|
+
canBid: boolean;
|
|
248
|
+
/**
|
|
249
|
+
* The host runs giveaways independently of bidding, so this does not travel with `canBid` — every
|
|
250
|
+
* live stream can have one.
|
|
251
|
+
*/
|
|
252
|
+
canEnterGiveaway: boolean;
|
|
253
|
+
}
|
|
254
|
+
export declare const LIVE_CAPABILITIES: LiveSessionCapabilities;
|
|
255
|
+
/** An auction is a live show plus bidding — derived, so additions to live reach it for free. */
|
|
256
|
+
export declare const AUCTION_CAPABILITIES: LiveSessionCapabilities;
|
|
257
|
+
/** A recording: shop and scrub, but nothing to publish into and no audience to count. */
|
|
258
|
+
export declare const REPLAY_CAPABILITIES: LiveSessionCapabilities;
|
|
259
|
+
/** Which flag set a stream calls for. The record's `allow_auction` is the only input. */
|
|
260
|
+
export declare function capabilitiesFor(stream: {
|
|
261
|
+
isAuction: boolean;
|
|
262
|
+
} | null | undefined): LiveSessionCapabilities;
|
|
263
|
+
export interface LiveSessionState<TRaw = unknown> {
|
|
264
|
+
status: LiveSessionStatus;
|
|
265
|
+
stream: LiveStream | null;
|
|
266
|
+
/** Already multiplied by the host's view multiplier; see `rawViewerCount` for the truth. */
|
|
267
|
+
viewerCount: number;
|
|
268
|
+
rawViewerCount: number;
|
|
269
|
+
comments: LiveComment[];
|
|
270
|
+
/** The product the host is featuring, resolved through the commerce adapter. */
|
|
271
|
+
activeProduct: LiveProduct<TRaw> | null;
|
|
272
|
+
/** Everything shoppable in this stream, in the order the host added it. */
|
|
273
|
+
products: LiveProduct<TRaw>[];
|
|
274
|
+
sold: SoldCard[];
|
|
275
|
+
reactions: FloatingReaction[];
|
|
276
|
+
poll: LivePollView | null;
|
|
277
|
+
muted: boolean;
|
|
278
|
+
/** Native view currently rendering the stream; a surface compares its own tag against this. */
|
|
279
|
+
videoTag: number | null;
|
|
280
|
+
/** Ms since the host went live; 0 when not started. */
|
|
281
|
+
elapsedMs: number;
|
|
282
|
+
/** Anything other than `none` means a surface outside the navigator owns the picture. */
|
|
283
|
+
pipMode: LivePipMode;
|
|
284
|
+
guest: LiveGuestState;
|
|
285
|
+
/**
|
|
286
|
+
* What this device comments under: the identity adapter's name, or one a signed-out shopper gave.
|
|
287
|
+
* **Null means nobody has said** — ask before letting the first comment out rather than publishing
|
|
288
|
+
* "Anonymous" to a room.
|
|
289
|
+
*/
|
|
290
|
+
viewerName: string | null;
|
|
291
|
+
/** Inert unless the stream is an auction. */
|
|
292
|
+
auction: AuctionState;
|
|
293
|
+
giveaway: GiveawayState;
|
|
294
|
+
error: string | null;
|
|
295
|
+
}
|
|
296
|
+
export interface LiveSessionActions {
|
|
297
|
+
/** Hand a native video view to the session. Rebindable; `force` re-issues an unchanged bind. */
|
|
298
|
+
bindVideoView: (reactTag: number | null, force?: boolean) => void;
|
|
299
|
+
sendComment: (text: string) => Promise<void>;
|
|
300
|
+
sendReaction: (reactionUrl: string) => Promise<void>;
|
|
301
|
+
announceAddToCart: (productTitle: string) => Promise<void>;
|
|
302
|
+
/** Cast this install's one vote. Ignored once it has voted, so a double tap needs no guard. */
|
|
303
|
+
voteInPoll: (optionId: string) => Promise<void>;
|
|
304
|
+
/**
|
|
305
|
+
* Remember the name a signed-out shopper typed. Resolves to the name as stored — trimmed,
|
|
306
|
+
* collapsed, capped — or null if the input was empty, so the caller can send the comment that
|
|
307
|
+
* prompted for it without normalising again.
|
|
308
|
+
*/
|
|
309
|
+
chooseViewerName: (raw: string) => Promise<string | null>;
|
|
310
|
+
/** Add to cart through the commerce adapter and tell the room. False when the line was refused. */
|
|
311
|
+
addToCart: (variantId: string, productTitle: string) => Promise<boolean>;
|
|
312
|
+
joinAsGuest: (params: {
|
|
313
|
+
inviteToken: string;
|
|
314
|
+
/** From a deep link, which carries it; absent for a code typed in by hand. */
|
|
315
|
+
streamingId?: string;
|
|
316
|
+
userName: string;
|
|
317
|
+
previewTag: number | null;
|
|
318
|
+
}) => Promise<GuestCredentials>;
|
|
319
|
+
/** Stop publishing, hand the room back to the viewer session, and give up the slot. */
|
|
320
|
+
leaveGuest: () => Promise<void>;
|
|
321
|
+
setGuestMicMuted: (muted: boolean) => Promise<void>;
|
|
322
|
+
setGuestCameraOff: (off: boolean) => Promise<void>;
|
|
323
|
+
flipGuestCamera: (front: boolean) => Promise<void>;
|
|
324
|
+
/** Local camera preview. Separate from joining: the view's tag only exists after layout. */
|
|
325
|
+
bindGuestPreview: (reactTag: number | null) => void;
|
|
326
|
+
/** The host's own stream, so a guest can see who they are talking to. */
|
|
327
|
+
bindGuestHostView: (reactTag: number | null) => void;
|
|
328
|
+
setMuted: (muted: boolean) => void;
|
|
329
|
+
/** Shrink to an app-drawn surface. The caller navigates away from the full-screen player. */
|
|
330
|
+
enterPip: () => void;
|
|
331
|
+
/**
|
|
332
|
+
* Back to no bubble. `stopVideo` is for dismissing PIP outright rather than returning to the
|
|
333
|
+
* full-screen player: without it the room keeps playing and the audio outlives the last surface.
|
|
334
|
+
*/
|
|
335
|
+
exitPip: (options?: {
|
|
336
|
+
stopVideo?: boolean;
|
|
337
|
+
}) => void;
|
|
338
|
+
/**
|
|
339
|
+
* Offers a bid. `amount` omitted means the round's `nextBid` — the slide-to-bid gesture.
|
|
340
|
+
* `variantId` rides along because a bid on a multi-variant lot commits to a specific variant.
|
|
341
|
+
* Resolves once the bid has been sent, not when the host accepts it.
|
|
342
|
+
*/
|
|
343
|
+
placeBid: (options?: {
|
|
344
|
+
amount?: number;
|
|
345
|
+
variantId?: string | null;
|
|
346
|
+
}) => Promise<void>;
|
|
347
|
+
/** Enters the open giveaway. Needs a signed-in customer; no-ops without one. */
|
|
348
|
+
enterGiveaway: () => Promise<void>;
|
|
349
|
+
dismissAuctionWin: () => void;
|
|
350
|
+
dismissGiveawayResult: () => void;
|
|
351
|
+
}
|
|
352
|
+
export type LiveSession<TRaw = unknown> = LiveSessionState<TRaw> & {
|
|
353
|
+
actions: LiveSessionActions;
|
|
354
|
+
};
|
|
355
|
+
export interface SessionReducerState {
|
|
356
|
+
connected: boolean;
|
|
357
|
+
ended: boolean;
|
|
358
|
+
publishing: boolean;
|
|
359
|
+
videoBroken: boolean;
|
|
360
|
+
audioBroken: boolean;
|
|
361
|
+
/** Consecutive quality samples with no video arriving. */
|
|
362
|
+
videoIdleSamples: number;
|
|
363
|
+
rawViewerCount: number;
|
|
364
|
+
/** Set only once the host changes it; until then the stream record's value stands. */
|
|
365
|
+
multiplierOverride: number | null;
|
|
366
|
+
comments: LiveComment[];
|
|
367
|
+
/** Null means fall back to the record's current product. */
|
|
368
|
+
activeStoreProductId: string | null;
|
|
369
|
+
/** Products the host added mid-stream that were not in the record. */
|
|
370
|
+
extraStoreProductIds: string[];
|
|
371
|
+
removedStoreProductIds: string[];
|
|
372
|
+
sold: SoldCard[];
|
|
373
|
+
reactions: FloatingReaction[];
|
|
374
|
+
poll: LivePoll | null;
|
|
375
|
+
pollResults: LivePollResults | null;
|
|
376
|
+
votedOptionId: string | null;
|
|
377
|
+
mutedDeviceIds: string[];
|
|
378
|
+
guestMode: boolean;
|
|
379
|
+
guestStatus: GuestStatus;
|
|
380
|
+
guestSlot: number | null;
|
|
381
|
+
guestMutedByHost: boolean;
|
|
382
|
+
guestCameraOffByHost: boolean;
|
|
383
|
+
mixerLayout: MixerLayout | null;
|
|
384
|
+
videoTag: number | null;
|
|
385
|
+
seq: number;
|
|
386
|
+
biddingOpen: boolean;
|
|
387
|
+
/** Deadline on the host's clock. 0 when no round is open. */
|
|
388
|
+
endsAtMs: number;
|
|
389
|
+
/**
|
|
390
|
+
* The deadline the round opened with. A later `endsAtMs` than this is the definition of extended
|
|
391
|
+
* bidding, so it has to survive every bid in the round.
|
|
392
|
+
*/
|
|
393
|
+
openedEndsAtMs: number;
|
|
394
|
+
/** `serverNowMs - Date.now()`, captured whenever the host moves the deadline. */
|
|
395
|
+
serverOffsetMs: number;
|
|
396
|
+
highestBid: number;
|
|
397
|
+
nextBid: number;
|
|
398
|
+
bidLeader: BidLeader | null;
|
|
399
|
+
auctionExtended: boolean;
|
|
400
|
+
biddingStoreProductId: string | null;
|
|
401
|
+
/** Bids are addressed to this moderator for the duration of the round. */
|
|
402
|
+
moderatorId: string | null;
|
|
403
|
+
lastWin: AuctionWin | null;
|
|
404
|
+
giveawayStoreProductId: string | null;
|
|
405
|
+
giveawayEntryCount: number;
|
|
406
|
+
giveawayRegistered: boolean;
|
|
407
|
+
giveawayResult: {
|
|
408
|
+
storeProductId: string;
|
|
409
|
+
winnerName: string;
|
|
410
|
+
} | null;
|
|
411
|
+
}
|
|
412
|
+
export type SessionAction = {
|
|
413
|
+
kind: 'event';
|
|
414
|
+
event: LiveEvent;
|
|
415
|
+
at: number;
|
|
416
|
+
} | {
|
|
417
|
+
kind: 'ownComment';
|
|
418
|
+
comment: LiveComment;
|
|
419
|
+
}
|
|
420
|
+
/** Applied before the request goes out; the host's next broadcast supersedes it. */
|
|
421
|
+
| {
|
|
422
|
+
kind: 'vote';
|
|
423
|
+
optionId: string;
|
|
424
|
+
} | {
|
|
425
|
+
kind: 'voteFailed';
|
|
426
|
+
optionId: string;
|
|
427
|
+
}
|
|
428
|
+
/** A vote from a previous session, read back from storage. Does not touch the tally. */
|
|
429
|
+
| {
|
|
430
|
+
kind: 'restoreVote';
|
|
431
|
+
pollUuid: string;
|
|
432
|
+
optionId: string;
|
|
433
|
+
} | {
|
|
434
|
+
kind: 'prune';
|
|
435
|
+
now: number;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* The clock ran out and the host has not said so — a dropped moderator, a host that closed the
|
|
439
|
+
* tab. Without it a bid bar sits there inviting bids into a round that is over.
|
|
440
|
+
*/
|
|
441
|
+
| {
|
|
442
|
+
kind: 'auctionExpired';
|
|
443
|
+
} | {
|
|
444
|
+
kind: 'giveawayRegistered';
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Giveaway state read off the polled record rather than a live event. This is how a viewer who
|
|
448
|
+
* joins mid-giveaway sees the nudge and their own entry at all.
|
|
449
|
+
*/
|
|
450
|
+
| {
|
|
451
|
+
kind: 'giveawaySynced';
|
|
452
|
+
storeProductId: string | null;
|
|
453
|
+
entryCount: number;
|
|
454
|
+
registered: boolean;
|
|
455
|
+
} | {
|
|
456
|
+
kind: 'dismissWin';
|
|
457
|
+
} | {
|
|
458
|
+
kind: 'dismissGiveawayResult';
|
|
459
|
+
} | {
|
|
460
|
+
kind: 'reset';
|
|
461
|
+
};
|
|
462
|
+
//# sourceMappingURL=sessionTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionTypes.d.ts","sourceRoot":"","sources":["../src/sessionTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,eAAe,EACf,UAAU,EACV,WAAW,EACX,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAElE,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,YAAY;AACd,0EAA0E;GACxE,gBAAgB,GAChB,SAAS,GACT,OAAO,GACP,OAAO,CAAC;AAEZ;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtD,MAAM,MAAM,QAAQ,GAAG,gBAAgB,GAAG;IAAE,EAAE,EAAE,MAA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,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE;AAChC;;;GAGG;GACD;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE;AAChC;;;GAGG;GACD;IACE,IAAI,EAAE,gBAAgB,CAAC;IACvB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB,GACD;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,uBAAuB,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REPLAY_CAPABILITIES = exports.AUCTION_CAPABILITIES = exports.LIVE_CAPABILITIES = exports.IDLE_GIVEAWAY = exports.IDLE_AUCTION = void 0;
|
|
4
|
+
exports.capabilitiesFor = capabilitiesFor;
|
|
5
|
+
/** No round open, nothing won. For a replay or anything else that cannot bid. */
|
|
6
|
+
exports.IDLE_AUCTION = {
|
|
7
|
+
biddingOpen: false,
|
|
8
|
+
highestBid: 0,
|
|
9
|
+
nextBid: 0,
|
|
10
|
+
timeLeftMs: 0,
|
|
11
|
+
isLeading: false,
|
|
12
|
+
leaderName: null,
|
|
13
|
+
extended: false,
|
|
14
|
+
storeProductId: null,
|
|
15
|
+
lastWin: null,
|
|
16
|
+
bidCap: null,
|
|
17
|
+
extendedBiddingMs: 0,
|
|
18
|
+
};
|
|
19
|
+
exports.IDLE_GIVEAWAY = {
|
|
20
|
+
active: null,
|
|
21
|
+
entryCount: 0,
|
|
22
|
+
registered: false,
|
|
23
|
+
result: null,
|
|
24
|
+
};
|
|
25
|
+
exports.LIVE_CAPABILITIES = {
|
|
26
|
+
canComment: true,
|
|
27
|
+
canReact: true,
|
|
28
|
+
canShop: true,
|
|
29
|
+
showLiveBadge: true,
|
|
30
|
+
showViewerCount: true,
|
|
31
|
+
canPip: true,
|
|
32
|
+
canBid: false,
|
|
33
|
+
canEnterGiveaway: true,
|
|
34
|
+
};
|
|
35
|
+
/** An auction is a live show plus bidding — derived, so additions to live reach it for free. */
|
|
36
|
+
exports.AUCTION_CAPABILITIES = {
|
|
37
|
+
...exports.LIVE_CAPABILITIES,
|
|
38
|
+
canBid: true,
|
|
39
|
+
};
|
|
40
|
+
/** A recording: shop and scrub, but nothing to publish into and no audience to count. */
|
|
41
|
+
exports.REPLAY_CAPABILITIES = {
|
|
42
|
+
canComment: false,
|
|
43
|
+
canReact: false,
|
|
44
|
+
canShop: true,
|
|
45
|
+
showLiveBadge: false,
|
|
46
|
+
showViewerCount: false,
|
|
47
|
+
canPip: true,
|
|
48
|
+
canBid: false,
|
|
49
|
+
canEnterGiveaway: false,
|
|
50
|
+
};
|
|
51
|
+
/** Which flag set a stream calls for. The record's `allow_auction` is the only input. */
|
|
52
|
+
function capabilitiesFor(stream) {
|
|
53
|
+
return (stream === null || stream === void 0 ? void 0 : stream.isAuction) ? exports.AUCTION_CAPABILITIES : exports.LIVE_CAPABILITIES;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=sessionTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionTypes.js","sourceRoot":"","sources":["../src/sessionTypes.ts"],"names":[],"mappings":";;;AA4UA,0CAIC;AApOD,iFAAiF;AACpE,QAAA,YAAY,GAAiB;IACxC,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,CAAC;IACb,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,CAAC;IACb,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,KAAK;IACf,cAAc,EAAE,IAAI;IACpB,OAAO,EAAE,IAAI;IACb,MAAM,EAAE,IAAI;IACZ,iBAAiB,EAAE,CAAC;CACrB,CAAC;AAiBW,QAAA,aAAa,GAAkB;IAC1C,MAAM,EAAE,IAAI;IACZ,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,KAAK;IACjB,MAAM,EAAE,IAAI;CACb,CAAC;AA+JW,QAAA,iBAAiB,GAA4B;IACxD,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,IAAI;IACnB,eAAe,EAAE,IAAI;IACrB,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,KAAK;IACb,gBAAgB,EAAE,IAAI;CACvB,CAAC;AAEF,gGAAgG;AACnF,QAAA,oBAAoB,GAA4B;IAC3D,GAAG,yBAAiB;IACpB,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,yFAAyF;AAC5E,QAAA,mBAAmB,GAA4B;IAC1D,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,KAAK;IACpB,eAAe,EAAE,KAAK;IACtB,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,KAAK;IACb,gBAAgB,EAAE,KAAK;CACxB,CAAC;AAEF,yFAAyF;AACzF,SAAgB,eAAe,CAC7B,MAAiD;IAEjD,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,EAAC,CAAC,CAAC,4BAAoB,CAAC,CAAC,CAAC,yBAAiB,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { GiveawayEntry, LiveGiveaway, LiveStream, LiveStreamProduct, LiveStreamsAPI } from './types';
|
|
2
|
+
type RawStreamProduct = {
|
|
3
|
+
product_id?: string | null;
|
|
4
|
+
store_product_id?: string | null;
|
|
5
|
+
product_name?: string | null;
|
|
6
|
+
product_price?: string | null;
|
|
7
|
+
product_thumbnail?: {
|
|
8
|
+
url?: string | null;
|
|
9
|
+
altText?: string | null;
|
|
10
|
+
} | null;
|
|
11
|
+
is_current?: boolean | null;
|
|
12
|
+
start_time?: number | null;
|
|
13
|
+
base_bid_price?: number | string | null;
|
|
14
|
+
auction_winner?: unknown[] | null;
|
|
15
|
+
};
|
|
16
|
+
type RawGiveawayProduct = {
|
|
17
|
+
store_product_id?: string | null;
|
|
18
|
+
variant_id?: string | null;
|
|
19
|
+
giveawayStatus?: string | null;
|
|
20
|
+
product_name?: string | null;
|
|
21
|
+
product_thumbnail?: string | null;
|
|
22
|
+
product_variant_title?: string | null;
|
|
23
|
+
product_variant_price?: number | string | null;
|
|
24
|
+
users?: {
|
|
25
|
+
displayName?: string | null;
|
|
26
|
+
userId?: string | null;
|
|
27
|
+
}[] | null;
|
|
28
|
+
moderatorInCharge?: string | null;
|
|
29
|
+
};
|
|
30
|
+
type RawProductSegment = {
|
|
31
|
+
product_id: string;
|
|
32
|
+
start_time: number;
|
|
33
|
+
sequence: number;
|
|
34
|
+
};
|
|
35
|
+
type RawLiveStream = {
|
|
36
|
+
streaming_id: string;
|
|
37
|
+
room_id: string;
|
|
38
|
+
mixed_stream_id?: string | null;
|
|
39
|
+
streaming_name?: string | null;
|
|
40
|
+
streaming_description?: string | null;
|
|
41
|
+
streaming_thumbnail?: string | null;
|
|
42
|
+
streaming_status: number;
|
|
43
|
+
start_time_unix?: number | null;
|
|
44
|
+
actual_start_time_unix?: number | null;
|
|
45
|
+
company_name?: string | null;
|
|
46
|
+
allow_auction?: boolean | null;
|
|
47
|
+
ext_bidding_duration?: number | null;
|
|
48
|
+
product_info?: RawStreamProduct[] | null;
|
|
49
|
+
product_segments?: RawProductSegment[] | null;
|
|
50
|
+
meta?: Record<string, unknown> | null;
|
|
51
|
+
};
|
|
52
|
+
type RawLiveStreams = {
|
|
53
|
+
data?: RawLiveStream[] | null;
|
|
54
|
+
};
|
|
55
|
+
export declare function toLiveStreamProduct(raw: RawStreamProduct): LiveStreamProduct | null;
|
|
56
|
+
/**
|
|
57
|
+
* Entrants for one giveaway lot, out of the flat `meta` bag. The host writes one
|
|
58
|
+
* `giveaway_<storeProductId>_<n>` key per entry, so this is a prefix scan; `giveawayProducts[].users`
|
|
59
|
+
* looks like the same list but lags, which is why the live count reads from here.
|
|
60
|
+
*/
|
|
61
|
+
export declare function toGiveawayEntries(meta: Record<string, unknown> | null | undefined, storeProductId: string): GiveawayEntry[];
|
|
62
|
+
export declare function toLiveGiveaway(raw: RawGiveawayProduct, meta: Record<string, unknown> | null | undefined): LiveGiveaway | null;
|
|
63
|
+
export declare function toLiveStream(raw: RawLiveStream): LiveStream;
|
|
64
|
+
export declare function toLiveStreams(response: RawLiveStreams): LiveStream[];
|
|
65
|
+
export declare const streams: LiveStreamsAPI;
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=streams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streams.d.ts","sourceRoot":"","sources":["../src/streams.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,iBAAiB,EAEjB,cAAc,EAEf,MAAM,SAAS,CAAC;AAIjB,KAAK,gBAAgB,GAAG;IACtB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,iBAAiB,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IAC5E,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,UAAU,CAAC,E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