@8btc/ppt-generator-mcp 0.0.3 → 0.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.
@@ -2,7 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generatePPTSlides = void 0;
4
4
  const crypto_1 = require("crypto");
5
- const canvas_1 = require("@napi-rs/canvas");
5
+ class CanvasBrowser {
6
+ constructor(width, height) {
7
+ this.el = document.createElement("canvas");
8
+ this.el.width = width;
9
+ this.el.height = height;
10
+ }
11
+ getContext(ctx) {
12
+ return this.el.getContext(ctx);
13
+ }
14
+ }
15
+ let CanvasImpl = CanvasBrowser;
6
16
  // Node.js环境DOM支持
7
17
  if (typeof window === "undefined") {
8
18
  const { JSDOM } = require("jsdom");
@@ -10,6 +20,8 @@ if (typeof window === "undefined") {
10
20
  global.DOMParser = dom.window.DOMParser;
11
21
  global.document = dom.window.document;
12
22
  global.NodeFilter = dom.window.NodeFilter;
23
+ const { Canvas } = require("@napi-rs/canvas");
24
+ CanvasImpl = Canvas;
13
25
  }
14
26
  // 生成随机ID的函数
15
27
  const nanoid = (length = 10) => {
@@ -435,7 +447,7 @@ const generateEnd = (outlineItem, imgs, endTemplates) => {
435
447
  };
436
448
  };
437
449
  const getAdaptedFontsize = ({ text, fontSize, fontFamily, width, height, lineHeight, maxLine, }) => {
438
- const canvas = new canvas_1.Canvas(width, height);
450
+ const canvas = new CanvasImpl(width, height);
439
451
  const context = canvas.getContext("2d");
440
452
  let newFontSize = fontSize;
441
453
  const minFontSize = 10;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@8btc/ppt-generator-mcp",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "MCP service for generating PPT files from AI-generated outlines and templates",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {