@dubsdotapp/expo 0.4.0 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dubsdotapp/expo",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "React Native SDK for the Dubs betting platform",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -90,6 +90,10 @@ export function useArcadeBridge({
90
90
  const sessionTokenRef = useRef<string | null>(null);
91
91
  const gameStartTimeRef = useRef<number>(0);
92
92
 
93
+ // Keep canPlay in a ref so TAP_PLAY handler always sees the latest value
94
+ const canPlayRef = useRef(canPlay);
95
+ canPlayRef.current = canPlay;
96
+
93
97
  const [lastResult, setLastResult] = useState<SubmitScoreResult | null>(null);
94
98
  const [bridgeLoading, setBridgeLoading] = useState(false);
95
99
 
@@ -134,12 +138,13 @@ export function useArcadeBridge({
134
138
  return; // non-JSON postMessages from the game's own code — ignore
135
139
  }
136
140
 
137
- // Only process messages from our bridge protocol
138
- if (data.dubsArcade !== PROTOCOL_VERSION) return;
141
+ // If dubsArcade version is present it must match — if absent, accept anyway
142
+ // (backward-compat: old game builds don't include the envelope yet)
143
+ if (data.dubsArcade !== undefined && data.dubsArcade !== PROTOCOL_VERSION) return;
139
144
 
140
145
  switch (data.type) {
141
146
  case 'TAP_PLAY': {
142
- if (canPlay) {
147
+ if (canPlayRef.current) {
143
148
  triggerPlay();
144
149
  }
145
150
  return;
@@ -181,7 +186,7 @@ export function useArcadeBridge({
181
186
  return;
182
187
  }
183
188
  },
184
- [canPlay, triggerPlay, submitScore, onScoreSubmitted, onError],
189
+ [triggerPlay, submitScore, onScoreSubmitted, onError],
185
190
  );
186
191
 
187
192
  return { webviewRef, handleMessage, triggerPlay, lastResult, bridgeLoading };