mulmocast-vision 1.0.2 → 1.0.4
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/lib/html_class.d.ts +1 -0
- package/lib/html_class.js +13 -4
- package/package.json +2 -3
package/lib/html_class.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare class htmlPlugin {
|
|
|
16
16
|
});
|
|
17
17
|
callNamedFunction: (functionName: string, args: ToolArgs, options: PluginOptionParams) => Promise<any>;
|
|
18
18
|
private generateHtml;
|
|
19
|
+
getHtml: (functionName: string, args: ToolArgs) => string;
|
|
19
20
|
setDirectory: (args: ToolArgs, __options: PluginOptionParams) => Promise<{
|
|
20
21
|
text: string;
|
|
21
22
|
}>;
|
package/lib/html_class.js
CHANGED
|
@@ -16,6 +16,7 @@ class htmlPlugin {
|
|
|
16
16
|
htmlDir, // relative path
|
|
17
17
|
templateDir, // absolute path
|
|
18
18
|
}) {
|
|
19
|
+
// api for mcp
|
|
19
20
|
this.callNamedFunction = async (functionName, args, options) => {
|
|
20
21
|
const member = this[functionName];
|
|
21
22
|
if (member && typeof member === "function") {
|
|
@@ -28,20 +29,28 @@ class htmlPlugin {
|
|
|
28
29
|
if (!functionName) {
|
|
29
30
|
throw new Error("functionName is required");
|
|
30
31
|
}
|
|
31
|
-
const
|
|
32
|
-
const templateFilePath = path_1.default.resolve(this.templateDir ? this.templateDir : path_1.default.resolve(this.rootDir, "html", this.htmlDir), `${templateFileName}.html`);
|
|
32
|
+
const html = this.getHtml(functionName, args);
|
|
33
33
|
const outfile = imageFilePath ?? path_1.default.resolve(this.outputDir, this.sessionDir, `${outputFileName}.png`);
|
|
34
34
|
const htmlFile = htmlFilePath ?? path_1.default.resolve(this.outputDir, this.sessionDir, `${outputFileName}.html`);
|
|
35
|
-
await (0, utils_1.createPage)(this.rootDir, outfile,
|
|
35
|
+
await (0, utils_1.createPage)(this.rootDir, outfile, html, { htmlFile, ...this.templateOptions });
|
|
36
36
|
return {
|
|
37
37
|
text: `html generated successfully to: ${outfile}`,
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
+
// for electron
|
|
41
|
+
this.getHtml = (functionName, args) => {
|
|
42
|
+
const templateFileName = (0, commons_1.functionNameToTemplateName)(functionName);
|
|
43
|
+
const templateFilePath = path_1.default.resolve(this.templateDir ? this.templateDir : path_1.default.resolve(this.rootDir, "html", this.htmlDir), `${templateFileName}.html`);
|
|
44
|
+
if (!fs_1.default.existsSync(templateFilePath)) {
|
|
45
|
+
throw new Error(`getHtml: file ${templateFilePath} not exists.`);
|
|
46
|
+
}
|
|
47
|
+
return nunjucks_1.default.render(templateFilePath, args);
|
|
48
|
+
};
|
|
40
49
|
// for mcp
|
|
41
50
|
this.setDirectory = async (args, __options) => {
|
|
42
51
|
this.sessionDir = args.directoryName;
|
|
43
52
|
const outputDir = path_1.default.resolve(this.outputDir, this.sessionDir);
|
|
44
|
-
console.error(outputDir);
|
|
53
|
+
// console.error(outputDir);
|
|
45
54
|
(0, utils_1.mkdir)(outputDir);
|
|
46
55
|
return {
|
|
47
56
|
text: `set directory: ${this.sessionDir}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mulmocast-vision",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Easy and stylish presentation slide generator",
|
|
5
5
|
"mcpName": "io.github.isamu/mulmocast-vision",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
"ai": "npx tsx ./old/presentation.ts",
|
|
21
21
|
"generate_all_images": "npx tsx ./tests/test.ts",
|
|
22
22
|
"design": "NODE_ENV=test npx tsx ./tests/design.ts",
|
|
23
|
-
"ci_test": "NODE_ENV=test npx tsx ./tests/test.ts"
|
|
24
|
-
"ci_test2": "NODE_ENV=test npx tsx ./tests/test2.ts"
|
|
23
|
+
"ci_test": "NODE_ENV=test npx tsx ./tests/test.ts"
|
|
25
24
|
},
|
|
26
25
|
"repository": {
|
|
27
26
|
"type": "git",
|