@sensiblestats/widget-react 0.156.0 → 0.157.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/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.156.0";
1386
+ var WIDGET_REACT_VERSION = "0.157.0";
1387
1387
 
1388
1388
  // src/config.ts
1389
1389
  var COLOR_KEYS = ["accent", "cta", "surface", "ink"];
@@ -8418,6 +8418,14 @@ function useMobileBinding(args) {
8418
8418
  });
8419
8419
  return () => binding.onHandle(null);
8420
8420
  }, [binding]);
8421
+ const { labels, theme } = args;
8422
+ const labelsKey = labels ? JSON.stringify([labels.launcher, labels.dismiss]) : "";
8423
+ useEffect30(() => {
8424
+ if (labels) binding?.onLabels?.(labels);
8425
+ }, [binding, labelsKey]);
8426
+ useEffect30(() => {
8427
+ if (theme) binding?.onTheme?.(theme);
8428
+ }, [binding, theme]);
8421
8429
  const onCloseRequested = useCallback26(() => bindingRef.current?.onCloseRequested(), []);
8422
8430
  const onRegisterBack = useCallback26((fn) => {
8423
8431
  backRef.current = fn;
@@ -8493,6 +8501,28 @@ function webTeaserBinding(host, deliver, drawsLauncher) {
8493
8501
  };
8494
8502
  }
8495
8503
 
8504
+ // src/resolvedTheme.ts
8505
+ import { useSyncExternalStore } from "react";
8506
+ var QUERY = "(prefers-color-scheme: dark)";
8507
+ function systemDark() {
8508
+ try {
8509
+ return typeof window.matchMedia === "function" && window.matchMedia(QUERY).matches;
8510
+ } catch {
8511
+ return false;
8512
+ }
8513
+ }
8514
+ function subscribe(onChange) {
8515
+ if (typeof window.matchMedia !== "function") return () => {
8516
+ };
8517
+ const query = window.matchMedia(QUERY);
8518
+ query.addEventListener("change", onChange);
8519
+ return () => query.removeEventListener("change", onChange);
8520
+ }
8521
+ function useResolvedTheme(choice) {
8522
+ const dark = useSyncExternalStore(subscribe, systemDark, () => false);
8523
+ return choice === "auto" ? dark ? "dark" : "light" : choice;
8524
+ }
8525
+
8496
8526
  // src/openTelemetry.ts
8497
8527
  import { useEffect as useEffect31, useRef as useRef26 } from "react";
8498
8528
  function useOpenTelemetry(log, isOpen) {
@@ -22678,6 +22708,7 @@ function StatsWidget(props) {
22678
22708
  const wantsTeaser = cfg?.launcher === false || cfg?.onTeaser !== void 0;
22679
22709
  const webBinding = useMemo17(() => wantsTeaser ? webTeaserBinding(props.host, (teaser2) => onTeaserRef.current?.(teaser2), cfg?.launcher === false) : void 0, [wantsTeaser, props.host, cfg?.launcher]);
22680
22710
  const hostDrawsLauncher = props.mobile !== void 0 || cfg?.launcher === false;
22711
+ const resolvedTheme = useResolvedTheme(oddsSettings.userTheme ?? ui.theme);
22681
22712
  const mobile = useMobileBinding({
22682
22713
  binding: props.mobile ?? webBinding,
22683
22714
  panelOpen,
@@ -22694,7 +22725,9 @@ function StatsWidget(props) {
22694
22725
  asks,
22695
22726
  open: controller.open,
22696
22727
  close: controller.close,
22697
- dismissPopup: () => dismissPopupRef.current()
22728
+ dismissPopup: () => dismissPopupRef.current(),
22729
+ labels: stringsPending ? null : { launcher: ui.launcherLabel, dismiss: ui.dismissGreeting },
22730
+ theme: resolvedTheme
22698
22731
  });
22699
22732
  const dismissPopup = usePopupTelemetry(logger, panelOpen, controller.state.popupText, controller.dismissPopup, hostDrawsLauncher ? mobile.confirmedShown : void 0);
22700
22733
  dismissPopupRef.current = dismissPopup;