@sensiblestats/widget-react 0.156.0 → 0.158.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/CHANGELOG.md +17 -0
- package/dist/index.cjs +402 -367
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +38 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1383,7 +1383,7 @@ function parseCustomTotal(text2, format2) {
|
|
|
1383
1383
|
}
|
|
1384
1384
|
|
|
1385
1385
|
// src/version.generated.ts
|
|
1386
|
-
var WIDGET_REACT_VERSION = "0.
|
|
1386
|
+
var WIDGET_REACT_VERSION = "0.158.0";
|
|
1387
1387
|
|
|
1388
1388
|
// src/config.ts
|
|
1389
1389
|
var COLOR_KEYS = ["accent", "cta", "surface", "ink"];
|
|
@@ -1793,6 +1793,8 @@ function toClientOptions(cfg) {
|
|
|
1793
1793
|
const opts = { operatorId: cfg.operatorId, publicKey: cfg.publicKey, client: `${cfg.transport?.client ?? "widget-react"}/${WIDGET_REACT_VERSION}` };
|
|
1794
1794
|
if (cfg.baseUrl !== void 0) opts.baseUrl = cfg.baseUrl;
|
|
1795
1795
|
if (cfg.transport?.fetch !== void 0) opts.fetch = cfg.transport.fetch;
|
|
1796
|
+
const timeZone = validZone(cfg.timeZone);
|
|
1797
|
+
if (timeZone !== void 0) opts.timeZone = timeZone;
|
|
1796
1798
|
return opts;
|
|
1797
1799
|
}
|
|
1798
1800
|
function toUserContext(cfg) {
|
|
@@ -8418,6 +8420,14 @@ function useMobileBinding(args) {
|
|
|
8418
8420
|
});
|
|
8419
8421
|
return () => binding.onHandle(null);
|
|
8420
8422
|
}, [binding]);
|
|
8423
|
+
const { labels, theme } = args;
|
|
8424
|
+
const labelsKey = labels ? JSON.stringify([labels.launcher, labels.dismiss]) : "";
|
|
8425
|
+
useEffect30(() => {
|
|
8426
|
+
if (labels) binding?.onLabels?.(labels);
|
|
8427
|
+
}, [binding, labelsKey]);
|
|
8428
|
+
useEffect30(() => {
|
|
8429
|
+
if (theme) binding?.onTheme?.(theme);
|
|
8430
|
+
}, [binding, theme]);
|
|
8421
8431
|
const onCloseRequested = useCallback26(() => bindingRef.current?.onCloseRequested(), []);
|
|
8422
8432
|
const onRegisterBack = useCallback26((fn) => {
|
|
8423
8433
|
backRef.current = fn;
|
|
@@ -8493,6 +8503,28 @@ function webTeaserBinding(host, deliver, drawsLauncher) {
|
|
|
8493
8503
|
};
|
|
8494
8504
|
}
|
|
8495
8505
|
|
|
8506
|
+
// src/resolvedTheme.ts
|
|
8507
|
+
import { useSyncExternalStore } from "react";
|
|
8508
|
+
var QUERY = "(prefers-color-scheme: dark)";
|
|
8509
|
+
function systemDark() {
|
|
8510
|
+
try {
|
|
8511
|
+
return typeof window.matchMedia === "function" && window.matchMedia(QUERY).matches;
|
|
8512
|
+
} catch {
|
|
8513
|
+
return false;
|
|
8514
|
+
}
|
|
8515
|
+
}
|
|
8516
|
+
function subscribe(onChange) {
|
|
8517
|
+
if (typeof window.matchMedia !== "function") return () => {
|
|
8518
|
+
};
|
|
8519
|
+
const query = window.matchMedia(QUERY);
|
|
8520
|
+
query.addEventListener("change", onChange);
|
|
8521
|
+
return () => query.removeEventListener("change", onChange);
|
|
8522
|
+
}
|
|
8523
|
+
function useResolvedTheme(choice) {
|
|
8524
|
+
const dark = useSyncExternalStore(subscribe, systemDark, () => false);
|
|
8525
|
+
return choice === "auto" ? dark ? "dark" : "light" : choice;
|
|
8526
|
+
}
|
|
8527
|
+
|
|
8496
8528
|
// src/openTelemetry.ts
|
|
8497
8529
|
import { useEffect as useEffect31, useRef as useRef26 } from "react";
|
|
8498
8530
|
function useOpenTelemetry(log, isOpen) {
|
|
@@ -22404,7 +22436,7 @@ function StatsWidget(props) {
|
|
|
22404
22436
|
onUnavailableRef.current?.(reason);
|
|
22405
22437
|
} catch {
|
|
22406
22438
|
}
|
|
22407
|
-
}), [injectedClient, cfg?.operatorId, cfg?.publicKey, cfg?.baseUrl, cfg?.userContext?.operatorUserId, cfg?.userContext?.anonymousUserId]);
|
|
22439
|
+
}), [injectedClient, cfg?.operatorId, cfg?.publicKey, cfg?.baseUrl, cfg?.userContext?.operatorUserId, cfg?.userContext?.anonymousUserId, cfg?.timeZone]);
|
|
22408
22440
|
const trackingRef = useRef50({ envelope: { operatorId: "", widgetVersion: WIDGET_REACT_VERSION } });
|
|
22409
22441
|
const track = useMemo17(() => createTracker(() => trackingRef.current), []);
|
|
22410
22442
|
const eventTextRef = useRef50(false);
|
|
@@ -22678,6 +22710,7 @@ function StatsWidget(props) {
|
|
|
22678
22710
|
const wantsTeaser = cfg?.launcher === false || cfg?.onTeaser !== void 0;
|
|
22679
22711
|
const webBinding = useMemo17(() => wantsTeaser ? webTeaserBinding(props.host, (teaser2) => onTeaserRef.current?.(teaser2), cfg?.launcher === false) : void 0, [wantsTeaser, props.host, cfg?.launcher]);
|
|
22680
22712
|
const hostDrawsLauncher = props.mobile !== void 0 || cfg?.launcher === false;
|
|
22713
|
+
const resolvedTheme = useResolvedTheme(oddsSettings.userTheme ?? ui.theme);
|
|
22681
22714
|
const mobile = useMobileBinding({
|
|
22682
22715
|
binding: props.mobile ?? webBinding,
|
|
22683
22716
|
panelOpen,
|
|
@@ -22694,7 +22727,9 @@ function StatsWidget(props) {
|
|
|
22694
22727
|
asks,
|
|
22695
22728
|
open: controller.open,
|
|
22696
22729
|
close: controller.close,
|
|
22697
|
-
dismissPopup: () => dismissPopupRef.current()
|
|
22730
|
+
dismissPopup: () => dismissPopupRef.current(),
|
|
22731
|
+
labels: stringsPending ? null : { launcher: ui.launcherLabel, dismiss: ui.dismissGreeting },
|
|
22732
|
+
theme: resolvedTheme
|
|
22698
22733
|
});
|
|
22699
22734
|
const dismissPopup = usePopupTelemetry(logger, panelOpen, controller.state.popupText, controller.dismissPopup, hostDrawsLauncher ? mobile.confirmedShown : void 0);
|
|
22700
22735
|
dismissPopupRef.current = dismissPopup;
|