@bendyline/squisq-react 2.12.24 → 2.12.26
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-TVYZINUR.js → chunk-UUGOEH5Q.js} +54 -2
- package/dist/{chunk-MPOVPKIJ.js → chunk-XR3KNKLP.js} +42 -21
- 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 +425 -425
- package/dist/squisq-player.global.js +82 -82
- 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;
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useDocPlayback,
|
|
7
7
|
useMediaSchedule,
|
|
8
8
|
useViewportOrientation
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-UUGOEH5Q.js";
|
|
10
10
|
import {
|
|
11
11
|
useAutoSurface
|
|
12
12
|
} from "./chunk-TT6ENR6T.js";
|
|
@@ -2938,6 +2938,7 @@ function useSlideSwipe(opts) {
|
|
|
2938
2938
|
|
|
2939
2939
|
// src/DocPlayer.tsx
|
|
2940
2940
|
import {
|
|
2941
|
+
coverRepeatsLeadingBlock,
|
|
2941
2942
|
expandCoverBlock,
|
|
2942
2943
|
createTemplateContext,
|
|
2943
2944
|
markdownToDoc,
|
|
@@ -3288,6 +3289,39 @@ function DocPlayerContent({
|
|
|
3288
3289
|
}),
|
|
3289
3290
|
[resolvedPipStyle]
|
|
3290
3291
|
);
|
|
3292
|
+
const coverLayers = useMemo6(() => {
|
|
3293
|
+
const startBlockConfig = doc.startBlock;
|
|
3294
|
+
if (!appearance.showCoverSlide || !startBlockConfig) return null;
|
|
3295
|
+
const context = createTemplateContext(effectiveTheme, 0, 1, activeViewport, {
|
|
3296
|
+
motion: resolveMotionForDoc(doc, effectiveTheme, motionProp)
|
|
3297
|
+
});
|
|
3298
|
+
return expandCoverBlock(startBlockConfig, context, appearance.coverSlideTemplate);
|
|
3299
|
+
}, [
|
|
3300
|
+
doc,
|
|
3301
|
+
motionProp,
|
|
3302
|
+
activeViewport,
|
|
3303
|
+
effectiveTheme,
|
|
3304
|
+
appearance.showCoverSlide,
|
|
3305
|
+
appearance.coverSlideTemplate
|
|
3306
|
+
]);
|
|
3307
|
+
const coverIsFirstSlide = !!coverLayers && coverRepeatsLeadingBlock(doc);
|
|
3308
|
+
const playbackDoc = useMemo6(() => {
|
|
3309
|
+
if (!coverIsFirstSlide || !coverLayers) return doc;
|
|
3310
|
+
const [first, ...rest] = doc.blocks;
|
|
3311
|
+
return {
|
|
3312
|
+
...doc,
|
|
3313
|
+
blocks: [
|
|
3314
|
+
{
|
|
3315
|
+
...first,
|
|
3316
|
+
template: void 0,
|
|
3317
|
+
autoTemplate: void 0,
|
|
3318
|
+
templateData: void 0,
|
|
3319
|
+
layers: coverLayers
|
|
3320
|
+
},
|
|
3321
|
+
...rest
|
|
3322
|
+
]
|
|
3323
|
+
};
|
|
3324
|
+
}, [doc, coverIsFirstSlide, coverLayers]);
|
|
3291
3325
|
const hasAnchoredBlocks = useMemo6(
|
|
3292
3326
|
() => doc.blocks.some(
|
|
3293
3327
|
(block) => typeof block.sourceStartTime === "number"
|
|
@@ -3307,7 +3341,7 @@ function DocPlayerContent({
|
|
|
3307
3341
|
prevBlock: _prevBlock,
|
|
3308
3342
|
blocks: expandedBlocks,
|
|
3309
3343
|
suppressOutgoingForNextBlock
|
|
3310
|
-
} = useDocPlayback(
|
|
3344
|
+
} = useDocPlayback(playbackDoc, currentTime, {
|
|
3311
3345
|
basePath,
|
|
3312
3346
|
viewport: activeViewport,
|
|
3313
3347
|
theme: effectiveTheme,
|
|
@@ -3327,31 +3361,18 @@ function DocPlayerContent({
|
|
|
3327
3361
|
// would no longer match live playback.
|
|
3328
3362
|
useAudioSegmentTiming: audioMode !== "synthetic" || renderMode && hasAnchoredBlocks
|
|
3329
3363
|
});
|
|
3330
|
-
const coverBlock = useMemo6(
|
|
3331
|
-
|
|
3332
|
-
if (!appearance.showCoverSlide) return null;
|
|
3333
|
-
if (!startBlockConfig) return null;
|
|
3334
|
-
const context = createTemplateContext(effectiveTheme, 0, 1, activeViewport, {
|
|
3335
|
-
motion: resolveMotionForDoc(doc, effectiveTheme, motionProp)
|
|
3336
|
-
});
|
|
3337
|
-
const layers = expandCoverBlock(startBlockConfig, context, appearance.coverSlideTemplate);
|
|
3338
|
-
return {
|
|
3364
|
+
const coverBlock = useMemo6(
|
|
3365
|
+
() => coverLayers && !coverIsFirstSlide ? {
|
|
3339
3366
|
id: "cover-block",
|
|
3340
3367
|
startTime: -1,
|
|
3341
3368
|
// Not part of timeline
|
|
3342
3369
|
duration: 0,
|
|
3343
3370
|
// Static
|
|
3344
3371
|
audioSegment: -1,
|
|
3345
|
-
layers
|
|
3346
|
-
}
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
motionProp,
|
|
3350
|
-
activeViewport,
|
|
3351
|
-
effectiveTheme,
|
|
3352
|
-
appearance.showCoverSlide,
|
|
3353
|
-
appearance.coverSlideTemplate
|
|
3354
|
-
]);
|
|
3372
|
+
layers: coverLayers
|
|
3373
|
+
} : null,
|
|
3374
|
+
[coverLayers, coverIsFirstSlide]
|
|
3375
|
+
);
|
|
3355
3376
|
const hasManagedCover = !!coverBlock;
|
|
3356
3377
|
const [slideshowCoverVisible, setSlideshowCoverVisible] = useState7(false);
|
|
3357
3378
|
const [isSlideshowPickerOpen, setIsSlideshowPickerOpen] = useState7(false);
|
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-XR3KNKLP.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-XR3KNKLP.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,
|