@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/CHANGELOG.md +14 -0
- package/README.md +4 -0
- package/dist/core.cjs +7 -0
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +8 -1
- package/dist/core.js.map +1 -1
- package/dist/react.cjs +7 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +8 -1
- package/dist/react.js.map +1 -1
- package/dist/viewers.cjs +7 -0
- package/dist/viewers.cjs.map +1 -1
- package/dist/viewers.js +8 -1
- package/dist/viewers.js.map +1 -1
- package/package.json +1 -1
package/dist/viewers.js
CHANGED
|
@@ -1392,7 +1392,7 @@ function HtmlSourceView({ source, maxBytes = 1024 * 1024 }) {
|
|
|
1392
1392
|
}
|
|
1393
1393
|
|
|
1394
1394
|
// src/core/use-media-load-recovery.ts
|
|
1395
|
-
import { useEffect as useEffect6, useRef as useRef3, useState as useState8 } from "react";
|
|
1395
|
+
import { useEffect as useEffect6, useLayoutEffect, useRef as useRef3, useState as useState8 } from "react";
|
|
1396
1396
|
|
|
1397
1397
|
// src/types.ts
|
|
1398
1398
|
function mintDurableSrc(url) {
|
|
@@ -1412,11 +1412,17 @@ function useMediaLoadRecovery(src, options) {
|
|
|
1412
1412
|
const failureRef = options?.failureRef;
|
|
1413
1413
|
const [result, setResult] = useState8({ source: src, retryKey: 0, failed: false });
|
|
1414
1414
|
const attemptRef = useRef3(0);
|
|
1415
|
+
const recoveryInFlightRef = useRef3(false);
|
|
1415
1416
|
useEffect6(() => {
|
|
1416
1417
|
attemptRef.current = 0;
|
|
1418
|
+
recoveryInFlightRef.current = false;
|
|
1417
1419
|
}, [src]);
|
|
1420
|
+
useLayoutEffect(() => {
|
|
1421
|
+
recoveryInFlightRef.current = false;
|
|
1422
|
+
}, [result.retryKey]);
|
|
1418
1423
|
const identity = () => failureMediaIdentity(failureRef ?? null, src);
|
|
1419
1424
|
const onLoadError = (event) => {
|
|
1425
|
+
if (recoveryInFlightRef.current) return;
|
|
1420
1426
|
if (!src || !recoverable) {
|
|
1421
1427
|
setResult({ source: src, retryKey: 0, failed: true });
|
|
1422
1428
|
if (src) {
|
|
@@ -1431,6 +1437,7 @@ function useMediaLoadRecovery(src, options) {
|
|
|
1431
1437
|
onTerminal?.(event);
|
|
1432
1438
|
return;
|
|
1433
1439
|
}
|
|
1440
|
+
recoveryInFlightRef.current = true;
|
|
1434
1441
|
attemptRef.current += 1;
|
|
1435
1442
|
const attempt = attemptRef.current;
|
|
1436
1443
|
client.recoverLoadError(mintDurableSrc(src), attempt).then(
|