@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.
Files changed (149) hide show
  1. package/README.md +322 -0
  2. package/android/build.gradle +33 -0
  3. package/android/src/main/AndroidManifest.xml +7 -0
  4. package/android/src/main/java/expo/modules/livepip/LivePipModule.kt +310 -0
  5. package/app.plugin.js +3 -0
  6. package/dist/auctions.d.ts +3 -0
  7. package/dist/auctions.d.ts.map +1 -0
  8. package/dist/auctions.js +152 -0
  9. package/dist/auctions.js.map +1 -0
  10. package/dist/client.d.ts +63 -0
  11. package/dist/client.d.ts.map +1 -0
  12. package/dist/client.js +154 -0
  13. package/dist/client.js.map +1 -0
  14. package/dist/clips.d.ts +3 -0
  15. package/dist/clips.d.ts.map +1 -0
  16. package/dist/clips.js +53 -0
  17. package/dist/clips.js.map +1 -0
  18. package/dist/commentLinks.d.ts +46 -0
  19. package/dist/commentLinks.d.ts.map +1 -0
  20. package/dist/commentLinks.js +120 -0
  21. package/dist/commentLinks.js.map +1 -0
  22. package/dist/engine.d.ts +13 -0
  23. package/dist/engine.d.ts.map +1 -0
  24. package/dist/engine.js +40 -0
  25. package/dist/engine.js.map +1 -0
  26. package/dist/engine.native.d.ts +3 -0
  27. package/dist/engine.native.d.ts.map +1 -0
  28. package/dist/engine.native.js +815 -0
  29. package/dist/engine.native.js.map +1 -0
  30. package/dist/flags.d.ts +5 -0
  31. package/dist/flags.d.ts.map +1 -0
  32. package/dist/flags.js +61 -0
  33. package/dist/flags.js.map +1 -0
  34. package/dist/guest.d.ts +5 -0
  35. package/dist/guest.d.ts.map +1 -0
  36. package/dist/guest.js +89 -0
  37. package/dist/guest.js.map +1 -0
  38. package/dist/index.d.ts +31 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +80 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/liveSelling.d.ts +3 -0
  43. package/dist/liveSelling.d.ts.map +1 -0
  44. package/dist/liveSelling.js +44 -0
  45. package/dist/liveSelling.js.map +1 -0
  46. package/dist/nativeViewTag.d.ts +15 -0
  47. package/dist/nativeViewTag.d.ts.map +1 -0
  48. package/dist/nativeViewTag.js +23 -0
  49. package/dist/nativeViewTag.js.map +1 -0
  50. package/dist/pip.d.ts +14 -0
  51. package/dist/pip.d.ts.map +1 -0
  52. package/dist/pip.js +15 -0
  53. package/dist/pip.js.map +1 -0
  54. package/dist/pip.native.d.ts +11 -0
  55. package/dist/pip.native.d.ts.map +1 -0
  56. package/dist/pip.native.js +47 -0
  57. package/dist/pip.native.js.map +1 -0
  58. package/dist/polls.d.ts +11 -0
  59. package/dist/polls.d.ts.map +1 -0
  60. package/dist/polls.js +135 -0
  61. package/dist/polls.js.map +1 -0
  62. package/dist/react/LiveSellingProvider.d.ts +16 -0
  63. package/dist/react/LiveSellingProvider.d.ts.map +1 -0
  64. package/dist/react/LiveSellingProvider.js +49 -0
  65. package/dist/react/LiveSellingProvider.js.map +1 -0
  66. package/dist/react/LiveVideoTarget.d.ts +22 -0
  67. package/dist/react/LiveVideoTarget.d.ts.map +1 -0
  68. package/dist/react/LiveVideoTarget.js +73 -0
  69. package/dist/react/LiveVideoTarget.js.map +1 -0
  70. package/dist/react/index.d.ts +19 -0
  71. package/dist/react/index.d.ts.map +1 -0
  72. package/dist/react/index.js +43 -0
  73. package/dist/react/index.js.map +1 -0
  74. package/dist/react/useAuction.d.ts +28 -0
  75. package/dist/react/useAuction.d.ts.map +1 -0
  76. package/dist/react/useAuction.js +66 -0
  77. package/dist/react/useAuction.js.map +1 -0
  78. package/dist/react/useAuctionBidGate.d.ts +48 -0
  79. package/dist/react/useAuctionBidGate.d.ts.map +1 -0
  80. package/dist/react/useAuctionBidGate.js +144 -0
  81. package/dist/react/useAuctionBidGate.js.map +1 -0
  82. package/dist/react/useAuctionWins.d.ts +51 -0
  83. package/dist/react/useAuctionWins.d.ts.map +1 -0
  84. package/dist/react/useAuctionWins.js +268 -0
  85. package/dist/react/useAuctionWins.js.map +1 -0
  86. package/dist/react/useClips.d.ts +9 -0
  87. package/dist/react/useClips.d.ts.map +1 -0
  88. package/dist/react/useClips.js +37 -0
  89. package/dist/react/useClips.js.map +1 -0
  90. package/dist/react/useLiveSession.d.ts +34 -0
  91. package/dist/react/useLiveSession.d.ts.map +1 -0
  92. package/dist/react/useLiveSession.js +876 -0
  93. package/dist/react/useLiveSession.js.map +1 -0
  94. package/dist/react/useLiveStreams.d.ts +9 -0
  95. package/dist/react/useLiveStreams.d.ts.map +1 -0
  96. package/dist/react/useLiveStreams.js +35 -0
  97. package/dist/react/useLiveStreams.js.map +1 -0
  98. package/dist/react/useOngoingLive.d.ts +13 -0
  99. package/dist/react/useOngoingLive.d.ts.map +1 -0
  100. package/dist/react/useOngoingLive.js +45 -0
  101. package/dist/react/useOngoingLive.js.map +1 -0
  102. package/dist/react/useReplays.d.ts +15 -0
  103. package/dist/react/useReplays.d.ts.map +1 -0
  104. package/dist/react/useReplays.js +66 -0
  105. package/dist/react/useReplays.js.map +1 -0
  106. package/dist/react/useStreamInfo.d.ts +21 -0
  107. package/dist/react/useStreamInfo.d.ts.map +1 -0
  108. package/dist/react/useStreamInfo.js +125 -0
  109. package/dist/react/useStreamInfo.js.map +1 -0
  110. package/dist/replays.d.ts +3 -0
  111. package/dist/replays.d.ts.map +1 -0
  112. package/dist/replays.js +114 -0
  113. package/dist/replays.js.map +1 -0
  114. package/dist/session.d.ts +23 -0
  115. package/dist/session.d.ts.map +1 -0
  116. package/dist/session.js +464 -0
  117. package/dist/session.js.map +1 -0
  118. package/dist/sessionTypes.d.ts +462 -0
  119. package/dist/sessionTypes.d.ts.map +1 -0
  120. package/dist/sessionTypes.js +55 -0
  121. package/dist/sessionTypes.js.map +1 -0
  122. package/dist/streams.d.ts +67 -0
  123. package/dist/streams.d.ts.map +1 -0
  124. package/dist/streams.js +170 -0
  125. package/dist/streams.js.map +1 -0
  126. package/dist/types.d.ts +591 -0
  127. package/dist/types.d.ts.map +1 -0
  128. package/dist/types.js +17 -0
  129. package/dist/types.js.map +1 -0
  130. package/dist/viewer.d.ts +5 -0
  131. package/dist/viewer.d.ts.map +1 -0
  132. package/dist/viewer.js +66 -0
  133. package/dist/viewer.js.map +1 -0
  134. package/dist/wire.d.ts +155 -0
  135. package/dist/wire.d.ts.map +1 -0
  136. package/dist/wire.js +73 -0
  137. package/dist/wire.js.map +1 -0
  138. package/dist/zego.d.ts +83 -0
  139. package/dist/zego.d.ts.map +1 -0
  140. package/dist/zego.js +13 -0
  141. package/dist/zego.js.map +1 -0
  142. package/expo-module.config.json +9 -0
  143. package/ios/LivePip.podspec +20 -0
  144. package/ios/LivePipController.swift +327 -0
  145. package/ios/LivePipModule.swift +35 -0
  146. package/package.json +91 -0
  147. package/plugin/build/index.d.ts +29 -0
  148. package/plugin/build/index.js +101 -0
  149. package/react/package.json +6 -0
