@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/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useArcadeBridge.ts +9 -4
package/package.json
CHANGED
|
@@ -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
|
-
//
|
|
138
|
-
|
|
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 (
|
|
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
|
-
[
|
|
189
|
+
[triggerPlay, submitScore, onScoreSubmitted, onError],
|
|
185
190
|
);
|
|
186
191
|
|
|
187
192
|
return { webviewRef, handleMessage, triggerPlay, lastResult, bridgeLoading };
|