mulmocast-vision 1.0.6 → 1.0.8

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.
@@ -1,3 +1,4 @@
1
+ import nunjucks from "nunjucks";
1
2
  import { type PluginOptionParams, type ToolArgs, type CreatePageOptions } from "./type";
2
3
  export declare class htmlPlugin {
3
4
  protected outputDir: string;
@@ -6,6 +7,7 @@ export declare class htmlPlugin {
6
7
  protected templateDir: string;
7
8
  protected sessionDir: string;
8
9
  protected templateOptions: CreatePageOptions;
10
+ protected nunjucksEnv: nunjucks.Environment;
9
11
  constructor({ outputDir, rootDir, templateOptions, htmlDir, // relative path
10
12
  templateDir, }: {
11
13
  outputDir?: string;
package/lib/html_class.js CHANGED
@@ -38,6 +38,12 @@ class htmlPlugin {
38
38
  const html = this.getHtml(functionName, args);
39
39
  const outfile = imageFilePath ?? path_1.default.resolve(this.outputDir, this.sessionDir, `${outputFileName}.png`);
40
40
  const htmlFile = htmlFilePath ?? path_1.default.resolve(this.outputDir, this.sessionDir, `${outputFileName}.html`);
41
+ // Ensure the output directory exists
42
+ const outputDir = path_1.default.dirname(outfile);
43
+ if (!fs_1.default.existsSync(outputDir)) {
44
+ logger.info("Creating output directory", { outputDir });
45
+ (0, utils_1.mkdir)(outputDir);
46
+ }
41
47
  await (0, utils_1.createPage)(this.rootDir, outfile, html, { htmlFile, ...this.templateOptions });
42
48
  logger.fileWrite(outfile);
43
49
  logger.fileWrite(htmlFile);
@@ -77,10 +83,12 @@ class htmlPlugin {
77
83
  logger.fileRead(templateFilePath);
78
84
  logger.debug("Rendering template", { templateFileName, args });
79
85
  try {
80
- return nunjucks_1.default.render(templateFilePath, args);
86
+ // Use the configured Nunjucks environment instead of the default
87
+ // This ensures the FileSystemLoader can find the template
88
+ return this.nunjucksEnv.render(`${templateFileName}.html`, args);
81
89
  }
82
90
  catch (error) {
83
- logger.error("Template rendering failed", error, { templateFilePath, args });
91
+ logger.error("Template rendering failed", error, { templateFilePath, templateFileName, args });
84
92
  throw error;
85
93
  }
86
94
  };
@@ -166,6 +174,15 @@ class htmlPlugin {
166
174
  this.htmlDir = htmlDir ?? "html2";
167
175
  this.templateDir = templateDir ?? "";
168
176
  this.templateOptions = templateOptions ?? {};
177
+ // Configure Nunjucks environment with FileSystemLoader
178
+ const templatePath = this.templateDir ? this.templateDir : path_1.default.resolve(this.rootDir, "html", this.htmlDir);
179
+ const loader = new nunjucks_1.default.FileSystemLoader(templatePath, {
180
+ noCache: true, // Disable cache to ensure fresh templates
181
+ });
182
+ this.nunjucksEnv = new nunjucks_1.default.Environment(loader, {
183
+ autoescape: false, // Don't escape HTML
184
+ throwOnUndefined: false, // Don't throw on undefined variables
185
+ });
169
186
  }
170
187
  }
171
188
  exports.htmlPlugin = htmlPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast-vision",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Easy and stylish presentation slide generator",
5
5
  "mcpName": "io.github.isamu/mulmocast-vision",
6
6
  "main": "lib/index.js",
@@ -33,7 +33,7 @@
33
33
  "homepage": "https://github.com/receptron/mulmocast-vision",
34
34
  "license": "AGPL-3.0-or-later",
35
35
  "dependencies": {
36
- "@modelcontextprotocol/sdk": "^1.24.2",
36
+ "@modelcontextprotocol/sdk": "^1.24.3",
37
37
  "nunjucks": "^3.2.4",
38
38
  "pdfkit": "^0.17.2",
39
39
  "puppeteer": "^24.32.0"