mulmocast 2.4.4 → 2.4.6

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.
@@ -73,7 +73,7 @@ export const imageGenAIAgent = async ({ namedInputs, params, config, }) => {
73
73
  }
74
74
  return new GoogleGenAI({ apiKey });
75
75
  })();
76
- if (model === "gemini-2.5-flash-image" || model === "gemini-3-pro-image-preview") {
76
+ if (model === "gemini-2.5-flash-image" || model === "gemini-3.1-flash-image-preview" || model === "gemini-3-pro-image-preview") {
77
77
  const contentParams = (() => {
78
78
  const contents = getGeminiContents(prompt, referenceImages);
79
79
  return {
@@ -61,6 +61,7 @@ export const provider2ImageAgent = {
61
61
  "imagen-4.0-ultra-generate-001",
62
62
  "imagen-4.0-fast-generate-001",
63
63
  "gemini-2.5-flash-image",
64
+ "gemini-3.1-flash-image-preview",
64
65
  "gemini-3-pro-image-preview",
65
66
  ],
66
67
  keyName: "GEMINI_API_KEY",
@@ -1,10 +1,21 @@
1
1
  import fs from "node:fs";
2
+ import nodePath from "node:path";
2
3
  import { MulmoBeatMethods } from "../../methods/mulmo_beat.js";
3
4
  import { getHTMLFile } from "../file.js";
4
5
  import { renderHTMLToImage, interpolate, renderHTMLToFrames } from "../html_render.js";
5
6
  import { framesToVideo } from "../ffmpeg_utils.js";
6
7
  import { parrotingImagePath } from "./utils.js";
7
8
  export const imageType = "html_tailwind";
9
+ /**
10
+ * Resolve relative paths in src attributes to file:// absolute paths.
11
+ * Paths starting with http://, https://, file://, data:, or / are left unchanged.
12
+ */
13
+ const resolveRelativeImagePaths = (html, baseDirPath) => {
14
+ return html.replace(/(\bsrc\s*=\s*)(["'])((?!https?:\/\/|file:\/\/|data:|\/)[^"']+)\2/gi, (_, prefix, quote, relativePath) => {
15
+ const absolutePath = nodePath.resolve(baseDirPath, relativePath);
16
+ return `${prefix}${quote}file://${absolutePath}${quote}`;
17
+ });
18
+ };
8
19
  const DEFAULT_ANIMATION_FPS = 30;
9
20
  /** Join html field into a single string (handles both string and string[]) */
10
21
  const joinHtml = (html) => {
@@ -28,7 +39,7 @@ const getAnimationConfig = (params) => {
28
39
  return { fps: DEFAULT_ANIMATION_FPS };
29
40
  };
30
41
  const processHtmlTailwindAnimated = async (params) => {
31
- const { beat, imagePath, canvasSize } = params;
42
+ const { beat, imagePath, canvasSize, context } = params;
32
43
  if (!beat.image || beat.image.type !== imageType)
33
44
  return;
34
45
  const animConfig = getAnimationConfig(params);
@@ -46,13 +57,14 @@ const processHtmlTailwindAnimated = async (params) => {
46
57
  const html = joinHtml(beat.image.html);
47
58
  const template = getHTMLFile("tailwind_animated");
48
59
  const script = "script" in beat.image ? beat.image.script : undefined;
49
- const htmlData = interpolate(template, {
60
+ const rawHtmlData = interpolate(template, {
50
61
  html_body: html,
51
62
  user_script: buildUserScript(script),
52
63
  totalFrames: String(totalFrames),
53
64
  fps: String(fps),
54
65
  custom_style: "",
55
66
  });
67
+ const htmlData = resolveRelativeImagePaths(rawHtmlData, context.fileDirs.mulmoFileDirPath);
56
68
  // imagePath is set to the .mp4 path by imagePluginAgent for animated beats
57
69
  const videoPath = imagePath;
58
70
  // Create frames directory next to the video file
@@ -68,16 +80,17 @@ const processHtmlTailwindAnimated = async (params) => {
68
80
  return videoPath;
69
81
  };
70
82
  const processHtmlTailwindStatic = async (params) => {
71
- const { beat, imagePath, canvasSize } = params;
83
+ const { beat, imagePath, canvasSize, context } = params;
72
84
  if (!beat.image || beat.image.type !== imageType)
73
85
  return;
74
86
  const html = joinHtml(beat.image.html);
75
87
  const template = getHTMLFile("tailwind");
76
88
  const script = "script" in beat.image ? beat.image.script : undefined;
77
- const htmlData = interpolate(template, {
89
+ const rawHtmlData = interpolate(template, {
78
90
  html_body: html,
79
91
  user_script: buildUserScript(script),
80
92
  });
93
+ const htmlData = resolveRelativeImagePaths(rawHtmlData, context.fileDirs.mulmoFileDirPath);
81
94
  await renderHTMLToImage(htmlData, imagePath, canvasSize.width, canvasSize.height);
82
95
  return imagePath;
83
96
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast",
3
- "version": "2.4.4",
3
+ "version": "2.4.6",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "lib/index.node.js",