@ai-matrx/media 0.4.1 → 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/viewers.cjs CHANGED
@@ -1454,11 +1454,17 @@ function useMediaLoadRecovery(src, options) {
1454
1454
  const failureRef = options?.failureRef;
1455
1455
  const [result, setResult] = (0, import_react11.useState)({ source: src, retryKey: 0, failed: false });
1456
1456
  const attemptRef = (0, import_react11.useRef)(0);
1457
+ const recoveryInFlightRef = (0, import_react11.useRef)(false);
1457
1458
  (0, import_react11.useEffect)(() => {
1458
1459
  attemptRef.current = 0;
1460
+ recoveryInFlightRef.current = false;
1459
1461
  }, [src]);
1462
+ (0, import_react11.useLayoutEffect)(() => {
1463
+ recoveryInFlightRef.current = false;
1464
+ }, [result.retryKey]);
1460
1465
  const identity = () => failureMediaIdentity(failureRef ?? null, src);
1461
1466
  const onLoadError = (event) => {
1467
+ if (recoveryInFlightRef.current) return;
1462
1468
  if (!src || !recoverable) {
1463
1469
  setResult({ source: src, retryKey: 0, failed: true });
1464
1470
  if (src) {
@@ -1473,6 +1479,7 @@ function useMediaLoadRecovery(src, options) {
1473
1479
  onTerminal?.(event);
1474
1480
  return;
1475
1481
  }
1482
+ recoveryInFlightRef.current = true;
1476
1483
  attemptRef.current += 1;
1477
1484
  const attempt = attemptRef.current;
1478
1485
  client.recoverLoadError(mintDurableSrc(src), attempt).then(