@sensiblestats/widget-react 0.60.4 → 0.60.5

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @sensiblestats/widget-react
2
2
 
3
+ ## 0.60.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Games: send the widget language with game config, result and play requests so server-written game text (quiz questions, grid labels, stat names, hints) arrives in Turkish; Beat the Grid resolves row abbreviations and header icons from stable keys.
8
+ - Updated dependencies
9
+ - @sensiblestats/widget-sdk@0.36.0
10
+
3
11
  ## 0.60.4
4
12
 
5
13
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -4704,15 +4704,15 @@ function toSubmitResult(payload) {
4704
4704
  attemptsUsed: payload.attemptsUsed
4705
4705
  };
4706
4706
  }
4707
- function useGamePlay(conversation, { gameId, gameDay, fixtureId, refresh }) {
4707
+ function useGamePlay(conversation, { gameId, gameDay, fixtureId, locale, refresh }) {
4708
4708
  const [result, setResult] = (0, import_react29.useState)(null);
4709
4709
  const [submitting, setSubmitting] = (0, import_react29.useState)(false);
4710
4710
  const [rawStatus, setRawStatus] = (0, import_react29.useState)(null);
4711
4711
  const inFlightRef = (0, import_react29.useRef)(false);
4712
4712
  const convRef = (0, import_react29.useRef)(conversation);
4713
4713
  convRef.current = conversation;
4714
- const optsRef = (0, import_react29.useRef)({ gameId, gameDay, fixtureId, refresh });
4715
- optsRef.current = { gameId, gameDay, fixtureId, refresh };
4714
+ const optsRef = (0, import_react29.useRef)({ gameId, gameDay, fixtureId, locale, refresh });
4715
+ optsRef.current = { gameId, gameDay, fixtureId, locale, refresh };
4716
4716
  const resultRef = (0, import_react29.useRef)(null);
4717
4717
  resultRef.current = result;
4718
4718
  const refetch = (0, import_react29.useCallback)(async () => {
@@ -4720,7 +4720,7 @@ function useGamePlay(conversation, { gameId, gameDay, fixtureId, refresh }) {
4720
4720
  if (!conv) return;
4721
4721
  const opts = optsRef.current;
4722
4722
  try {
4723
- const payload = await conv.getGameResult(opts.gameId, opts.fixtureId, opts.gameDay);
4723
+ const payload = await conv.getGameResult(opts.gameId, opts.fixtureId, opts.gameDay, opts.locale);
4724
4724
  if (payload === null) return;
4725
4725
  if (payload.clientStateJson == null && resultRef.current?.clientStateJson != null) {
4726
4726
  setRawStatus(payload.status);
@@ -4738,7 +4738,7 @@ function useGamePlay(conversation, { gameId, gameDay, fixtureId, refresh }) {
4738
4738
  setSubmitting(true);
4739
4739
  try {
4740
4740
  const opts = optsRef.current;
4741
- const playResult = await conv.postPlay(opts.gameId, answerJson, opts.gameDay, opts.fixtureId);
4741
+ const playResult = await conv.postPlay(opts.gameId, answerJson, opts.gameDay, opts.fixtureId, opts.locale);
4742
4742
  if (playResult !== null) {
4743
4743
  const hasFreshState = playResult.clientStateJson != null;
4744
4744
  const isTerminal2 = playResult.alreadyPlayed === true;
@@ -5515,8 +5515,8 @@ function CareerPathGame({
5515
5515
  // src/components/games/BeatTheGridGame.tsx
5516
5516
  var import_react34 = __toESM(require("react"), 1);
5517
5517
  var import_jsx_runtime71 = require("react/jsx-runtime");
5518
- function criterionIconKind(label) {
5519
- const l = label.toLowerCase();
5518
+ function criterionIconKind(label, key) {
5519
+ const l = (key ?? label).toLowerCase();
5520
5520
  if (l.includes("app")) return "calendar";
5521
5521
  if (l.includes("goal")) return "ball";
5522
5522
  if (l.includes("assist")) return "boot";
@@ -5524,8 +5524,10 @@ function criterionIconKind(label) {
5524
5524
  if (l.includes("tackle")) return "shield";
5525
5525
  return "flag";
5526
5526
  }
5527
- function rowAbbrev(label, map) {
5528
- return map[label] ?? label;
5527
+ function rowAbbrev(label, map, key) {
5528
+ const suffix = key?.split(".").pop();
5529
+ const english = suffix ? suffix.charAt(0).toUpperCase() + suffix.slice(1) : label;
5530
+ return map[english] ?? map[label] ?? label;
5529
5531
  }
5530
5532
  function CriterionIcon({ kind }) {
5531
5533
  switch (kind) {
@@ -5700,12 +5702,12 @@ function BeatTheGridGame({
5700
5702
  role: "grid",
5701
5703
  children: [
5702
5704
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "ss-g-btg-corner" }),
5703
- cols.map((col) => /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "ss-g-btg-colhdr", children: [
5704
- /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(CriterionIcon, { kind: criterionIconKind(col) }),
5705
+ cols.map((col, colIdx) => /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "ss-g-btg-colhdr", children: [
5706
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(CriterionIcon, { kind: criterionIconKind(col, config.colsI18n?.[colIdx]?.key) }),
5705
5707
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { children: col })
5706
5708
  ] }, col)),
5707
5709
  rows.map((rowLabel, rowIdx) => {
5708
- const abbr = rowAbbrev(rowLabel, s.rowAbbrev);
5710
+ const abbr = rowAbbrev(rowLabel, s.rowAbbrev, config.rowsI18n?.[rowIdx]?.key);
5709
5711
  return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_react34.default.Fragment, { children: [
5710
5712
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "ss-g-btg-rowhdr", children: abbr === rowLabel ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { children: rowLabel }) : /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
5711
5713
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { "aria-hidden": "true", children: abbr }),
@@ -6834,7 +6836,7 @@ function GameScreenHost({
6834
6836
  let cancelled = false;
6835
6837
  void (async () => {
6836
6838
  try {
6837
- const payload = await conversation.getGameConfig(gameId, fixtureId, gameDay || void 0);
6839
+ const payload = await conversation.getGameConfig(gameId, fixtureId, gameDay || void 0, ui.games.lang);
6838
6840
  if (!cancelled && payload?.configJson) {
6839
6841
  setConfigJson(payload.configJson);
6840
6842
  }
@@ -6844,11 +6846,12 @@ function GameScreenHost({
6844
6846
  return () => {
6845
6847
  cancelled = true;
6846
6848
  };
6847
- }, [conversation, gameId, fixtureId, gameDay]);
6849
+ }, [conversation, gameId, fixtureId, gameDay, ui.games.lang]);
6848
6850
  const { result, submitting, submit, hydrate, rawStatus } = useGamePlay(conversation, {
6849
6851
  gameId,
6850
6852
  gameDay,
6851
- fixtureId: fixtureId || void 0
6853
+ fixtureId: fixtureId || void 0,
6854
+ locale: ui.games.lang
6852
6855
  });
6853
6856
  (0, import_react40.useEffect)(() => {
6854
6857
  if (conversation) hydrate();