@bendyline/squisq-react 2.12.26 → 2.12.28
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-HPABEDRG.js → chunk-3UITZDNL.js} +9 -2
- package/dist/{chunk-OWC7DNGJ.js → chunk-CFJRBRRG.js} +32 -15
- package/dist/{chunk-E7TEWUNF.js → chunk-DRPMS5JK.js} +144 -297
- package/dist/chunk-FXAKS6KU.js +403 -0
- package/dist/{chunk-74MMSPTK.js → chunk-M4IUYVXU.js} +1 -1
- package/dist/{chunk-UUGOEH5Q.js → chunk-MNY6M5QG.js} +1 -1
- package/dist/{chunk-XR3KNKLP.js → chunk-NZHL2VKW.js} +90 -75
- package/dist/{chunk-L3PODEKP.js → chunk-Q66DDGKP.js} +4 -3
- package/dist/{chunk-26J5MZBI.js → chunk-RVTMYNVX.js} +1 -1
- package/dist/{chunk-OTYJ4MRH.js → chunk-ZKMBIWAA.js} +6 -2
- package/dist/diagram-pictures/index.js +4 -7
- package/dist/hooks/index.d.ts +6 -228
- package/dist/hooks/index.js +2 -2
- package/dist/hooks-Dxpfol0l.d.ts +233 -0
- package/dist/index.d.ts +87 -7
- package/dist/index.js +30 -12
- package/dist/json-view/index.js +4 -4
- package/dist/layers/index.js +3 -3
- package/dist/markdown/index.js +3 -3
- package/dist/page/index.js +7 -7
- package/dist/player/index.d.ts +1 -1
- package/dist/player/index.js +8 -8
- package/dist/{player-C-k_8OaA.d.ts → player-B-2-utvs.d.ts} +10 -3
- package/dist/squisq-player.full.global.js +478 -475
- package/dist/squisq-player.global.js +95 -92
- package/dist/standalone-player-full.js +1 -1
- package/dist/standalone-source.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-A65WPCGZ.js +0 -67
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LinearDocView
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Q66DDGKP.js";
|
|
4
4
|
import {
|
|
5
5
|
useAudioSync,
|
|
6
6
|
useDocPlayback,
|
|
7
7
|
useMediaSchedule,
|
|
8
8
|
useViewportOrientation
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-MNY6M5QG.js";
|
|
10
10
|
import {
|
|
11
11
|
useAutoSurface
|
|
12
12
|
} from "./chunk-TT6ENR6T.js";
|
|
13
13
|
import {
|
|
14
14
|
MarkdownRenderer
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-CFJRBRRG.js";
|
|
16
16
|
import {
|
|
17
17
|
BlockRenderer
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-3UITZDNL.js";
|
|
19
19
|
import {
|
|
20
|
+
applyMediaLevel,
|
|
21
|
+
blockVideoSourceTime,
|
|
20
22
|
isCaptureDrivenVideo,
|
|
23
|
+
mediaCropStyle,
|
|
21
24
|
seekVideoToFrame
|
|
22
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-FXAKS6KU.js";
|
|
23
26
|
import {
|
|
27
|
+
ProcessedAudioContext,
|
|
24
28
|
useMediaProvider,
|
|
25
29
|
useMediaUrl,
|
|
26
30
|
useResourcePolicy
|
|
27
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-ZKMBIWAA.js";
|
|
28
32
|
|
|
29
33
|
// src/hooks/useBuildNavigation.ts
|
|
30
34
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
@@ -128,33 +132,6 @@ function mountedClips(clips, time) {
|
|
|
128
132
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
129
133
|
var DRIFT = 0.25;
|
|
130
134
|
var PRESEEK = 0.75;
|
|
131
|
-
var boostContext = null;
|
|
132
|
-
var boostNodes = /* @__PURE__ */ new WeakMap();
|
|
133
|
-
function boostNodeFor(el) {
|
|
134
|
-
const existing = boostNodes.get(el);
|
|
135
|
-
if (existing) return existing;
|
|
136
|
-
if (typeof AudioContext === "undefined") return null;
|
|
137
|
-
try {
|
|
138
|
-
boostContext ?? (boostContext = new AudioContext());
|
|
139
|
-
const gain = boostContext.createGain();
|
|
140
|
-
boostContext.createMediaElementSource(el).connect(gain).connect(boostContext.destination);
|
|
141
|
-
boostNodes.set(el, gain);
|
|
142
|
-
return gain;
|
|
143
|
-
} catch {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function applyLevel(el, level) {
|
|
148
|
-
const boost = level > 1 ? boostNodeFor(el) : boostNodes.get(el);
|
|
149
|
-
if (boost) {
|
|
150
|
-
el.volume = 1;
|
|
151
|
-
boost.gain.value = level;
|
|
152
|
-
if (boostContext?.state === "suspended") void boostContext.resume().catch(() => {
|
|
153
|
-
});
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
el.volume = Math.min(1, Math.max(0, level));
|
|
157
|
-
}
|
|
158
135
|
function mediaGroupStyle(presentation) {
|
|
159
136
|
return {
|
|
160
137
|
position: "absolute",
|
|
@@ -207,12 +184,6 @@ function mediaVideoStyle({
|
|
|
207
184
|
...pipCornerStyle(pipPosition)
|
|
208
185
|
};
|
|
209
186
|
}
|
|
210
|
-
function cropStyle(crop) {
|
|
211
|
-
if (!crop) return {};
|
|
212
|
-
const pct = (n) => `${(n * 100).toFixed(3)}%`;
|
|
213
|
-
const inset = `inset(${pct(crop.y)} ${pct(1 - crop.x - crop.w)} ${pct(1 - crop.y - crop.h)} ${pct(crop.x)})`;
|
|
214
|
-
return { objectViewBox: inset };
|
|
215
|
-
}
|
|
216
187
|
function MediaClipLayer({
|
|
217
188
|
schedule,
|
|
218
189
|
currentTime,
|
|
@@ -315,7 +286,7 @@ function MediaClipElement({
|
|
|
315
286
|
return;
|
|
316
287
|
}
|
|
317
288
|
if (!renderMode) {
|
|
318
|
-
|
|
289
|
+
applyMediaLevel(
|
|
319
290
|
el,
|
|
320
291
|
clipLevelAt({ absoluteStart, absoluteEnd, gain, fadeIn, fadeOut }, currentTime)
|
|
321
292
|
);
|
|
@@ -378,7 +349,7 @@ function MediaClipElement({
|
|
|
378
349
|
pipFrameStyle,
|
|
379
350
|
active
|
|
380
351
|
}),
|
|
381
|
-
...
|
|
352
|
+
...mediaCropStyle(clip.crop)
|
|
382
353
|
}
|
|
383
354
|
}
|
|
384
355
|
);
|
|
@@ -395,8 +366,12 @@ function MediaClipElement({
|
|
|
395
366
|
|
|
396
367
|
// src/hooks/useMediaClipDurations.ts
|
|
397
368
|
import { useEffect as useEffect3, useMemo as useMemo2, useState as useState2 } from "react";
|
|
398
|
-
import {
|
|
399
|
-
|
|
369
|
+
import { applyVideoDurations, collectVideoDurationSources } from "@bendyline/squisq/doc";
|
|
370
|
+
import {
|
|
371
|
+
DEFAULT_INTERACTIVE_RESOURCE_POLICY,
|
|
372
|
+
isResourceUrlAllowed
|
|
373
|
+
} from "@bendyline/squisq/markdown";
|
|
374
|
+
var probeCache = /* @__PURE__ */ new Map();
|
|
400
375
|
var PROBE_TIMEOUT_MS = 8e3;
|
|
401
376
|
async function resolveMediaUrl(src, provider, basePath, policy) {
|
|
402
377
|
const isAbsolute = !src || /^(?:[a-z][a-z0-9+.-]*:|\/\/|\/)/i.test(src);
|
|
@@ -461,21 +436,63 @@ function probeVideoDuration(url) {
|
|
|
461
436
|
el.src = url;
|
|
462
437
|
});
|
|
463
438
|
}
|
|
439
|
+
function probeCachedVideoDuration(url) {
|
|
440
|
+
let probe = probeCache.get(url);
|
|
441
|
+
if (!probe) {
|
|
442
|
+
probe = probeVideoDuration(url).then((seconds) => {
|
|
443
|
+
if (seconds == null) probeCache.delete(url);
|
|
444
|
+
return seconds;
|
|
445
|
+
});
|
|
446
|
+
probeCache.set(url, probe);
|
|
447
|
+
}
|
|
448
|
+
return probe;
|
|
449
|
+
}
|
|
450
|
+
async function probeVideoDurations(srcs, options = {}) {
|
|
451
|
+
const {
|
|
452
|
+
provider = null,
|
|
453
|
+
basePath = "/",
|
|
454
|
+
resourcePolicy = DEFAULT_INTERACTIVE_RESOURCE_POLICY
|
|
455
|
+
} = options;
|
|
456
|
+
const durations = /* @__PURE__ */ new Map();
|
|
457
|
+
const unique = [...new Set(srcs)].filter((src) => src.length > 0);
|
|
458
|
+
await Promise.all(
|
|
459
|
+
unique.map(async (src) => {
|
|
460
|
+
try {
|
|
461
|
+
const url = await resolveMediaUrl(src, provider, basePath, resourcePolicy);
|
|
462
|
+
if (!url) return;
|
|
463
|
+
const seconds = await probeCachedVideoDuration(url);
|
|
464
|
+
if (seconds != null) durations.set(src, seconds);
|
|
465
|
+
} catch {
|
|
466
|
+
}
|
|
467
|
+
})
|
|
468
|
+
);
|
|
469
|
+
return durations;
|
|
470
|
+
}
|
|
471
|
+
async function resolveVideoDurations(doc, options = {}) {
|
|
472
|
+
const sources = collectVideoDurationSources(doc);
|
|
473
|
+
if (sources.length === 0) return doc;
|
|
474
|
+
const durations = await probeVideoDurations(sources, options);
|
|
475
|
+
return durations.size > 0 ? applyVideoDurations(doc, (src) => durations.get(src)) : doc;
|
|
476
|
+
}
|
|
464
477
|
function useMediaClipDurations(schedule, basePath, mediaProviderOverride) {
|
|
478
|
+
const srcs = useMemo2(
|
|
479
|
+
() => schedule.filter((clip) => clip.kind === "video" && clip.src).map((clip) => clip.src),
|
|
480
|
+
[schedule]
|
|
481
|
+
);
|
|
482
|
+
return useVideoDurations(srcs, basePath, mediaProviderOverride);
|
|
483
|
+
}
|
|
484
|
+
function useVideoDurations(srcs, basePath, mediaProviderOverride) {
|
|
465
485
|
const contextProvider = useMediaProvider();
|
|
466
486
|
const provider = mediaProviderOverride !== void 0 ? mediaProviderOverride : contextProvider;
|
|
467
487
|
const resourcePolicy = useResourcePolicy();
|
|
468
|
-
const srcKey = useMemo2(
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}
|
|
473
|
-
return Array.from(set).sort().join("\n");
|
|
474
|
-
}, [schedule]);
|
|
488
|
+
const srcKey = useMemo2(
|
|
489
|
+
() => Array.from(new Set(srcs.filter((src) => src.length > 0))).sort().join("\n"),
|
|
490
|
+
[srcs]
|
|
491
|
+
);
|
|
475
492
|
const [durations, setDurations] = useState2(() => /* @__PURE__ */ new Map());
|
|
476
493
|
useEffect3(() => {
|
|
477
|
-
const
|
|
478
|
-
if (
|
|
494
|
+
const srcs2 = srcKey ? srcKey.split("\n") : [];
|
|
495
|
+
if (srcs2.length === 0) {
|
|
479
496
|
setDurations((prev) => prev.size === 0 ? prev : /* @__PURE__ */ new Map());
|
|
480
497
|
return;
|
|
481
498
|
}
|
|
@@ -484,22 +501,16 @@ function useMediaClipDurations(schedule, basePath, mediaProviderOverride) {
|
|
|
484
501
|
const commit = () => {
|
|
485
502
|
if (!cancelled) setDurations(new Map(resolved));
|
|
486
503
|
};
|
|
487
|
-
for (const src of
|
|
488
|
-
resolveMediaUrl(src, provider, basePath, resourcePolicy).then((url) =>
|
|
489
|
-
|
|
490
|
-
const cached = durationCache.get(url);
|
|
491
|
-
if (cached != null) {
|
|
492
|
-
resolved.set(src, cached);
|
|
493
|
-
commit();
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
probeVideoDuration(url).then((seconds) => {
|
|
504
|
+
for (const src of srcs2) {
|
|
505
|
+
resolveMediaUrl(src, provider, basePath, resourcePolicy).then((url) => cancelled || !url ? null : probeCachedVideoDuration(url)).then(
|
|
506
|
+
(seconds) => {
|
|
497
507
|
if (cancelled || seconds == null) return;
|
|
498
|
-
durationCache.set(url, seconds);
|
|
499
508
|
resolved.set(src, seconds);
|
|
500
509
|
commit();
|
|
501
|
-
}
|
|
502
|
-
|
|
510
|
+
},
|
|
511
|
+
() => {
|
|
512
|
+
}
|
|
513
|
+
);
|
|
503
514
|
}
|
|
504
515
|
return () => {
|
|
505
516
|
cancelled = true;
|
|
@@ -1378,7 +1389,10 @@ function DocControlsOverlay({
|
|
|
1378
1389
|
background: "linear-gradient(transparent, rgba(0,0,0,0.8))",
|
|
1379
1390
|
display: "flex",
|
|
1380
1391
|
alignItems: "center",
|
|
1381
|
-
|
|
1392
|
+
// In a phone-width player the timeline wraps to its own row rather
|
|
1393
|
+
// than being squeezed to a dot between the time and the counter.
|
|
1394
|
+
flexWrap: "wrap",
|
|
1395
|
+
gap: "4px 8px",
|
|
1382
1396
|
zIndex: 100
|
|
1383
1397
|
},
|
|
1384
1398
|
children: [
|
|
@@ -1430,7 +1444,7 @@ function DocControlsOverlay({
|
|
|
1430
1444
|
" / ",
|
|
1431
1445
|
formatTime(state.totalDuration)
|
|
1432
1446
|
] }),
|
|
1433
|
-
/* @__PURE__ */ jsx6(
|
|
1447
|
+
/* @__PURE__ */ jsx6("div", { style: { flex: "1 1 120px", minWidth: 0, display: "flex" }, children: /* @__PURE__ */ jsx6(
|
|
1434
1448
|
DocProgressBar,
|
|
1435
1449
|
{
|
|
1436
1450
|
state,
|
|
@@ -1439,7 +1453,7 @@ function DocControlsOverlay({
|
|
|
1439
1453
|
expandedBlocks,
|
|
1440
1454
|
getBlockTitle
|
|
1441
1455
|
}
|
|
1442
|
-
),
|
|
1456
|
+
) }),
|
|
1443
1457
|
/* @__PURE__ */ jsxs3("span", { style: { color: "rgba(255,255,255,0.5)", fontSize: "11px", whiteSpace: "nowrap" }, children: [
|
|
1444
1458
|
state.currentBlockIndex + 1,
|
|
1445
1459
|
"/",
|
|
@@ -3529,11 +3543,9 @@ function DocPlayerContent({
|
|
|
3529
3543
|
const videos = activeBlockEl.querySelectorAll("video[data-clip-start]");
|
|
3530
3544
|
videos.forEach((el) => {
|
|
3531
3545
|
const video = el;
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
const targetTime = Math.min(clipStart + Math.max(0, blockElapsed - startAt), clipEnd);
|
|
3536
|
-
videoSeekPromises.push(selectVideoFrame(video, targetTime));
|
|
3546
|
+
videoSeekPromises.push(
|
|
3547
|
+
selectVideoFrame(video, blockVideoSourceTime(video, blockElapsed))
|
|
3548
|
+
);
|
|
3537
3549
|
});
|
|
3538
3550
|
}
|
|
3539
3551
|
root.querySelectorAll("video[data-clip-id]").forEach((el) => {
|
|
@@ -4116,7 +4128,7 @@ function DocPlayerContent({
|
|
|
4116
4128
|
}
|
|
4117
4129
|
);
|
|
4118
4130
|
}
|
|
4119
|
-
return /* @__PURE__ */ jsxs7(
|
|
4131
|
+
return /* @__PURE__ */ jsx10(ProcessedAudioContext.Provider, { value: processedAudio, children: /* @__PURE__ */ jsxs7(
|
|
4120
4132
|
"div",
|
|
4121
4133
|
{
|
|
4122
4134
|
ref: containerRef,
|
|
@@ -4471,7 +4483,7 @@ function DocPlayerContent({
|
|
|
4471
4483
|
!isSlideshowMode && tapFeedback && /* @__PURE__ */ jsx10("div", { className: "doc-player__tap-feedback", children: /* @__PURE__ */ jsx10("svg", { viewBox: "0 0 24 24", fill: "white", width: "48", height: "48", children: tapFeedback === "pause" ? /* @__PURE__ */ jsx10("path", { d: "M6 19h4V5H6v14zm8-14v14h4V5h-4z" }) : /* @__PURE__ */ jsx10("path", { d: "M8 5v14l11-7z" }) }) }, tapFeedback)
|
|
4472
4484
|
]
|
|
4473
4485
|
}
|
|
4474
|
-
);
|
|
4486
|
+
) });
|
|
4475
4487
|
}
|
|
4476
4488
|
|
|
4477
4489
|
// src/DocControlsBottom.tsx
|
|
@@ -4700,7 +4712,10 @@ function DocPlayerWithSidebar({
|
|
|
4700
4712
|
export {
|
|
4701
4713
|
useBuildNavigation,
|
|
4702
4714
|
MediaClipLayer,
|
|
4715
|
+
probeVideoDurations,
|
|
4716
|
+
resolveVideoDurations,
|
|
4703
4717
|
useMediaClipDurations,
|
|
4718
|
+
useVideoDurations,
|
|
4704
4719
|
SocialCaptionOverlay,
|
|
4705
4720
|
CaptionOverlay,
|
|
4706
4721
|
formatTime,
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
InlineVideoPlayer,
|
|
6
6
|
MarkdownRenderer,
|
|
7
7
|
VideoEmbedFrame
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CFJRBRRG.js";
|
|
9
9
|
import {
|
|
10
10
|
BlockRenderer
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-3UITZDNL.js";
|
|
12
12
|
import {
|
|
13
13
|
svgDataImageSrc,
|
|
14
14
|
useMediaUrl
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ZKMBIWAA.js";
|
|
16
16
|
|
|
17
17
|
// src/page/PageViewContext.ts
|
|
18
18
|
import { createContext, useContext } from "react";
|
|
@@ -184,6 +184,7 @@ function StatBandSection({ section }) {
|
|
|
184
184
|
);
|
|
185
185
|
const maxValue = Math.max(1, ...numericValues.filter((value) => Number.isFinite(value)));
|
|
186
186
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
187
|
+
section.slots.title && /* @__PURE__ */ jsx2("h2", { className: "squisq-page-section-title squisq-page-stats-title", children: section.slots.title }),
|
|
187
188
|
/* @__PURE__ */ jsx2("div", { className: "squisq-page-stats", children: items.map((item, i) => /* @__PURE__ */ jsxs("div", { className: `squisq-page-stat${comparison ? " squisq-page-stat--bars" : ""}`, children: [
|
|
188
189
|
/* @__PURE__ */ jsx2("span", { className: "squisq-page-stat-value", children: item.value }),
|
|
189
190
|
comparison && Number.isFinite(numericValues[i]) && /* @__PURE__ */ jsx2(
|
|
@@ -67,6 +67,7 @@ import {
|
|
|
67
67
|
isSvgImageSource
|
|
68
68
|
} from "@bendyline/squisq/markdown";
|
|
69
69
|
var MediaContext = createContext(null);
|
|
70
|
+
var ProcessedAudioContext = createContext(void 0);
|
|
70
71
|
var ResourcePolicyContext = createContext(
|
|
71
72
|
DEFAULT_INTERACTIVE_RESOURCE_POLICY
|
|
72
73
|
);
|
|
@@ -122,7 +123,7 @@ function useMediaUrl(relativePath, basePath, options = {}) {
|
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
// src/mermaid/mermaidRuntime.ts
|
|
125
|
-
import { buildMermaidThemeVariables } from "@bendyline/squisq/schemas";
|
|
126
|
+
import { buildMermaidThemeCss, buildMermaidThemeVariables } from "@bendyline/squisq/schemas";
|
|
126
127
|
import { DEFAULT_THEME } from "@bendyline/squisq/doc";
|
|
127
128
|
var mermaidPromise = null;
|
|
128
129
|
var MERMAID_BASE_CONFIG = {
|
|
@@ -176,7 +177,8 @@ function renderMermaidSvg(id, source, container, theme = DEFAULT_THEME) {
|
|
|
176
177
|
mermaid.initialize({
|
|
177
178
|
...MERMAID_BASE_CONFIG,
|
|
178
179
|
theme: "base",
|
|
179
|
-
themeVariables: buildMermaidThemeVariables(theme)
|
|
180
|
+
themeVariables: buildMermaidThemeVariables(theme),
|
|
181
|
+
themeCSS: buildMermaidThemeCss(theme)
|
|
180
182
|
});
|
|
181
183
|
const { svg, diagramType } = await withMermaidLabelWrapping(
|
|
182
184
|
() => mermaid.render(id, source, container)
|
|
@@ -192,6 +194,7 @@ function renderMermaidSvgForExport(id, source, theme = DEFAULT_THEME, fontFamily
|
|
|
192
194
|
...MERMAID_BASE_CONFIG,
|
|
193
195
|
theme: "base",
|
|
194
196
|
themeVariables: fontFamily ? { ...themeVariables, fontFamily } : themeVariables,
|
|
197
|
+
themeCSS: buildMermaidThemeCss(theme),
|
|
195
198
|
htmlLabels: false,
|
|
196
199
|
journey: { textPlacement: "tspan" }
|
|
197
200
|
});
|
|
@@ -210,6 +213,7 @@ export {
|
|
|
210
213
|
svgDataImageSrc,
|
|
211
214
|
useSanitizedSvgImage,
|
|
212
215
|
MediaContext,
|
|
216
|
+
ProcessedAudioContext,
|
|
213
217
|
ResourcePolicyContext,
|
|
214
218
|
useResourcePolicy,
|
|
215
219
|
useMediaProvider,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BlockRenderer
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-3UITZDNL.js";
|
|
4
|
+
import "../chunk-DRPMS5JK.js";
|
|
5
|
+
import "../chunk-FXAKS6KU.js";
|
|
6
6
|
import {
|
|
7
7
|
renderMermaidSvgForExport
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-ZKMBIWAA.js";
|
|
9
9
|
|
|
10
10
|
// src/export/diagramPictures.ts
|
|
11
11
|
import { createElement } from "react";
|
|
@@ -89,9 +89,6 @@ async function renderMermaidPicture(source, options = {}) {
|
|
|
89
89
|
if (!svg) throw new Error("Mermaid produced no SVG.");
|
|
90
90
|
const box = parseViewBox(svg);
|
|
91
91
|
if (!box) throw new Error("The Mermaid SVG has no size.");
|
|
92
|
-
const style = document.createElementNS(SVG_NS, "style");
|
|
93
|
-
style.textContent = `.edgeLabel text, .edgeLabel tspan { fill: ${theme.colors.text} !important; }`;
|
|
94
|
-
svg.append(style);
|
|
95
92
|
const width = Math.min(maxWidth, box.width);
|
|
96
93
|
return svgToPng(svg, width, box.height * width / box.width, options);
|
|
97
94
|
}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,228 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import { ResourcePolicy } from '@bendyline/squisq/markdown';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* useAudioSync Hook
|
|
11
|
-
*
|
|
12
|
-
* Synchronizes playback state with an audio element. Provides current
|
|
13
|
-
* playback time, playing state, and methods to control audio playback.
|
|
14
|
-
*
|
|
15
|
-
* Handles multiple audio segments (MP3 files) by tracking which segment
|
|
16
|
-
* is currently playing and calculating the overall timeline position.
|
|
17
|
-
*
|
|
18
|
-
* This is the HTML5 Audio implementation of the AudioController interface.
|
|
19
|
-
* Hosts that drive audio through an external player (e.g. a native shell)
|
|
20
|
-
* can supply their own AudioController to DocPlayer instead of this hook.
|
|
21
|
-
*
|
|
22
|
-
* In `synthetic` mode there is no audio element to follow, so a caller that
|
|
23
|
-
* has no segments passes `syntheticDuration` — the document's own timeline
|
|
24
|
-
* length — and the same segment machinery drives a timer instead.
|
|
25
|
-
*
|
|
26
|
-
* Each segment is downloaded whole and attached as a blob URL, so a segment is
|
|
27
|
-
* only playable once its download finishes. A `play()` that arrives earlier (a
|
|
28
|
-
* listener pressing Play right away, or right after seeking into another
|
|
29
|
-
* segment) is recorded as intent and started by the load path on `canplay`.
|
|
30
|
-
* Playing the element immediately would either start an element with no
|
|
31
|
-
* source, whose pending play the attaching `load()` aborts, or start the
|
|
32
|
-
* previous segment. An `AbortError` from `play()` therefore means "superseded",
|
|
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
|
|
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.
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
type AudioSyncMode = 'media' | 'synthetic';
|
|
46
|
-
declare function useAudioSync(audioRef: RefObject<HTMLAudioElement>, track: AudioTrack | undefined, basePath?: string, enabled?: boolean, mode?: AudioSyncMode, syntheticDuration?: number): AudioController;
|
|
47
|
-
|
|
48
|
-
interface ModalDialogOptions {
|
|
49
|
-
/** The backdrop/portal root. Siblings of this branch are made inert. */
|
|
50
|
-
rootRef: RefObject<HTMLElement | null>;
|
|
51
|
-
/** The element with `role="dialog"`; focus is trapped within it. */
|
|
52
|
-
dialogRef: RefObject<HTMLElement | null>;
|
|
53
|
-
initialFocusRef?: RefObject<HTMLElement | null>;
|
|
54
|
-
/** Explicit opener/owner to restore after unmount (important when a child uses autofocus). */
|
|
55
|
-
returnFocusRef?: RefObject<HTMLElement | null>;
|
|
56
|
-
/** Whether Escape requests that the dialog close. Defaults to true. */
|
|
57
|
-
closeOnEscape?: boolean;
|
|
58
|
-
onClose: () => void;
|
|
59
|
-
}
|
|
60
|
-
/** Shared focus, keyboard, background-isolation, and restoration behavior for modal dialogs. */
|
|
61
|
-
declare function useModalDialog({ rootRef, dialogRef, initialFocusRef, returnFocusRef, closeOnEscape, onClose, }: ModalDialogOptions): void;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* useMediaSchedule
|
|
65
|
-
*
|
|
66
|
-
* Pure follower of the playback clock for the media-clip model. Given the
|
|
67
|
-
* resolved {@link ScheduledClip}s and the current time, it returns the clips
|
|
68
|
-
* the player should mount and which of them are active right now.
|
|
69
|
-
* {@link MediaClipLayer} consumes this to drive one hidden `<audio>` /
|
|
70
|
-
* full-bleed `<video>` element per clip. (Annotation-authored clips all render
|
|
71
|
-
* at the player level; template-produced `VideoLayer`s are a separate path and
|
|
72
|
-
* are not part of the schedule.)
|
|
73
|
-
*
|
|
74
|
-
* It owns no clock: `currentTime`/`isPlaying` come from the existing
|
|
75
|
-
* `useAudioSync` provider via `DocPlayer`. With an empty schedule it returns
|
|
76
|
-
* empty lists, so documents without the new media model are unaffected.
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
interface MediaScheduleController {
|
|
80
|
-
/** Clips the player mounts (every scheduled clip). */
|
|
81
|
-
renderClips: ScheduledClip[];
|
|
82
|
-
/** Ids of clips whose [absoluteStart, absoluteEnd) contains currentTime. */
|
|
83
|
-
activeIds: Set<string>;
|
|
84
|
-
}
|
|
85
|
-
declare function useMediaSchedule(schedule: ScheduledClip[], currentTime: number): MediaScheduleController;
|
|
86
|
-
|
|
87
|
-
interface PlaybackState {
|
|
88
|
-
/** Currently visible block */
|
|
89
|
-
currentBlock: Block | null;
|
|
90
|
-
/** Index of current block */
|
|
91
|
-
currentBlockIndex: number;
|
|
92
|
-
/** Previous block (for transitions) */
|
|
93
|
-
previousBlock: Block | null;
|
|
94
|
-
/** Whether current block is entering */
|
|
95
|
-
isEntering: boolean;
|
|
96
|
-
/** Whether previous block is exiting */
|
|
97
|
-
isExiting: boolean;
|
|
98
|
-
/** Time relative to current block start */
|
|
99
|
-
blockTime: number;
|
|
100
|
-
/** Progress through current block (0-1) */
|
|
101
|
-
blockProgress: number;
|
|
102
|
-
/** Overall progress through doc (0-1) */
|
|
103
|
-
docProgress: number;
|
|
104
|
-
/** Expanded blocks (templates converted to full blocks with layers) */
|
|
105
|
-
blocks: Block[];
|
|
106
|
-
}
|
|
107
|
-
interface PlaybackActions {
|
|
108
|
-
/** Go to next block */
|
|
109
|
-
nextBlock: () => void;
|
|
110
|
-
/** Go to previous block */
|
|
111
|
-
prevBlock: () => void;
|
|
112
|
-
/** Go to specific block by index */
|
|
113
|
-
goToBlock: (index: number) => void;
|
|
114
|
-
/**
|
|
115
|
-
* Let the identified block enter without remounting the outgoing block.
|
|
116
|
-
* Used when another interaction (such as a swipe) already removed it.
|
|
117
|
-
*/
|
|
118
|
-
suppressOutgoingForNextBlock: (blockId: string) => void;
|
|
119
|
-
}
|
|
120
|
-
interface UseDocPlaybackOptions {
|
|
121
|
-
/** Fallback media root for intrinsic feature metadata. */
|
|
122
|
-
basePath?: string;
|
|
123
|
-
/** Target viewport used to materialize template blocks. */
|
|
124
|
-
viewport?: ViewportConfig;
|
|
125
|
-
/** Active theme used for materialization and transition defaults. */
|
|
126
|
-
theme?: Theme;
|
|
127
|
-
/** Host seek callback used by block navigation actions. */
|
|
128
|
-
onSeek?: (time: number) => void;
|
|
129
|
-
/**
|
|
130
|
-
* Whether real audio-segment timing should reshape the authored block
|
|
131
|
-
* sequence. Synthetic preview tracks are only a playback clock; treating
|
|
132
|
-
* them as narration can merge short authored slides to satisfy narration
|
|
133
|
-
* pacing rules.
|
|
134
|
-
*/
|
|
135
|
-
useAudioSegmentTiming?: boolean;
|
|
136
|
-
/**
|
|
137
|
-
* Derive the outgoing (exiting) block from block order instead of from the
|
|
138
|
-
* block rendered last. Offline capture seeks frames out of order (resume,
|
|
139
|
-
* dedupe, sampling), so the crossfade partner must be a pure function of
|
|
140
|
-
* time. Live playback keeps the render-history path so swipes and manual
|
|
141
|
-
* jumps crossfade from what the viewer actually saw.
|
|
142
|
-
*/
|
|
143
|
-
deterministicTransitions?: boolean;
|
|
144
|
-
/**
|
|
145
|
-
* Motion profile override. Omitted → the doc's own `motion` / frontmatter
|
|
146
|
-
* `squisq-motion`, then the theme's `renderStyle.motionProfile`, then `calm`.
|
|
147
|
-
*/
|
|
148
|
-
motion?: MotionSpec | null;
|
|
149
|
-
}
|
|
150
|
-
declare function useDocPlayback(script: Doc | null, currentTime: number, options?: UseDocPlaybackOptions): PlaybackState & PlaybackActions;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* useViewportOrientation Hook
|
|
154
|
-
*
|
|
155
|
-
* Detects the current viewport orientation and returns the appropriate
|
|
156
|
-
* VIEWPORT_PRESET for rendering docs. Automatically updates when
|
|
157
|
-
* the window is resized.
|
|
158
|
-
*
|
|
159
|
-
* Thresholds:
|
|
160
|
-
* - Portrait: height > width * 1.2 (significantly taller than wide)
|
|
161
|
-
* - Square: width and height within 20% of each other
|
|
162
|
-
* - Landscape: width > height * 1.2 (significantly wider than tall)
|
|
163
|
-
*/
|
|
164
|
-
|
|
165
|
-
interface UseViewportOrientationResult {
|
|
166
|
-
/** Current viewport preset configuration */
|
|
167
|
-
viewport: ViewportConfig;
|
|
168
|
-
/** Current orientation name */
|
|
169
|
-
orientation: ViewportOrientation;
|
|
170
|
-
/** Current window dimensions */
|
|
171
|
-
windowSize: {
|
|
172
|
-
width: number;
|
|
173
|
-
height: number;
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Hook to detect viewport orientation and return appropriate preset.
|
|
178
|
-
* Updates automatically when window is resized.
|
|
179
|
-
*/
|
|
180
|
-
declare function useViewportOrientation(): UseViewportOrientationResult;
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* React context holding the current MediaProvider (or null if none provided).
|
|
184
|
-
*/
|
|
185
|
-
declare const MediaContext: react.Context<MediaProvider | null>;
|
|
186
|
-
/**
|
|
187
|
-
* Policy for document-controlled media URLs. Hosts rendering untrusted
|
|
188
|
-
* documents can provide `LOCAL_ONLY_RESOURCE_POLICY` or an explicit host
|
|
189
|
-
* allow-list without changing their MediaProvider.
|
|
190
|
-
*/
|
|
191
|
-
declare const ResourcePolicyContext: react.Context<ResourcePolicy>;
|
|
192
|
-
declare function useResourcePolicy(): ResourcePolicy;
|
|
193
|
-
/**
|
|
194
|
-
* Hook to access the current MediaProvider from context.
|
|
195
|
-
* Returns null if no provider is set.
|
|
196
|
-
*/
|
|
197
|
-
declare function useMediaProvider(): MediaProvider | null;
|
|
198
|
-
interface UseMediaUrlOptions {
|
|
199
|
-
/** For an SVG image: draw a still (no SMIL/CSS animation), for capture. */
|
|
200
|
-
staticSvg?: boolean;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Hook to resolve a media URL via the MediaProvider (if available).
|
|
204
|
-
* Only provider-less paths use basePath-based resolution; a failed workspace
|
|
205
|
-
* lookup stays unresolved instead of requesting the same path from the page origin.
|
|
206
|
-
*
|
|
207
|
-
* Returns the resolved URL string. Updates when the provider or path changes.
|
|
208
|
-
*
|
|
209
|
-
* An SVG image (`logo.svg`, or an SVG `data:` URL) resolves to core's
|
|
210
|
-
* sanitized re-serialization of it — never the file as written — exactly as
|
|
211
|
-
* an SVG island is shown; see `sanitizedSvgImageUrl`.
|
|
212
|
-
*
|
|
213
|
-
* @param relativePath - Relative media path from the document (e.g., 'hero.jpg')
|
|
214
|
-
* @param basePath - Fallback base path for URL construction
|
|
215
|
-
*/
|
|
216
|
-
declare function useMediaUrl(relativePath: string, basePath: string, options?: UseMediaUrlOptions): string;
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Live-track `prefers-color-scheme` and return a stable SurfaceScheme.
|
|
220
|
-
* `enabled: false` short-circuits to LIGHT_SURFACE (callers pass `false`
|
|
221
|
-
* when a static surface was provided so the hook never observes the
|
|
222
|
-
* media query). The `MediaQueryList` and the `subscribe`/`getSnapshot`
|
|
223
|
-
* callbacks are memoized so `useSyncExternalStore` doesn't resubscribe on
|
|
224
|
-
* every parent render.
|
|
225
|
-
*/
|
|
226
|
-
declare function useAutoSurface(enabled: boolean): SurfaceScheme;
|
|
227
|
-
|
|
228
|
-
export { AudioController, MediaContext, type MediaScheduleController, type ModalDialogOptions, ResourcePolicyContext, type UseDocPlaybackOptions, useAudioSync, useAutoSurface, useDocPlayback, useMediaProvider, useMediaSchedule, useMediaUrl, useModalDialog, useResourcePolicy, useViewportOrientation };
|
|
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, h as useModalDialog, i as useResourcePolicy, j as useViewportOrientation } from '../hooks-Dxpfol0l.js';
|
|
2
|
+
export { A as AudioActions, a as AudioController, b as AudioState } from '../AudioController-DAwQyEM_.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '@bendyline/squisq/schemas';
|
|
5
|
+
import '@bendyline/squisq/doc';
|
|
6
|
+
import '@bendyline/squisq/markdown';
|
package/dist/hooks/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useDocPlayback,
|
|
7
7
|
useMediaSchedule,
|
|
8
8
|
useViewportOrientation
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-MNY6M5QG.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-
|
|
19
|
+
} from "../chunk-ZKMBIWAA.js";
|
|
20
20
|
export {
|
|
21
21
|
MediaContext,
|
|
22
22
|
ResourcePolicyContext,
|