@bendyline/squisq-react 2.12.6 → 2.12.8
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-TQYJ54WQ.js → chunk-3SMC447F.js} +1 -1
- package/dist/{chunk-DQGV2LEY.js → chunk-M44RDTSG.js} +6 -0
- package/dist/{chunk-AX2FWY2N.js → chunk-R7PHQNC7.js} +17 -3
- package/dist/hooks/index.d.ts +4 -1
- package/dist/hooks/index.js +1 -1
- package/dist/index.js +3 -3
- package/dist/page/index.js +1 -1
- package/dist/player/index.js +2 -2
- package/dist/squisq-player.full.global.js +450 -451
- package/dist/squisq-player.global.js +78 -79
- package/dist/standalone-player-full.js +1 -1
- package/dist/standalone-source.js +1 -1
- package/package.json +2 -2
|
@@ -90,6 +90,7 @@ function useAudioSync(audioRef, track, basePath = "", enabled = true, mode = "me
|
|
|
90
90
|
const segmentStarts = useRef([]);
|
|
91
91
|
const pendingSeekTime = useRef(null);
|
|
92
92
|
const pendingSeekCompletion = useRef(null);
|
|
93
|
+
const pendingSeekPromise = useRef(null);
|
|
93
94
|
const shouldPlayAfterLoad = useRef(false);
|
|
94
95
|
const blobUrls = useRef(/* @__PURE__ */ new Map());
|
|
95
96
|
const loadingPromises = useRef(/* @__PURE__ */ new Map());
|
|
@@ -402,6 +403,7 @@ function useAudioSync(audioRef, track, basePath = "", enabled = true, mode = "me
|
|
|
402
403
|
const timer = setTimeout(settle, SEEK_COMPLETION_TIMEOUT_MS);
|
|
403
404
|
pendingSeekCompletion.current = settle;
|
|
404
405
|
});
|
|
406
|
+
pendingSeekPromise.current = completion;
|
|
405
407
|
setCurrentSegment(segmentIndex);
|
|
406
408
|
if (mode === "synthetic") {
|
|
407
409
|
setCurrentTime(clampedTime);
|
|
@@ -410,6 +412,10 @@ function useAudioSync(audioRef, track, basePath = "", enabled = true, mode = "me
|
|
|
410
412
|
pendingSeekCompletion.current = null;
|
|
411
413
|
}
|
|
412
414
|
await completion;
|
|
415
|
+
} else if (pendingSeekTime.current !== null && mode === "media" && enabled) {
|
|
416
|
+
pendingSeekTime.current = clampedTime;
|
|
417
|
+
setCurrentTime(clampedTime);
|
|
418
|
+
await pendingSeekPromise.current;
|
|
413
419
|
} else {
|
|
414
420
|
const segmentTime = clampedTime - segmentStart;
|
|
415
421
|
if (audio && mode === "media") audio.currentTime = Math.max(0, segmentTime);
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
useCallback,
|
|
8
8
|
useEffect,
|
|
9
|
+
useLayoutEffect,
|
|
9
10
|
useMemo,
|
|
10
11
|
useRef,
|
|
11
12
|
useState
|
|
@@ -53,6 +54,7 @@ function PaginatedDocView({
|
|
|
53
54
|
)
|
|
54
55
|
}));
|
|
55
56
|
}, [doc, linearViewProps, pages]);
|
|
57
|
+
const pageKeys = JSON.stringify(resolvedPages.map((page) => page.key));
|
|
56
58
|
const lastPage = Math.max(0, resolvedPages.length - 1);
|
|
57
59
|
const [currentPage, setCurrentPage] = useState(
|
|
58
60
|
() => Math.min(Math.max(0, initialPage), lastPage)
|
|
@@ -94,15 +96,27 @@ function PaginatedDocView({
|
|
|
94
96
|
},
|
|
95
97
|
[commitPage, einkMode, lastPage]
|
|
96
98
|
);
|
|
97
|
-
|
|
99
|
+
const previousLayoutRef = useRef(null);
|
|
100
|
+
useLayoutEffect(() => {
|
|
98
101
|
const container = scrollRef.current;
|
|
99
102
|
if (!container) return;
|
|
100
|
-
const
|
|
103
|
+
const keys = JSON.parse(pageKeys);
|
|
104
|
+
const previous = previousLayoutRef.current;
|
|
105
|
+
const selected = pendingPageRef.current ?? currentPage;
|
|
106
|
+
const preserveSelection = previous && previous.initialPage === initialPage && (selected > 0 || pendingPageRef.current !== null);
|
|
107
|
+
const retained = preserveSelection ? keys.indexOf(previous.keys[selected]) : -1;
|
|
108
|
+
const requested = preserveSelection ? retained >= 0 ? retained : selected : initialPage;
|
|
109
|
+
const initial = Math.min(Math.max(0, requested), lastPage);
|
|
110
|
+
previousLayoutRef.current = { keys, initialPage };
|
|
101
111
|
pendingPageRef.current = null;
|
|
112
|
+
if (pendingPageTimeoutRef.current !== null) {
|
|
113
|
+
clearTimeout(pendingPageTimeoutRef.current);
|
|
114
|
+
pendingPageTimeoutRef.current = null;
|
|
115
|
+
}
|
|
102
116
|
container.scrollLeft = initial * container.clientWidth;
|
|
103
117
|
setCurrentPage(initial);
|
|
104
118
|
if (focusOnMount) container.focus({ preventScroll: true });
|
|
105
|
-
}, [focusOnMount, initialPage, lastPage,
|
|
119
|
+
}, [focusOnMount, initialPage, lastPage, pageKeys]);
|
|
106
120
|
useEffect(
|
|
107
121
|
() => () => {
|
|
108
122
|
if (pendingPageTimeoutRef.current !== null) {
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -30,7 +30,10 @@ import { ResourcePolicy } from '@bendyline/squisq/markdown';
|
|
|
30
30
|
* Playing the element immediately would either start an element with no
|
|
31
31
|
* source, whose pending play the attaching `load()` aborts, or start the
|
|
32
32
|
* previous segment. An `AbortError` from `play()` therefore means "superseded",
|
|
33
|
-
* never "unavailable".
|
|
33
|
+
* never "unavailable". Seeks are handled the same way: a seek into a segment
|
|
34
|
+
* that is still loading moves the pending position (a scrub drag keeps
|
|
35
|
+
* seeking after it crosses a chapter boundary), because the element still
|
|
36
|
+
* holds the previous segment. The next segment is downloaded shortly before the
|
|
34
37
|
* current one ends, so chapter boundaries do not stall on a fresh download.
|
|
35
38
|
*/
|
|
36
39
|
|
package/dist/hooks/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
resolveDocPlayerAppearance,
|
|
18
18
|
useBuildNavigation,
|
|
19
19
|
useMediaClipDurations
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-3SMC447F.js";
|
|
21
21
|
import {
|
|
22
22
|
PaginatedDocView
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-R7PHQNC7.js";
|
|
24
24
|
import {
|
|
25
25
|
CanvasSection,
|
|
26
26
|
LinearDocView,
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
useDocPlayback,
|
|
37
37
|
useMediaSchedule,
|
|
38
38
|
useViewportOrientation
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-M44RDTSG.js";
|
|
40
40
|
import {
|
|
41
41
|
JsonView,
|
|
42
42
|
createJsonFormFenceRenderer
|
package/dist/page/index.js
CHANGED
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-3SMC447F.js";
|
|
16
16
|
import "../chunk-6BKIY72Q.js";
|
|
17
|
-
import "../chunk-
|
|
17
|
+
import "../chunk-M44RDTSG.js";
|
|
18
18
|
import "../chunk-TT6ENR6T.js";
|
|
19
19
|
import {
|
|
20
20
|
InlineAudioPlayer,
|