@fjyueke/bify-mcp 1.0.2 → 1.0.3
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 +177 -67
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -172,9 +172,11 @@ var componentMappings = [
|
|
|
172
172
|
{ arcoProp: "label", bifyProp: "title" },
|
|
173
173
|
{ arcoProp: "desc", bifyProp: "brief" },
|
|
174
174
|
{ arcoProp: "text", bifyProp: "children" },
|
|
175
|
-
{ arcoProp: "showArrow", bifyProp: "clickable" },
|
|
175
|
+
{ arcoProp: "showArrow", bifyProp: "clickable", transform: () => "true" },
|
|
176
|
+
{ arcoProp: "arrow", bifyProp: "rightIcon" },
|
|
176
177
|
{ arcoProp: "bordered", bifyProp: "bordered" },
|
|
177
|
-
{ arcoProp: "icon", bifyProp: "icon" }
|
|
178
|
+
{ arcoProp: "icon", bifyProp: "icon" },
|
|
179
|
+
{ arcoProp: "onClick", bifyProp: "onClick" }
|
|
178
180
|
]
|
|
179
181
|
},
|
|
180
182
|
{
|
|
@@ -182,7 +184,10 @@ var componentMappings = [
|
|
|
182
184
|
bifyName: "CellGroup",
|
|
183
185
|
arcoImport: "@arco-design/mobile-react",
|
|
184
186
|
bifyImport: "@fjyueke/bify-core",
|
|
185
|
-
propMappings: [
|
|
187
|
+
propMappings: [
|
|
188
|
+
{ arcoProp: "bordered", bifyProp: "bordered" },
|
|
189
|
+
{ arcoProp: "onClick", bifyProp: "onClick" }
|
|
190
|
+
]
|
|
186
191
|
},
|
|
187
192
|
{
|
|
188
193
|
arcoName: "Button",
|
|
@@ -194,16 +199,25 @@ var componentMappings = [
|
|
|
194
199
|
{ arcoProp: "size", bifyProp: "size" },
|
|
195
200
|
{ arcoProp: "disabled", bifyProp: "disabled" },
|
|
196
201
|
{ arcoProp: "loading", bifyProp: "loading" },
|
|
197
|
-
{ arcoProp: "
|
|
198
|
-
{ arcoProp: "
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
202
|
+
{ arcoProp: "icon", bifyProp: "icon" },
|
|
203
|
+
{ arcoProp: "onClick", bifyProp: "onClick" },
|
|
204
|
+
{ arcoProp: "className", bifyProp: "className" },
|
|
205
|
+
{ arcoProp: "style", bifyProp: "style" }
|
|
206
|
+
],
|
|
207
|
+
valueMappings: {
|
|
208
|
+
type: {
|
|
209
|
+
ghost: "outlined",
|
|
210
|
+
default: "default",
|
|
211
|
+
primary: "primary"
|
|
212
|
+
},
|
|
213
|
+
size: {
|
|
214
|
+
mini: "mini",
|
|
215
|
+
small: "small",
|
|
216
|
+
medium: "medium",
|
|
217
|
+
large: "large",
|
|
218
|
+
huge: "large"
|
|
219
|
+
}
|
|
220
|
+
}
|
|
207
221
|
},
|
|
208
222
|
{
|
|
209
223
|
arcoName: "Avatar",
|
|
@@ -235,8 +249,18 @@ var componentMappings = [
|
|
|
235
249
|
propMappings: [
|
|
236
250
|
{ arcoProp: "type", bifyProp: "type" },
|
|
237
251
|
{ arcoProp: "size", bifyProp: "size" },
|
|
238
|
-
{ arcoProp: "closable", bifyProp: "closable" }
|
|
239
|
-
|
|
252
|
+
{ arcoProp: "closable", bifyProp: "closable" },
|
|
253
|
+
{ arcoProp: "onClose", bifyProp: "onClose" }
|
|
254
|
+
],
|
|
255
|
+
valueMappings: {
|
|
256
|
+
type: {
|
|
257
|
+
default: "default",
|
|
258
|
+
primary: "primary",
|
|
259
|
+
success: "success",
|
|
260
|
+
warning: "warning",
|
|
261
|
+
danger: "danger"
|
|
262
|
+
}
|
|
263
|
+
}
|
|
240
264
|
},
|
|
241
265
|
{
|
|
242
266
|
arcoName: "Switch",
|
|
@@ -257,6 +281,17 @@ var componentMappings = [
|
|
|
257
281
|
propMappings: [
|
|
258
282
|
{ arcoProp: "checked", bifyProp: "checked" },
|
|
259
283
|
{ arcoProp: "disabled", bifyProp: "disabled" },
|
|
284
|
+
{ arcoProp: "onChange", bifyProp: "onChange" },
|
|
285
|
+
{ arcoProp: "label", bifyProp: "children" }
|
|
286
|
+
]
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
arcoName: "CheckboxGroup",
|
|
290
|
+
bifyName: "Checkbox.Group",
|
|
291
|
+
arcoImport: "@arco-design/mobile-react",
|
|
292
|
+
bifyImport: "@fjyueke/bify-core",
|
|
293
|
+
propMappings: [
|
|
294
|
+
{ arcoProp: "value", bifyProp: "modelValue" },
|
|
260
295
|
{ arcoProp: "onChange", bifyProp: "onChange" }
|
|
261
296
|
]
|
|
262
297
|
},
|
|
@@ -268,6 +303,17 @@ var componentMappings = [
|
|
|
268
303
|
propMappings: [
|
|
269
304
|
{ arcoProp: "checked", bifyProp: "checked" },
|
|
270
305
|
{ arcoProp: "disabled", bifyProp: "disabled" },
|
|
306
|
+
{ arcoProp: "onChange", bifyProp: "onChange" },
|
|
307
|
+
{ arcoProp: "label", bifyProp: "children" }
|
|
308
|
+
]
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
arcoName: "RadioGroup",
|
|
312
|
+
bifyName: "Radio.Group",
|
|
313
|
+
arcoImport: "@arco-design/mobile-react",
|
|
314
|
+
bifyImport: "@fjyueke/bify-core",
|
|
315
|
+
propMappings: [
|
|
316
|
+
{ arcoProp: "value", bifyProp: "modelValue" },
|
|
271
317
|
{ arcoProp: "onChange", bifyProp: "onChange" }
|
|
272
318
|
]
|
|
273
319
|
},
|
|
@@ -332,13 +378,6 @@ var componentMappings = [
|
|
|
332
378
|
{ arcoProp: "onClose", bifyProp: "onClose" }
|
|
333
379
|
]
|
|
334
380
|
},
|
|
335
|
-
{
|
|
336
|
-
arcoName: "PickerView",
|
|
337
|
-
bifyName: "Picker",
|
|
338
|
-
arcoImport: "@arco-design/mobile-react",
|
|
339
|
-
bifyImport: "@fjyueke/bify-core",
|
|
340
|
-
propMappings: []
|
|
341
|
-
},
|
|
342
381
|
{
|
|
343
382
|
arcoName: "DatePicker",
|
|
344
383
|
bifyName: "DatePicker",
|
|
@@ -505,6 +544,16 @@ var componentMappings = [
|
|
|
505
544
|
{ arcoProp: "activeKey", bifyProp: "activeNames" }
|
|
506
545
|
]
|
|
507
546
|
},
|
|
547
|
+
{
|
|
548
|
+
arcoName: "CollapseItem",
|
|
549
|
+
bifyName: "Collapse.Item",
|
|
550
|
+
arcoImport: "@arco-design/mobile-react",
|
|
551
|
+
bifyImport: "@fjyueke/bify-core",
|
|
552
|
+
propMappings: [
|
|
553
|
+
{ arcoProp: "title", bifyProp: "title" },
|
|
554
|
+
{ arcoProp: "name", bifyProp: "name" }
|
|
555
|
+
]
|
|
556
|
+
},
|
|
508
557
|
{
|
|
509
558
|
arcoName: "PullRefresh",
|
|
510
559
|
bifyName: "PullRefresh",
|
|
@@ -533,6 +582,29 @@ var componentMappings = [
|
|
|
533
582
|
propMappings: [
|
|
534
583
|
{ arcoProp: "endTime", bifyProp: "endTime" }
|
|
535
584
|
]
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
arcoName: "List",
|
|
588
|
+
bifyName: "List",
|
|
589
|
+
arcoImport: "@arco-design/mobile-react",
|
|
590
|
+
bifyImport: "@fjyueke/bify-core",
|
|
591
|
+
propMappings: []
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
arcoName: "RefreshControl",
|
|
595
|
+
bifyName: "PullRefresh",
|
|
596
|
+
arcoImport: "@arco-design/mobile-react",
|
|
597
|
+
bifyImport: "@fjyueke/bify-core",
|
|
598
|
+
propMappings: [
|
|
599
|
+
{ arcoProp: "onRefresh", bifyProp: "onRefresh" }
|
|
600
|
+
]
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
arcoName: "PickerView",
|
|
604
|
+
bifyName: "PickerView",
|
|
605
|
+
arcoImport: "@arco-design/mobile-react",
|
|
606
|
+
bifyImport: "@fjyueke/bify-core",
|
|
607
|
+
propMappings: []
|
|
536
608
|
}
|
|
537
609
|
];
|
|
538
610
|
function findMappingByArcoName(arcoName) {
|
|
@@ -548,6 +620,7 @@ async function convertArcoToBify(arcoCode) {
|
|
|
548
620
|
result = convertImports(result);
|
|
549
621
|
result = convertComponents(result);
|
|
550
622
|
result = convertIconImports(result);
|
|
623
|
+
result = fixCodeFormat(result);
|
|
551
624
|
return result;
|
|
552
625
|
}
|
|
553
626
|
function convertImports(code) {
|
|
@@ -582,12 +655,14 @@ function convertImports(code) {
|
|
|
582
655
|
}
|
|
583
656
|
result = result.trim();
|
|
584
657
|
if (bifyCoreComponents.length > 0) {
|
|
585
|
-
const
|
|
658
|
+
const uniqueCoreComponents = [...new Set(bifyCoreComponents)];
|
|
659
|
+
const coreImport = `import { ${uniqueCoreComponents.join(", ")} } from "@fjyueke/bify-core"
|
|
586
660
|
`;
|
|
587
661
|
result = coreImport + result;
|
|
588
662
|
}
|
|
589
663
|
if (bifyIconComponents.length > 0) {
|
|
590
|
-
const
|
|
664
|
+
const uniqueIconComponents = [...new Set(bifyIconComponents)];
|
|
665
|
+
const iconImport = `import { ${uniqueIconComponents.join(", ")} } from "@fjyueke/bify-icons"
|
|
591
666
|
`;
|
|
592
667
|
result = iconImport + result;
|
|
593
668
|
}
|
|
@@ -606,22 +681,8 @@ function convertComponents(code) {
|
|
|
606
681
|
);
|
|
607
682
|
result = result.replace(componentRegex, (match, props) => {
|
|
608
683
|
let newProps = props;
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
`${propMapping.arcoProp}=(["'])(.*?)\\1`,
|
|
612
|
-
"g"
|
|
613
|
-
);
|
|
614
|
-
newProps = newProps.replace(propRegex, `${propMapping.bifyProp}=$1$2$1`);
|
|
615
|
-
}
|
|
616
|
-
if (arcoComponent === "Dialog" || arcoComponent === "Popup") {
|
|
617
|
-
newProps = newProps.replace(/visible=/g, "open=");
|
|
618
|
-
}
|
|
619
|
-
if (arcoComponent === "SearchBar" || arcoComponent === "Field" || arcoComponent === "Textarea") {
|
|
620
|
-
newProps = newProps.replace(/value=/g, "modelValue=");
|
|
621
|
-
}
|
|
622
|
-
if (arcoComponent === "Cell") {
|
|
623
|
-
newProps = newProps.replace(/showArrow/g, "clickable");
|
|
624
|
-
}
|
|
684
|
+
newProps = applyPropMappings(newProps, mapping);
|
|
685
|
+
newProps = applyValueMappings(newProps, mapping);
|
|
625
686
|
return `<${bifyComponent}${newProps}/>`;
|
|
626
687
|
});
|
|
627
688
|
const closingComponentRegex = new RegExp(
|
|
@@ -630,41 +691,88 @@ function convertComponents(code) {
|
|
|
630
691
|
);
|
|
631
692
|
result = result.replace(closingComponentRegex, (match, props, children) => {
|
|
632
693
|
let newProps = props;
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
`${propMapping.arcoProp}=(["'])(.*?)\\1`,
|
|
636
|
-
"g"
|
|
637
|
-
);
|
|
638
|
-
newProps = newProps.replace(propRegex, `${propMapping.bifyProp}=$1$2$1`);
|
|
639
|
-
}
|
|
640
|
-
if (arcoComponent === "Dialog" || arcoComponent === "Popup") {
|
|
641
|
-
newProps = newProps.replace(/visible=/g, "open=");
|
|
642
|
-
}
|
|
643
|
-
if (arcoComponent === "SearchBar" || arcoComponent === "Field" || arcoComponent === "Textarea") {
|
|
644
|
-
newProps = newProps.replace(/value=/g, "modelValue=");
|
|
645
|
-
}
|
|
646
|
-
if (arcoComponent === "Cell") {
|
|
647
|
-
newProps = newProps.replace(/showArrow/g, "clickable");
|
|
648
|
-
}
|
|
694
|
+
newProps = applyPropMappings(newProps, mapping);
|
|
695
|
+
newProps = applyValueMappings(newProps, mapping);
|
|
649
696
|
return `<${bifyComponent}${newProps}>${children}</${bifyComponent}>`;
|
|
650
697
|
});
|
|
651
698
|
}
|
|
652
699
|
return result;
|
|
653
700
|
}
|
|
701
|
+
function applyPropMappings(props, mapping) {
|
|
702
|
+
let result = props;
|
|
703
|
+
for (const propMapping of mapping.propMappings) {
|
|
704
|
+
const propRegex = new RegExp(
|
|
705
|
+
`${propMapping.arcoProp}=(["'])(.*?)\\1`,
|
|
706
|
+
"g"
|
|
707
|
+
);
|
|
708
|
+
result = result.replace(propRegex, (match, quote, value) => {
|
|
709
|
+
if (propMapping.transform) {
|
|
710
|
+
const transformedValue = propMapping.transform(value);
|
|
711
|
+
return `${propMapping.bifyProp}=${quote}${transformedValue}${quote}`;
|
|
712
|
+
}
|
|
713
|
+
return `${propMapping.bifyProp}=${quote}${value}${quote}`;
|
|
714
|
+
});
|
|
715
|
+
const booleanPropRegex = new RegExp(`\\b${propMapping.arcoProp}\\b`, "g");
|
|
716
|
+
if (propMapping.transform) {
|
|
717
|
+
result = result.replace(booleanPropRegex, `${propMapping.bifyProp}=${propMapping.transform("")}`);
|
|
718
|
+
} else {
|
|
719
|
+
result = result.replace(booleanPropRegex, propMapping.bifyProp);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
return result;
|
|
723
|
+
}
|
|
724
|
+
function applyValueMappings(props, mapping) {
|
|
725
|
+
if (!mapping.valueMappings) return props;
|
|
726
|
+
let result = props;
|
|
727
|
+
for (const [propName, valueMap] of Object.entries(mapping.valueMappings)) {
|
|
728
|
+
const propRegex = new RegExp(
|
|
729
|
+
`${propName}=(["'])(.*?)\\1`,
|
|
730
|
+
"g"
|
|
731
|
+
);
|
|
732
|
+
result = result.replace(propRegex, (match, quote, value) => {
|
|
733
|
+
const mappedValue = valueMap[value] || value;
|
|
734
|
+
return `${propName}=${quote}${mappedValue}${quote}`;
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
return result;
|
|
738
|
+
}
|
|
654
739
|
function convertIconImports(code) {
|
|
655
740
|
let result = code;
|
|
656
741
|
const arcoIconRegex = /import\s+Icon(\w+)\s+from\s+['"]@arco-design\/mobile-react\/es\/icon\/Icon(\w+)['"]/g;
|
|
657
742
|
result = result.replace(arcoIconRegex, 'import { Icon$1 } from "@fjyueke/bify-icons"');
|
|
743
|
+
const arcoIconsImportRegex = /import\s+\{([^}]+)\}\s+from\s+['"]@arco-design\/mobile-react\/es\/icon['"]/g;
|
|
744
|
+
result = result.replace(arcoIconsImportRegex, 'import { $1 } from "@fjyueke/bify-icons"');
|
|
658
745
|
return result;
|
|
659
746
|
}
|
|
747
|
+
function fixCodeFormat(code) {
|
|
748
|
+
let result = code;
|
|
749
|
+
result = result.replace(/\n{3,}/g, "\n\n");
|
|
750
|
+
result = result.replace(/import\s+\{\s*\}\s+from/g, "");
|
|
751
|
+
const lines = result.split("\n");
|
|
752
|
+
const nonEmptyLines = lines.filter((line) => line.trim() !== "");
|
|
753
|
+
result = nonEmptyLines.join("\n");
|
|
754
|
+
return result.trim();
|
|
755
|
+
}
|
|
660
756
|
async function getArcoConversionHelp() {
|
|
661
757
|
const availableComponents = componentMappings.filter((m) => m.bifyName).map((m) => `- ${m.arcoName} \u2192 ${m.bifyName}`).join("\n");
|
|
758
|
+
const valueMappingExamples = componentMappings.filter((m) => m.valueMappings).map((m) => {
|
|
759
|
+
const mappings = Object.entries(m.valueMappings).map(([prop, values]) => {
|
|
760
|
+
const valuePairs = Object.entries(values).map(([from, to]) => `${from} \u2192 ${to}`).join(", ");
|
|
761
|
+
return ` - ${prop}: ${valuePairs}`;
|
|
762
|
+
}).join("\n");
|
|
763
|
+
return `**${m.arcoName}**
|
|
764
|
+
${mappings}`;
|
|
765
|
+
}).join("\n\n");
|
|
662
766
|
return `## Arco Mobile \u2192 Bify \u4EE3\u7801\u8F6C\u6362
|
|
663
767
|
|
|
664
|
-
### \u652F\u6301\u7684\u7EC4\u4EF6
|
|
768
|
+
### \u652F\u6301\u7684\u7EC4\u4EF6 (${componentMappings.length} \u4E2A)
|
|
665
769
|
|
|
666
770
|
${availableComponents}
|
|
667
771
|
|
|
772
|
+
### \u503C\u6620\u5C04\u793A\u4F8B
|
|
773
|
+
|
|
774
|
+
${valueMappingExamples || "\u6682\u65E0"}
|
|
775
|
+
|
|
668
776
|
### \u4F7F\u7528\u65B9\u5F0F
|
|
669
777
|
|
|
670
778
|
\`\`\`tsx
|
|
@@ -674,7 +782,7 @@ import { Cell, CellGroup, Button } from '@arco-design/mobile-react';
|
|
|
674
782
|
<CellGroup>
|
|
675
783
|
<Cell label="\u6807\u9898" desc="\u63CF\u8FF0" showArrow>\u5185\u5BB9</Cell>
|
|
676
784
|
</CellGroup>
|
|
677
|
-
<Button type="primary">\u6309\u94AE</Button>
|
|
785
|
+
<Button type="primary" ghost>\u6309\u94AE</Button>
|
|
678
786
|
|
|
679
787
|
// \u8F6C\u6362\u4E3A Bify \u4EE3\u7801
|
|
680
788
|
import { Cell, CellGroup, Button } from '@fjyueke/bify-core';
|
|
@@ -682,19 +790,21 @@ import { Cell, CellGroup, Button } from '@fjyueke/bify-core';
|
|
|
682
790
|
<CellGroup>
|
|
683
791
|
<Cell title="\u6807\u9898" brief="\u63CF\u8FF0" clickable>\u5185\u5BB9</Cell>
|
|
684
792
|
</CellGroup>
|
|
685
|
-
<Button type="primary">\u6309\u94AE</Button>
|
|
793
|
+
<Button type="primary" outlined>\u6309\u94AE</Button>
|
|
686
794
|
\`\`\`
|
|
687
795
|
|
|
688
796
|
### \u5C5E\u6027\u6620\u5C04\u793A\u4F8B
|
|
689
797
|
|
|
690
|
-
| Arco \u5C5E\u6027 | Bify \u5C5E\u6027 |
|
|
691
|
-
|
|
692
|
-
| \`label\` | \`title\` |
|
|
693
|
-
| \`desc\` | \`brief\` |
|
|
694
|
-
| \`showArrow\` | \`clickable\` |
|
|
695
|
-
| \`visible\` | \`open\` |
|
|
696
|
-
| \`value\` | \`modelValue\` |
|
|
697
|
-
| \`ghost\` | \`
|
|
798
|
+
| Arco \u5C5E\u6027 | Bify \u5C5E\u6027 | \u8BF4\u660E |
|
|
799
|
+
|-----------|-----------|------|
|
|
800
|
+
| \`label\` | \`title\` | \u5355\u5143\u683C\u6807\u9898 |
|
|
801
|
+
| \`desc\` | \`brief\` | \u5355\u5143\u683C\u63CF\u8FF0 |
|
|
802
|
+
| \`showArrow\` | \`clickable\` | \u662F\u5426\u663E\u793A\u7BAD\u5934 |
|
|
803
|
+
| \`visible\` | \`open\` | \u5F39\u7A97\u663E\u793A\u72B6\u6001 |
|
|
804
|
+
| \`value\` | \`modelValue\` | \u8868\u5355\u503C\u7ED1\u5B9A |
|
|
805
|
+
| \`ghost\` | \`outlined\` | \u9542\u7A7A\u6309\u94AE\u6837\u5F0F |
|
|
806
|
+
| \`max\` | \`count\` | Rate \u6700\u5927\u6570\u91CF |
|
|
807
|
+
| \`percent\` | \`percentage\` | Progress \u767E\u5206\u6BD4 |
|
|
698
808
|
|
|
699
809
|
### \u8C03\u7528\u65B9\u5F0F
|
|
700
810
|
|