@ai-matrx/media 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/CHANGELOG.md +40 -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 +21 -5
- package/dist/viewers.cjs.map +1 -1
- package/dist/viewers.js +25 -9
- package/dist/viewers.js.map +1 -1
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -621,7 +621,7 @@ function useMediaBlob(ref) {
|
|
|
621
621
|
}
|
|
622
622
|
|
|
623
623
|
// src/core/use-media-load-recovery.ts
|
|
624
|
-
import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
624
|
+
import { useEffect as useEffect2, useLayoutEffect, useRef as useRef2, useState as useState2 } from "react";
|
|
625
625
|
|
|
626
626
|
// src/types.ts
|
|
627
627
|
function mintDurableSrc(url) {
|
|
@@ -641,11 +641,17 @@ function useMediaLoadRecovery(src, options) {
|
|
|
641
641
|
const failureRef = options?.failureRef;
|
|
642
642
|
const [result, setResult] = useState2({ source: src, retryKey: 0, failed: false });
|
|
643
643
|
const attemptRef = useRef2(0);
|
|
644
|
+
const recoveryInFlightRef = useRef2(false);
|
|
644
645
|
useEffect2(() => {
|
|
645
646
|
attemptRef.current = 0;
|
|
647
|
+
recoveryInFlightRef.current = false;
|
|
646
648
|
}, [src]);
|
|
649
|
+
useLayoutEffect(() => {
|
|
650
|
+
recoveryInFlightRef.current = false;
|
|
651
|
+
}, [result.retryKey]);
|
|
647
652
|
const identity = () => failureMediaIdentity(failureRef ?? null, src);
|
|
648
653
|
const onLoadError = (event) => {
|
|
654
|
+
if (recoveryInFlightRef.current) return;
|
|
649
655
|
if (!src || !recoverable) {
|
|
650
656
|
setResult({ source: src, retryKey: 0, failed: true });
|
|
651
657
|
if (src) {
|
|
@@ -660,6 +666,7 @@ function useMediaLoadRecovery(src, options) {
|
|
|
660
666
|
onTerminal?.(event);
|
|
661
667
|
return;
|
|
662
668
|
}
|
|
669
|
+
recoveryInFlightRef.current = true;
|
|
663
670
|
attemptRef.current += 1;
|
|
664
671
|
const attempt = attemptRef.current;
|
|
665
672
|
client.recoverLoadError(mintDurableSrc(src), attempt).then(
|