@bendyline/squisq-react 2.12.5 → 2.12.7

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,30 +1,30 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-5KK6I55U.js";
3
+ } from "./chunk-6BKIY72Q.js";
4
4
  import {
5
5
  useAudioSync,
6
6
  useDocPlayback,
7
7
  useMediaSchedule,
8
8
  useViewportOrientation
9
- } from "./chunk-3H6QBEYX.js";
9
+ } from "./chunk-M44RDTSG.js";
10
10
  import {
11
11
  useAutoSurface
12
12
  } from "./chunk-TT6ENR6T.js";
13
13
  import {
14
14
  MarkdownRenderer
15
- } from "./chunk-IERUAQFK.js";
15
+ } from "./chunk-FLPGMUXM.js";
16
16
  import {
17
17
  BlockRenderer
18
- } from "./chunk-PFKYO6C2.js";
18
+ } from "./chunk-WACTP75S.js";
19
19
  import {
20
20
  isCaptureDrivenVideo,
21
21
  seekVideoToFrame
22
- } from "./chunk-4ILJDBJ7.js";
22
+ } from "./chunk-DN6JZRJI.js";
23
23
  import {
24
24
  useMediaProvider,
25
25
  useMediaUrl,
26
26
  useResourcePolicy
27
- } from "./chunk-JP2VHB5H.js";
27
+ } from "./chunk-P6MT4F3R.js";
28
28
 
29
29
  // src/hooks/useBuildNavigation.ts
30
30
  import { useCallback, useEffect, useMemo, useState } from "react";
@@ -5,14 +5,14 @@ import {
5
5
  InlineVideoPlayer,
6
6
  MarkdownRenderer,
7
7
  VideoEmbedFrame
8
- } from "./chunk-IERUAQFK.js";
8
+ } from "./chunk-FLPGMUXM.js";
9
9
  import {
10
10
  BlockRenderer
11
- } from "./chunk-PFKYO6C2.js";
11
+ } from "./chunk-WACTP75S.js";
12
12
  import {
13
13
  svgDataImageSrc,
14
14
  useMediaUrl
15
- } from "./chunk-JP2VHB5H.js";
15
+ } from "./chunk-P6MT4F3R.js";
16
16
 
17
17
  // src/page/PageViewContext.ts
18
18
  import { createContext, useContext } from "react";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  mermaidRenderErrorMessage,
3
3
  renderMermaidSvg
4
- } from "./chunk-JP2VHB5H.js";
4
+ } from "./chunk-P6MT4F3R.js";
5
5
 
6
6
  // src/mermaid/MermaidDiagram.tsx
7
7
  import { useEffect, useState } from "react";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  MermaidDiagram
3
- } from "./chunk-EY3DUCK7.js";
3
+ } from "./chunk-BXPGK5VO.js";
4
4
  import {
5
5
  useMediaUrl,
6
6
  useResourcePolicy
7
- } from "./chunk-JP2VHB5H.js";
7
+ } from "./chunk-P6MT4F3R.js";
8
8
 
9
9
  // src/utils/animationUtils.ts
10
10
  import {
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  MermaidDiagram
3
- } from "./chunk-EY3DUCK7.js";
3
+ } from "./chunk-BXPGK5VO.js";
4
4
  import {
5
5
  svgDataImageSrc,
6
6
  useMediaProvider,
7
7
  useMediaUrl
8
- } from "./chunk-JP2VHB5H.js";
8
+ } from "./chunk-P6MT4F3R.js";
9
9
 
10
10
  // src/hooks/FenceRendererContext.tsx
11
11
  import { createContext, useContext } from "react";
@@ -2,7 +2,7 @@ import {
2
2
  renderMermaidSvg,
3
3
  useMediaProvider,
4
4
  useResourcePolicy
5
- } from "./chunk-JP2VHB5H.js";
5
+ } from "./chunk-P6MT4F3R.js";
6
6
 
7
7
  // src/hooks/useMediaSchedule.ts
8
8
  import { useMemo } from "react";
