@8btc/office-assistant-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.
Files changed (2) hide show
  1. package/dist/index.cjs +89 -22
  2. package/package.json +3 -1
package/dist/index.cjs CHANGED
@@ -11932,23 +11932,23 @@ function isCorrectDomain(domain2) {
11932
11932
  }
11933
11933
  return true;
11934
11934
  }
11935
- function splitUrl(url) {
11936
- const trailExec = /[!"&'),.:;<>?\]}]+$/.exec(url);
11935
+ function splitUrl(url2) {
11936
+ const trailExec = /[!"&'),.:;<>?\]}]+$/.exec(url2);
11937
11937
  if (!trailExec) {
11938
- return [url, void 0];
11938
+ return [url2, void 0];
11939
11939
  }
11940
- url = url.slice(0, trailExec.index);
11940
+ url2 = url2.slice(0, trailExec.index);
11941
11941
  let trail2 = trailExec[0];
11942
11942
  let closingParenIndex = trail2.indexOf(")");
11943
- const openingParens = ccount(url, "(");
11944
- let closingParens = ccount(url, ")");
11943
+ const openingParens = ccount(url2, "(");
11944
+ let closingParens = ccount(url2, ")");
11945
11945
  while (closingParenIndex !== -1 && openingParens > closingParens) {
11946
- url += trail2.slice(0, closingParenIndex + 1);
11946
+ url2 += trail2.slice(0, closingParenIndex + 1);
11947
11947
  trail2 = trail2.slice(closingParenIndex + 1);
11948
11948
  closingParenIndex = trail2.indexOf(")");
11949
11949
  closingParens++;
11950
11950
  }
11951
- return [url, trail2];
11951
+ return [url2, trail2];
11952
11952
  }
11953
11953
  function previous$1(match, email) {
11954
11954
  const code2 = match.input.charCodeAt(match.index - 1);
@@ -13341,7 +13341,7 @@ const domain = {
13341
13341
  tokenize: tokenizeDomain,
13342
13342
  partial: true
13343
13343
  };
13344
- const path$1 = {
13344
+ const path$2 = {
13345
13345
  tokenize: tokenizePath,
13346
13346
  partial: true
13347
13347
  };
@@ -13447,7 +13447,7 @@ function tokenizeWwwAutolink(effects, ok2, nok) {
13447
13447
  }
13448
13448
  effects.enter("literalAutolink");
13449
13449
  effects.enter("literalAutolinkWww");
13450
- return effects.check(wwwPrefix, effects.attempt(domain, effects.attempt(path$1, wwwAfter), nok), nok)(code2);
13450
+ return effects.check(wwwPrefix, effects.attempt(domain, effects.attempt(path$2, wwwAfter), nok), nok)(code2);
13451
13451
  }
13452
13452
  function wwwAfter(code2) {
13453
13453
  effects.exit("literalAutolinkWww");
@@ -13497,7 +13497,7 @@ function tokenizeProtocolAutolink(effects, ok2, nok) {
13497
13497
  return nok(code2);
13498
13498
  }
13499
13499
  function afterProtocol(code2) {
13500
- return code2 === null || asciiControl(code2) || markdownLineEndingOrSpace(code2) || unicodeWhitespace(code2) || unicodePunctuation(code2) ? nok(code2) : effects.attempt(domain, effects.attempt(path$1, protocolAfter), nok)(code2);
13500
+ return code2 === null || asciiControl(code2) || markdownLineEndingOrSpace(code2) || unicodeWhitespace(code2) || unicodePunctuation(code2) ? nok(code2) : effects.attempt(domain, effects.attempt(path$2, protocolAfter), nok)(code2);
13501
13501
  }
13502
13502
  function protocolAfter(code2) {
13503
13503
  effects.exit("literalAutolinkHttp");
@@ -51407,8 +51407,8 @@ var assert = function assert2(value) {
51407
51407
  }
51408
51408
  return value;
51409
51409
  };
51410
- var protocolFromUrl = function protocolFromUrl2(url) {
51411
- var protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(url);
51410
+ var protocolFromUrl = function protocolFromUrl2(url2) {
51411
+ var protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(url2);
51412
51412
  if (!protocol) {
51413
51413
  return "_relative";
51414
51414
  }
@@ -51859,7 +51859,7 @@ var innerPath = function innerPath2(name2, height) {
51859
51859
  return "";
51860
51860
  }
51861
51861
  };
51862
- var path = {
51862
+ var path$1 = {
51863
51863
  // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main
51864
51864
  doubleleftarrow: "M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z",
51865
51865
  // doublerightarrow is from glyph U+21D2 in font KaTeX Main
@@ -54952,7 +54952,7 @@ class PathNode {
54952
54952
  if (this.alternate) {
54953
54953
  node2.setAttribute("d", this.alternate);
54954
54954
  } else {
54955
- node2.setAttribute("d", path[this.pathName]);
54955
+ node2.setAttribute("d", path$1[this.pathName]);
54956
54956
  }
54957
54957
  return node2;
54958
54958
  }
@@ -54960,7 +54960,7 @@ class PathNode {
54960
54960
  if (this.alternate) {
54961
54961
  return '<path d="' + utils.escape(this.alternate) + '"/>';
54962
54962
  } else {
54963
- return '<path d="' + utils.escape(path[this.pathName]) + '"/>';
54963
+ return '<path d="' + utils.escape(path$1[this.pathName]) + '"/>';
54964
54964
  }
54965
54965
  }
54966
54966
  }
@@ -65383,11 +65383,11 @@ let Parser$1 = class Parser {
65383
65383
  if (res == null) {
65384
65384
  return null;
65385
65385
  }
65386
- var url = res.text.replace(/\\([#$%&~_^{}])/g, "$1");
65386
+ var url2 = res.text.replace(/\\([#$%&~_^{}])/g, "$1");
65387
65387
  return {
65388
65388
  type: "url",
65389
65389
  mode: this.mode,
65390
- url
65390
+ url: url2
65391
65391
  };
65392
65392
  }
65393
65393
  /**
@@ -76028,9 +76028,6 @@ const style = `/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com *
76028
76028
  .markdown-body > *:first-child {
76029
76029
  margin-top: 0 !important;
76030
76030
  }
76031
- .markdown-body > *:last-child {
76032
- margin-bottom: 0 !important;
76033
- }
76034
76031
  .markdown-body a:not([href]) {
76035
76032
  color: inherit;
76036
76033
  text-decoration: none;
@@ -76587,7 +76584,7 @@ code {
76587
76584
  }
76588
76585
  .pdf-columns-2 {
76589
76586
  columns: 2;
76590
- column-fill: auto;
76587
+ column-fill: balance;
76591
76588
  column-gap: 32px;
76592
76589
  }
76593
76590
  mjx-container:not([display='true']) svg {
@@ -76963,6 +76960,50 @@ function getDateString() {
76963
76960
  const minu = date.getMinutes();
76964
76961
  return `${month}_${d}_${h2}_${minu}`;
76965
76962
  }
76963
+ require("https");
76964
+ require("http");
76965
+ const fsPromise = require("fs/promises");
76966
+ const path = require("path");
76967
+ const url = require("url");
76968
+ const isLocalPath = (inputPath) => {
76969
+ if (typeof inputPath !== "string" || inputPath.trim() === "") {
76970
+ return false;
76971
+ }
76972
+ const normalizedPath = inputPath.trim();
76973
+ const isNetworkUrl = /^(http|https|ftp):\/\/|^\/\//i.test(normalizedPath);
76974
+ if (isNetworkUrl) {
76975
+ return false;
76976
+ }
76977
+ try {
76978
+ const parsedUrl = new url.URL(normalizedPath);
76979
+ if (parsedUrl.host && parsedUrl.protocol !== "file:") {
76980
+ return false;
76981
+ }
76982
+ } catch (err) {
76983
+ }
76984
+ const resolvedPath = path.resolve(normalizedPath);
76985
+ const isWindowsLocal = process.platform === "win32" && /^[a-zA-Z]:[\\/]/i.test(resolvedPath);
76986
+ const isUnixLocal = (process.platform === "linux" || process.platform === "darwin") && resolvedPath.startsWith("/");
76987
+ return isWindowsLocal || isUnixLocal || normalizedPath.startsWith("./") || normalizedPath.startsWith("../");
76988
+ };
76989
+ const localImageToBase64 = async (imagePath) => {
76990
+ try {
76991
+ logger.info("imagePath:::" + imagePath);
76992
+ if (!imagePath) {
76993
+ return null;
76994
+ }
76995
+ const buffer = await fsPromise.readFile(imagePath);
76996
+ const mimeType = require("mime-types").lookup(imagePath) || "image/jpeg";
76997
+ return {
76998
+ mimeType,
76999
+ src: imagePath,
77000
+ base64: `data:${mimeType};base64,${buffer.toString("base64")}`
77001
+ };
77002
+ } catch (err) {
77003
+ logger.error("localImageToBase64 err:::" + err.message);
77004
+ }
77005
+ return null;
77006
+ };
76966
77007
  const createPage = async (page, item) => {
76967
77008
  const {
76968
77009
  tempFileName,
@@ -76980,6 +77021,32 @@ const createPage = async (page, item) => {
76980
77021
  </header>
76981
77022
  `;
76982
77023
  await page.setContent(html2, { waitUntil: "networkidle" });
77024
+ const imgElements = await page.evaluate(async () => {
77025
+ return Array.from(document.querySelectorAll("img")).map((it) => it.src);
77026
+ });
77027
+ const fileInfoArray = await Promise.all(
77028
+ imgElements.filter((src) => isLocalPath(src)).map(
77029
+ (src) => new Promise((resolve) => {
77030
+ localImageToBase64(src).then((fileInfo) => {
77031
+ resolve(fileInfo);
77032
+ }).catch(() => {
77033
+ resolve("");
77034
+ });
77035
+ })
77036
+ )
77037
+ );
77038
+ await page.evaluate(
77039
+ async (fileInfoArray2) => Array.from(document.querySelectorAll("img")).forEach((img) => {
77040
+ const imgInfo = fileInfoArray2.find(
77041
+ (it) => it && img.src && it.src === img.src
77042
+ );
77043
+ if (!imgInfo) {
77044
+ return;
77045
+ }
77046
+ img.src = imgInfo.base64;
77047
+ }),
77048
+ fileInfoArray
77049
+ );
76983
77050
  const pageRes = await page.pdf({
76984
77051
  path: tempFileName,
76985
77052
  format: "A4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@8btc/office-assistant-mcp",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "办公agent辅助mcp工具",
5
5
  "main": "dist/index.cjs",
6
6
  "type": "module",
@@ -48,6 +48,7 @@
48
48
  "lodash": "^4.17.21",
49
49
  "mathjax-full": "^3.2.2",
50
50
  "mermaid": "^11.8.1",
51
+ "mime-types": "^3.0.2",
51
52
  "pdf-lib": "^1.17.1",
52
53
  "playwright": "^1.57.0",
53
54
  "qrcode.react": "^4.2.0",
@@ -75,6 +76,7 @@
75
76
  "@testing-library/react": "^16.2.0",
76
77
  "@types/cors": "^2.8.19",
77
78
  "@types/express": "^5.0.5",
79
+ "@types/mime-types": "^3.0.1",
78
80
  "@types/node": "^22.10.2",
79
81
  "@types/react": "^19.2.0",
80
82
  "@types/react-dom": "^19.2.0",