mulmocast 2.1.13 → 2.1.14

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.
@@ -15,19 +15,19 @@ const downloadFile = async (url, destPath) => {
15
15
  const buffer = await response.arrayBuffer();
16
16
  fs.writeFileSync(destPath, Buffer.from(buffer));
17
17
  };
18
- const processBgm = async (bgm, dir, zipper) => {
18
+ const processBgm = async (bgm, outDir, baseDir, zipper) => {
19
19
  if (!bgm) {
20
20
  return undefined;
21
21
  }
22
22
  if (bgm.kind === "path") {
23
23
  // Local file path
24
- const sourcePath = path.resolve(bgm.path);
24
+ const sourcePath = path.resolve(baseDir, bgm.path);
25
25
  if (!fs.existsSync(sourcePath)) {
26
26
  GraphAILogger.log(`BGM file not found: ${sourcePath}`);
27
27
  return undefined;
28
28
  }
29
29
  const fileName = path.basename(bgm.path);
30
- const destPath = path.resolve(dir, fileName);
30
+ const destPath = path.resolve(outDir, fileName);
31
31
  fs.copyFileSync(sourcePath, destPath);
32
32
  zipper.addFile(sourcePath, fileName);
33
33
  return fileName;
@@ -35,7 +35,7 @@ const processBgm = async (bgm, dir, zipper) => {
35
35
  else if (bgm.kind === "url") {
36
36
  // URL download
37
37
  const fileName = path.basename(new URL(bgm.url).pathname) || "bgm.mp3";
38
- const destPath = path.resolve(dir, fileName);
38
+ const destPath = path.resolve(outDir, fileName);
39
39
  await downloadFile(bgm.url, destPath);
40
40
  zipper.addFile(destPath);
41
41
  return fileName;
@@ -54,9 +54,10 @@ const imageSourceMappings = [
54
54
  ];
55
55
  export const mulmoViewerBundle = async (context) => {
56
56
  const isZip = true;
57
- const dir = context.fileDirs.outDirPath;
58
- mkdir(dir);
59
- const zipper = new ZipBuilder(path.resolve(dir, zipFileName));
57
+ const outDir = context.fileDirs.outDirPath;
58
+ const baseDir = context.fileDirs.baseDirPath;
59
+ mkdir(outDir);
60
+ const zipper = new ZipBuilder(path.resolve(outDir, zipFileName));
60
61
  // text
61
62
  const resultJson = [];
62
63
  context.studio.script.beats.forEach((beat, index) => {
@@ -76,12 +77,12 @@ export const mulmoViewerBundle = async (context) => {
76
77
  }
77
78
  if (fileName === "silent300.mp3") {
78
79
  // Download from GitHub URL
79
- const destPath = path.resolve(dir, fileName);
80
+ const destPath = path.resolve(outDir, fileName);
80
81
  await downloadFile(silentMp3, destPath);
81
82
  zipper.addFile(destPath, fileName);
82
83
  }
83
84
  else if (fs.existsSync(audio)) {
84
- fs.copyFileSync(audio, path.resolve(dir, fileName));
85
+ fs.copyFileSync(audio, path.resolve(outDir, fileName));
85
86
  zipper.addFile(audio, fileName);
86
87
  }
87
88
  }
@@ -95,7 +96,7 @@ export const mulmoViewerBundle = async (context) => {
95
96
  if (typeof value === "string") {
96
97
  data[source] = path.basename(value);
97
98
  if (fs.existsSync(value)) {
98
- fs.copyFileSync(value, path.resolve(dir, path.basename(value)));
99
+ fs.copyFileSync(value, path.resolve(outDir, path.basename(value)));
99
100
  zipper.addFile(value);
100
101
  }
101
102
  }
@@ -110,7 +111,7 @@ export const mulmoViewerBundle = async (context) => {
110
111
  data.videoWithAudioSource === undefined &&
111
112
  data.duration) {
112
113
  const file = `silent_${index}.mp3`;
113
- const audioFile = path.resolve(dir, file);
114
+ const audioFile = path.resolve(outDir, file);
114
115
  await createSilentAudio(audioFile, data.duration);
115
116
  zipper.addFile(audioFile);
116
117
  data.audioSources.ja = file;
@@ -126,10 +127,10 @@ export const mulmoViewerBundle = async (context) => {
126
127
  });
127
128
  });
128
129
  // BGM
129
- const bgmFileName = await processBgm(context.studio?.script.audioParams?.bgm, dir, zipper);
130
+ const bgmFileName = await processBgm(context.studio?.script.audioParams?.bgm, outDir, baseDir, zipper);
130
131
  const bundleData = { beats: resultJson, bgmSource: bgmFileName, title: context.studio.script.title };
131
- fs.writeFileSync(path.resolve(dir, viewJsonFileName), JSON.stringify(bundleData, null, 2));
132
- zipper.addFile(path.resolve(dir, viewJsonFileName));
132
+ fs.writeFileSync(path.resolve(outDir, viewJsonFileName), JSON.stringify(bundleData, null, 2));
133
+ zipper.addFile(path.resolve(outDir, viewJsonFileName));
133
134
  if (isZip) {
134
135
  await zipper.finalize();
135
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast",
3
- "version": "2.1.13",
3
+ "version": "2.1.14",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "lib/index.node.js",