@@ -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);
@@ -655,7 +661,9 @@ function useFeatureMediaAspectRatios(blocks, basePath, theme) {
655
661
  if (!absolute && provider) {
656
662
  try {
657
663
  url = await provider.resolveUrl(source);
664
+ if (!url || url === source) return;
658
665
  } catch {
666
+ return;
659
667
  }
660
668
  }
661
669
  if (!current || !isResourceUrlAllowed2(url, policy)) return;
@@ -104,19 +104,19 @@ function useMediaUrl(relativePath, basePath, options = {}) {
104
104
  path: safePath,
105
105
  provider,
106
106
  policy: resourcePolicy,
107
- url: allowed(resolved2) ? resolved2 : ""
107
+ // Providers return the original path when the asset is absent.
108
+ url: resolved2 !== safePath && allowed(resolved2) ? resolved2 : ""
108
109
  });
109
110
  }
110
111
  },
111
112
  () => {
112
- if (!cancelled)
113
- setResolved({ path: safePath, provider, policy: resourcePolicy, url: fallback });
113
+ if (!cancelled) setResolved({ path: safePath, provider, policy: resourcePolicy, url: "" });
114
114
  }
115
115
  );
116
116
  return () => {
117
117
  cancelled = true;
118
118
  };
119
- }, [needsProvider, provider, safePath, fallback, resourcePolicy, allowed]);
119
+ }, [needsProvider, provider, safePath, resourcePolicy, allowed]);
120
120
  const url = !needsProvider ? fallback : resolved?.path === safePath && resolved.provider === provider && resolved.policy === resourcePolicy ? resolved.url : "";
121
121
  return useSanitizedSvgImage(url, isSvg, { static: options.staticSvg === true }) ?? "";
122
122
  }
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-5KK6I55U.js";
3
+ } from "./chunk-6BKIY72Q.js";
4
4
 
5
5
  // src/PaginatedDocView.tsx
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
- useEffect(() => {
99
+ const previousLayoutRef = useRef(null);
100
+ useLayoutEffect(() => {
98
101
  const container = scrollRef.current;
99
102
  if (!container) return;
100
- const initial = Math.min(Math.max(0, initialPage), lastPage);
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, resolvedPages]);
119
+ }, [focusOnMount, initialPage, lastPage, pageKeys]);
106
120
  useEffect(
107
121
  () => () => {
108
122
  if (pendingPageTimeoutRef.current !== null) {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-TT6ENR6T.js";
4
4
  import {
5
5
  MarkdownRenderer
6
- } from "./chunk-IERUAQFK.js";
6
+ } from "./chunk-FLPGMUXM.js";
7
7
 
8
8
  // src/jsonView/useJsonViewTokens.ts
9
9
  import { useMemo } from "react";
@@ -12,7 +12,7 @@ import {
12
12
  getAnchorOffset,
13
13
  getTransitionClass,
14
14
  resolveValue
15
- } from "./chunk-4ILJDBJ7.js";
15
+ } from "./chunk-DN6JZRJI.js";
16
16
 
17
17
  // src/BlockRenderer.tsx
18
18
  import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  BlockRenderer
3
- } from "../chunk-PFKYO6C2.js";
4
- import "../chunk-4ILJDBJ7.js";
5
- import "../chunk-EY3DUCK7.js";
3
+ } from "../chunk-WACTP75S.js";
4
+ import "../chunk-DN6JZRJI.js";
5
+ import "../chunk-BXPGK5VO.js";
6
6
  import {
7
7
  renderMermaidSvgForExport
8
- } from "../chunk-JP2VHB5H.js";
8
+ } from "../chunk-P6MT4F3R.js";
9
9
 
10
10
  // src/export/diagramPictures.ts
11
11
  import { createElement } from "react";
@@ -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". The next segment is downloaded shortly before the
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
 
@@ -192,8 +195,9 @@ interface UseMediaUrlOptions {
192
195
  staticSvg?: boolean;
193
196
  }
