@fjyueke/arco-mcp 1.0.1 → 1.0.2

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 (62) hide show
  1. package/dist/index.js +113 -1
  2. package/metaData/components/action-sheet/style.md +57 -0
  3. package/metaData/components/avatar/style.md +147 -0
  4. package/metaData/components/badge/style.md +74 -0
  5. package/metaData/components/button/style.md +151 -0
  6. package/metaData/components/carousel/style.md +208 -0
  7. package/metaData/components/cell/style.md +123 -0
  8. package/metaData/components/checkbox/style.md +62 -0
  9. package/metaData/components/circle-progress/style.md +52 -0
  10. package/metaData/components/collapse/style.md +53 -0
  11. package/metaData/components/context-provider/style.md +1 -0
  12. package/metaData/components/count-down/style.md +7 -0
  13. package/metaData/components/date-picker/style.md +27 -0
  14. package/metaData/components/dialog/style.md +271 -0
  15. package/metaData/components/divider/style.md +68 -0
  16. package/metaData/components/dropdown/style.md +108 -0
  17. package/metaData/components/dropdown-menu/style.md +60 -0
  18. package/metaData/components/ellipsis/style.md +31 -0
  19. package/metaData/components/form/style.md +105 -0
  20. package/metaData/components/grid/style.md +109 -0
  21. package/metaData/components/image/style.md +144 -0
  22. package/metaData/components/image-picker/style.md +116 -0
  23. package/metaData/components/image-preview/style.md +103 -0
  24. package/metaData/components/index-bar/style.md +122 -0
  25. package/metaData/components/input/style.md +108 -0
  26. package/metaData/components/keyboard/style.md +80 -0
  27. package/metaData/components/load-more/style.md +7 -0
  28. package/metaData/components/loading/style.md +102 -0
  29. package/metaData/components/masking/style.md +30 -0
  30. package/metaData/components/nav-bar/style.md +112 -0
  31. package/metaData/components/notice-bar/style.md +124 -0
  32. package/metaData/components/notify/style.md +40 -0
  33. package/metaData/components/pagination/style.md +105 -0
  34. package/metaData/components/picker/style.md +46 -0
  35. package/metaData/components/picker-view/style.md +75 -0
  36. package/metaData/components/popover/style.md +226 -0
  37. package/metaData/components/popup/style.md +115 -0
  38. package/metaData/components/popup-swiper/style.md +10 -0
  39. package/metaData/components/portal/style.md +1 -0
  40. package/metaData/components/progress/style.md +114 -0
  41. package/metaData/components/pull-refresh/style.md +86 -0
  42. package/metaData/components/radio/style.md +57 -0
  43. package/metaData/components/rate/style.md +63 -0
  44. package/metaData/components/search-bar/style.md +115 -0
  45. package/metaData/components/show-monitor/style.md +1 -0
  46. package/metaData/components/skeleton/style.md +147 -0
  47. package/metaData/components/slider/style.md +292 -0
  48. package/metaData/components/stepper/style.md +85 -0
  49. package/metaData/components/steps/style.md +304 -0
  50. package/metaData/components/sticky/style.md +5 -0
  51. package/metaData/components/swipe-action/style.md +89 -0
  52. package/metaData/components/swipe-load/style.md +29 -0
  53. package/metaData/components/switch/style.md +158 -0
  54. package/metaData/components/tab-bar/style.md +57 -0
  55. package/metaData/components/tabs/style.md +436 -0
  56. package/metaData/components/tag/style.md +133 -0
  57. package/metaData/components/textarea/style.md +37 -0
  58. package/metaData/components/toast/style.md +93 -0
  59. package/metaData/components/transition/style.md +28 -0
  60. package/metaData/components/uploader/style.md +86 -0
  61. package/metaData/tokens.json +2358 -0
  62. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -23,7 +23,8 @@ var config = {
23
23
  componentsIndexPath: resolve(
24
24
  __dirname,
25
25
  "../metaData/components-index.json"
26
- )
26
+ ),
27
+ tokensPath: resolve(__dirname, "../metaData/tokens.json")
27
28
  },
28
29
  server: {
29
30
  name: "arco-mcp",
@@ -156,6 +157,70 @@ ${content}
156
157
  return `Failed to load examples for ${component.name}`;
157
158
  }
158
159
  };
