@8btc/ppt-generator-mcp 0.0.5 → 0.0.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.
@@ -12,16 +12,8 @@ class CanvasBrowser {
12
12
  return this.el.getContext(ctx);
13
13
  }
14
14
  }
15
- let CanvasImpl = CanvasBrowser;
16
- // Node.js环境DOM支持
17
- if (typeof window === "undefined") {
18
- const { JSDOM } = require("jsdom");
19
- const dom = new JSDOM("<!DOCTYPE html><html><body></body></html>");
20
- global.DOMParser = dom.window.DOMParser;
21
- global.document = dom.window.document;
22
- global.NodeFilter = dom.window.NodeFilter;
23
- const { Canvas } = require("@napi-rs/canvas");
24
- CanvasImpl = Canvas;
15
+ if (!global.CanvasImpl) {
16
+ global.CanvasImpl = CanvasBrowser;
25
17
  }
26
18
  // 生成随机ID的函数
27
19
  const nanoid = (length = 10) => {
@@ -447,6 +439,7 @@ const generateEnd = (outlineItem, imgs, endTemplates) => {
447
439
  };
448
440
  };
449
441
  const getAdaptedFontsize = ({ text, fontSize, fontFamily, width, height, lineHeight, maxLine, }) => {
442
+ // @ts-ignore
450
443
  const canvas = new CanvasImpl(width, height);
451
444
  const context = canvas.getContext("2d");
452
445
  let newFontSize = fontSize;
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export {};
1
+ #!/usr/bin/env node
2
+ import "./node-only";
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  "use strict";
2
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -11,6 +12,7 @@ const node_path_1 = __importDefault(require("node:path"));
11
12
  const zod_1 = require("zod");
12
13
  const fs_extra_1 = __importDefault(require("fs-extra"));
13
14
  const package_json_1 = __importDefault(require("../package.json"));
15
+ require("./node-only");
14
16
  class PPTGeneratorMCPServer {
15
17
  constructor() {
16
18
  this.server = new mcp_js_1.McpServer({
@@ -0,0 +1,3 @@
1
+ declare const JSDOM: any;
2
+ declare const dom: any;
3
+ declare const Canvas: any;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ const { JSDOM } = require("jsdom");
3
+ const dom = new JSDOM("<!DOCTYPE html><html><body></body></html>");
4
+ global.DOMParser = dom.window.DOMParser;
5
+ global.document = dom.window.document;
6
+ global.NodeFilter = dom.window.NodeFilter;
7
+ const { Canvas } = require("@napi-rs/canvas");
8
+ global.CanvasImpl = Canvas;
@@ -7,13 +7,6 @@ interface IResult {
7
7
  slides: Slide[];
8
8
  }
9
9
  export declare class PPTGenerator {
10
- /**
11
- * 列出可用的模板
12
- */
13
- listTemplates(templateDir?: string): Promise<{
14
- templates: string[];
15
- defaultDir: string;
16
- }>;
17
10
  /**
18
11
  * 两步生成PPT - 第一步:生成result.json
19
12
  */
@@ -1,35 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.PPTGenerator = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const posix_1 = __importDefault(require("node:path/posix"));
9
4
  const export_pptx_1 = require("./export-pptx");
10
5
  const generate_ppt_slides_1 = require("./generate-ppt-slides");
11
6
  class PPTGenerator {
12
- /**
13
- * 列出可用的模板
14
- */
15
- async listTemplates(templateDir) {
16
- const defaultDir = templateDir || posix_1.default.join(__dirname, "../../data");
17
- const templates = [];
18
- try {
19
- if (await fs_extra_1.default.pathExists(defaultDir)) {
20
- const files = await fs_extra_1.default.readdir(defaultDir);
21
- const templateFiles = files.filter((file) => file.startsWith("tpl-") && file.endsWith(".json"));
22
- templates.push(...templateFiles);
23
- }
24
- }
25
- catch (error) {
26
- console.warn(`无法读取模板目录 ${defaultDir}:`, error);
27
- }
28
- return {
29
- templates,
30
- defaultDir,
31
- };
32
- }
33
7
  /**
34
8
  * 两步生成PPT - 第一步:生成result.json
35
9
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@8btc/ppt-generator-mcp",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "MCP service for generating PPT files from AI-generated outlines and templates",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {