sloth-d2c-mcp 1.0.4-beta75 → 1.0.4-beta76

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sloth-d2c-mcp",
3
- "version": "1.0.4-beta75",
3
+ "version": "1.0.4-beta76",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {
@@ -58,6 +58,7 @@
58
58
  "md5": "~2.3.0",
59
59
  "multer": "~2.0.2",
60
60
  "nanoid": "~3.3.7",
61
+ "node-machine-id": "~1.1.12",
61
62
  "open": "^10.2.0",
62
63
  "openai": "~4.67.3",
63
64
  "prettier": "^3.5.3",
@@ -68,8 +69,8 @@
68
69
  "react-inspector": "~6.0.2",
69
70
  "reflect-metadata": "^0.2.0",
70
71
  "rxjs": "^7.8.1",
71
- "sloth-d2c-figma-plugin": "2.0.3-beta58",
72
- "sloth-d2c-node": "0.0.1-beta55",
72
+ "sloth-d2c-figma-plugin": "2.0.3-beta61",
73
+ "sloth-d2c-node": "0.0.1-beta56",
73
74
  "tailwindcss": "4.0.0-alpha.26",
74
75
  "uuid": "^11.1.0",
75
76
  "webpack-obfuscator": "~3.5.1",
@@ -85,7 +86,7 @@
85
86
  "scripts": {
86
87
  "build": "rm -rf ./dist && tsc && pnpm run build-interceptor-web && pnpm run copy-interceptor-web",
87
88
  "start": "node dist/build/index.js",
88
- "dev": "nodemon --watch src --exec node --loader ts-node/esm src/index.ts",
89
+ "dev": "tsc --watch",
89
90
  "dev:log": "nodemon --watch src --exec node --loader ts-node/esm src/index.ts > dev.log",
90
91
  "build-interceptor-web": "cd ../interceptor-web && pnpm run build",
91
92
  "copy-interceptor-web": "mkdir -p ./dist/interceptor-web/dist && cp -r ../interceptor-web/dist/* dist/interceptor-web/dist"
@@ -1,45 +0,0 @@
1
- /**
2
- * 适配器管理器
3
- */
4
- import { WebPlatformAdapter } from './adapters/web-adapter.js';
5
- import { IOSPlatformAdapter } from './adapters/ios-adapter.js';
6
- export class AdapterManager {
7
- adapters = new Map();
8
- constructor() {
9
- this.registerDefaultAdapters();
10
- }
11
- /**
12
- * 注册默认适配器
13
- */
14
- registerDefaultAdapters() {
15
- this.registerAdapter(new WebPlatformAdapter());
16
- this.registerAdapter(new IOSPlatformAdapter());
17
- // TODO: 注册其他平台适配器
18
- // this.registerAdapter(new AndroidPlatformAdapter())
19
- // this.registerAdapter(new FlutterPlatformAdapter())
20
- }
21
- /**
22
- * 注册适配器
23
- */
24
- registerAdapter(adapter) {
25
- this.adapters.set(adapter.platform, adapter);
26
- }
27
- /**
28
- * 获取适配器
29
- */
30
- getAdapter(platform) {
31
- return this.adapters.get(platform);
32
- }
33
- /**
34
- * 获取所有适配器
35
- */
36
- getAllAdapters() {
37
- return this.adapters;
38
- }
39
- /**
40
- * 获取支持的平台列表
41
- */
42
- getSupportedPlatforms() {
43
- return Array.from(this.adapters.keys());
44
- }
45
- }
@@ -1,137 +0,0 @@
1
- /**
2
- * 平台适配器基类
3
- */
4
- import * as path from 'path';
5
- /**
6
- * 适配器基类 - 提供通用功能
7
- */
8
- export class BasePlatformAdapter {
9
- async validateComponent(componentPath) {
10
- try {
11
- const fs = await import('fs/promises');
12
- await fs.access(componentPath);
13
- return true;
14
- }
15
- catch {
16
- return false;
17
- }
18
- }
19
- /**
20
- * 生成组件唯一ID
21
- */
22
- generateComponentId(filePath, componentName) {
23
- const hash = this.simpleHash(filePath + (componentName || ''));
24
- return `${this.platform}_${hash}`;
25
- }
26
- /**
27
- * 简单哈希函数
28
- */
29
- simpleHash(str) {
30
- let hash = 0;
31
- for (let i = 0; i < str.length; i++) {
32
- const char = str.charCodeAt(i);
33
- hash = (hash << 5) - hash + char;
34
- hash = hash & hash;
35
- }
36
- return Math.abs(hash).toString(36);
37
- }
38
- /**
39
- * 推断组件类型
40
- */
41
- inferComponentType(name, metadata) {
42
- const lowerName = name.toLowerCase();
43
- if (lowerName.includes('button') || lowerName.includes('btn'))
44
- return 'button';
45
- if (lowerName.includes('input') || lowerName.includes('textfield'))
46
- return 'input';
47
- if (lowerName.includes('card'))
48
- return 'card';
49
- if (lowerName.includes('text') || lowerName.includes('label'))
50
- return 'text';
51
- if (lowerName.includes('image') || lowerName.includes('img'))
52
- return 'image';
53
- if (lowerName.includes('container') || lowerName.includes('box'))
54
- return 'container';
55
- if (lowerName.includes('list') || lowerName.includes('flatlist'))
56
- return 'list';
57
- return 'custom';
58
- }
59
- /**
60
- * 去重组件列表
61
- */
62
- deduplicateComponents(components) {
63
- const seen = new Set();
64
- return components.filter((comp) => {
65
- const key = `${comp.name}_${comp.path}`;
66
- if (seen.has(key))
67
- return false;
68
- seen.add(key);
69
- return true;
70
- });
71
- }
72
- /**
73
- * 递归查找文件
74
- */
75
- async findFiles(dir, extensions, options) {
76
- const fs = await import('fs/promises');
77
- const path = await import('path');
78
- const files = [];
79
- try {
80
- console.log(`[findFiles] 扫描目录: ${dir}, 扩展名: ${extensions.join(', ')}`);
81
- const entries = await fs.readdir(dir, { withFileTypes: true });
82
- console.log(`[findFiles] 目录 ${dir} 包含 ${entries.length} 个条目`);
83
- for (const entry of entries) {
84
- const fullPath = path.join(dir, entry.name);
85
- // 检查排除路径
86
- if (options?.excludePaths?.some((pattern) => fullPath.includes(pattern))) {
87
- console.log(`[findFiles] 排除路径: ${fullPath}`);
88
- continue;
89
- }
90
- if (entry.isDirectory()) {
91
- if (!entry.name.startsWith('.') &&
92
- entry.name !== 'node_modules' &&
93
- entry.name !== 'build' &&
94
- entry.name !== 'dist') {
95
- const subFiles = await this.findFiles(fullPath, extensions, options);
96
- files.push(...subFiles);
97
- }
98
- }
99
- else if (entry.isFile()) {
100
- const ext = path.extname(entry.name);
101
- if (extensions.includes(ext)) {
102
- console.log(`[findFiles] 找到匹配文件: ${fullPath}`);
103
- files.push(fullPath);
104
- }
105
- }
106
- }
107
- }
108
- catch (error) {
109
- console.warn(`无法读取目录 ${dir}:`, error);
110
- }
111
- console.log(`[findFiles] 目录 ${dir} 总共找到 ${files.length} 个匹配文件`);
112
- return files;
113
- }
114
- /**
115
- * 读取文件内容
116
- */
117
- async readFile(filePath) {
118
- const fs = await import('fs/promises');
119
- return fs.readFile(filePath, 'utf-8');
120
- }
121
- /**
122
- * 计算相对路径
123
- */
124
- getRelativePath(from, to) {
125
- let relativePath = path.relative(path.dirname(from), to);
126
- // 移除文件扩展名(对于需要移除扩展名的语言)
127
- // Swift/TypeScript/JavaScript/Vue 需要移除,但 Objective-C 的 .h 文件需要保留
128
- if (!to.endsWith('.h') && !to.endsWith('.m')) {
129
- relativePath = relativePath.replace(/\.(tsx?|jsx?|vue|swift)$/, '');
130
- }
131
- // 确保以 ./ 或 ../ 开头
132
- if (!relativePath.startsWith('.')) {
133
- relativePath = './' + relativePath;
134
- }
135
- return relativePath;
136
- }
137
- }