@sensiblestats/widget-react 0.108.0 → 0.108.1
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 +6 -0
- package/dist/index.cjs +28 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -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.1";
|
|
1453
1453
|
|
|
1454
1454
|
// src/config.ts
|
|
1455
1455
|
function normalizeUi(cfg) {
|
|
@@ -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)("");
|