@bendyline/squisq-react 2.12.24 → 2.12.25
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/{chunk-MPOVPKIJ.js → chunk-2GNCILIQ.js} +1 -1
- package/dist/{chunk-TVYZINUR.js → chunk-UUGOEH5Q.js} +54 -2
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.js +1 -1
- package/dist/index.js +2 -2
- package/dist/player/index.js +2 -2
- package/dist/squisq-player.full.global.js +363 -363
- package/dist/squisq-player.global.js +85 -85
- package/dist/standalone-player-full.js +1 -1
- package/dist/standalone-source.js +1 -1
- package/package.json +2 -2
|
@@ -64,6 +64,33 @@ function isBenignPlayRejection(error) {
|
|
|
64
64
|
if (!(error instanceof Error)) return false;
|
|
65
65
|
return error.name === "NotAllowedError" || error.name === "AbortError";
|
|
66
66
|
}
|
|
67
|
+
var LOAD_RETRY_DELAYS_MS = [1e3, 3e3, 8e3];
|
|
68
|
+
function waitToRetry(delayMs, signal) {
|
|
69
|
+
return new Promise((resolve) => {
|
|
70
|
+
if (signal.aborted) {
|
|
71
|
+
resolve();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
let timer;
|
|
75
|
+
const hasDocument = typeof document !== "undefined";
|
|
76
|
+
const ready = () => (!hasDocument || document.visibilityState !== "hidden") && (typeof navigator === "undefined" || navigator.onLine !== false);
|
|
77
|
+
const finish = () => {
|
|
78
|
+
clearTimeout(timer);
|
|
79
|
+
if (hasDocument) document.removeEventListener("visibilitychange", check);
|
|
80
|
+
if (typeof window !== "undefined") window.removeEventListener("online", check);
|
|
81
|
+
signal.removeEventListener("abort", finish);
|
|
82
|
+
resolve();
|
|
83
|
+
};
|
|
84
|
+
function check() {
|
|
85
|
+
clearTimeout(timer);
|
|
86
|
+
timer = ready() ? setTimeout(finish, delayMs) : void 0;
|
|
87
|
+
}
|
|
88
|
+
signal.addEventListener("abort", finish);
|
|
89
|
+
if (hasDocument) document.addEventListener("visibilitychange", check);
|
|
90
|
+
if (typeof window !== "undefined") window.addEventListener("online", check);
|
|
91
|
+
check();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
67
94
|
function resolveAudioUrl(src, basePath) {
|
|
68
95
|
if (!src || /^(?:[a-z][a-z0-9+.-]*:|\/\/|\/)/i.test(src)) return src;
|
|
69
96
|
if (!basePath) return src;
|
|
@@ -284,6 +311,9 @@ function useAudioSync(audioRef, track, basePath = "", enabled = true, mode = "me
|
|
|
284
311
|
const segment = audioTrack.segments[currentSegment];
|
|
285
312
|
if (!segment) return;
|
|
286
313
|
const applyPendingSeek = () => {
|
|
314
|
+
if (pendingSeekTime.current !== null && findSegmentAtTime(pendingSeekTime.current, audioTrack.segments, segmentStarts.current).segmentIndex !== currentSegment) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
287
317
|
if (pendingSeekTime.current !== null) {
|
|
288
318
|
const segmentStart = segmentStarts.current[currentSegment] || 0;
|
|
289
319
|
const segmentTime = pendingSeekTime.current - segmentStart;
|
|
@@ -314,10 +344,21 @@ function useAudioSync(audioRef, track, basePath = "", enabled = true, mode = "me
|
|
|
314
344
|
const isSameSource = isBoundTo(audio, segment.src);
|
|
315
345
|
let cancelled = false;
|
|
316
346
|
let handleCanPlay = null;
|
|
347
|
+
const retryAbort = new AbortController();
|
|
317
348
|
if (!isSameSource) {
|
|
318
349
|
const loadAndPlay = async () => {
|
|
319
350
|
loadingSegment.current = segment.src;
|
|
320
|
-
|
|
351
|
+
let blobUrl = await preloadAudio(segment.src);
|
|
352
|
+
const fetchable = isResourceUrlAllowed(
|
|
353
|
+
resolveAudioUrl(segment.src, basePath),
|
|
354
|
+
resourcePolicy
|
|
355
|
+
);
|
|
356
|
+
for (const delay of LOAD_RETRY_DELAYS_MS) {
|
|
357
|
+
if (blobUrl || cancelled || !fetchable) break;
|
|
358
|
+
await waitToRetry(delay, retryAbort.signal);
|
|
359
|
+
if (cancelled) return;
|
|
360
|
+
blobUrl = await preloadAudio(segment.src);
|
|
361
|
+
}
|
|
321
362
|
if (cancelled) return;
|
|
322
363
|
loadingSegment.current = null;
|
|
323
364
|
if (!blobUrl) {
|
|
@@ -363,9 +404,20 @@ function useAudioSync(audioRef, track, basePath = "", enabled = true, mode = "me
|
|
|
363
404
|
}
|
|
364
405
|
return () => {
|
|
365
406
|
cancelled = true;
|
|
407
|
+
retryAbort.abort();
|
|
366
408
|
if (handleCanPlay) audio.removeEventListener("canplay", handleCanPlay);
|
|
367
409
|
};
|
|
368
|
-
}, [
|
|
410
|
+
}, [
|
|
411
|
+
audioRef,
|
|
412
|
+
currentSegment,
|
|
413
|
+
audioTrack,
|
|
414
|
+
preloadAudio,
|
|
415
|
+
enabled,
|
|
416
|
+
mode,
|
|
417
|
+
isBoundTo,
|
|
418
|
+
basePath,
|
|
419
|
+
resourcePolicy
|
|
420
|
+
]);
|
|
369
421
|
const seekTo = useCallback(
|
|
370
422
|
async (time) => {
|
|
371
423
|
const audio = audioRef.current;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -35,6 +35,11 @@ import { ResourcePolicy } from '@bendyline/squisq/markdown';
|
|
|
35
35
|
* seeking after it crosses a chapter boundary), because the element still
|
|
36
36
|
* holds the previous segment. The next segment is downloaded shortly before the
|
|
37
37
|
* current one ends, so chapter boundaries do not stall on a fresh download.
|
|
38
|
+
*
|
|
39
|
+
* A segment whose download fails is retried a few times before the narration
|
|
40
|
+
* is reported unavailable, and the waits only count while the page is visible
|
|
41
|
+
* and online. A phone app in the background can lose its network; the segment
|
|
42
|
+
* that failed there now loads, and plays on, when the listener comes back.
|
|
38
43
|
*/
|
|
39
44
|
|
|
40
45
|
type AudioSyncMode = 'media' | 'synthetic';
|
package/dist/hooks/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
resolveDocPlayerAppearance,
|
|
18
18
|
useBuildNavigation,
|
|
19
19
|
useMediaClipDurations
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-2GNCILIQ.js";
|
|
21
21
|
import {
|
|
22
22
|
PaginatedDocView
|
|
23
23
|
} from "./chunk-74MMSPTK.js";
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
useDocPlayback,
|
|
37
37
|
useMediaSchedule,
|
|
38
38
|
useViewportOrientation
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-UUGOEH5Q.js";
|
|
40
40
|
import {
|
|
41
41
|
JsonView,
|
|
42
42
|
createJsonFormFenceRenderer
|
package/dist/player/index.js
CHANGED
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
MediaClipLayer,
|
|
13
13
|
SocialCaptionOverlay,
|
|
14
14
|
formatTime
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-2GNCILIQ.js";
|
|
16
16
|
import "../chunk-L3PODEKP.js";
|
|
17
|
-
import "../chunk-
|
|
17
|
+
import "../chunk-UUGOEH5Q.js";
|
|
18
18
|
import "../chunk-TT6ENR6T.js";
|
|
19
19
|
import {
|
|
20
20
|
InlineAudioPlayer,
|