@miyucy/storybook-mcp 1.0.4 → 1.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.
package/dist/index.js CHANGED
@@ -6,9 +6,10 @@ import path from "node:path";
6
6
  import fs from "node:fs/promises";
7
7
  import process from "node:process";
8
8
  import os from "node:os";
9
+ import { fileURLToPath } from "node:url";
10
+ import { Worker } from "node:worker_threads";
9
11
  import { z } from "zod";
10
12
  import glob from "fast-glob";
11
- import { Worker } from "node:worker_threads";
12
13
  const escapeRegExp = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
13
14
  class Storybook {
14
15
  constructor(storybookRoot) {
@@ -186,7 +187,9 @@ class Storybook {
186
187
  worker.postMessage(task);
187
188
  };
188
189
  for (let i = 0; i < this.AVAILABLE_PARALLELISM; i++) {
189
- const worker = new Worker("./dist/parser.js");
190
+ const __filename = fileURLToPath(import.meta.url);
191
+ const __dirname = path.dirname(__filename);
192
+ const worker = new Worker(path.resolve(__dirname, "parser.js"));
190
193
  worker.on("message", (event) => {
191
194
  // console.log("message", event);
192
195
  const { componentPath, data } = event;
package/dist/parser.js CHANGED
@@ -1,16 +1,13 @@
1
- import { builtinHandlers, parse, builtinResolvers } from "react-docgen";
1
+ import { parse, builtinResolvers } from "react-docgen";
2
2
  import { parentPort } from "node:worker_threads";
3
3
  import { readFile } from "node:fs/promises";
4
4
  const resolver = new builtinResolvers.FindExportedDefinitionsResolver();
5
- const handlers = Object.values(builtinHandlers);
6
5
  parentPort?.on("message", async (message) => {
7
- // console.log("message", message);
8
6
  if (message.filepath) {
9
7
  try {
10
8
  const content = await readFile(message.filepath, "utf-8");
11
9
  const result = parse(content, {
12
10
  filename: message.filepath,
13
- handlers,
14
11
  resolver,
15
12
  });
16
13
  parentPort?.postMessage({
@@ -18,6 +15,7 @@ parentPort?.on("message", async (message) => {
18
15
  filepath: message.filepath,
19
16
  componentPath: message.componentPath,
20
17
  data: result,
18
+ content,
21
19
  });
22
20
  }
23
21
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miyucy/storybook-mcp",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {