@bendyline/squisq 2.13.14 → 2.13.16

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.
Files changed (43) hide show
  1. package/dist/{Doc-BhvotZx_.d.ts → Doc-DLfTam0R.d.ts} +82 -6
  2. package/dist/{ImageEditDoc-D8hYio6b.d.ts → ImageEditDoc-DdSHb6sj.d.ts} +1 -1
  3. package/dist/{chunk-YQQWE4HG.js → chunk-33CAD575.js} +200 -262
  4. package/dist/{chunk-L7QZORLB.js → chunk-37RLFDIT.js} +11 -4
  5. package/dist/chunk-4R3YZTPX.js +42 -0
  6. package/dist/{chunk-DBVCSVNV.js → chunk-A4ZFYGU6.js} +13 -38
  7. package/dist/{chunk-CTT4XAGO.js → chunk-BG2OYBGC.js} +2534 -737
  8. package/dist/{chunk-2SRF5III.js → chunk-BVL3F64S.js} +1 -1
  9. package/dist/chunk-C7DKMO4H.js +88 -0
  10. package/dist/{chunk-SGNWO7OF.js → chunk-MA7XUCSQ.js} +517 -30
  11. package/dist/{chunk-JSGIWW35.js → chunk-MTIR5PWF.js} +1 -1
  12. package/dist/{chunk-C4SB3NN4.js → chunk-NBDF6SQ5.js} +22 -2
  13. package/dist/chunk-TOPEP5B7.js +515 -0
  14. package/dist/{chunk-OIQ2GO2O.js → chunk-TXN23SG2.js} +1 -1
  15. package/dist/{chunk-7MS26OXD.js → chunk-UDPPWYYM.js} +6 -0
  16. package/dist/{chunk-J2G6EOEJ.js → chunk-XY5Z23C4.js} +75 -16
  17. package/dist/{chunk-5DFFVW75.js → chunk-Z73DG6IL.js} +1 -1
  18. package/dist/doc/index.d.ts +412 -26
  19. package/dist/doc/index.js +66 -11
  20. package/dist/fence/index.d.ts +1 -1
  21. package/dist/generate/index.d.ts +1 -1
  22. package/dist/imageEdit/index.d.ts +3 -3
  23. package/dist/index.d.ts +9 -9
  24. package/dist/index.js +147 -29
  25. package/dist/jsonForm/index.d.ts +1 -1
  26. package/dist/jsonForm/index.js +5 -4
  27. package/dist/markdown/index.js +3 -3
  28. package/dist/{materializePageSection-CWxou4mX.d.ts → materializePageSection-HIoRYiZu.d.ts} +121 -8
  29. package/dist/mediaEdit/index.d.ts +154 -3
  30. package/dist/mediaEdit/index.js +241 -2
  31. package/dist/narration/index.d.ts +1 -1
  32. package/dist/narration/index.js +7 -5
  33. package/dist/recommend/index.d.ts +129 -2
  34. package/dist/recommend/index.js +13 -4
  35. package/dist/schemas/index.d.ts +26 -7
  36. package/dist/schemas/index.js +14 -8
  37. package/dist/{themeLibrary-BIYE6aLw.d.ts → themeLibrary-B2K-aAOy.d.ts} +1 -1
  38. package/dist/timing/index.d.ts +66 -2
  39. package/dist/timing/index.js +12 -0
  40. package/dist/transform/index.d.ts +173 -16
  41. package/dist/transform/index.js +58 -17
  42. package/package.json +1 -1
  43. package/dist/chunk-FCB6JLWB.js +0 -125
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createMediaTimeMap
3
- } from "./chunk-JSGIWW35.js";
3
+ } from "./chunk-MTIR5PWF.js";
4
4
 
5
5
  // src/schemas/Media.ts
6
6
  function flatten(blocks, out = []) {
@@ -0,0 +1,88 @@
1
+ // src/timing/captionFiles.ts
2
+ function cuesOf(track, offset) {
3
+ const cues = (track?.phrases ?? []).map((phrase) => ({
4
+ start: Math.max(0, phrase.startTime + offset),
5
+ end: Math.max(0, phrase.endTime + offset),
6
+ text: phrase.text.replace(/\s+/gu, " ").trim()
7
+ })).filter((cue) => cue.text && Number.isFinite(cue.start) && Number.isFinite(cue.end)).sort((a, b) => a.start - b.start);
8
+ return cues.map((cue, index) => {
9
+ const next = cues[index + 1];
10
+ return next && cue.end > next.start ? { ...cue, end: next.start } : cue;
11
+ }).filter((cue) => cue.end > cue.start);
12
+ }
13
+ function timestamp(seconds, separator) {
14
+ const total = Math.max(0, Math.round(seconds * 1e3));
15
+ const pad = (value, width = 2) => String(value).padStart(width, "0");
16
+ return `${pad(Math.floor(total / 36e5))}:${pad(Math.floor(total / 6e4) % 60)}:${pad(Math.floor(total / 1e3) % 60)}${separator}${pad(total % 1e3, 3)}`;
17
+ }
18
+ function formatCaptionsSrt(track, options = {}) {
19
+ return cuesOf(track, options.offset ?? 0).map(
20
+ (cue, index) => `${index + 1}
21
+ ${timestamp(cue.start, ",")} --> ${timestamp(cue.end, ",")}
22
+ ${cue.text}
23
+ `
24
+ ).join("\n");
25
+ }
26
+ function formatCaptionsVtt(track, options = {}) {
27
+ const escape = (text) => text.replace(/&/gu, "&amp;").replace(/</gu, "&lt;").replace(/-->/gu, "--&gt;");
28
+ const cues = cuesOf(track, options.offset ?? 0).map(
29
+ (cue) => `${timestamp(cue.start, ".")} --> ${timestamp(cue.end, ".")}
30
+ ${escape(cue.text)}
31
+ `
32
+ );
33
+ return ["WEBVTT\n", ...cues].join("\n");
34
+ }
35
+ function docChapters(doc, options = {}) {
36
+ const offset = options.offset ?? 0;
37
+ const minDuration = options.minDuration ?? 10;
38
+ const blocks = Array.isArray(doc) ? doc : doc.blocks;
39
+ const chapters = [];
40
+ const visit = (list) => {
41
+ for (const block of list) {
42
+ const title = (block.title ?? "").replace(/\s+/gu, " ").trim();
43
+ const startTime = Math.max(0, (block.startTime ?? 0) + offset);
44
+ const previous = chapters[chapters.length - 1];
45
+ const opens = !previous || title !== previous.title && startTime - previous.startTime >= minDuration;
46
+ if (title && (block.duration ?? 0) > 0 && Number.isFinite(startTime) && opens)
47
+ chapters.push({ startTime, title });
48
+ if (block.children?.length) visit(block.children);
49
+ }
50
+ };
51
+ visit(blocks);
52
+ if (chapters.length) chapters[0] = { ...chapters[0], startTime: 0 };
53
+ return chapters;
54
+ }
55
+ function formatChaptersFfmetadata(chapters, duration) {
56
+ const escape = (text) => text.replace(/[=;#\\\n]/gu, (match) => `\\${match}`);
57
+ const lines = [";FFMETADATA1"];
58
+ chapters.forEach((chapter, index) => {
59
+ const end = chapters[index + 1]?.startTime ?? Math.max(duration, chapter.startTime);
60
+ lines.push(
61
+ "[CHAPTER]",
62
+ "TIMEBASE=1/1000",
63
+ `START=${Math.round(chapter.startTime * 1e3)}`,
64
+ `END=${Math.round(end * 1e3)}`,
65
+ `title=${escape(chapter.title)}`
66
+ );
67
+ });
68
+ return `${lines.join("\n")}
69
+ `;
70
+ }
71
+ function formatChaptersText(chapters) {
72
+ const long = chapters.some((chapter) => chapter.startTime >= 3600);
73
+ const stamp = (seconds) => {
74
+ const total = Math.floor(seconds);
75
+ const [h, m, s] = [Math.floor(total / 3600), Math.floor(total / 60) % 60, total % 60];
76
+ const two = (value) => String(value).padStart(2, "0");
77
+ return long ? `${h}:${two(m)}:${two(s)}` : `${m}:${two(s)}`;
78
+ };
79
+ return chapters.map((chapter) => `${stamp(chapter.startTime)} ${chapter.title}`).join("\n");
80
+ }
81
+
82
+ export {
83
+ formatCaptionsSrt,
84
+ formatCaptionsVtt,
85
+ docChapters,
86
+ formatChaptersFfmetadata,
87
+ formatChaptersText
88
+ };