@revenuecat/purchases-ui-js 4.5.0 → 4.5.1

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.
@@ -311,7 +311,9 @@
311
311
  playbackMutedOverride = true;
312
312
  });
313
313
  applyVideoPlaybackFlags();
314
- void el.play().catch(() => {});
314
+ // Do not call el.play() here. A non-user-initiated play() call after a
315
+ // failed unmute corrupts the media element state machine on certain WebKit
316
+ // versions, leaving native controls unresponsive. Let the user tap to resume.
315
317
  });
316
318
  });
317
319
  };
@@ -321,14 +323,20 @@
321
323
  playingUnmuteListener = null;
322
324
  tryRestoreAudioAfterMutedAutoplay();
323
325
  };
324
- playingUnmuteListener = onPlayingAfterMutedBootstrap;
325
- el.addEventListener("playing", onPlayingAfterMutedBootstrap, {
326
- once: true,
327
- });
328
326
 
327
+ // Call muted play before registering the `playing` listener. The listener is
328
+ // registered only inside p2.then() — after muted play is confirmed started.
329
+ // Registering before p2 resolves risks the listener surviving indefinitely if
330
+ // p2's promise hangs (a known WebKit bug on certain devices), causing it to
331
+ // fire on user-initiated play and sabotage playback via the unmute restore flow.
329
332
  const p2 = el.play();
330
333
  if (p2 !== undefined) {
331
334
  p2.then(() => {
335
+ if (cancelled || mute_audio || unmuteAfterMutedStartHandled) return;
336
+ playingUnmuteListener = onPlayingAfterMutedBootstrap;
337
+ el.addEventListener("playing", onPlayingAfterMutedBootstrap, {
338
+ once: true,
339
+ });
332
340
  // `playing` may have fired before our listener ran; retry unmute once playback exists.
333
341
  queueMicrotask(() => {
334
342
  if (
@@ -345,8 +353,13 @@
345
353
  }
346
354
  tryRestoreAudioAfterMutedAutoplay();
347
355
  });
348
- }).catch(() => {
349
- clearPlayingUnmuteListener();
356
+ });
357
+ } else {
358
+ // p2 undefined: older iOS that doesn't return a promise from play().
359
+ // Register the listener directly — it's the only available signal.
360
+ playingUnmuteListener = onPlayingAfterMutedBootstrap;
361
+ el.addEventListener("playing", onPlayingAfterMutedBootstrap, {
362
+ once: true,
350
363
  });
351
364
  }
352
365
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@revenuecat/purchases-ui-js",
3
3
  "description": "Web components for Paywalls. Powered by RevenueCat",
4
4
  "private": false,
5
- "version": "4.5.0",
5
+ "version": "4.5.1",
6
6
  "author": {
7
7
  "name": "RevenueCat, Inc."
8
8
  },