@bendyline/squisq-react 2.12.32 → 2.12.34
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/README.md +9 -8
- package/dist/{chunk-MNY6M5QG.js → chunk-EQCHV3QH.js} +52 -4
- package/dist/{chunk-FHYMC4S6.js → chunk-IPTOV4W7.js} +3 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +5 -1
- package/dist/{hooks-Dxpfol0l.d.ts → hooks-xs6mDZLE.d.ts} +19 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -2
- package/dist/player/index.js +2 -2
- package/dist/squisq-player.full.global.js +354 -354
- package/dist/squisq-player.global.js +77 -77
- package/dist/standalone-player-full.js +1 -1
- package/dist/standalone-source.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -94,14 +94,15 @@ Blocks are composed of typed layers rendered as SVG:
|
|
|
94
94
|
|
|
95
95
|
## Hooks
|
|
96
96
|
|
|
97
|
-
| Hook | Description
|
|
98
|
-
| ---------------------------------- |
|
|
99
|
-
| `useDocPlayback` | Core playback state machine — timing, block transitions, scripting
|
|
100
|
-
| `useAudioSync` | Synchronizes audio playback with doc timeline
|
|
101
|
-
| `useMediaSchedule` | Resolves which timed media clips are active at the current time
|
|
102
|
-
| `useViewportOrientation` | Tracks viewport orientation for responsive layouts
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
97
|
+
| Hook | Description |
|
|
98
|
+
| ---------------------------------- | ------------------------------------------------------------------- |
|
|
99
|
+
| `useDocPlayback` | Core playback state machine — timing, block transitions, scripting |
|
|
100
|
+
| `useAudioSync` | Synchronizes audio playback with doc timeline |
|
|
101
|
+
| `useMediaSchedule` | Resolves which timed media clips are active at the current time |
|
|
102
|
+
| `useViewportOrientation` | Tracks viewport orientation for responsive layouts |
|
|
103
|
+
| `useScreenWakeLock` | Keeps the screen on while active (DocPlayer holds it while playing) |
|
|
104
|
+
| `useAutoSurface` | Live light/dark surface detection via `prefers-color-scheme` |
|
|
105
|
+
| `useMediaProvider` / `useMediaUrl` | Media URL resolution via `MediaContext` |
|
|
105
106
|
|
|
106
107
|
`useDocPlayback` takes configuration as an options object:
|
|
107
108
|
|
|
@@ -591,6 +591,52 @@ function useAudioSync(audioRef, track, basePath = "", enabled = true, mode = "me
|
|
|
591
591
|
};
|
|
592
592
|
}
|
|
593
593
|
|
|
594
|
+
// src/hooks/useScreenWakeLock.ts
|
|
595
|
+
import { useEffect as useEffect2 } from "react";
|
|
596
|
+
function holdScreenWakeLock(doc = globalThis.document) {
|
|
597
|
+
const wakeLock = typeof navigator === "undefined" ? void 0 : navigator.wakeLock;
|
|
598
|
+
if (!doc || !wakeLock) return () => {
|
|
599
|
+
};
|
|
600
|
+
let released = false;
|
|
601
|
+
let requesting = false;
|
|
602
|
+
let sentinel = null;
|
|
603
|
+
const request = () => {
|
|
604
|
+
if (released || requesting || sentinel || doc.visibilityState !== "visible") return;
|
|
605
|
+
requesting = true;
|
|
606
|
+
wakeLock.request("screen").then(
|
|
607
|
+
(lock) => {
|
|
608
|
+
requesting = false;
|
|
609
|
+
if (released) {
|
|
610
|
+
void lock.release().catch(() => {
|
|
611
|
+
});
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
sentinel = lock;
|
|
615
|
+
lock.addEventListener("release", () => {
|
|
616
|
+
if (sentinel === lock) sentinel = null;
|
|
617
|
+
});
|
|
618
|
+
},
|
|
619
|
+
() => {
|
|
620
|
+
requesting = false;
|
|
621
|
+
}
|
|
622
|
+
);
|
|
623
|
+
};
|
|
624
|
+
doc.addEventListener("visibilitychange", request);
|
|
625
|
+
request();
|
|
626
|
+
return () => {
|
|
627
|
+
if (released) return;
|
|
628
|
+
released = true;
|
|
629
|
+
doc.removeEventListener("visibilitychange", request);
|
|
630
|
+
const lock = sentinel;
|
|
631
|
+
sentinel = null;
|
|
632
|
+
if (lock) void lock.release().catch(() => {
|
|
633
|
+
});
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
function useScreenWakeLock(active) {
|
|
637
|
+
useEffect2(() => active ? holdScreenWakeLock() : void 0, [active]);
|
|
638
|
+
}
|
|
639
|
+
|
|
594
640
|
// src/hooks/useDocPlayback.ts
|
|
595
641
|
import { resolveDocBuildTiming } from "@bendyline/squisq/doc";
|
|
596
642
|
import { useMemo as useMemo4, useCallback as useCallback2, useRef as useRef2 } from "react";
|
|
@@ -610,7 +656,7 @@ import {
|
|
|
610
656
|
} from "@bendyline/squisq/doc";
|
|
611
657
|
|
|
612
658
|
// src/hooks/useFeatureMediaAspectRatios.ts
|
|
613
|
-
import { useEffect as
|
|
659
|
+
import { useEffect as useEffect3, useMemo as useMemo3, useState as useState2 } from "react";
|
|
614
660
|
import {
|
|
615
661
|
extractImages,
|
|
616
662
|
extractEmbeddedVideos,
|
|
@@ -682,7 +728,7 @@ function useFeatureMediaAspectRatios(blocks, basePath, theme) {
|
|
|
682
728
|
[sourceKey, provider, policy, basePath, theme]
|
|
683
729
|
);
|
|
684
730
|
const [result, setResult] = useState2();
|
|
685
|
-
|
|
731
|
+
useEffect3(() => {
|
|
686
732
|
if (typeof document === "undefined") return;
|
|
687
733
|
let current = true;
|
|
688
734
|
const cleanups = [];
|
|
@@ -883,7 +929,7 @@ function useDocPlayback(script, currentTime, options = {}) {
|
|
|
883
929
|
}
|
|
884
930
|
|
|
885
931
|
// src/hooks/useViewportOrientation.ts
|
|
886
|
-
import { useState as useState3, useEffect as
|
|
932
|
+
import { useState as useState3, useEffect as useEffect4, useMemo as useMemo5 } from "react";
|
|
887
933
|
import {
|
|
888
934
|
VIEWPORT_PRESETS as VIEWPORT_PRESETS2
|
|
889
935
|
} from "@bendyline/squisq/doc";
|
|
@@ -913,7 +959,7 @@ function useViewportOrientation() {
|
|
|
913
959
|
width: typeof window !== "undefined" ? window.innerWidth : 1920,
|
|
914
960
|
height: typeof window !== "undefined" ? window.innerHeight : 1080
|
|
915
961
|
}));
|
|
916
|
-
|
|
962
|
+
useEffect4(() => {
|
|
917
963
|
if (typeof window === "undefined") return;
|
|
918
964
|
const handleResize = () => {
|
|
919
965
|
setWindowSize({
|
|
@@ -947,6 +993,8 @@ function useViewportOrientation() {
|
|
|
947
993
|
export {
|
|
948
994
|
useMediaSchedule,
|
|
949
995
|
useAudioSync,
|
|
996
|
+
holdScreenWakeLock,
|
|
997
|
+
useScreenWakeLock,
|
|
950
998
|
useDocPlayback,
|
|
951
999
|
useViewportOrientation
|
|
952
1000
|
};
|
|
@@ -5,8 +5,9 @@ import {
|
|
|
5
5
|
useAudioSync,
|
|
6
6
|
useDocPlayback,
|
|
7
7
|
useMediaSchedule,
|
|
8
|
+
useScreenWakeLock,
|
|
8
9
|
useViewportOrientation
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-EQCHV3QH.js";
|
|
10
11
|
import {
|
|
11
12
|
useAutoSurface
|
|
12
13
|
} from "./chunk-TT6ENR6T.js";
|
|
@@ -3174,6 +3175,7 @@ function DocPlayerContent({
|
|
|
3174
3175
|
} = audio;
|
|
3175
3176
|
const [renderClock, setRenderClock] = useState7(null);
|
|
3176
3177
|
const renderTimeOverride = renderClock?.doc === doc ? renderClock.time : null;
|
|
3178
|
+
useScreenWakeLock(isPlaying && !renderMode);
|
|
3177
3179
|
const currentTime = renderMode ? renderTimeOverride ?? audioCurrentTime : audioCurrentTime;
|
|
3178
3180
|
const rawSchedule = useMemo6(() => resolveMediaSchedule(doc), [doc]);
|
|
3179
3181
|
const clipDurations = useMediaClipDurations(rawSchedule, basePath);
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { M as MediaContext, a as MediaScheduleController, b as ModalDialogOptions, R as ResourcePolicyContext, U as UseDocPlaybackOptions, u as useAudioSync, c as useAutoSurface, d as useDocPlayback, e as useMediaProvider, f as useMediaSchedule, g as useMediaUrl,
|
|
1
|
+
export { M as MediaContext, a as MediaScheduleController, b as ModalDialogOptions, R as ResourcePolicyContext, U as UseDocPlaybackOptions, h as holdScreenWakeLock, u as useAudioSync, c as useAutoSurface, d as useDocPlayback, e as useMediaProvider, f as useMediaSchedule, g as useMediaUrl, i as useModalDialog, j as useResourcePolicy, k as useScreenWakeLock, l as useViewportOrientation } from '../hooks-xs6mDZLE.js';
|
|
2
2
|
export { A as AudioActions, a as AudioController, b as AudioState } from '../AudioController-DAwQyEM_.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '@bendyline/squisq/schemas';
|
package/dist/hooks/index.js
CHANGED
|
@@ -2,11 +2,13 @@ import {
|
|
|
2
2
|
useModalDialog
|
|
3
3
|
} from "../chunk-JP457U6N.js";
|
|
4
4
|
import {
|
|
5
|
+
holdScreenWakeLock,
|
|
5
6
|
useAudioSync,
|
|
6
7
|
useDocPlayback,
|
|
7
8
|
useMediaSchedule,
|
|
9
|
+
useScreenWakeLock,
|
|
8
10
|
useViewportOrientation
|
|
9
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-EQCHV3QH.js";
|
|
10
12
|
import {
|
|
11
13
|
useAutoSurface
|
|
12
14
|
} from "../chunk-TT6ENR6T.js";
|
|
@@ -20,6 +22,7 @@ import {
|
|
|
20
22
|
export {
|
|
21
23
|
MediaContext,
|
|
22
24
|
ResourcePolicyContext,
|
|
25
|
+
holdScreenWakeLock,
|
|
23
26
|
useAudioSync,
|
|
24
27
|
useAutoSurface,
|
|
25
28
|
useDocPlayback,
|
|
@@ -28,5 +31,6 @@ export {
|
|
|
28
31
|
useMediaUrl,
|
|
29
32
|
useModalDialog,
|
|
30
33
|
useResourcePolicy,
|
|
34
|
+
useScreenWakeLock,
|
|
31
35
|
useViewportOrientation
|
|
32
36
|
};
|
|
@@ -178,6 +178,24 @@ interface UseViewportOrientationResult {
|
|
|
178
178
|
*/
|
|
179
179
|
declare function useViewportOrientation(): UseViewportOrientationResult;
|
|
180
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Keep the screen on while a document plays.
|
|
183
|
+
*
|
|
184
|
+
* Nobody touches the screen while watching, so auto-lock would darken it
|
|
185
|
+
* partway through. On a phone the app then leaves the foreground and playback
|
|
186
|
+
* stops. Video players hold a screen wake lock while they play, and so does
|
|
187
|
+
* DocPlayer.
|
|
188
|
+
*
|
|
189
|
+
* Uses the standard Screen Wake Lock API. Best effort: where it is missing or
|
|
190
|
+
* denied, playback runs as before. The platform drops the lock whenever the
|
|
191
|
+
* page is hidden, so it is requested again each time the page is visible.
|
|
192
|
+
* (Video export holds its own lock the same way, in squisq-video-react.)
|
|
193
|
+
*/
|
|
194
|
+
/** Hold a screen wake lock until the returned function is called. */
|
|
195
|
+
declare function holdScreenWakeLock(doc?: Document | undefined): () => void;
|
|
196
|
+
/** Keep the screen on while `active` is true. */
|
|
197
|
+
declare function useScreenWakeLock(active: boolean): void;
|
|
198
|
+
|
|
181
199
|
/**
|
|
182
200
|
* React context holding the current MediaProvider (or null if none provided).
|
|
183
201
|
*/
|
|
@@ -230,4 +248,4 @@ declare function useMediaUrl(relativePath: string, basePath: string, options?: U
|
|
|
230
248
|
*/
|
|
231
249
|
declare function useAutoSurface(enabled: boolean): SurfaceScheme;
|
|
232
250
|
|
|
233
|
-
export { MediaContext as M, ProcessedAudioContext as P, ResourcePolicyContext as R, type UseDocPlaybackOptions as U, type MediaScheduleController as a, type ModalDialogOptions as b, useAutoSurface as c, useDocPlayback as d, useMediaProvider as e, useMediaSchedule as f, useMediaUrl as g,
|
|
251
|
+
export { MediaContext as M, ProcessedAudioContext as P, ResourcePolicyContext as R, type UseDocPlaybackOptions as U, type MediaScheduleController as a, type ModalDialogOptions as b, useAutoSurface as c, useDocPlayback as d, useMediaProvider as e, useMediaSchedule as f, useMediaUrl as g, holdScreenWakeLock as h, useModalDialog as i, useResourcePolicy as j, useScreenWakeLock as k, useViewportOrientation as l, useAudioSync as u };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { ReactNode, RefObject, CSSProperties } from 'react';
|
|
|
12
12
|
import { AnimatedImageInfo } from '@bendyline/squisq/imageEdit';
|
|
13
13
|
export { ImageLayer, MapLayer, MermaidLayer, PathLayer, ShapeLayer, SvgLayer, TextLayer, TreeLayer } from './layers/index.js';
|
|
14
14
|
export { T as TableLayer, a as TableLayerContentRenderer, b as TableLayerContentRendererProps, V as VideoLayer } from './VideoLayer-Bg3TRIOb.js';
|
|
15
|
-
export { M as MediaContext, a as MediaScheduleController, b as ModalDialogOptions, P as ProcessedAudioContext, R as ResourcePolicyContext, U as UseDocPlaybackOptions, u as useAudioSync, c as useAutoSurface, d as useDocPlayback, e as useMediaProvider, f as useMediaSchedule, g as useMediaUrl,
|
|
15
|
+
export { M as MediaContext, a as MediaScheduleController, b as ModalDialogOptions, P as ProcessedAudioContext, R as ResourcePolicyContext, U as UseDocPlaybackOptions, h as holdScreenWakeLock, u as useAudioSync, c as useAutoSurface, d as useDocPlayback, e as useMediaProvider, f as useMediaSchedule, g as useMediaUrl, i as useModalDialog, j as useResourcePolicy, k as useScreenWakeLock, l as useViewportOrientation } from './hooks-xs6mDZLE.js';
|
|
16
16
|
import { ResourcePolicy } from '@bendyline/squisq/markdown';
|
|
17
17
|
import { MediaCrop, MediaCut, MediaTimeMap } from '@bendyline/squisq/mediaEdit';
|
|
18
18
|
export { FenceRenderContext, FenceRenderer, FenceRendererMap } from '@bendyline/squisq/fence';
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
useBuildNavigation,
|
|
21
21
|
useMediaClipDurations,
|
|
22
22
|
useVideoDurations
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-IPTOV4W7.js";
|
|
24
24
|
import {
|
|
25
25
|
PaginatedDocView
|
|
26
26
|
} from "./chunk-GIRDBU3E.js";
|
|
@@ -35,11 +35,13 @@ import {
|
|
|
35
35
|
useModalDialog
|
|
36
36
|
} from "./chunk-JP457U6N.js";
|
|
37
37
|
import {
|
|
38
|
+
holdScreenWakeLock,
|
|
38
39
|
useAudioSync,
|
|
39
40
|
useDocPlayback,
|
|
40
41
|
useMediaSchedule,
|
|
42
|
+
useScreenWakeLock,
|
|
41
43
|
useViewportOrientation
|
|
42
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-EQCHV3QH.js";
|
|
43
45
|
import {
|
|
44
46
|
JsonView,
|
|
45
47
|
createJsonFormFenceRenderer
|
|
@@ -143,6 +145,7 @@ export {
|
|
|
143
145
|
formatTime,
|
|
144
146
|
getAnimationStyle,
|
|
145
147
|
getTransitionClass,
|
|
148
|
+
holdScreenWakeLock,
|
|
146
149
|
isLocalSvgUrl,
|
|
147
150
|
mediaCropStyle,
|
|
148
151
|
probeVideoDurations,
|
|
@@ -165,6 +168,7 @@ export {
|
|
|
165
168
|
usePageView,
|
|
166
169
|
useResourcePolicy,
|
|
167
170
|
useSanitizedSvgImage,
|
|
171
|
+
useScreenWakeLock,
|
|
168
172
|
useSkipCuts,
|
|
169
173
|
useVideoDurations,
|
|
170
174
|
useViewportOrientation,
|
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-IPTOV4W7.js";
|
|
16
16
|
import "../chunk-MLONAXXN.js";
|
|
17
|
-
import "../chunk-
|
|
17
|
+
import "../chunk-EQCHV3QH.js";
|
|
18
18
|
import "../chunk-TT6ENR6T.js";
|
|
19
19
|
import {
|
|
20
20
|
InlineAudioPlayer,
|