package/dist/polls.js ADDED
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.polls = void 0;
4
+ exports.toLivePoll = toLivePoll;
5
+ exports.toLivePollResults = toLivePollResults;
6
+ exports.toEmbeddedResults = toEmbeddedResults;
7
+ /**
8
+ * Live polls.
9
+ *
10
+ * The host owns a poll end to end: it creates one, starts it, then republishes the tally to the room.
11
+ * A viewer reads those broadcasts and POSTs a vote — there is no poll GET on the viewer path, so
12
+ * despite the name nothing here polls anything.
13
+ *
14
+ * Two normalisations on the way in: option ids become strings (the dashboard sends numbers in the poll
15
+ * but strings in the tally), and the pre-rendered `percentage` is dropped in favour of deriving from
16
+ * the raw counts.
17
+ */
18
+ const client_1 = require("./client");
19
+ const wire_1 = require("./wire");
20
+ /** The dashboard numbers its options in the poll and stringifies them in the tally. */
21
+ function toOptionId(raw) {
22
+ return (0, wire_1.str)(raw);
23
+ }
24
+ function toCount(raw) {
25
+ const value = (0, wire_1.num)(raw);
26
+ return value !== null && value > 0 ? Math.floor(value) : 0;
27
+ }
28
+ function toLivePoll(raw) {
29
+ var _a, _b, _c;
30
+ const wire = raw;
31
+ const pollUuid = (0, wire_1.str)((0, wire_1.get)(wire, 'poll_uuid'));
32
+ if (!pollUuid)
33
+ return null;
34
+ const options = [];
35
+ const wireOptionIds = {};
36
+ for (const entry of (0, wire_1.arr)((0, wire_1.get)(wire, 'options'))) {
37
+ const option = entry;
38
+ // Kept exactly as it arrived: a vote has to echo the original type, and sending `"1"` where every
39
+ // other viewer sends `1` risks the service tallying the two apart.
40
+ const original = (_a = (0, wire_1.get)(option, 'optionId')) !== null && _a !== void 0 ? _a : (0, wire_1.get)(option, 'option_id');
41
+ if (typeof original !== 'string' && typeof original !== 'number')
42
+ continue;
43
+ const optionId = toOptionId(original);
44
+ if (!optionId)
45
+ continue;
46
+ options.push({ optionId, text: (_b = (0, wire_1.str)((0, wire_1.get)(option, 'text'))) !== null && _b !== void 0 ? _b : '' });
47
+ wireOptionIds[optionId] = original;
48
+ }
49
+ // A poll with nothing to vote on is not one; an empty sheet is worse than none.
50
+ if (!options.length)
51
+ return null;
52
+ return {
53
+ pollUuid,
54
+ streamingId: (0, wire_1.str)((0, wire_1.get)(wire, 'streaming_id')),
55
+ question: (_c = (0, wire_1.str)((0, wire_1.get)(wire, 'question'))) !== null && _c !== void 0 ? _c : '',
56
+ options,
57
+ wireOptionIds,
58
+ };
59
+ }
60
+ function toLivePollResults(raw) {
61
+ var _a;
62
+ if (!(0, wire_1.isRecord)(raw))
63
+ return null;
64
+ const votes = {};
65
+ let counted = 0;
66
+ for (const entry of (0, wire_1.arr)(raw.options)) {
67
+ const option = entry;
68
+ const optionId = toOptionId((_a = (0, wire_1.get)(option, 'optionId')) !== null && _a !== void 0 ? _a : (0, wire_1.get)(option, 'option_id'));
69
+ if (!optionId)
70
+ continue;
71
+ votes[optionId] = toCount((0, wire_1.get)(option, 'votes'));
72
+ counted += votes[optionId];
73
+ }
74
+ const total = toCount(raw.total_votes);
75
+ return {
76
+ pollUuid: (0, wire_1.str)(raw.poll_uuid),
77
+ // The host's own sum wins, but never below what the options add up to.
78
+ totalVotes: Math.max(total, counted),
79
+ votes,
80
+ };
81
+ }
82
+ /**
83
+ * The tally a poll payload carries with it, or null when it carries none. A tally of zero is treated
84
+ * as absent — a plain `START_POLL` would otherwise wipe a real count with an authoritative "nobody
85
+ * voted".
86
+ */
87
+ function toEmbeddedResults(raw) {
88
+ var _a;
89
+ const results = (_a = toLivePollResults((0, wire_1.get)(raw, 'pollResults'))) !== null && _a !== void 0 ? _a : toLivePollResults(raw);
90
+ return results && results.totalVotes > 0 ? results : null;
91
+ }
92
+ // ─── Remembering the vote ────────────────────────────────────────────────────
93
+ const VOTES_KEY = 'live.pollVotes';
94
+ const MAX_REMEMBERED = 20;
95
+ async function readVotes() {
96
+ try {
97
+ const raw = await (0, client_1.storageGet)(VOTES_KEY);
98
+ const parsed = raw ? JSON.parse(raw) : null;
99
+ return Array.isArray(parsed) ? parsed : [];
100
+ }
101
+ catch {
102
+ return [];
103
+ }
104
+ }
105
+ // ─── Namespace ─────────────────────────────────────────────────────────────
106
+ exports.polls = {
107
+ async vote(params) {
108
+ var _a;
109
+ await (0, client_1.liveSellingRequest)('/live-streaming/poll/vote', {
110
+ method: 'POST',
111
+ body: {
112
+ streaming_id: params.streamingId,
113
+ company_id: (_a = (0, client_1.getCompanyId)()) !== null && _a !== void 0 ? _a : (0, client_1.getConfig)().companyId,
114
+ poll_uuid: params.pollUuid,
115
+ viewer_id: params.viewerId,
116
+ option_id: params.optionId,
117
+ },
118
+ });
119
+ },
120
+ async loadVotedOption(pollUuid) {
121
+ var _a, _b;
122
+ const votes = await readVotes();
123
+ return (_b = (_a = votes.find(([uuid]) => uuid === pollUuid)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : null;
124
+ },
125
+ async rememberVote(pollUuid, optionId) {
126
+ const votes = (await readVotes()).filter(([uuid]) => uuid !== pollUuid);
127
+ votes.push([pollUuid, optionId]);
128
+ await (0, client_1.storageSet)(VOTES_KEY, JSON.stringify(votes.slice(-MAX_REMEMBERED)));
129
+ },
130
+ async forgetVote(pollUuid) {
131
+ const votes = (await readVotes()).filter(([uuid]) => uuid !== pollUuid);
132
+ await (0, client_1.storageSet)(VOTES_KEY, JSON.stringify(votes));
133
+ },
134
+ };
135
+ //# sourceMappingURL=polls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polls.js","sourceRoot":"","sources":["../src/polls.ts"],"names":[],"mappings":";;;AA+BA,gCA4BC;AAED,8CAoBC;AAOD,8CAGC;AA3FD;;;;;;;;;;GAUG;AACH,qCAMkB;AAClB,iCAA0F;AAG1F,uFAAuF;AACvF,SAAS,UAAU,CAAC,GAAY;IAC9B,OAAO,IAAA,UAAG,EAAC,GAAG,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,OAAO,CAAC,GAAY;IAC3B,MAAM,KAAK,GAAG,IAAA,UAAG,EAAC,GAAG,CAAC,CAAC;IACvB,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED,SAAgB,UAAU,CAAC,GAAY;;IACrC,MAAM,IAAI,GAAG,GAAsB,CAAC;IACpC,MAAM,QAAQ,GAAG,IAAA,UAAG,EAAC,IAAA,UAAG,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IAC7C,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE3B,MAAM,OAAO,GAAqB,EAAE,CAAC;IACrC,MAAM,aAAa,GAAoC,EAAE,CAAC;IAC1D,KAAK,MAAM,KAAK,IAAI,IAAA,UAAG,EAAC,IAAA,UAAG,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,KAAuB,CAAC;QACvC,kGAAkG;QAClG,mEAAmE;QACnE,MAAM,QAAQ,GAAG,MAAA,IAA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G,CAAC,MAAM,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;QACxE,MAAM,IAAA,mBAAU,EAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IACrD,CAAC;CACF,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { LiveEvent, LiveSellingClient, LiveSellingConfig } from '../types';
3
+ export interface LiveSellingContextType {
4
+ ready: boolean;
5
+ error: string | null;
6
+ client: LiveSellingClient;
7
+ }
8
+ export interface LiveSellingProviderProps {
9
+ children: ReactNode;
10
+ config: LiveSellingConfig;
11
+ /** Every live-engine event, for a host that wants to react without subscribing to the engine. */
12
+ onEvent?: (event: LiveEvent) => void;
13
+ }
14
+ export declare function LiveSellingProvider({ children, config, onEvent }: LiveSellingProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<LiveSellingContextType | undefined>>;
15
+ export declare function useLiveSelling(): LiveSellingContextType;
16
+ //# sourceMappingURL=LiveSellingProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveSellingProvider.d.ts","sourceRoot":"","sources":["../../src/react/LiveSellingProvider.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEhF,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,iGAAiG;IACjG,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CACtC;AAID,wBAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,wBAAwB,+GA6B1F;AAED,wBAAgB,cAAc,IAAI,sBAAsB,CAIvD"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LiveSellingProvider = LiveSellingProvider;
4
+ exports.useLiveSelling = useLiveSelling;
5
+ /**
6
+ * `LiveSellingProvider` — configures the client once and exposes readiness + the client to the tree.
7
+ *
8
+ * Mirrors `@apptile/sdk-shopify`'s `ShopifyProvider`: wrap the app once, then read the namespaces through
9
+ * hooks. Written with `createElement` rather than JSX so the file stays a plain `.ts` and needs no JSX
10
+ * runtime configured in a consumer's build.
11
+ *
12
+ * `onEvent` is a passthrough of the live engine's `LiveEvent` union, so a host can react to comments,
13
+ * bids, sold announcements and co-host signals without subscribing to the engine directly.
14
+ */
15
+ const react_1 = require("react");
16
+ const liveSelling_1 = require("../liveSelling");
17
+ const LiveSellingContext = (0, react_1.createContext)(undefined);
18
+ function LiveSellingProvider({ children, config, onEvent }) {
19
+ const [ready, setReady] = (0, react_1.useState)(false);
20
+ const [error, setError] = (0, react_1.useState)(null);
21
+ (0, react_1.useEffect)(() => {
22
+ try {
23
+ liveSelling_1.liveSelling.configure(config);
24
+ setError(null);
25
+ setReady(true);
26
+ }
27
+ catch (caught) {
28
+ setError(caught instanceof Error ? caught.message : String(caught));
29
+ // Ready so downstream UIs render an error state rather than an indefinite spinner.
30
+ setReady(true);
31
+ }
32
+ // Re-run only when the identifying config fields change.
33
+ // eslint-disable-next-line react-hooks/exhaustive-deps
34
+ }, [config.apiUrl, config.companyId, config.videoCollectionId]);
35
+ (0, react_1.useEffect)(() => {
36
+ if (!onEvent)
37
+ return;
38
+ return liveSelling_1.liveSelling.engine.subscribe(onEvent);
39
+ }, [onEvent]);
40
+ const value = (0, react_1.useMemo)(() => ({ ready, error, client: liveSelling_1.liveSelling }), [ready, error]);
41
+ return (0, react_1.createElement)(LiveSellingContext.Provider, { value }, children);
42
+ }
43
+ function useLiveSelling() {
44
+ const ctx = (0, react_1.useContext)(LiveSellingContext);
45
+ if (!ctx)
46
+ throw new Error('useLiveSelling must be used within a LiveSellingProvider');
47
+ return ctx;
48
+ }
49
+ //# sourceMappingURL=LiveSellingProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveSellingProvider.js","sourceRoot":"","sources":["../../src/react/LiveSellingProvider.ts"],"names":[],"mappings":";;AA+BA,kDA6BC;AAED,wCAIC;AAlED;;;;;;;;;GASG;AACH,iCAA+F;AAG/F,gDAA6C;AAgB7C,MAAM,kBAAkB,GAAG,IAAA,qBAAa,EAAqC,SAAS,CAAC,CAAC;AAExF,SAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAA4B;IACzF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAgB,IAAI,CAAC,CAAC;IAExD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC;YACH,yBAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAC9B,QAAQ,CAAC,IAAI,CAAC,CAAC;YACf,QAAQ,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,QAAQ,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YACpE,mFAAmF;YACnF,QAAQ,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;QACD,yDAAyD;QACzD,uDAAuD;IACzD,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAEhE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,OAAO,yBAAW,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,MAAM,KAAK,GAAG,IAAA,eAAO,EACnB,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,yBAAW,EAAE,CAAC,EAC7C,CAAC,KAAK,EAAE,KAAK,CAAC,CACf,CAAC;IAEF,OAAO,IAAA,qBAAa,EAAC,kBAAkB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,QAAQ,CAAC,CAAC;AACzE,CAAC;AAED,SAAgB,cAAc;IAC5B,MAAM,GAAG,GAAG,IAAA,kBAAU,EAAC,kBAAkB,CAAC,CAAC;IAC3C,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IACtF,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { ReactNode } from 'react';
2
+ import { View } from 'react-native';
3
+ import type { ViewProps, ViewStyle } from 'react-native';
4
+ /** Whether real video can be rendered at all. False off-device, and on any build without the SDK. */
5
+ export declare const isNativeVideoSupported: boolean;
6
+ /**
7
+ * Falls back to a plain `View` rather than to null: callers position this and usually draw a poster
8
+ * over the top, and a missing child would collapse that layout instead of leaving the poster the
9
+ * right shape.
10
+ */
11
+ export declare const NativeVideoView: import("react").ForwardRefExoticComponent<ViewProps & import("react").RefAttributes<unknown>>;
12
+ export interface LiveVideoTargetProps {
13
+ /** Claim the picture while true. Exactly one mounted target should ever have this set. */
14
+ active: boolean;
15
+ /** A card usually wants picture without sound; the full-screen player and PIP want both. */
16
+ muted?: boolean;
17
+ style?: ViewStyle;
18
+ /** Rendered above the video — a poster, a spinner, a "waiting for the host" panel. */
19
+ children?: ReactNode;
20
+ }
21
+ export declare function LiveVideoTarget({ active, muted, style, children, }: LiveVideoTargetProps): import("react").CElement<ViewProps, View>;
22
+ //# sourceMappingURL=LiveVideoTarget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveVideoTarget.d.ts","sourceRoot":"","sources":["../../src/react/LiveVideoTarget.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAiB,SAAS,EAAO,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAY,IAAI,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAsBzD,qGAAqG;AACrG,eAAO,MAAM,sBAAsB,SAA4B,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,eAAe,+FAG1B,CAAC;AAEH,MAAM,WAAW,oBAAoB;IACnC,0FAA0F;IAC1F,MAAM,EAAE,OAAO,CAAC;IAChB,4FAA4F;IAC5F,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,sFAAsF;IACtF,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,KAAa,EACb,KAAK,EACL,QAAQ,GACT,EAAE,oBAAoB,6CA2BtB"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NativeVideoView = exports.isNativeVideoSupported = void 0;
4
+ exports.LiveVideoTarget = LiveVideoTarget;
5
+ /**
6
+ * `LiveVideoTarget` — the one primitive this package draws.
7
+ *
8
+ * A render target, not a player: it mounts the engine's native texture view and hands its tag to the
9
+ * session, which points the room's video at it. Everything else on a live screen — the header, the
10
+ * comments, the bid bar, the poster shown while there is no picture — is the host app's, by design.
11
+ *
12
+ * Ownership comes from the `active` prop rather than navigation focus, because a picture-in-picture
13
+ * surface is drawn *outside* the navigator where there is no route to read focus from. Exactly one
14
+ * mounted target should have it set; the usual expression is
15
+ * `active={isFocused && session.pipMode === 'none'}`.
16
+ *
17
+ * `createElement` rather than JSX, like the providers, so this stays a plain `.ts`.
18
+ */
19
+ const react_1 = require("react");
20
+ const react_native_1 = require("react-native");
21
+ const nativeViewTag_1 = require("../nativeViewTag");
22
+ const useLiveSession_1 = require("./useLiveSession");
23
+ /**
24
+ * The engine's texture view, or undefined where there is no engine.
25
+ *
26
+ * `require` inside the branch rather than a top-level import, and the decision made in source rather
27
+ * than left to a bundler alias: a static import is evaluated whichever branch runs, and the Zego entry
28
+ * module touches `NativeModules.ZegoExpressNativeModule` while it loads. A resolver alias fixes that
29
+ * only where that resolver does the bundling — a runtime-transpiling host (a web preview that ships
30
+ * `src/**`) resolves the real module, finds no `ZegoTextureView` on it, and rendering an element of
31
+ * type `undefined` throws. So the branch has to be something every bundler honours.
32
+ */
33
+ /** A host component, so it takes a ref — that ref's tag is what the engine renders into. */
34
+ const NativeTextureView = react_native_1.Platform.OS === 'web'
35
+ ? undefined
36
+ : // eslint-disable-next-line @typescript-eslint/no-var-requires
37
+ require('zego-express-engine-reactnative').ZegoTextureView;
38
+ /** Whether real video can be rendered at all. False off-device, and on any build without the SDK. */
39
+ exports.isNativeVideoSupported = NativeTextureView != null;
40
+ /**
41
+ * Falls back to a plain `View` rather than to null: callers position this and usually draw a poster
42
+ * over the top, and a missing child would collapse that layout instead of leaving the poster the
43
+ * right shape.
44
+ */
45
+ exports.NativeVideoView = (0, react_1.forwardRef)(function NativeVideoView(props, ref) {
46
+ if (!NativeTextureView)
47
+ return (0, react_1.createElement)(react_native_1.View, props);
48
+ return (0, react_1.createElement)(NativeTextureView, { ...props, ref });
49
+ });
50
+ function LiveVideoTarget({ active, muted = false, style, children, }) {
51
+ const viewRef = (0, react_1.useRef)(null);
52
+ const { status, actions } = (0, useLiveSession_1.useLiveSession)();
53
+ const claim = (0, react_1.useCallback)(() => {
54
+ if (!active)
55
+ return;
56
+ if (status !== 'playing' && status !== 'connecting')
57
+ return;
58
+ const tag = (0, nativeViewTag_1.nativeViewTag)(viewRef.current);
59
+ if (tag == null)
60
+ return;
61
+ // Forced: this runs when the surface takes ownership, and the engine may still believe it is
62
+ // rendering into this view when in fact the view was torn down behind another screen.
63
+ actions.bindVideoView(tag, true);
64
+ actions.setMuted(muted);
65
+ }, [active, status, muted, actions]);
66
+ (0, react_1.useEffect)(claim, [claim]);
67
+ return (0, react_1.createElement)(react_native_1.View, { style: style !== null && style !== void 0 ? style : { flex: 1 } }, (0, react_1.createElement)(exports.NativeVideoView, {
68
+ ref: viewRef,
69
+ style: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 },
70
+ onLayout: claim,
71
+ }), children);
72
+ }
73
+ //# sourceMappingURL=LiveVideoTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveVideoTarget.js","sourceRoot":"","sources":["../../src/react/LiveVideoTarget.ts"],"names":[],"mappings":";;;AA8DA,0CAgCC;AA9FD;;;;;;;;;;;;;GAaG;AACH,iCAAkF;AAElF,+CAA8C;AAG9C,oDAAiD;AACjD,qDAAkD;AAElD;;;;;;;;;GASG;AACH,4FAA4F;AAC5F,MAAM,iBAAiB,GACrB,uBAAQ,CAAC,EAAE,KAAK,KAAK;IACnB,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,8DAA8D;QAC9D,OAAO,CAAC,iCAAiC,CAAC,CAAC,eAAe,CAAC;AAEjE,qGAAqG;AACxF,QAAA,sBAAsB,GAAG,iBAAiB,IAAI,IAAI,CAAC;AAEhE;;;;GAIG;AACU,QAAA,eAAe,GAAG,IAAA,kBAAU,EAAqB,SAAS,eAAe,CAAC,KAAK,EAAE,GAAG;IAC/F,IAAI,CAAC,iBAAiB;QAAE,OAAO,IAAA,qBAAa,EAAC,mBAAI,EAAE,KAAK,CAAC,CAAC;IAC1D,OAAO,IAAA,qBAAa,EAA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QACrE,QAAQ,EAAE,KAAK;KAChB,CAAC,EACF,QAAQ,CACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * React helpers for `@tiledev/sdk-apptile-live-selling` — the provider and the read hooks.
3
+ *
4
+ * Ships under the `/react` subpath so a consumer only pays for `react` if it uses them; the pure data
5
+ * client and the native engine work without React entirely.
6
+ */
7
+ export { LiveSellingProvider, useLiveSelling, type LiveSellingProviderProps, type LiveSellingContextType, } from './LiveSellingProvider';
8
+ export { useOngoingLive, type UseOngoingLiveOptions, type UseOngoingLiveState } from './useOngoingLive';
9
+ export { useLiveStreams, type UseLiveStreamsState } from './useLiveStreams';
10
+ export { useAuction, type UseAuctionState } from './useAuction';
11
+ export { useReplays, type UseReplaysOptions, type UseReplaysState } from './useReplays';
12
+ export { useClips, type UseClipsState } from './useClips';
13
+ export { LiveSessionProvider, useLiveSession, type LiveSessionProviderProps, } from './useLiveSession';
14
+ export { useStreamInfo, refreshStreamRecords, refreshStreamRecordsIfStale, } from './useStreamInfo';
15
+ export { LiveVideoTarget, NativeVideoView, isNativeVideoSupported, type LiveVideoTargetProps, } from './LiveVideoTarget';
16
+ export { useAuctionBidGate, SHEET_HANDOFF_MS, type AuctionBidGate, type BidBlocker } from './useAuctionBidGate';
17
+ export { useAuctionWins, type AuctionWinRow, type UseAuctionWinsOptions, type UseAuctionWinsState, } from './useAuctionWins';
18
+ export { nativeViewTag } from '../nativeViewTag';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,GAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACxG,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAG1D,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,KAAK,wBAAwB,GAC9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAChH,OAAO,EACL,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nativeViewTag = exports.useAuctionWins = exports.SHEET_HANDOFF_MS = exports.useAuctionBidGate = exports.isNativeVideoSupported = exports.NativeVideoView = exports.LiveVideoTarget = exports.refreshStreamRecordsIfStale = exports.refreshStreamRecords = exports.useStreamInfo = exports.useLiveSession = exports.LiveSessionProvider = exports.useClips = exports.useReplays = exports.useAuction = exports.useLiveStreams = exports.useOngoingLive = exports.useLiveSelling = exports.LiveSellingProvider = void 0;
4
+ /**
5
+ * React helpers for `@tiledev/sdk-apptile-live-selling` — the provider and the read hooks.
6
+ *
7
+ * Ships under the `/react` subpath so a consumer only pays for `react` if it uses them; the pure data
8
+ * client and the native engine work without React entirely.
9
+ */
10
+ var LiveSellingProvider_1 = require("./LiveSellingProvider");
11
+ Object.defineProperty(exports, "LiveSellingProvider", { enumerable: true, get: function () { return LiveSellingProvider_1.LiveSellingProvider; } });
12
+ Object.defineProperty(exports, "useLiveSelling", { enumerable: true, get: function () { return LiveSellingProvider_1.useLiveSelling; } });
13
+ var useOngoingLive_1 = require("./useOngoingLive");
14
+ Object.defineProperty(exports, "useOngoingLive", { enumerable: true, get: function () { return useOngoingLive_1.useOngoingLive; } });
15
+ var useLiveStreams_1 = require("./useLiveStreams");
16
+ Object.defineProperty(exports, "useLiveStreams", { enumerable: true, get: function () { return useLiveStreams_1.useLiveStreams; } });
17
+ var useAuction_1 = require("./useAuction");
18
+ Object.defineProperty(exports, "useAuction", { enumerable: true, get: function () { return useAuction_1.useAuction; } });
19
+ var useReplays_1 = require("./useReplays");
20
+ Object.defineProperty(exports, "useReplays", { enumerable: true, get: function () { return useReplays_1.useReplays; } });
21
+ var useClips_1 = require("./useClips");
22
+ Object.defineProperty(exports, "useClips", { enumerable: true, get: function () { return useClips_1.useClips; } });
23
+ // The assembled session: the engine's events plus the polled record, folded into one state.
24
+ var useLiveSession_1 = require("./useLiveSession");
25
+ Object.defineProperty(exports, "LiveSessionProvider", { enumerable: true, get: function () { return useLiveSession_1.LiveSessionProvider; } });
26
+ Object.defineProperty(exports, "useLiveSession", { enumerable: true, get: function () { return useLiveSession_1.useLiveSession; } });
27
+ var useStreamInfo_1 = require("./useStreamInfo");
28
+ Object.defineProperty(exports, "useStreamInfo", { enumerable: true, get: function () { return useStreamInfo_1.useStreamInfo; } });
29
+ Object.defineProperty(exports, "refreshStreamRecords", { enumerable: true, get: function () { return useStreamInfo_1.refreshStreamRecords; } });
30
+ Object.defineProperty(exports, "refreshStreamRecordsIfStale", { enumerable: true, get: function () { return useStreamInfo_1.refreshStreamRecordsIfStale; } });
31
+ var LiveVideoTarget_1 = require("./LiveVideoTarget");
32
+ Object.defineProperty(exports, "LiveVideoTarget", { enumerable: true, get: function () { return LiveVideoTarget_1.LiveVideoTarget; } });
33
+ Object.defineProperty(exports, "NativeVideoView", { enumerable: true, get: function () { return LiveVideoTarget_1.NativeVideoView; } });
34
+ Object.defineProperty(exports, "isNativeVideoSupported", { enumerable: true, get: function () { return LiveVideoTarget_1.isNativeVideoSupported; } });
35
+ var useAuctionBidGate_1 = require("./useAuctionBidGate");
36
+ Object.defineProperty(exports, "useAuctionBidGate", { enumerable: true, get: function () { return useAuctionBidGate_1.useAuctionBidGate; } });
37
+ Object.defineProperty(exports, "SHEET_HANDOFF_MS", { enumerable: true, get: function () { return useAuctionBidGate_1.SHEET_HANDOFF_MS; } });
38
+ var useAuctionWins_1 = require("./useAuctionWins");
39
+ Object.defineProperty(exports, "useAuctionWins", { enumerable: true, get: function () { return useAuctionWins_1.useAuctionWins; } });
40
+ // React Native only, so it lives here rather than on the root entry.
41
+ var nativeViewTag_1 = require("../nativeViewTag");
42
+ Object.defineProperty(exports, "nativeViewTag", { enumerable: true, get: function () { return nativeViewTag_1.nativeViewTag; } });
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,6DAK+B;AAJ7B,0HAAA,mBAAmB,OAAA;AACnB,qHAAA,cAAc,OAAA;AAIhB,mDAAwG;AAA/F,gHAAA,cAAc,OAAA;AACvB,mDAA4E;AAAnE,gHAAA,cAAc,OAAA;AACvB,2CAAgE;AAAvD,wGAAA,UAAU,OAAA;AACnB,2CAAwF;AAA/E,wGAAA,UAAU,OAAA;AACnB,uCAA0D;AAAjD,oGAAA,QAAQ,OAAA;AAEjB,4FAA4F;AAC5F,mDAI0B;AAHxB,qHAAA,mBAAmB,OAAA;AACnB,gHAAA,cAAc,OAAA;AAGhB,iDAIyB;AAHvB,8GAAA,aAAa,OAAA;AACb,qHAAA,oBAAoB,OAAA;AACpB,4HAAA,2BAA2B,OAAA;AAE7B,qDAK2B;AAJzB,kHAAA,eAAe,OAAA;AACf,kHAAA,eAAe,OAAA;AACf,yHAAA,sBAAsB,OAAA;AAGxB,yDAAgH;AAAvG,sHAAA,iBAAiB,OAAA;AAAE,qHAAA,gBAAgB,OAAA;AAC5C,mDAK0B;AAJxB,gHAAA,cAAc,OAAA;AAKhB,qEAAqE;AACrE,kDAAiD;AAAxC,8GAAA,aAAa,OAAA"}
@@ -0,0 +1,28 @@
1
+ import type { AuctionWins } from '../types';
2
+ export interface UseAuctionState {
3
+ /** Null until the first read; true once this install has accepted the bidding rules. */
4
+ acceptedTerms: boolean | null;
5
+ acceptTerms: () => Promise<void>;
6
+ /** Records a bid to the ledger. The round is still decided by the host's broadcast. */
7
+ recordBid: (params: {
8
+ amount: number;
9
+ bidderId: string;
10
+ bidderName: string;
11
+ storeProductId: string | null;
12
+ }) => Promise<void>;
13
+ enterGiveaway: (params: {
14
+ storeProductId: string;
15
+ customerGid: string;
16
+ displayName: string;
17
+ viewerId: string;
18
+ }) => Promise<boolean>;
19
+ /** Streams the customer owes on. Empty without `customerAccountRequest`. */
20
+ unpaidStreamIds: string[];
21
+ /** Everything won and not checked out. Null without `customerAccountRequest`. */
22
+ wins: AuctionWins | null;
23
+ /** Whether an unsettled previous auction blocks bidding on this stream. */
24
+ biddingBlocked: boolean;
25
+ refreshWins: () => Promise<void>;
26
+ }
27
+ export declare function useAuction(streamingId?: string | null): UseAuctionState;
28
+ //# sourceMappingURL=useAuction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuction.d.ts","sourceRoot":"","sources":["../../src/react/useAuction.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,MAAM,WAAW,eAAe;IAC9B,wFAAwF;IACxF,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,uFAAuF;IACvF,SAAS,EAAE,CAAC,MAAM,EAAE;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;KAC/B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,aAAa,EAAE,CAAC,MAAM,EAAE;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;KAClB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACvB,4EAA4E;IAC5E,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,iFAAiF;IACjF,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,2EAA2E;IAC3E,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC;AAED,wBAAgB,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,eAAe,CAyDvE"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAuction = useAuction;
4
+ /**
5
+ * `useAuction` — the durable (REST) side of bidding, bound for a screen.
6
+ *
7
+ * The interactive round — who is leading, the countdown, the hammer — arrives over the live engine's
8
+ * `LiveEvent` stream (subscribe via the provider's `onEvent` or `client.engine.subscribe`). This hook
9
+ * owns the parts that outlive a socket: the one-time terms acceptance, recording a bid to the ledger,
10
+ * entering a giveaway, and the unpaid-wins gate that decides whether this customer may bid at all.
11
+ *
12
+ * The wins/gate reads need `customerAccountRequest` in the config; without it they stay empty and
13
+ * `biddingBlocked` is always false.
14
+ */
15
+ const react_1 = require("react");
16
+ const liveSelling_1 = require("../liveSelling");
17
+ const LiveSellingProvider_1 = require("./LiveSellingProvider");
18
+ function useAuction(streamingId) {
19
+ const { ready } = (0, LiveSellingProvider_1.useLiveSelling)();
20
+ const [acceptedTerms, setAcceptedTerms] = (0, react_1.useState)(null);
21
+ const [unpaidStreamIds, setUnpaidStreamIds] = (0, react_1.useState)([]);
22
+ const [wins, setWins] = (0, react_1.useState)(null);
23
+ (0, react_1.useEffect)(() => {
24
+ if (!ready)
25
+ return;
26
+ void liveSelling_1.liveSelling.auctions.hasAcceptedTerms().then(setAcceptedTerms);
27
+ }, [ready]);
28
+ const refreshWins = (0, react_1.useCallback)(async () => {
29
+ const [ids, won] = await Promise.all([
30
+ liveSelling_1.liveSelling.auctions.unpaidStreamIds(),
31
+ liveSelling_1.liveSelling.auctions.wins(),
32
+ ]);
33
+ setUnpaidStreamIds(ids);
34
+ setWins(won);
35
+ }, []);
36
+ (0, react_1.useEffect)(() => {
37
+ if (ready)
38
+ void refreshWins();
39
+ }, [ready, refreshWins]);
40
+ const acceptTerms = (0, react_1.useCallback)(async () => {
41
+ await liveSelling_1.liveSelling.auctions.acceptTerms();
42
+ setAcceptedTerms(true);
43
+ }, []);
44
+ const recordBid = (0, react_1.useCallback)((params) => {
45
+ if (!streamingId)
46
+ return Promise.resolve();
47
+ return liveSelling_1.liveSelling.auctions.recordBid({ streamingId, ...params });
48
+ }, [streamingId]);
49
+ const enterGiveaway = (0, react_1.useCallback)((params) => {
50
+ if (!streamingId)
51
+ return Promise.resolve(false);
52
+ return liveSelling_1.liveSelling.auctions.enterGiveaway({ streamingId, ...params });
53
+ }, [streamingId]);
54
+ const biddingBlocked = liveSelling_1.liveSelling.auctions.isBiddingBlocked(unpaidStreamIds, streamingId !== null && streamingId !== void 0 ? streamingId : null);
55
+ return {
56
+ acceptedTerms,
57
+ acceptTerms,
58
+ recordBid,
59
+ enterGiveaway,
60
+ unpaidStreamIds,
61
+ wins,
62
+ biddingBlocked,
63
+ refreshWins,
64
+ };
65
+ }
66
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AE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;IAEzB,MAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QACzC,MAAM,yBAAW,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QACzC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,SAAS,GAAG,IAAA,mBAAW,EAC3B,CAAC,MAAM,EAAE,EAAE;QACT,IAAI,CAAC,WAAW;YAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3C,OAAO,yBAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IACpE,CAAC,EACD,CAAC,WAAW,CAAC,CACd,CAAC;IAEF,MAAM,aAAa,GAAG,IAAA,mBAAW,EAC/B,CAAC,MAAM,EAAE,EAAE;QACT,IAAI,CAAC,WAAW;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAChD,OAAO,yBAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IACxE,CAAC,EACD,CAAC,WAAW,CAAC,CACd,CAAC;IAEF,MAAM,cAAc,GAAG,yBAAW,CAAC,QAAQ,CAAC,gBAAgB,CAAC,eAAe,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,IAAI,CAAC,CAAC;IAEnG,OAAO;QACL,aAAa;QACb,WAAW;QACX,SAAS;QACT,aAAa;QACb,eAAe;QACf,IAAI;QACJ,cAAc;QACd,WAAW;KACZ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * How long to leave between one panel closing and the next opening.
3
+ *
4
+ * Not cosmetic, if the host renders these as React Native `Modal`s: presenting one while another is
5
+ * still dismissing throws `Attempt to present … which is already presenting` on iOS — a native
6
+ * exception, so the app disappears rather than showing an error. The gate chains panels by design
7
+ * (rules, then the variant), so this is the one place that has to be careful about it.
8
+ *
9
+ * Long enough to outlast a slide-out, short enough not to read as a pause.
10
+ */
11
+ export declare const SHEET_HANDOFF_MS = 380;
12
+ /** What is standing between the viewer and the bid they asked for. */
13
+ export type BidBlocker = 'signIn' | 'unpaidWins' | 'terms' | 'variant' | null;
14
+ export interface AuctionBidGate {
15
+ blocker: BidBlocker;
16
+ /** The variant chosen for this round, once asked. */
17
+ variantId: string | null;
18
+ /** Runs the gate. `amount` omitted means the round's minimum — the slide gesture. */
19
+ requestBid: (amount?: number) => void;
20
+ /** Rules accepted: persists, then completes the held bid. */
21
+ acceptTerms: () => void;
22
+ /** A variant picked: remembers it for the round, then completes the held bid. */
23
+ chooseVariant: (variantId: string) => void;
24
+ /** Abandons the held bid and clears the blocker. */
25
+ dismiss: () => void;
26
+ /**
27
+ * Re-read the unpaid-wins gate.
28
+ *
29
+ * Call it when the live screen regains focus: the blocked state sends the customer to a cart to
30
+ * settle their tab, and on their return this is what unblocks them without an app restart. The SDK
31
+ * cannot hook navigation focus itself.
32
+ */
33
+ refreshUnpaidWins: () => void;
34
+ }
35
+ export interface UseAuctionBidGateOptions {
36
+ streamingId: string | null;
37
+ isLoggedIn: boolean;
38
+ /** True while a round is open. Closing one forgets the chosen variant. */
39
+ biddingOpen: boolean;
40
+ /** How many variants the lot under the hammer has. 1 or 0 skips the variant step. */
41
+ variantCount: number;
42
+ placeBid: (options?: {
43
+ amount?: number;
44
+ variantId?: string | null;
45
+ }) => Promise<void>;
46
+ }
47
+ export declare function useAuctionBidGate({ streamingId, isLoggedIn, biddingOpen, variantCount, placeBid, }: UseAuctionBidGateOptions): AuctionBidGate;
48
+ //# sourceMappingURL=useAuctionBidGate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuctionBidGate.d.ts","sourceRoot":"","sources":["../../src/react/useAuctionBidGate.ts"],"names":[],"mappings":"AA6BA;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,sEAAsE;AACtE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;AAE9E,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,UAAU,CAAC;IACpB,qDAAqD;IACrD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,qFAAqF;IACrF,UAAU,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,6DAA6D;IAC7D,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,iFAAiF;IACjF,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,oDAAoD;IACpD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;;;;;OAMG;IACH,iBAAiB,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,0EAA0E;IAC1E,WAAW,EAAE,OAAO,CAAC;IACrB,qFAAqF;IACrF,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvF;AAED,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,EACZ,QAAQ,GACT,EAAE,wBAAwB,GAAG,cAAc,CAyH3C"}