160
+ var fetchComponentStyle = async (componentName) => {
161
+ const component = await locateComponentByName(componentName);
162
+ if (!component) {
163
+ return "Component not found";
164
+ }
165
+ const stylePath = join3(
166
+ config.paths.componentsDir,
167
+ component.dirName,
168
+ "style.md"
169
+ );
170
+ try {
171
+ if (existsSync(stylePath)) {
172
+ const content = await readFile(stylePath, "utf-8");
173
+ return `\`\`\`less
174
+ ${content}
175
+ \`\`\``;
176
+ }
177
+ return `Style documentation for ${component.name} not found`;
178
+ } catch (error) {
179
+ await logService.error(`${component.name}: ${error.message}`);
180
+ return `Failed to load style for ${component.name}`;
181
+ }
182
+ };
183
+ var fetchCssTokens = async (category) => {
184
+ try {
185
+ const tokensData = await readFile(config.paths.tokensPath, "utf-8");
186
+ const tokens = JSON.parse(tokensData);
187
+ if (category) {
188
+ const categoryTokens = tokens[category];
189
+ if (categoryTokens) {
190
+ const result2 = categoryTokens.map(
191
+ (token) => `- **${token.name}**: ${token.value} - ${token.description}`
192
+ ).join("\n");
193
+ return `## ${category}
194
+
195
+ ${result2}`;
196
+ }
197
+ return `Category "${category}" not found`;
198
+ }
199
+ const categories = Object.keys(tokens);
200
+ const result = categories.map((cat) => {
201
+ const catTokens = tokens[cat].map(
202
+ (token) => ` - ${token.name}: ${token.value}`
203
+ ).join("\n");
204
+ return `## ${cat}
205
+
206
+ ${catTokens}`;
207
+ }).join("\n\n");
208
+ return result;
209
+ } catch (error) {
210
+ await logService.error(`Failed to load CSS tokens: ${error.message}`);
211
+ return "Failed to load CSS tokens";
212
+ }
213
+ };
214
+ var listTokenCategories = async () => {
215
+ try {
216
+ const tokensData = await readFile(config.paths.tokensPath, "utf-8");
217
+ const tokens = JSON.parse(tokensData);
218
+ return Object.keys(tokens).join(", ");
219
+ } catch (error) {
220
+ await logService.error(`Failed to load CSS tokens: ${error.message}`);
221
+ return "Failed to load CSS token categories";
222
+ }
223
+ };
159
224
 
160
225
  // src/tools/components.ts
161
226
  function registerArcoTools(server) {
@@ -224,6 +289,53 @@ function registerArcoTools(server) {
224
289
  };
225
290
  }
226
291
  );
292
+ server.tool(
293
+ "get-component-style",
294
+ "Gets the style/less file content for a specific Arco Design Mobile component",
295
+ { componentName: z.string() },
296
+ async (args) => {
297
+ const styleContent = await fetchComponentStyle(args.componentName);
298
+ return {
299
+ content: [
300
+ {
301
+ type: "text",
302
+ text: styleContent
303
+ }
304
+ ]
305
+ };
306
+ }
307
+ );
308
+ server.tool(
309
+ "list-token-categories",
310
+ "Lists all CSS token categories available in Arco Design Mobile",
311
+ async () => {
312
+ const categories = await listTokenCategories();
313
+ return {
314
+ content: [
315
+ {
316
+ type: "text",
317
+ text: categories
318
+ }
319
+ ]
320
+ };
321
+ }
322
+ );
323
+ server.tool(
324
+ "get-css-tokens",
325
+ "Gets CSS tokens for a specific category or all categories in Arco Design Mobile",
326
+ { category: z.string().optional() },
327
+ async (args) => {
328
+ const tokens = await fetchCssTokens(args.category);
329
+ return {
330
+ content: [
331
+ {
332
+ type: "text",
333
+ text: tokens
334
+ }
335
+ ]
336
+ };
337
+ }
338
+ );
227
339
  }
228
340
 
229
341
  // src/index.ts
