@bendyline/squisq-react 2.11.25 → 2.12.1

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-E7UE2PCJ.js";
3
+ } from "./chunk-2K74UJ4T.js";
4
4
 
5
5
  // src/PaginatedDocView.tsx
6
6
  import {
@@ -11,10 +11,16 @@ import {
11
11
  getAnchorOffset,
12
12
  getTransitionClass,
13
13
  resolveValue
14
- } from "./chunk-5OA2DYA2.js";
14
+ } from "./chunk-3RVUSY4V.js";
15
15
 
16
16
  // src/BlockRenderer.tsx
17
- import { useId, useLayoutEffect, useRef, useState } from "react";
17
+ import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
18
+ import {
19
+ blockBuildSteps,
20
+ buildCursorAtTime,
21
+ resolveBuildTimeline,
22
+ buildTargetState
23
+ } from "@bendyline/squisq/doc";
18
24
  import { resolveTransitionDuration } from "@bendyline/squisq/schemas";
19
25
  import { isGeometryBoundTemplate } from "@bendyline/squisq/doc";
20
26
 
@@ -248,6 +254,8 @@ function overlapPairs(rects) {
248
254
  }
249
255
  function BlockRenderer({
250
256
  block,
257
+ buildPlayback = "all",
258
+ respectReducedMotion = true,
251
259
  blockTime,
252
260
  basePath,
253
261
  isEntering = false,
@@ -276,6 +284,56 @@ function BlockRenderer({
276
284
  const clipId = `vb-clip-${instanceId}-${block.id}`;
277
285
  const svgRef = useRef(null);
278
286
  const [textScale, setTextScale] = useState(1);
287
+ const steps = useMemo(() => blockBuildSteps(block), [block]);
288
+ const timeline = useMemo(
289
+ () => block.build ? resolveBuildTimeline(steps, block.build, block.duration, block.buildTiming) : void 0,
290
+ [steps, block.build, block.duration, block.buildTiming]
291
+ );
292
+ const [reducedMotion, setReducedMotion] = useState(false);
293
+ useEffect(() => {
294
+ if (!respectReducedMotion) {
295
+ setReducedMotion(false);
296
+ return;
297
+ }
298
+ const query = window.matchMedia?.("(prefers-reduced-motion: reduce)");
299
+ if (!query) return;
300
+ const update = () => setReducedMotion(query.matches);
301
+ update();
302
+ query.addEventListener?.("change", update);
303
+ return () => query.removeEventListener?.("change", update);
304
+ }, [respectReducedMotion]);
305
+ useLayoutEffect(() => {
306
+ const svg = svgRef.current;
307
+ if (!svg) return;
308
+ const cursor = buildPlayback === "all" || !timeline ? { revealed: steps.length, progress: 1 } : buildPlayback === "timed" ? buildCursorAtTime(timeline, blockTime) : buildPlayback;
309
+ svg.dataset.buildRevealed = String(cursor.revealed);
310
+ svg.dataset.buildCount = String(steps.length);
311
+ for (const target of svg.querySelectorAll("[data-squisq-build-step]")) {
312
+ const index = Number(target.dataset.squisqBuildStep);
313
+ if (!Number.isInteger(index) || index < 0 || index >= steps.length || !block.build) {
314
+ target.style.visibility = "visible";
315
+ target.style.opacity = "1";
316
+ target.style.transform = "";
317
+ target.style.pointerEvents = "";
318
+ target.removeAttribute("aria-hidden");
319
+ target.removeAttribute("inert");
320
+ continue;
321
+ }
322
+ const state = buildTargetState(
323
+ index,
324
+ steps,
325
+ cursor,
326
+ buildPlayback === "all" ? { ...block.build, previous: "keep" } : block.build,
327
+ animationsEnabled && !reducedMotion
328
+ );
329
+ target.style.visibility = state.hidden ? "hidden" : "visible";
330
+ target.style.opacity = String(state.opacity);
331
+ target.style.transform = `translate(${state.x}px, ${state.y}px)`;
332
+ target.style.pointerEvents = state.hidden ? "none" : "";
333
+ target.setAttribute("aria-hidden", String(state.hidden));
334
+ target.toggleAttribute("inert", state.hidden);
335
+ }
336
+ }, [block.build, steps, timeline, blockTime, buildPlayback, animationsEnabled, reducedMotion]);
279
337
  const growText = growTextToFit && !isGeometryBoundTemplate(block.template);
280
338
  useLayoutEffect(() => {
281
339
  const svg = svgRef.current;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  BlockRenderer
3
- } from "../chunk-TN3NQAFM.js";
4
- import "../chunk-5OA2DYA2.js";
3
+ } from "../chunk-XSSIHHDY.js";
4
+ import "../chunk-3RVUSY4V.js";
5
5
  import "../chunk-Z7OW6RGR.js";
6
6
  import {
7
7
  renderMermaidSvgForExport
@@ -76,20 +76,6 @@ interface MediaScheduleController {
76
76
  }
77
77
  declare function useMediaSchedule(schedule: ScheduledClip[], currentTime: number): MediaScheduleController;
78
78
 
79
- /**
80
- * useDocPlayback Hook
81
- *
82
- * Manages the playback state for a visual doc, including which block
83
- * is currently active, transition states, and synchronization with audio.
84
- *
85
- * This hook provides:
86
- * - Current block determination based on time
87
- * - Transition tracking (entering/exiting blocks)
88
- * - Manual navigation (next/prev block)
89
- * - Time-based seeking
90
- * - Automatic expansion of template blocks
91
- */
92
-
93
79
  interface PlaybackState {
94
80
  /** Currently visible block */
95
81
  currentBlock: Block | null;
@@ -6,7 +6,7 @@ import {
6
6
  useDocPlayback,
7
7
  useMediaSchedule,
8
8
  useViewportOrientation
9
- } from "../chunk-245G4EEN.js";
9
+ } from "../chunk-AA6NGEP7.js";
10
10
  import {
11
11
  useAutoSurface
12
12
  } from "../chunk-TT6ENR6T.js";
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { S as SquisqRenderAPI, V as VideoPresentation$1, P as PipSize, a as PipShape, b as PipPosition } from './player-BrLTAA_l.js';
2
- export { B as BlockMarker, c as BlockRenderer, C as CaptionMode, d as CaptionOverlay, e as CaptionPosition, f as CaptionStyle, g as ControlsLayout, D as DisplayMode, h as DocControlsBottom, i as DocControlsOverlay, j as DocControlsSidebar, k as DocControlsSlideshow, l as DocPlayer, m as DocPlayerProps, n as DocPlayerWithSidebar, o as DocProgressBar, F as FlashcardFaceView, p as FlashcardFaceViewProps, q as FlashcardView, r as FlashcardViewProps, I as InlineAudioPlayer, s as InlineAudioPlayerProps, t as InlineVideoPlayer, u as InlineVideoPlayerProps, M as MediaClipLayer, v as MediaClipLayerProps, w as PlaybackActions, x as PlaybackState, R as RenderAudioSegmentInfo, y as RenderBlockInfo, z as RenderCaptionInfo, A as RenderChapterInfo, E as RenderVideoFrameSelector, G as SlideNavActions, H as SocialCaptionOverlay, J as formatTime } from './player-BrLTAA_l.js';
3
- import { Theme, VideoPresentation, VideoPipSize, VideoPipShape, VideoPipPosition, MotionSpec, Doc, ScheduledClip, MediaProvider } from '@bendyline/squisq/schemas';
1
+ import { S as SquisqRenderAPI, V as VideoPresentation$1, P as PipSize, a as PipShape, b as PipPosition } from './player-Dnka50W4.js';
2
+ export { B as BlockMarker, c as BlockRenderer, C as CaptionMode, d as CaptionOverlay, e as CaptionPosition, f as CaptionStyle, g as ControlsLayout, D as DisplayMode, h as DocControlsBottom, i as DocControlsOverlay, j as DocControlsSidebar, k as DocControlsSlideshow, l as DocPlayer, m as DocPlayerProps, n as DocPlayerWithSidebar, o as DocProgressBar, F as FlashcardFaceView, p as FlashcardFaceViewProps, q as FlashcardView, r as FlashcardViewProps, I as InlineAudioPlayer, s as InlineAudioPlayerProps, t as InlineVideoPlayer, u as InlineVideoPlayerProps, M as MediaClipLayer, v as MediaClipLayerProps, w as PlaybackActions, x as PlaybackState, R as RenderAudioSegmentInfo, y as RenderBlockInfo, z as RenderCaptionInfo, A as RenderChapterInfo, E as RenderVideoFrameSelector, G as SlideNavActions, H as SocialCaptionOverlay, J as formatTime } from './player-Dnka50W4.js';
3
+ import { Theme, VideoPresentation, VideoPipSize, VideoPipShape, VideoPipPosition, MotionSpec, Doc, ScheduledClip, MediaProvider, Block, BuildCursor } from '@bendyline/squisq/schemas';
4
4
  import { DashboardStyleId, ViewportConfig, CoverSlideTemplate, CoverSlidePlayback } from '@bendyline/squisq/doc';
5
5
  export { getAnimationStyle, getTransitionClass } from '@bendyline/squisq/doc';
6
6
  import { C as CodeBlockCopyHandler } from './MarkdownRenderer-C63CQ9Ca.js';
@@ -122,6 +122,7 @@ interface MountOptions {
122
122
  * Timed media continues to play when disabled.
123
123
  */
124
124
  animationsEnabled?: boolean;
125
+ buildsEnabled?: boolean;
125
126
  /** Caption style: 'standard' or 'social'. Omit or set to undefined for no captions. */
126
127
  captionStyle?: 'standard' | 'social';
127
128
  /** Caption placement over the frame; omit for the style's classic spot. */
@@ -255,4 +256,14 @@ declare function resolveDocPlayerAppearance(doc: Doc, overrides?: DocPlayerAppea
255
256
  */
256
257
  declare function useMediaClipDurations(schedule: ScheduledClip[], basePath: string, mediaProviderOverride?: MediaProvider | null): Map<string, number>;
257
258
 
258
- export { AnimatedImageControls, type AnimatedImageControlsProps, type AnimatedImagePlayback, type AnimatedImageStatus, CodeBlockCopyHandler, DashboardView, type DashboardViewProps, type DocPlayerAppearanceOverrides, type MountOptions, PipPosition, PipShape, PipSize, type ResolvedDocPlayerAppearance, type SquisqPlayerHandle, SquisqRenderAPI, VideoPresentation$1 as VideoPresentation, resolveDocPlayerAppearance, useAnimatedImage, useMediaClipDurations };
259
+ /** A manual build clock never seeks or starts the document's audio clock. */
260
+ declare function useBuildNavigation(block: Block | null | undefined, enabled: boolean, motion: boolean): {
261
+ cursor: BuildCursor;
262
+ count: number;
263
+ next: () => boolean;
264
+ previous: () => boolean;
265
+ enter: (target: Block | null | undefined, complete?: boolean) => void;
266
+ showAll: () => void;
267
+ };
268
+
269
+ export { AnimatedImageControls, type AnimatedImageControlsProps, type AnimatedImagePlayback, type AnimatedImageStatus, CodeBlockCopyHandler, DashboardView, type DashboardViewProps, type DocPlayerAppearanceOverrides, type MountOptions, PipPosition, PipShape, PipSize, type ResolvedDocPlayerAppearance, type SquisqPlayerHandle, SquisqRenderAPI, VideoPresentation$1 as VideoPresentation, resolveDocPlayerAppearance, useAnimatedImage, useBuildNavigation, useMediaClipDurations };
package/dist/index.js CHANGED
@@ -14,18 +14,19 @@ import {
14
14
  SocialCaptionOverlay,
15
15
  formatTime,
16
16
  resolveDocPlayerAppearance,
17
+ useBuildNavigation,
17
18
  useMediaClipDurations
18
- } from "./chunk-JKR5LJXK.js";
19
+ } from "./chunk-NZMF2G7M.js";
19
20
  import {
20
21
  PaginatedDocView
21
- } from "./chunk-KORFPHSJ.js";
22
+ } from "./chunk-UNZSCTBU.js";
22
23
  import {
23
24
  CanvasSection,
24
25
  LinearDocView,
25
26
  PageSectionView,
26
27
  PageViewContext,
27
28
  usePageView
28
- } from "./chunk-E7UE2PCJ.js";
29
+ } from "./chunk-2K74UJ4T.js";
29
30
  import {
30
31
  useModalDialog
31
32
  } from "./chunk-JP457U6N.js";
@@ -34,7 +35,7 @@ import {
34
35
  useDocPlayback,
35
36
  useMediaSchedule,
36
37
  useViewportOrientation
37
- } from "./chunk-245G4EEN.js";
38
+ } from "./chunk-AA6NGEP7.js";
38
39
  import {
39
40
  JsonView,
40
41
  createJsonFormFenceRenderer
@@ -54,7 +55,7 @@ import {
54
55
  } from "./chunk-T7NVETOH.js";
55
56
  import {
56
57
  BlockRenderer
57
- } from "./chunk-TN3NQAFM.js";
58
+ } from "./chunk-XSSIHHDY.js";
58
59
  import {
59
60
  ImageLayer,
60
61
  MapLayer,
@@ -67,7 +68,7 @@ import {
67
68
  VideoLayer,
68
69
  getAnimationStyle,
69
70
  getTransitionClass
70
- } from "./chunk-5OA2DYA2.js";
71
+ } from "./chunk-3RVUSY4V.js";
71
72
  import {
72
73
  MermaidDiagram
73
74
  } from "./chunk-Z7OW6RGR.js";
@@ -125,6 +126,7 @@ export {
125
126
  useAnimatedImage,
126
127
  useAudioSync,
127
128
  useAutoSurface,
129
+ useBuildNavigation,
128
130
  useDocPlayback,
129
131
  useFenceRenderers,
130
132
  useMediaClipDurations,
@@ -8,7 +8,7 @@ import {
8
8
  TextLayer,
9
9
  TreeLayer,
10
10
  VideoLayer
11
- } from "../chunk-5OA2DYA2.js";
11
+ } from "../chunk-3RVUSY4V.js";
12
12
  import "../chunk-Z7OW6RGR.js";
13
13
  import "../chunk-HCKL2AFN.js";
14
14
  export {
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  PaginatedDocView
3
- } from "../chunk-KORFPHSJ.js";
3
+ } from "../chunk-UNZSCTBU.js";
4
4
  import {
5
5
  CanvasSection,
6
6
  LinearDocView,
7
7
  PageSectionView,
8
8
  PageViewContext,
9
9
  usePageView
10
- } from "../chunk-E7UE2PCJ.js";
10
+ } from "../chunk-2K74UJ4T.js";
11
11
  import "../chunk-TT6ENR6T.js";
12
12
  import "../chunk-T7NVETOH.js";
13
- import "../chunk-TN3NQAFM.js";
14
- import "../chunk-5OA2DYA2.js";
13
+ import "../chunk-XSSIHHDY.js";
14
+ import "../chunk-3RVUSY4V.js";
15
15
  import "../chunk-Z7OW6RGR.js";
16
16
  import "../chunk-HCKL2AFN.js";
17
17
  export {
@@ -1,4 +1,4 @@
1
- export { B as BlockMarker, c as BlockRenderer, C as CaptionMode, d as CaptionOverlay, f as CaptionStyle, g as ControlsLayout, D as DisplayMode, h as DocControlsBottom, i as DocControlsOverlay, j as DocControlsSidebar, k as DocControlsSlideshow, l as DocPlayer, m as DocPlayerProps, n as DocPlayerWithSidebar, o as DocProgressBar, F as FlashcardFaceView, p as FlashcardFaceViewProps, q as FlashcardView, r as FlashcardViewProps, I as InlineAudioPlayer, s as InlineAudioPlayerProps, t as InlineVideoPlayer, u as InlineVideoPlayerProps, M as MediaClipLayer, v as MediaClipLayerProps, b as PipPosition, a as PipShape, P as PipSize, w as PlaybackActions, x as PlaybackState, R as RenderAudioSegmentInfo, y as RenderBlockInfo, z as RenderCaptionInfo, A as RenderChapterInfo, G as SlideNavActions, H as SocialCaptionOverlay, S as SquisqRenderAPI, V as VideoPresentation, J as formatTime } from '../player-BrLTAA_l.js';
1
+ export { B as BlockMarker, c as BlockRenderer, C as CaptionMode, d as CaptionOverlay, f as CaptionStyle, g as ControlsLayout, D as DisplayMode, h as DocControlsBottom, i as DocControlsOverlay, j as DocControlsSidebar, k as DocControlsSlideshow, l as DocPlayer, m as DocPlayerProps, n as DocPlayerWithSidebar, o as DocProgressBar, F as FlashcardFaceView, p as FlashcardFaceViewProps, q as FlashcardView, r as FlashcardViewProps, I as InlineAudioPlayer, s as InlineAudioPlayerProps, t as InlineVideoPlayer, u as InlineVideoPlayerProps, M as MediaClipLayer, v as MediaClipLayerProps, b as PipPosition, a as PipShape, P as PipSize, w as PlaybackActions, x as PlaybackState, R as RenderAudioSegmentInfo, y as RenderBlockInfo, z as RenderCaptionInfo, A as RenderChapterInfo, G as SlideNavActions, H as SocialCaptionOverlay, S as SquisqRenderAPI, V as VideoPresentation, J as formatTime } from '../player-Dnka50W4.js';
2
2
  export { a as CodeBlockCopyContext, C as CodeBlockCopyHandler } from '../MarkdownRenderer-C63CQ9Ca.js';
3
3
  import 'react';
4
4
  import '@bendyline/squisq/schemas';
@@ -12,9 +12,9 @@ import {
12
12
  MediaClipLayer,
13
13
  SocialCaptionOverlay,
14
14
  formatTime
15
- } from "../chunk-JKR5LJXK.js";
16
- import "../chunk-E7UE2PCJ.js";
17
- import "../chunk-245G4EEN.js";
15
+ } from "../chunk-NZMF2G7M.js";
16
+ import "../chunk-2K74UJ4T.js";
17
+ import "../chunk-AA6NGEP7.js";
18
18
  import "../chunk-TT6ENR6T.js";
19
19
  import {
20
20
  InlineAudioPlayer,
@@ -22,8 +22,8 @@ import {
22
22
  } from "../chunk-T7NVETOH.js";
23
23
  import {
24
24
  BlockRenderer
25
- } from "../chunk-TN3NQAFM.js";
26
- import "../chunk-5OA2DYA2.js";
25
+ } from "../chunk-XSSIHHDY.js";
26
+ import "../chunk-3RVUSY4V.js";
27
27
  import "../chunk-Z7OW6RGR.js";
28
28
  import "../chunk-HCKL2AFN.js";
29
29
  export {
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { CSSProperties } from 'react';
3
- import { Block, VideoPresentation as VideoPresentation$1, VideoPipSize, VideoPipShape, VideoPipPosition, Doc, MediaScheduleOptions, Theme, MotionSpec, SurfaceScheme, Transition, CaptionTrack, ViewportConfig as ViewportConfig$1, CustomTemplateDefinition, ScheduledClip } from '@bendyline/squisq/schemas';
3
+ import { Block, VideoPresentation as VideoPresentation$1, VideoPipSize, VideoPipShape, VideoPipPosition, Doc, MediaScheduleOptions, Theme, MotionSpec, SurfaceScheme, BuildCursor, Transition, CaptionTrack, ViewportConfig as ViewportConfig$1, CustomTemplateDefinition, ScheduledClip } from '@bendyline/squisq/schemas';
4
4
  import { ViewportConfig, DashboardStyleId, CoverSlideTemplate, CoverSlidePlayback, FlashcardFace, FlashcardSourceMode } from '@bendyline/squisq/doc';
5
5
  import { FenceRendererMap } from '@bendyline/squisq/fence';
6
6
  import { a as AudioController } from './AudioController-DAwQyEM_.js';
@@ -87,6 +87,9 @@ type CaptionPosition = 'top' | 'center' | 'bottom';
87
87
  type CaptionMode = 'off' | 'standard' | 'social';
88
88
  /** Slide navigation actions for slideshow display mode */
89
89
  interface SlideNavActions {
90
+ nextStep?: () => void;
91
+ prevStep?: () => void;
92
+ showAllBuilds?: () => void;
90
93
  /** Navigate to the next slide */
91
94
  nextSlide: () => void;
92
95
  /** Navigate to the previous slide */
@@ -96,6 +99,10 @@ interface SlideNavActions {
96
99
  }
97
100
  /** Playback state exposed to external control components */
98
101
  interface PlaybackState {
102
+ buildStep?: number;
103
+ buildCount?: number;
104
+ /** True while the newest build step is entering. */
105
+ isBuilding?: boolean;
99
106
  isPlaying: boolean;
100
107
  /** Playback was requested but audio has not started yet (see AudioState.isBuffering). */
101
108
  isBuffering?: boolean;
@@ -126,6 +133,9 @@ interface PlaybackState {
126
133
  }
127
134
  /** Playback actions exposed to external control components */
128
135
  interface PlaybackActions {
136
+ nextBuild?: () => void;
137
+ previousBuild?: () => void;
138
+ showAllBuilds?: () => void;
129
139
  toggle: () => void;
130
140
  restart: () => void;
131
141
  seekTo: (time: number) => void;
@@ -224,6 +234,8 @@ interface DocPlayerProps {
224
234
  renderMode?: boolean;
225
235
  /** Render slide transitions and per-layer animations (default: true). */
226
236
  animationsEnabled?: boolean;
237
+ /** False shows every build step. Disabling motion alone preserves reveal order. */
238
+ buildsEnabled?: boolean;
227
239
  /** Receives the instance-scoped render API, and `null` on cleanup. */
228
240
  onRenderAPIReady?: (api: SquisqRenderAPI | null) => void;
229
241
  /**
@@ -337,6 +349,10 @@ interface ViewportDimensions {
337
349
  height: number;
338
350
  }
339
351
  interface BlockRendererProps {
352
+ /** Static consumers default to all content. Players opt into a timed or manual cursor. */
353
+ buildPlayback?: 'all' | 'timed' | BuildCursor;
354
+ /** Export hosts use false so system preferences cannot change captured frames. */
355
+ respectReducedMotion?: boolean;
340
356
  /** The block to render */
341
357
  block: Block;
342
358
  /** Current time relative to block start (seconds) */
@@ -374,7 +390,7 @@ interface BlockRendererProps {
374
390
  */
375
391
  videoEmbeds?: VideoEmbedMode;
376
392
  }
377
- declare function BlockRenderer({ block, blockTime, basePath, isEntering, isExiting, transition, viewport, isPlaying, muted, animationsEnabled, theme, tableContentRenderer, growTextToFit, videoEmbeds, }: BlockRendererProps): react.JSX.Element;
393
+ declare function BlockRenderer({ block, buildPlayback, respectReducedMotion, blockTime, basePath, isEntering, isExiting, transition, viewport, isPlaying, muted, animationsEnabled, theme, tableContentRenderer, growTextToFit, videoEmbeds, }: BlockRendererProps): react.JSX.Element;
378
394
 
379
395
  interface CaptionOverlayProps {
380
396
  /** Caption track with timestamped phrases */