@sensiblestats/widget-react 0.108.0 → 0.108.2
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/CHANGELOG.md +12 -0
- package/dist/index.cjs +32 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @sensiblestats/widget-react
|
|
2
2
|
|
|
3
|
+
## 0.108.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- The Odds tab is now called Trends (Trendler in Turkish). Only the visible label changes.
|
|
8
|
+
|
|
9
|
+
## 0.108.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Show a market's insight in the Following tab when it arrives after the market was first fetched.
|
|
14
|
+
|
|
3
15
|
## 0.108.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -145,7 +145,7 @@ var STRINGS = {
|
|
|
145
145
|
bettingKickoff: (kickoffUtc, now) => formatBettingKickoff(kickoffUtc, STRINGS.en, "en", now),
|
|
146
146
|
tabChat: "Chat",
|
|
147
147
|
tabFollowing: "Following",
|
|
148
|
-
|
|
148
|
+
tabTrends: "Trends",
|
|
149
149
|
pinLabel: "Track odds",
|
|
150
150
|
unpinLabel: "Stop tracking odds",
|
|
151
151
|
matchPinLabel: "Track match",
|
|
@@ -821,7 +821,7 @@ var STRINGS = {
|
|
|
821
821
|
bettingKickoff: (kickoffUtc, now) => formatBettingKickoff(kickoffUtc, STRINGS.tr, "tr", now),
|
|
822
822
|
tabChat: "Sohbet",
|
|
823
823
|
tabFollowing: "Takip",
|
|
824
|
-
|
|
824
|
+
tabTrends: "Trendler",
|
|
825
825
|
pinLabel: "Oran\u0131 takip et",
|
|
826
826
|
unpinLabel: "Oran takibini b\u0131rak",
|
|
827
827
|
matchPinLabel: "Ma\xE7\u0131 takip et",
|
|
@@ -1449,7 +1449,7 @@ function isEnglishLocale(locale) {
|
|
|
1449
1449
|
}
|
|
1450
1450
|
|
|
1451
1451
|
// src/version.generated.ts
|
|
1452
|
-
var WIDGET_REACT_VERSION = "0.108.
|
|
1452
|
+
var WIDGET_REACT_VERSION = "0.108.2";
|
|
1453
1453
|
|
|
1454
1454
|
// src/config.ts
|
|
1455
1455
|
function normalizeUi(cfg) {
|
|
@@ -1535,7 +1535,7 @@ function normalizeUi(cfg) {
|
|
|
1535
1535
|
bettingKickoff: strings.bettingKickoff,
|
|
1536
1536
|
tabChat: strings.tabChat,
|
|
1537
1537
|
tabFollowing: strings.tabFollowing,
|
|
1538
|
-
|
|
1538
|
+
tabTrends: strings.tabTrends,
|
|
1539
1539
|
tabToday: strings.tabToday,
|
|
1540
1540
|
tabFixtures: strings.tabFixtures,
|
|
1541
1541
|
tabStandings: strings.tabStandings,
|
|
@@ -4026,7 +4026,7 @@ function useLiveMonitor(opts) {
|
|
|
4026
4026
|
const marketKey = (mk, dev) => `${mk}:${dev}`;
|
|
4027
4027
|
const getMarketOddsRef = (0, import_react6.useRef)(opts.getMarketOdds);
|
|
4028
4028
|
getMarketOddsRef.current = opts.getMarketOdds;
|
|
4029
|
-
const fetchMarket = (0, import_react6.useCallback)((matchId, dev, sport) => {
|
|
4029
|
+
const fetchMarket = (0, import_react6.useCallback)((matchId, dev, sport, background = false) => {
|
|
4030
4030
|
const key = marketKey(monitorMatchKey(sport, matchId), dev);
|
|
4031
4031
|
const existing = marketOddsRef.current[key];
|
|
4032
4032
|
if (existing?.loading) return;
|
|
@@ -4041,15 +4041,33 @@ function useLiveMonitor(opts) {
|
|
|
4041
4041
|
timer = setTimeout(() => reject(new Error("market timeout")), MARKET_FETCH_TIMEOUT_MS);
|
|
4042
4042
|
});
|
|
4043
4043
|
void Promise.race([request, timeout]).finally(() => clearTimeout(timer)).then((block) => {
|
|
4044
|
-
const
|
|
4044
|
+
const kept = background ? marketOddsRef.current[key]?.block : void 0;
|
|
4045
|
+
const entry = { block: block ?? kept, loading: false, error: false, fetchedAt: Date.now() };
|
|
4045
4046
|
marketOddsRef.current = { ...marketOddsRef.current, [key]: entry };
|
|
4046
4047
|
setMarketOdds((prev) => ({ ...prev, [key]: entry }));
|
|
4047
4048
|
}).catch(() => {
|
|
4048
|
-
const
|
|
4049
|
+
const cur = marketOddsRef.current[key];
|
|
4050
|
+
const entry = { ...cur, loading: false, error: !(background && cur?.block) };
|
|
4049
4051
|
marketOddsRef.current = { ...marketOddsRef.current, [key]: entry };
|
|
4050
4052
|
setMarketOdds((prev) => ({ ...prev, [key]: entry }));
|
|
4051
4053
|
});
|
|
4052
4054
|
}, []);
|
|
4055
|
+
const insightAskedAtRef = (0, import_react6.useRef)({});
|
|
4056
|
+
const refreshMissingInsight = (0, import_react6.useCallback)((snap) => {
|
|
4057
|
+
const pin = pinsRef.current.find((p) => p.kind === "match" && p.key === selectedRef.current);
|
|
4058
|
+
if (!pin) return;
|
|
4059
|
+
const mk = monitorMatchKey(pin.sport, pin.matchId);
|
|
4060
|
+
const dev = openMarketRef.current[mk];
|
|
4061
|
+
if (!dev) return;
|
|
4062
|
+
const available = matchFor(snap, pin)?.availableMarkets?.find((m) => m.marketDeveloperName === dev);
|
|
4063
|
+
if (!available?.hasInsight || available.suspended) return;
|
|
4064
|
+
const key = marketKey(mk, dev);
|
|
4065
|
+
const entry = marketOddsRef.current[key];
|
|
4066
|
+
if (!entry || entry.loading || entry.error || entry.block?.insight?.text) return;
|
|
4067
|
+
if (Date.now() - (insightAskedAtRef.current[key] ?? 0) < MARKET_FRESH_MS) return;
|
|
4068
|
+
insightAskedAtRef.current[key] = Date.now();
|
|
4069
|
+
fetchMarket(pin.matchId, dev, pin.sport, true);
|
|
4070
|
+
}, [fetchMarket]);
|
|
4053
4071
|
const getPlayerPropsRef = (0, import_react6.useRef)(opts.getPlayerProps);
|
|
4054
4072
|
getPlayerPropsRef.current = opts.getPlayerProps;
|
|
4055
4073
|
const playerPropsRef = (0, import_react6.useRef)({});
|
|
@@ -4078,7 +4096,8 @@ function useLiveMonitor(opts) {
|
|
|
4078
4096
|
if (!wasOpen && !marketUsable(existing)) {
|
|
4079
4097
|
fetchMarket(matchId, dev, sport);
|
|
4080
4098
|
}
|
|
4081
|
-
|
|
4099
|
+
refreshMissingInsight(snapshotRef.current);
|
|
4100
|
+
}, [fetchMarket, refreshMissingInsight]);
|
|
4082
4101
|
const retryMarket = (0, import_react6.useCallback)((matchId, dev, sport) => {
|
|
4083
4102
|
fetchMarket(matchId, dev, sport);
|
|
4084
4103
|
}, [fetchMarket]);
|
|
@@ -4098,7 +4117,8 @@ function useLiveMonitor(opts) {
|
|
|
4098
4117
|
selectedRef.current = key;
|
|
4099
4118
|
setSelectedMatchKey(key);
|
|
4100
4119
|
openSelectedDefault(snapshotRef.current);
|
|
4101
|
-
|
|
4120
|
+
refreshMissingInsight(snapshotRef.current);
|
|
4121
|
+
}, [openSelectedDefault, refreshMissingInsight]);
|
|
4102
4122
|
const applySnapshot = (0, import_react6.useCallback)((next) => {
|
|
4103
4123
|
if (next === null) {
|
|
4104
4124
|
setEnabled(false);
|
|
@@ -4119,6 +4139,7 @@ function useLiveMonitor(opts) {
|
|
|
4119
4139
|
}
|
|
4120
4140
|
if (sawNewGoalOrRed && activeTabRef.current !== "following") setMatchesDot(true);
|
|
4121
4141
|
openSelectedDefault(next);
|
|
4142
|
+
refreshMissingInsight(next);
|
|
4122
4143
|
const marketPins = currentPins.filter((p) => p.kind !== "match");
|
|
4123
4144
|
if (activeTabRef.current === "odds") {
|
|
4124
4145
|
setLastViewedPrices((prevMap) => {
|
|
@@ -4157,7 +4178,7 @@ function useLiveMonitor(opts) {
|
|
|
4157
4178
|
if (recoveredKeys.length > 0) store.clearGrace(recoveredKeys);
|
|
4158
4179
|
snapshotRef.current = next;
|
|
4159
4180
|
setSnapshotState(next);
|
|
4160
|
-
}, [store, openSelectedDefault]);
|
|
4181
|
+
}, [store, openSelectedDefault, refreshMissingInsight]);
|
|
4161
4182
|
const inFlightRef = (0, import_react6.useRef)(false);
|
|
4162
4183
|
const pendingRef = (0, import_react6.useRef)(false);
|
|
4163
4184
|
const inFlightKeysRef = (0, import_react6.useRef)("");
|
|
@@ -9330,7 +9351,7 @@ function TabBar({ monitor, ui, matchCount, oddsCount, todayCount, hasToday, game
|
|
|
9330
9351
|
] : [
|
|
9331
9352
|
...hasToday ? [{ tab: "today", label: ui.tabToday, count: todayCount, dot: monitor.todayDot }] : [],
|
|
9332
9353
|
...matchCount > 0 ? [{ tab: "following", label: ui.tabFollowing, count: matchCount, dot: monitor.matchesDot }] : [],
|
|
9333
|
-
...oddsCount > 0 ? [{ tab: "odds", label: ui.
|
|
9354
|
+
...oddsCount > 0 ? [{ tab: "odds", label: ui.tabTrends, count: oddsCount, dot: monitor.oddsDot }] : []
|
|
9334
9355
|
],
|
|
9335
9356
|
...gamesEnabled ? [{ tab: "games", label: ui.tabGames, count: 0, dot: false }] : [],
|
|
9336
9357
|
...favouritesEnabled && !clubEnabled ? [{ tab: "favourites", label: ui.tabFavourites, count: 0, dot: false }] : []
|