@miyucy/storybook-mcp 1.0.3 → 1.0.5

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) {
@@ -164,7 +165,7 @@ class Storybook {
164
165
  absolute: true,
165
166
  });
166
167
  if (paths.length > 0) {
167
- resolved[componentPath] = path.resolve(this.storybookRoot, paths[0]);
168
+ resolved[componentPath] = paths[0];
168
169
  }
169
170
  }
170
171
  }
@@ -181,12 +182,14 @@ class Storybook {
181
182
  const task = tasks.pop();
182
183
  if (!task) {
183
184
  worker.terminate();
184
- return;
185
+ return processNext();
185
186
  }
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, "worker.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.3",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {