@bendyline/squisq-cli 2.4.1 → 2.4.2

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 CHANGED
@@ -58,7 +58,7 @@ Notes:
58
58
 
59
59
  ### `squisq video <input> [output]`
60
60
 
61
- Render a document to MP4 or animated GIF. Playwright captures deterministic frames from a headless player page; native ffmpeg encodes H.264 + AAC for MP4 or a generated global palette for GIF. GIF has no audio track.
61
+ Render a document to MP4 or animated GIF. Playwright captures deterministic frames from a headless player page; native ffmpeg encodes H.264 + AAC for MP4 or a generated global palette for GIF. Documents with Mermaid fences automatically use the full standalone player so diagrams are captured; other documents keep the smaller light player. GIF has no audio track.
62
62
 
63
63
  ```bash
64
64
  squisq video input.md output.mp4
@@ -1,6 +1,6 @@
1
1
  THIRD-PARTY LICENSES FOR @bendyline/squisq-cli
2
2
 
3
- The inventory below covers the bundled light standalone player artifact.
3
+ The inventory below covers the bundled light and full standalone player artifacts.
4
4
 
5
5
  Generated from the actual esbuild input graph. Package-local license, copying,
6
6
  and notice files are reproduced verbatim. When an npm tarball omits its
@@ -11,7 +11,7 @@ import {
11
11
  readInput,
12
12
  renderDocToGif,
13
13
  renderDocToMp4
14
- } from "./chunk-WR2BZJ77.js";
14
+ } from "./chunk-VK6WPOSG.js";
15
15
  import {
16
16
  GIF_EXPORT_DEFAULTS,
17
17
  framesToGifNative,
package/dist/api.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  // src/api.ts
11
11
  import { readFile as readFile3 } from "fs/promises";
12
12
  import { resolveMediaSchedule } from "@bendyline/squisq/schemas";
13
- import { flattenBlocks } from "@bendyline/squisq/doc";
13
+ import { flattenBlocks as flattenBlocks2 } from "@bendyline/squisq/doc";
14
14
  import { ffmpegGifOutputArgs, generateRenderHtml } from "@bendyline/squisq-video";
15
15
  import { resolveDimensions } from "@bendyline/squisq-video";
16
16
  import {
@@ -271,6 +271,27 @@ function createMediaBudget() {
271
271
  };
272
272
  }
273
273
 
274
+ // src/util/playerBundle.ts
275
+ import { flattenBlocks } from "@bendyline/squisq/doc";
276
+ function selectStandalonePlayerVariant(doc) {
277
+ for (const block of flattenBlocks(doc.blocks)) {
278
+ if (block.layers?.some((layer) => layer.type === "mermaid")) return "full";
279
+ if (containsMermaidFence(block.contents)) return "full";
280
+ }
281
+ return "light";
282
+ }
283
+ function containsMermaidFence(value) {
284
+ if (Array.isArray(value)) return value.some(containsMermaidFence);
285
+ if (!isRecord(value)) return false;
286
+ if (value.type === "code" && typeof value.lang === "string" && value.lang.trim().toLowerCase() === "mermaid") {
287
+ return true;
288
+ }
289
+ return containsMermaidFence(value.children);
290
+ }
291
+ function isRecord(value) {
292
+ return typeof value === "object" && value !== null;
293
+ }
294
+
274
295
  // src/registry.ts
275
296
  import { randomBytes } from "crypto";
276
297
  import { readFile, rm } from "fs/promises";
@@ -667,6 +688,7 @@ function throwIfAborted(signal) {
667
688
  // src/api.ts
668
689
  import { ConversionError } from "@bendyline/squisq-formats";
669
690
  var playerBundlePromise;
691
+ var fullPlayerBundlePromise;
670
692
  function loadPlayerBundle() {
671
693
  playerBundlePromise ??= readFile3(
672
694
  new URL("../dist/squisq-player.global.js", import.meta.url),
@@ -674,6 +696,13 @@ function loadPlayerBundle() {
674
696
  );
675
697
  return playerBundlePromise;
676
698
  }
699
+ function loadFullPlayerBundle() {
700
+ fullPlayerBundlePromise ??= readFile3(
701
+ new URL("../dist/squisq-player.full.global.js", import.meta.url),
702
+ "utf8"
703
+ );
704
+ return fullPlayerBundlePromise;
705
+ }
677
706
  async function convert(source, to, options = {}) {
678
707
  return formatsConvert(source, to, {
679
708
  registry: createCliRegistry(),
@@ -726,7 +755,7 @@ async function captureDocFrames(doc, container, options) {
726
755
  }
727
756
  }
728
757
  const mediaSrcs = new Set(resolveMediaSchedule(doc).map((clip) => clip.src));
729
- for (const block of flattenBlocks(doc.blocks)) {
758
+ for (const block of flattenBlocks2(doc.blocks)) {
730
759
  for (const layer of block.layers ?? []) {
731
760
  if (layer.type === "video") mediaSrcs.add(layer.content.src);
732
761
  }
@@ -743,7 +772,7 @@ async function captureDocFrames(doc, container, options) {
743
772
  }
744
773
  onProgress?.("generating render HTML", 10);
745
774
  signal?.throwIfAborted();
746
- const playerBundle = await loadPlayerBundle();
775
+ const playerBundle = await (selectStandalonePlayerVariant(doc) === "full" ? loadFullPlayerBundle() : loadPlayerBundle());
747
776
  signal?.throwIfAborted();
748
777
  const renderHtml = generateRenderHtml(doc, {
749
778
  playerScript: playerBundle,
@@ -7,7 +7,7 @@ import {
7
7
  // src/api.ts
8
8
  import { readFile as readFile3 } from "fs/promises";
9
9
  import { resolveMediaSchedule } from "@bendyline/squisq/schemas";
10
- import { flattenBlocks } from "@bendyline/squisq/doc";
10
+ import { flattenBlocks as flattenBlocks2 } from "@bendyline/squisq/doc";
11
11
  import { ffmpegGifOutputArgs, generateRenderHtml } from "@bendyline/squisq-video";
12
12
  import { resolveDimensions } from "@bendyline/squisq-video";
13
13
  import {
@@ -268,6 +268,27 @@ function createMediaBudget() {
268
268
  };
269
269
  }
270
270
 
271
+ // src/util/playerBundle.ts
272
+ import { flattenBlocks } from "@bendyline/squisq/doc";
273
+ function selectStandalonePlayerVariant(doc) {
274
+ for (const block of flattenBlocks(doc.blocks)) {
275
+ if (block.layers?.some((layer) => layer.type === "mermaid")) return "full";
276
+ if (containsMermaidFence(block.contents)) return "full";
277
+ }
278
+ return "light";
279
+ }
280
+ function containsMermaidFence(value) {
281
+ if (Array.isArray(value)) return value.some(containsMermaidFence);
282
+ if (!isRecord(value)) return false;
283
+ if (value.type === "code" && typeof value.lang === "string" && value.lang.trim().toLowerCase() === "mermaid") {
284
+ return true;
285
+ }
286
+ return containsMermaidFence(value.children);
287
+ }
288
+ function isRecord(value) {
289
+ return typeof value === "object" && value !== null;
290
+ }
291
+
271
292
  // src/registry.ts
272
293
  import { randomBytes } from "crypto";
273
294
  import { readFile, rm } from "fs/promises";
@@ -309,7 +330,7 @@ function mp4Format() {
309
330
  const animationsEnabled = typeof mp4Opts.animationsEnabled === "boolean" ? mp4Opts.animationsEnabled : MP4_DEFAULTS.animationsEnabled;
310
331
  const outputPath = join(tmpdir(), `squisq-mp4-${randomBytes(8).toString("hex")}.mp4`);
311
332
  try {
312
- const { renderDocToMp4: renderDocToMp42 } = await import("./api-HBPJQ7MA.js");
333
+ const { renderDocToMp4: renderDocToMp42 } = await import("./api-KYHSJM5T.js");
313
334
  await renderDocToMp42(input.doc, input.container, {
314
335
  outputPath,
315
336
  fps,
@@ -350,7 +371,7 @@ function gifFormat() {
350
371
  const defaultHeight = portrait ? GIF_DEFAULTS.width : GIF_DEFAULTS.height;
351
372
  const outputPath = join(tmpdir(), `squisq-gif-${randomBytes(8).toString("hex")}.gif`);
352
373
  try {
353
- const { renderDocToGif: renderDocToGif2 } = await import("./api-HBPJQ7MA.js");
374
+ const { renderDocToGif: renderDocToGif2 } = await import("./api-KYHSJM5T.js");
354
375
  const result = await renderDocToGif2(input.doc, input.container, {
355
376
  outputPath,
356
377
  fps: typeof gifOpts.fps === "number" ? gifOpts.fps : GIF_DEFAULTS.fps,
@@ -664,6 +685,7 @@ function throwIfAborted(signal) {
664
685
  // src/api.ts
665
686
  import { ConversionError } from "@bendyline/squisq-formats";
666
687
  var playerBundlePromise;
688
+ var fullPlayerBundlePromise;
667
689
  function loadPlayerBundle() {
668
690
  playerBundlePromise ??= readFile3(
669
691
  new URL("../dist/squisq-player.global.js", import.meta.url),
@@ -671,6 +693,13 @@ function loadPlayerBundle() {
671
693
  );
672
694
  return playerBundlePromise;
673
695
  }
696
+ function loadFullPlayerBundle() {
697
+ fullPlayerBundlePromise ??= readFile3(
698
+ new URL("../dist/squisq-player.full.global.js", import.meta.url),
699
+ "utf8"
700
+ );
701
+ return fullPlayerBundlePromise;
702
+ }
674
703
  async function convert(source, to, options = {}) {
675
704
  return formatsConvert(source, to, {
676
705
  registry: createCliRegistry(),
@@ -723,7 +752,7 @@ async function captureDocFrames(doc, container, options) {
723
752
  }
724
753
  }
725
754
  const mediaSrcs = new Set(resolveMediaSchedule(doc).map((clip) => clip.src));
726
- for (const block of flattenBlocks(doc.blocks)) {
755
+ for (const block of flattenBlocks2(doc.blocks)) {
727
756
  for (const layer of block.layers ?? []) {
728
757
  if (layer.type === "video") mediaSrcs.add(layer.content.src);
729
758
  }
@@ -740,7 +769,7 @@ async function captureDocFrames(doc, container, options) {
740
769
  }
741
770
  onProgress?.("generating render HTML", 10);
742
771
  signal?.throwIfAborted();
743
- const playerBundle = await loadPlayerBundle();
772
+ const playerBundle = await (selectStandalonePlayerVariant(doc) === "full" ? loadFullPlayerBundle() : loadPlayerBundle());
744
773
  signal?.throwIfAborted();
745
774
  const renderHtml = generateRenderHtml(doc, {
746
775
  playerScript: playerBundle,
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  readInput,
8
8
  renderDocToGif,
9
9
  renderDocToMp4
10
- } from "./chunk-WR2BZJ77.js";
10
+ } from "./chunk-VK6WPOSG.js";
11
11
  import "./chunk-GGVASRPG.js";
12
12
 
13
13
  // src/index.ts