@@ -0,0 +1,57 @@
1
+ @import "../../../style/mixin.less";
2
+
3
+ .@{prefix}-action-sheet {
4
+ .use-var(color, font-color);
5
+
6
+ &-header {
7
+ .use-var(padding, action-sheet-header-padding);
8
+ text-align: center;
9
+ .onepx-border-var(bottom, line-color);
10
+ }
11
+
12
+ &-title {
13
+ .use-var(font-size, action-sheet-title-font-size);
14
+ .text-medium();
15
+ }
16
+
17
+ &-sub-title {
18
+ .use-var(color, sub-info-font-color);
19
+ .use-var(font-size, action-sheet-sub-title-font-size);
20
+ }
21
+
22
+ &-title + &-sub-title {
23
+ .rem(margin-top, 4);
24
+ }
25
+
26
+ &-content {
27
+ .use-var(border-top-left-radius, action-sheet-border-radius);
28
+ .use-var(border-top-right-radius, action-sheet-border-radius);
29
+ }
30
+
31
+ &-item {
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ .use-var(height, action-sheet-item-height);
36
+ .use-var(font-size, action-sheet-item-font-size);
37
+ .noselect();
38
+
39
+ &:not(:last-child) {
40
+ .onepx-border-var(bottom, line-color);
41
+ }
42
+
43
+ &.disabled {
44
+ .use-var(color, disabled-color);
45
+ }
46
+
47
+ &.danger {
48
+ .use-var(color, danger-color);
49
+ }
50
+
51
+ &.cancel-item {
52
+ border-top-style: solid;
53
+ .use-var(border-top-color, action-sheet-cancel-border-color);
54
+ .use-var(border-top-width, action-sheet-cancel-border-width);
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,147 @@
1
+ @import "../../../style/mixin.less";
2
+
3
+ @size-map: @avatar-size-map;
4
+
5
+ .@{prefix}-avatar {
6
+ position: relative;
7
+ font-size: 0;
8
+ display: flex;
9
+ align-items: center;
10
+ justify-content: center;
11
+ .use-var(color, avatar-text-font-color);
12
+ .use-var(background-color, avatar-background);
13
+
14
+ &-mode-image {
15
+ background-color: transparent !important;
16
+ }
17
+
18
+ &-default-overlap {
19
+ .use-var(background-color, avatar-default-overlap-background);
20
+ }
21
+
22
+ &-shape-circle {
23
+ .set-avatar-radius(50%);
24
+ }
25
+
26
+ &-shape-square {
27
+ .set-avatar-radius(.08rem);
28
+ }
29
+
30
+ .set-avatar-size(length(@size-map));
31
+
32
+ &-img {
33
+ width: 100%;
34
+ height: 100%;
35
+ }
36
+
37
+ &-decoration {
38
+ position: absolute;
39
+ }
40
+
41
+ &-text {
42
+ flex: 0 0 auto;
43
+ font-weight: bold;
44
+ }
45
+
46
+ &-wrapper {
47
+ display: inline-block;
48
+
49
+ &-with-info {
50
+ display: flex;
51
+ align-items: center;
52
+ }
53
+ }
54
+
55
+ &-info {
56
+ display: flex;
57
+ justify-content: center;
58
+ flex-direction: column;
59
+ .rem-with-rtl(margin-left, 16);
60
+ }
61
+
62
+ &-name {
63
+ .use-var(color, avatar-name-color);
64
+ }
65
+
66
+ &-desc {
67
+ .use-var(color, avatar-desc-color);
68
+ }
69
+ }
70
+
71
+ .@{prefix}-avatar-group {
72
+ .@{prefix}-avatar-wrapper-shape-circle {
73
+ position: relative; // 为了让z-index属性生效
74
+
75
+ &:first-child {
76
+ margin-left: 0;
77
+ }
78
+ }
79
+
80
+ .@{prefix}-avatar {
81
+ border-style: solid;
82
+ .use-var(border-color, avatar-group-border-color);
83
+ }
84
+
85
+ .set-avatar-group-size(length(@size-map));
86
+ }
87
+
88
+ .set-avatar-radius(@radius) {
89
+ border-radius: @radius;
90
+ .@{prefix}-avatar-img .image-content {
91
+ border-radius: @radius;
92
+ }
93
+ }
94
+
95
+ // 循环设置头像叠层的样式
96
+ .set-avatar-group-size(@index) when (@index > 0) {
97
+
98
+ @size: extract(@size-map, @index);
99
+
100
+ &-size-@{size} {
101
+ .@{prefix}-avatar-wrapper {
102
+ .use-var-with-rtl(margin-left, "avatar-group-@{size}-size-offset");
103
+ }
104
+ .@{prefix}-avatar {
105
+ .use-var(border-width, "avatar-group-@{size}-size-border");
106
+ }
107
+ }
108
+
109
+ .set-avatar-group-size(@index - 1);
110
+ }
111
+
112
+ // 循环设置头像的样式
113
+ .set-avatar-size(@index) when (@index > 0) {
114
+
115
+ @size: extract(@size-map, @index);
116
+
117
+ &-size-@{size} {
118
+ .use-var(width, "avatar-@{size}-size");
119
+ .use-var(height, "avatar-@{size}-size");
120
+ }
121
+ &-default-icon-size-@{size} {
122
+ .use-var(font-size, "avatar-default-overlap-@{size}-size");
123
+ }
124
+ &-text-size-@{size} {
125
+ .use-var(font-size, "avatar-@{size}-text-font-size");
126
+ }
127
+
128
+ // 有辅助信息的样式
129
+ &-wrapper-with-info-size-@{size} {
130
+ .use-var(height, "avatar-info-box-@{size}-size");
131
+ }
132
+
133
+ // 用户名样式
134
+ &-name-size-@{size} {
135
+ .use-var(font-size, "avatar-name-@{size}-font-size");
136
+ .use-var(line-height, "avatar-name-@{size}-line-height");
137
+ }
138
+
139
+ // 用户描述样式
140
+ &-desc-size-@{size} {
141
+ .use-var(margin-top, "avatar-desc-@{size}-margin-top");
142
+ .use-var(font-size, "avatar-desc-@{size}-font-size");
143
+ .use-var(line-height, "avatar-desc-@{size}-line-height");
144
+ }
145
+
146
+ .set-avatar-size(@index - 1);
147
+ }
@@ -0,0 +1,74 @@
1
+ @import "../../../style/mixin.less";
2
+
3
+ @keyframes scale-on {
4
+
5
+ 0% {
6
+ transform: scale(0);opacity: 0; }
7
+
8
+ 100% {
9
+ transform: scale(1); opacity: 1; }
10
+ }
11
+
12
+ @keyframes scale-off {
13
+
14
+ 0% {
15
+ transform: scale(1); opacity: 1; }
16
+
17
+ 100% {
18
+ transform: scale(0); opacity: 0; }
19
+ }
20
+
21
+ .@{prefix}-scale-enter-active {
22
+ animation: scale-on cubic-bezier(.3, 1.3, .3, 1) forwards;
23
+ animation-duration: var(--builtin-transition-scale-enter-duration, .4s);
24
+ }
25
+
26
+ .@{prefix}-scale-exit-active {
27
+ animation: scale-off cubic-bezier(.3, 1.3, .3, 1) forwards;
28
+ animation-duration: var(--builtin-transition-scale-exit-duration, .4s);
29
+ }
30
+
31
+ .@{prefix}-badge {
32
+ cursor: pointer;
33
+ box-sizing: content-box;
34
+ display: inline-block;
35
+ z-index: 2;
36
+ .use-var(color, badge-text-color);
37
+ .use-var(background-color, badge-background-color);
38
+ white-space: nowrap;
39
+ .use-var(border-radius, badge-border-radius);
40
+ .use-var(height, badge-text-width);
41
+ .use-var(line-height, badge-text-width);
42
+ .set-content-box-width-var(min-width, badge-text-width, badge-text-padding, badge-text-padding);
43
+ .use-var(padding, badge-text-padding, 0);
44
+
45
+ &-text {
46
+ display: block;
47
+ font-weight: 500;
48
+ .set-font-size-var(badge-font-size);
49
+ }
50
+
51
+ &-dot {
52
+ .use-var(width, badge-dot-width);
53
+ .use-var(height, badge-dot-width);
54
+ padding: 0;
55
+ min-width: auto;
56
+ }
57
+
58
+ &-bordered {
59
+ .use-var(border, badge-border-color, 1PX solid);
60
+ }
61
+
62
+ &-absolute {
63
+ position: absolute;
64
+ top: 0;
65
+ .set-prop-with-rtl(left, 100%);
66
+ .use-var-with-rtl(margin-left, badge-text-deviation);
67
+ .use-var(margin-top, badge-text-deviation);
68
+ }
69
+
70
+ &-absolute&-dot {
71
+ .use-var-with-rtl(margin-left, badge-dot-deviation);
72
+ .use-var(margin-top, badge-dot-deviation);
73
+ }
74
+ }
@@ -0,0 +1,151 @@
1
+ @import '../../../style/mixin.less';
2
+
3
+ @size-map: huge, large, medium, small, mini;
4
+
5
+ .button-has-border(@color) {
6
+ .use-var(border, @color, 1PX solid);
7
+ &.half-border {
8
+ border-width: 0;
9
+ .hairline-var(@color);
10
+ }
11
+ }
12
+
13
+ .button-has-border-value(@value) {
14
+ border: 1PX solid @value;
15
+ &.half-border {
16
+ border-width: 0;
17
+ .hairline(@value);
18
+ }
19
+ }
20
+
21
+ .button-no-border() {
22
+ border-width: 0;
23
+ box-shadow: none;
24
+ }
25
+
26
+ .button-text-size(@font-size) {
27
+ .@{prefix}-button-icon,
28
+ i,
29
+ .@{prefix}-button-text,
30
+ svg {
31
+ .use-var(font-size, @font-size);
32
+ }
33
+ }
34
+
35
+ .button-size-height(@height) {
36
+ .use-var(height, @height);
37
+ &-is-round {
38
+ .use-var(border-radius, @height);
39
+ }
40
+ &-is-square {
41
+ .rem(border-radius, 0);
42
+ }
43
+ }
44
+
45
+ .@{prefix}-button {
46
+ cursor: pointer;
47
+ text-align: center;
48
+ line-height: 1.2;
49
+ font-size: 0;
50
+ display: block;
51
+ width: 100%;
52
+ box-sizing: border-box;
53
+ .use-var(line-height, button-line-height);
54
+ .use-var(border-radius, button-radius);
55
+ .noselect();
56
+
57
+ &&-inline {
58
+ width: auto;
59
+ display: inline-block;
60
+ }
61
+
62
+ &&-type-primary {
63
+ .use-var(background, button-primary-background);
64
+ .use-var(color, button-primary-text-color);
65
+ &-disabled {
66
+ .use-var(background, button-primary-disabled-background);
67
+ .use-var(color, button-primary-disabled-text-color)
68
+ }
69
+ &-active {
70
+ .use-var(background, button-primary-clicked-background);
71
+ }
72
+ }
73
+ &-type-primary {
74
+ .set-loading-color-var(button-primary-text-color);
75
+ }
76
+
77
+ &&-type-default {
78
+ .use-var(background, button-default-background);
79
+ .use-var(color, button-default-text-color);
80
+ &-disabled {
81
+ .use-var(background, button-default-disabled-background);
82
+ .use-var(color, button-default-disabled-text-color)
83
+ }
84
+ &-active {
85
+ .use-var(background, button-default-clicked-background);
86
+ }
87
+ }
88
+ &-type-default {
89
+ .set-loading-color-var(button-default-text-color);
90
+ }
91
+
92
+ &&-type-ghost {
93
+ .use-var(background, button-ghost-background);
94
+ .use-var(color, button-ghost-text-color);
95
+ &-disabled {
96
+ .use-var(background, button-ghost-disabled-background);
97
+ .use-var(color, button-ghost-disabled-text-color)
98
+ }
99
+ &-active {
100
+ .use-var(background, button-ghost-clicked-background);
101
+ }
102
+ }
103
+ &-type-ghost {
104
+ .set-loading-color-var(button-ghost-text-color);
105
+ }
106
+
107
+ &&-type-ghost {
108
+ .button-has-border-value(currentColor);
109
+ }
110
+
111
+ .set-button-size(length(@size-map));
112
+
113
+ &-text-android {
114
+ .rem(padding-top, 2);
115
+ }
116
+
117
+ &-icon {
118
+ vertical-align: middle;
119
+ display: inline-flex;
120
+ align-items: center;
121
+ justify-content: center;
122
+ }
123
+ &-text {
124
+ display: inline-block;
125
+ vertical-align: middle;
126
+ }
127
+ &-text-has-icon {
128
+ .use-var-with-rtl(margin-left, button-icon-text-gutter);
129
+ }
130
+
131
+ &-loading-icon {
132
+ display: inline-block;
133
+ vertical-align: middle;
134
+ }
135
+
136
+ &.has-custom-border {
137
+ border: 1PX solid;
138
+ }
139
+ }
140
+
141
+ .set-button-size(@index) when (@index > 0) {
142
+ @size: extract(@size-map, @index);
143
+
144
+ &&-size-@{size} {
145
+ .use-var(padding, "button-@{size}-padding");
146
+ .button-size-height("button-@{size}-height");
147
+ .button-text-size("button-@{size}-text-size");
148
+ }
149
+
150
+ .set-button-size(@index - 1);
151
+ }