194
197
  /**
195
- * Hook to resolve a media URL via the MediaProvider (if available),
196
- * falling back to basePath-based resolution.
198
+ * Hook to resolve a media URL via the MediaProvider (if available).
199
+ * Only provider-less paths use basePath-based resolution; a failed workspace
200
+ * lookup stays unresolved instead of requesting the same path from the page origin.
197
201
  *
198
202
  * Returns the resolved URL string. Updates when the provider or path changes.
199
203
  *
@@ -6,7 +6,7 @@ import {
6
6
  useDocPlayback,
7
7
  useMediaSchedule,
8
8
  useViewportOrientation
9
- } from "../chunk-3H6QBEYX.js";
9
+ } from "../chunk-M44RDTSG.js";
10
10
  import {
11
11
  useAutoSurface
12
12
  } from "../chunk-TT6ENR6T.js";
@@ -16,7 +16,7 @@ import {
16
16
  useMediaProvider,
17
17
  useMediaUrl,
18
18
  useResourcePolicy
19
- } from "../chunk-JP2VHB5H.js";
19
+ } from "../chunk-P6MT4F3R.js";
20
20
  export {
21
21
  MediaContext,
22
22
  ResourcePolicyContext,
package/dist/index.js CHANGED
@@ -17,17 +17,17 @@ import {
17
17
  resolveDocPlayerAppearance,
18
18
  useBuildNavigation,
19
19
  useMediaClipDurations
20
- } from "./chunk-RYLHJNQX.js";
20
+ } from "./chunk-3SMC447F.js";
21
21
  import {
22
22
  PaginatedDocView
23
- } from "./chunk-FI7UATA5.js";
23
+ } from "./chunk-R7PHQNC7.js";
24
24
  import {
25
25
  CanvasSection,
26
26
  LinearDocView,
27
27
  PageSectionView,
28
28
  PageViewContext,
29
29
  usePageView
30
- } from "./chunk-5KK6I55U.js";
30
+ } from "./chunk-6BKIY72Q.js";
31
31
  import {
32
32
  useModalDialog
33
33
  } from "./chunk-JP457U6N.js";
@@ -36,11 +36,11 @@ import {
36
36
  useDocPlayback,
37
37
  useMediaSchedule,
38
38
  useViewportOrientation
39
- } from "./chunk-3H6QBEYX.js";
39
+ } from "./chunk-M44RDTSG.js";
40
40
  import {
41
41
  JsonView,
42
42
  createJsonFormFenceRenderer
43
- } from "./chunk-OSTSRQD3.js";
43
+ } from "./chunk-UQOVF7IL.js";
44
44
  import {
45
45
  useAutoSurface
46
46
  } from "./chunk-TT6ENR6T.js";
@@ -54,10 +54,10 @@ import {
54
54
  VideoEmbedFrame,
55
55
  useAnimatedImage,
56
56
  useFenceRenderers
57
- } from "./chunk-IERUAQFK.js";
57
+ } from "./chunk-FLPGMUXM.js";
58
58
  import {
59
59
  BlockRenderer
60
- } from "./chunk-PFKYO6C2.js";
60
+ } from "./chunk-WACTP75S.js";
61
61
  import {
62
62
  ImageLayer,
63
63
  MapLayer,
@@ -71,10 +71,10 @@ import {
71
71
  VideoLayer,
72
72
  getAnimationStyle,
73
73
  getTransitionClass
74
- } from "./chunk-4ILJDBJ7.js";
74
+ } from "./chunk-DN6JZRJI.js";
75
75
  import {
76
76
  MermaidDiagram
77
- } from "./chunk-EY3DUCK7.js";
77
+ } from "./chunk-BXPGK5VO.js";
78
78
  import {
79
79
  MediaContext,
80
80
  ResourcePolicyContext,
@@ -84,7 +84,7 @@ import {
84
84
  useMediaUrl,
85
85
  useResourcePolicy,
86
86
  useSanitizedSvgImage
87
- } from "./chunk-JP2VHB5H.js";
87
+ } from "./chunk-P6MT4F3R.js";
88
88
  export {
89
89
  AnimatedImageControls,
90
90
  BlockRenderer,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  JsonView,
3
3
  createJsonFormFenceRenderer
4
- } from "../chunk-OSTSRQD3.js";
4
+ } from "../chunk-UQOVF7IL.js";
5
5
  import "../chunk-TT6ENR6T.js";
6
- import "../chunk-IERUAQFK.js";
7
- import "../chunk-EY3DUCK7.js";
8
- import "../chunk-JP2VHB5H.js";
6
+ import "../chunk-FLPGMUXM.js";
7
+ import "../chunk-BXPGK5VO.js";
8
+ import "../chunk-P6MT4F3R.js";
9
9
  export {
10
10
  JsonView,
11
11
  createJsonFormFenceRenderer
@@ -9,9 +9,9 @@ import {
9
9
  TextLayer,
10
10
  TreeLayer,
11
11
  VideoLayer
12
- } from "../chunk-4ILJDBJ7.js";
13
- import "../chunk-EY3DUCK7.js";
14
- import "../chunk-JP2VHB5H.js";
12
+ } from "../chunk-DN6JZRJI.js";
13
+ import "../chunk-BXPGK5VO.js";
14
+ import "../chunk-P6MT4F3R.js";
15
15
  export {
16
16
  ImageLayer,
17
17
  MapLayer,
@@ -3,11 +3,11 @@ import {
3
3
  MarkdownRenderer,
4
4
  VideoEmbedFrame,
5
5
  useFenceRenderers
6
- } from "../chunk-IERUAQFK.js";
6
+ } from "../chunk-FLPGMUXM.js";
7
7
  import {
8
8
  MermaidDiagram
9
- } from "../chunk-EY3DUCK7.js";
10
- import "../chunk-JP2VHB5H.js";
9
+ } from "../chunk-BXPGK5VO.js";
10
+ import "../chunk-P6MT4F3R.js";
11
11
  export {
12
12
  FenceRendererContext,
13
13
  MarkdownRenderer,
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  PaginatedDocView
3
- } from "../chunk-FI7UATA5.js";
3
+ } from "../chunk-R7PHQNC7.js";
4
4
  import {
5
5
  CanvasSection,
6
6
  LinearDocView,
7
7
  PageSectionView,
8
8
  PageViewContext,
9
9
  usePageView
10
- } from "../chunk-5KK6I55U.js";
10
+ } from "../chunk-6BKIY72Q.js";
11
11
  import "../chunk-TT6ENR6T.js";
12
- import "../chunk-IERUAQFK.js";
13
- import "../chunk-PFKYO6C2.js";
14
- import "../chunk-4ILJDBJ7.js";
15
- import "../chunk-EY3DUCK7.js";
16
- import "../chunk-JP2VHB5H.js";
12
+ import "../chunk-FLPGMUXM.js";
13
+ import "../chunk-WACTP75S.js";
14
+ import "../chunk-DN6JZRJI.js";
15
+ import "../chunk-BXPGK5VO.js";
16
+ import "../chunk-P6MT4F3R.js";
17
17
  export {
18
18
  CanvasSection,
19
19
  LinearDocView,
@@ -12,20 +12,20 @@ import {
12
12
  MediaClipLayer,
13
13
  SocialCaptionOverlay,
14
14
  formatTime
15
- } from "../chunk-RYLHJNQX.js";
16
- import "../chunk-5KK6I55U.js";
17
- import "../chunk-3H6QBEYX.js";
15
+ } from "../chunk-3SMC447F.js";
16
+ import "../chunk-6BKIY72Q.js";
17
+ import "../chunk-M44RDTSG.js";
18
18
  import "../chunk-TT6ENR6T.js";
19
19
  import {
20
20
  InlineAudioPlayer,
21
21
  InlineVideoPlayer
22
- } from "../chunk-IERUAQFK.js";
22
+ } from "../chunk-FLPGMUXM.js";
23
23
  import {
24
24
  BlockRenderer
25
- } from "../chunk-PFKYO6C2.js";
26
- import "../chunk-4ILJDBJ7.js";
27
- import "../chunk-EY3DUCK7.js";
28
- import "../chunk-JP2VHB5H.js";
25
+ } from "../chunk-WACTP75S.js";
26
+ import "../chunk-DN6JZRJI.js";
27
+ import "../chunk-BXPGK5VO.js";
28
+ import "../chunk-P6MT4F3R.js";
29
29
  export {
30
30
  BlockRenderer,
31
31
  CaptionOverlay,