@fangzhongya/vue-archive 0.0.33 → 0.0.35
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/node/index.cjs +61 -23
- package/dist/node/index.js +61 -23
- package/dist/packages/components/compo/index.cjs +1 -1
- package/dist/packages/components/compo/index.js +2 -1
- package/dist/packages/components/use/code.cjs +9 -7
- package/dist/packages/components/use/code.js +85 -73
- package/dist/packages/components/use/util.cjs +3 -3
- package/dist/packages/components/use/util.d.ts +0 -8
- package/dist/packages/components/use/util.js +70 -70
- package/dist/packages/utils/common.d.ts +1 -0
- package/dist/packages/utils/glob.cjs +2 -2
- package/dist/packages/utils/glob.d.ts +1 -1
- package/dist/packages/utils/glob.js +226 -221
- package/dist/packages/utils/props.cjs +1 -1
- package/dist/packages/utils/props.js +6 -0
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -2037,7 +2037,7 @@ function getKeyMds(key) {
|
|
|
2037
2037
|
getTestObj(key);
|
|
2038
2038
|
return componentsObj[key].mds;
|
|
2039
2039
|
}
|
|
2040
|
-
async function getTestImportUrl(key, text, type, dir, url, comprops) {
|
|
2040
|
+
async function getTestImportUrl(key, text, type, dir, url, comprops, curprops) {
|
|
2041
2041
|
let arr = await getImport(text, type) || [];
|
|
2042
2042
|
let urs = url.split("/");
|
|
2043
2043
|
return arr.map((value) => {
|
|
@@ -2051,6 +2051,7 @@ async function getTestImportUrl(key, text, type, dir, url, comprops) {
|
|
|
2051
2051
|
key: ukey,
|
|
2052
2052
|
name: value,
|
|
2053
2053
|
comprops: comprops || "",
|
|
2054
|
+
curprops: curprops || "",
|
|
2054
2055
|
value: v,
|
|
2055
2056
|
suffix: getSuffix2(value),
|
|
2056
2057
|
head,
|
|
@@ -2078,6 +2079,7 @@ async function getTestImportUrl(key, text, type, dir, url, comprops) {
|
|
|
2078
2079
|
key: ukey,
|
|
2079
2080
|
name: v,
|
|
2080
2081
|
comprops: comprops || "",
|
|
2082
|
+
curprops: curprops || "",
|
|
2081
2083
|
value: v,
|
|
2082
2084
|
suffix: getSuffix2(value),
|
|
2083
2085
|
head,
|
|
@@ -2094,6 +2096,7 @@ async function getTestImportUrl(key, text, type, dir, url, comprops) {
|
|
|
2094
2096
|
key: value,
|
|
2095
2097
|
name: v,
|
|
2096
2098
|
comprops: comprops || "",
|
|
2099
|
+
curprops: curprops || "",
|
|
2097
2100
|
value: v,
|
|
2098
2101
|
suffix: getSuffix2(value),
|
|
2099
2102
|
head,
|
|
@@ -2180,9 +2183,10 @@ async function getPropsImport(text, obj) {
|
|
|
2180
2183
|
obj.suffix,
|
|
2181
2184
|
obj.dir,
|
|
2182
2185
|
obj.url,
|
|
2183
|
-
obj.comprops
|
|
2186
|
+
obj.comprops,
|
|
2187
|
+
obj.curprops
|
|
2184
2188
|
)).filter((v) => {
|
|
2185
|
-
return isComprops(v.key, obj.comprops || "");
|
|
2189
|
+
return isComprops(v.key, obj.comprops || "") || isCurprops(v.key, obj.curprops || "");
|
|
2186
2190
|
});
|
|
2187
2191
|
ts = await getPropsTexts(arr) + ts;
|
|
2188
2192
|
}
|
|
@@ -2236,7 +2240,8 @@ async function getComponentsProps(text, obj) {
|
|
|
2236
2240
|
obj.suffix,
|
|
2237
2241
|
obj.dir,
|
|
2238
2242
|
obj.url,
|
|
2239
|
-
obj.comprops || ""
|
|
2243
|
+
obj.comprops || "",
|
|
2244
|
+
obj.curprops
|
|
2240
2245
|
)).filter((v) => {
|
|
2241
2246
|
return isComprops(v.key, obj.comprops || "") || isCurprops(v.key, obj.curprops || "");
|
|
2242
2247
|
});
|
|
@@ -2331,6 +2336,19 @@ var props = {
|
|
|
2331
2336
|
} else {
|
|
2332
2337
|
return "";
|
|
2333
2338
|
}
|
|
2339
|
+
},
|
|
2340
|
+
return(obj) {
|
|
2341
|
+
if (obj.return) {
|
|
2342
|
+
let t = obj.return.type;
|
|
2343
|
+
if (t) {
|
|
2344
|
+
t = `[${t}]`;
|
|
2345
|
+
}
|
|
2346
|
+
return t + (obj.return.description || obj.return.name);
|
|
2347
|
+
} else if (obj.props) {
|
|
2348
|
+
return obj.props.return;
|
|
2349
|
+
} else {
|
|
2350
|
+
return "";
|
|
2351
|
+
}
|
|
2334
2352
|
}
|
|
2335
2353
|
};
|
|
2336
2354
|
var emits = {
|
|
@@ -3166,9 +3184,9 @@ var splitIgnoringNesting = (str, delimiter) => {
|
|
|
3166
3184
|
return parts;
|
|
3167
3185
|
};
|
|
3168
3186
|
var parseTypeDefinition = (typeDef) => {
|
|
3169
|
-
if (!typeDef
|
|
3187
|
+
if (!typeDef) {
|
|
3170
3188
|
return { type: "any", dataType: ["any"] };
|
|
3171
|
-
} else if (typeDef.startsWith("[") && typeDef.endsWith("]")) {
|
|
3189
|
+
} else if (typeDef.startsWith("[") && typeDef.endsWith("]") || typeDef.startsWith("(") && typeDef.endsWith(")")) {
|
|
3172
3190
|
const inner = typeDef.slice(1, -1).trim();
|
|
3173
3191
|
if (!inner) return { type: "any", dataType: ["any"] };
|
|
3174
3192
|
const types = splitIgnoringNesting(inner, ",");
|
|
@@ -3202,7 +3220,6 @@ function parseParamString(input) {
|
|
|
3202
3220
|
const typeDefStart = nameMatch[0].length;
|
|
3203
3221
|
const typeDef = trimmedPart.substring(typeDefStart).trim();
|
|
3204
3222
|
let bracketStack = [];
|
|
3205
|
-
let endIndex = -1;
|
|
3206
3223
|
let t = "";
|
|
3207
3224
|
let description = "";
|
|
3208
3225
|
for (let i = 0; i < typeDef.length; i++) {
|
|
@@ -3213,9 +3230,13 @@ function parseParamString(input) {
|
|
|
3213
3230
|
bracketStack.pop();
|
|
3214
3231
|
}
|
|
3215
3232
|
if (bracketStack.length === 0 && i > 0) {
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3233
|
+
if (i == 1 && char !== "]" && char !== ">" && char !== ")") {
|
|
3234
|
+
t = "";
|
|
3235
|
+
description = typeDef.substring(0);
|
|
3236
|
+
} else {
|
|
3237
|
+
t = typeDef.substring(0, i + 1).trim();
|
|
3238
|
+
description = typeDef.substring(i + 1);
|
|
3239
|
+
}
|
|
3219
3240
|
break;
|
|
3220
3241
|
}
|
|
3221
3242
|
}
|
|
@@ -3280,7 +3301,6 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3280
3301
|
const sp = getSpecObjs(es, name) || {};
|
|
3281
3302
|
const s = sp.selectable || "";
|
|
3282
3303
|
const css = parseParamString(s);
|
|
3283
|
-
console.log(css);
|
|
3284
3304
|
const cs = getParameStr(css);
|
|
3285
3305
|
sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
|
|
3286
3306
|
sarr.push("function " + strs + "(" + cs + ") {");
|
|
@@ -3310,10 +3330,11 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3310
3330
|
sarr.unshift("import { ref } from 'vue';");
|
|
3311
3331
|
}
|
|
3312
3332
|
if (typeof val == "undefined") {
|
|
3313
|
-
|
|
3314
|
-
|
|
3333
|
+
if (t.type == "function") {
|
|
3334
|
+
const tv = getTypeValueFunction(sp);
|
|
3315
3335
|
sarr.push("const " + z + " = " + tv + ";");
|
|
3316
3336
|
} else {
|
|
3337
|
+
const tv = getTypeValue(t.dataType);
|
|
3317
3338
|
sarr.push(
|
|
3318
3339
|
"const " + z + " = ref(" + (tv === "undefined" ? "" : tv) + ");"
|
|
3319
3340
|
);
|
|
@@ -3429,6 +3450,18 @@ ${vueFormat(getFunBody(st.body), " ")}
|
|
|
3429
3450
|
return "undefined";
|
|
3430
3451
|
}
|
|
3431
3452
|
}
|
|
3453
|
+
function getTypeValueFunction(sp) {
|
|
3454
|
+
const css = parseParamString(sp.selectable);
|
|
3455
|
+
const cs = getParameStr(css);
|
|
3456
|
+
let rs = "";
|
|
3457
|
+
if (sp.return) {
|
|
3458
|
+
rs = "return ";
|
|
3459
|
+
}
|
|
3460
|
+
let body = `{
|
|
3461
|
+
${vueFormat(getFunBody(rs), " ")}
|
|
3462
|
+
}`;
|
|
3463
|
+
return `function (${cs}) ${body}`;
|
|
3464
|
+
}
|
|
3432
3465
|
function getChange(str) {
|
|
3433
3466
|
const tr = str.trim();
|
|
3434
3467
|
if (/^\(/.test(tr)) {
|
|
@@ -3459,15 +3492,19 @@ function getSpecType(val) {
|
|
|
3459
3492
|
let selectable = (val?.selectable || "").trim();
|
|
3460
3493
|
let arr = [];
|
|
3461
3494
|
if (selectable && type != "boolean") {
|
|
3462
|
-
selectable.
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3495
|
+
if (selectable.includes("|")) {
|
|
3496
|
+
selectable.split("|").forEach((v) => {
|
|
3497
|
+
if (v) {
|
|
3498
|
+
let z = v.split(":");
|
|
3499
|
+
arr.push({
|
|
3500
|
+
label: v,
|
|
3501
|
+
prop: z[0].trim()
|
|
3502
|
+
});
|
|
3503
|
+
}
|
|
3504
|
+
});
|
|
3505
|
+
} else {
|
|
3506
|
+
arr = parseParamString(selectable);
|
|
3507
|
+
}
|
|
3471
3508
|
if (type == "function") {
|
|
3472
3509
|
type = "function";
|
|
3473
3510
|
} else if (type == "array") {
|
|
@@ -3606,7 +3643,8 @@ function setProps(obj) {
|
|
|
3606
3643
|
"default",
|
|
3607
3644
|
"selectable",
|
|
3608
3645
|
"description",
|
|
3609
|
-
"descriptions"
|
|
3646
|
+
"descriptions",
|
|
3647
|
+
"return"
|
|
3610
3648
|
];
|
|
3611
3649
|
let fobj = getFilter2(obj, arr);
|
|
3612
3650
|
let value = {};
|
package/dist/node/index.js
CHANGED
|
@@ -2022,7 +2022,7 @@ function getKeyMds(key) {
|
|
|
2022
2022
|
getTestObj(key);
|
|
2023
2023
|
return componentsObj[key].mds;
|
|
2024
2024
|
}
|
|
2025
|
-
async function getTestImportUrl(key, text, type, dir, url, comprops) {
|
|
2025
|
+
async function getTestImportUrl(key, text, type, dir, url, comprops, curprops) {
|
|
2026
2026
|
let arr = await getImport(text, type) || [];
|
|
2027
2027
|
let urs = url.split("/");
|
|
2028
2028
|
return arr.map((value) => {
|
|
@@ -2036,6 +2036,7 @@ async function getTestImportUrl(key, text, type, dir, url, comprops) {
|
|
|
2036
2036
|
key: ukey,
|
|
2037
2037
|
name: value,
|
|
2038
2038
|
comprops: comprops || "",
|
|
2039
|
+
curprops: curprops || "",
|
|
2039
2040
|
value: v,
|
|
2040
2041
|
suffix: getSuffix2(value),
|
|
2041
2042
|
head,
|
|
@@ -2063,6 +2064,7 @@ async function getTestImportUrl(key, text, type, dir, url, comprops) {
|
|
|
2063
2064
|
key: ukey,
|
|
2064
2065
|
name: v,
|
|
2065
2066
|
comprops: comprops || "",
|
|
2067
|
+
curprops: curprops || "",
|
|
2066
2068
|
value: v,
|
|
2067
2069
|
suffix: getSuffix2(value),
|
|
2068
2070
|
head,
|
|
@@ -2079,6 +2081,7 @@ async function getTestImportUrl(key, text, type, dir, url, comprops) {
|
|
|
2079
2081
|
key: value,
|
|
2080
2082
|
name: v,
|
|
2081
2083
|
comprops: comprops || "",
|
|
2084
|
+
curprops: curprops || "",
|
|
2082
2085
|
value: v,
|
|
2083
2086
|
suffix: getSuffix2(value),
|
|
2084
2087
|
head,
|
|
@@ -2165,9 +2168,10 @@ async function getPropsImport(text, obj) {
|
|
|
2165
2168
|
obj.suffix,
|
|
2166
2169
|
obj.dir,
|
|
2167
2170
|
obj.url,
|
|
2168
|
-
obj.comprops
|
|
2171
|
+
obj.comprops,
|
|
2172
|
+
obj.curprops
|
|
2169
2173
|
)).filter((v) => {
|
|
2170
|
-
return isComprops(v.key, obj.comprops || "");
|
|
2174
|
+
return isComprops(v.key, obj.comprops || "") || isCurprops(v.key, obj.curprops || "");
|
|
2171
2175
|
});
|
|
2172
2176
|
ts = await getPropsTexts(arr) + ts;
|
|
2173
2177
|
}
|
|
@@ -2221,7 +2225,8 @@ async function getComponentsProps(text, obj) {
|
|
|
2221
2225
|
obj.suffix,
|
|
2222
2226
|
obj.dir,
|
|
2223
2227
|
obj.url,
|
|
2224
|
-
obj.comprops || ""
|
|
2228
|
+
obj.comprops || "",
|
|
2229
|
+
obj.curprops
|
|
2225
2230
|
)).filter((v) => {
|
|
2226
2231
|
return isComprops(v.key, obj.comprops || "") || isCurprops(v.key, obj.curprops || "");
|
|
2227
2232
|
});
|
|
@@ -2316,6 +2321,19 @@ var props = {
|
|
|
2316
2321
|
} else {
|
|
2317
2322
|
return "";
|
|
2318
2323
|
}
|
|
2324
|
+
},
|
|
2325
|
+
return(obj) {
|
|
2326
|
+
if (obj.return) {
|
|
2327
|
+
let t = obj.return.type;
|
|
2328
|
+
if (t) {
|
|
2329
|
+
t = `[${t}]`;
|
|
2330
|
+
}
|
|
2331
|
+
return t + (obj.return.description || obj.return.name);
|
|
2332
|
+
} else if (obj.props) {
|
|
2333
|
+
return obj.props.return;
|
|
2334
|
+
} else {
|
|
2335
|
+
return "";
|
|
2336
|
+
}
|
|
2319
2337
|
}
|
|
2320
2338
|
};
|
|
2321
2339
|
var emits = {
|
|
@@ -3151,9 +3169,9 @@ var splitIgnoringNesting = (str, delimiter) => {
|
|
|
3151
3169
|
return parts;
|
|
3152
3170
|
};
|
|
3153
3171
|
var parseTypeDefinition = (typeDef) => {
|
|
3154
|
-
if (!typeDef
|
|
3172
|
+
if (!typeDef) {
|
|
3155
3173
|
return { type: "any", dataType: ["any"] };
|
|
3156
|
-
} else if (typeDef.startsWith("[") && typeDef.endsWith("]")) {
|
|
3174
|
+
} else if (typeDef.startsWith("[") && typeDef.endsWith("]") || typeDef.startsWith("(") && typeDef.endsWith(")")) {
|
|
3157
3175
|
const inner = typeDef.slice(1, -1).trim();
|
|
3158
3176
|
if (!inner) return { type: "any", dataType: ["any"] };
|
|
3159
3177
|
const types = splitIgnoringNesting(inner, ",");
|
|
@@ -3187,7 +3205,6 @@ function parseParamString(input) {
|
|
|
3187
3205
|
const typeDefStart = nameMatch[0].length;
|
|
3188
3206
|
const typeDef = trimmedPart.substring(typeDefStart).trim();
|
|
3189
3207
|
let bracketStack = [];
|
|
3190
|
-
let endIndex = -1;
|
|
3191
3208
|
let t = "";
|
|
3192
3209
|
let description = "";
|
|
3193
3210
|
for (let i = 0; i < typeDef.length; i++) {
|
|
@@ -3198,9 +3215,13 @@ function parseParamString(input) {
|
|
|
3198
3215
|
bracketStack.pop();
|
|
3199
3216
|
}
|
|
3200
3217
|
if (bracketStack.length === 0 && i > 0) {
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3218
|
+
if (i == 1 && char !== "]" && char !== ">" && char !== ")") {
|
|
3219
|
+
t = "";
|
|
3220
|
+
description = typeDef.substring(0);
|
|
3221
|
+
} else {
|
|
3222
|
+
t = typeDef.substring(0, i + 1).trim();
|
|
3223
|
+
description = typeDef.substring(i + 1);
|
|
3224
|
+
}
|
|
3204
3225
|
break;
|
|
3205
3226
|
}
|
|
3206
3227
|
}
|
|
@@ -3265,7 +3286,6 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3265
3286
|
const sp = getSpecObjs(es, name) || {};
|
|
3266
3287
|
const s = sp.selectable || "";
|
|
3267
3288
|
const css = parseParamString(s);
|
|
3268
|
-
console.log(css);
|
|
3269
3289
|
const cs = getParameStr(css);
|
|
3270
3290
|
sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
|
|
3271
3291
|
sarr.push("function " + strs + "(" + cs + ") {");
|
|
@@ -3295,10 +3315,11 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3295
3315
|
sarr.unshift("import { ref } from 'vue';");
|
|
3296
3316
|
}
|
|
3297
3317
|
if (typeof val == "undefined") {
|
|
3298
|
-
|
|
3299
|
-
|
|
3318
|
+
if (t.type == "function") {
|
|
3319
|
+
const tv = getTypeValueFunction(sp);
|
|
3300
3320
|
sarr.push("const " + z + " = " + tv + ";");
|
|
3301
3321
|
} else {
|
|
3322
|
+
const tv = getTypeValue(t.dataType);
|
|
3302
3323
|
sarr.push(
|
|
3303
3324
|
"const " + z + " = ref(" + (tv === "undefined" ? "" : tv) + ");"
|
|
3304
3325
|
);
|
|
@@ -3414,6 +3435,18 @@ ${vueFormat(getFunBody(st.body), " ")}
|
|
|
3414
3435
|
return "undefined";
|
|
3415
3436
|
}
|
|
3416
3437
|
}
|
|
3438
|
+
function getTypeValueFunction(sp) {
|
|
3439
|
+
const css = parseParamString(sp.selectable);
|
|
3440
|
+
const cs = getParameStr(css);
|
|
3441
|
+
let rs = "";
|
|
3442
|
+
if (sp.return) {
|
|
3443
|
+
rs = "return ";
|
|
3444
|
+
}
|
|
3445
|
+
let body = `{
|
|
3446
|
+
${vueFormat(getFunBody(rs), " ")}
|
|
3447
|
+
}`;
|
|
3448
|
+
return `function (${cs}) ${body}`;
|
|
3449
|
+
}
|
|
3417
3450
|
function getChange(str) {
|
|
3418
3451
|
const tr = str.trim();
|
|
3419
3452
|
if (/^\(/.test(tr)) {
|
|
@@ -3444,15 +3477,19 @@ function getSpecType(val) {
|
|
|
3444
3477
|
let selectable = (val?.selectable || "").trim();
|
|
3445
3478
|
let arr = [];
|
|
3446
3479
|
if (selectable && type != "boolean") {
|
|
3447
|
-
selectable.
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3480
|
+
if (selectable.includes("|")) {
|
|
3481
|
+
selectable.split("|").forEach((v) => {
|
|
3482
|
+
if (v) {
|
|
3483
|
+
let z = v.split(":");
|
|
3484
|
+
arr.push({
|
|
3485
|
+
label: v,
|
|
3486
|
+
prop: z[0].trim()
|
|
3487
|
+
});
|
|
3488
|
+
}
|
|
3489
|
+
});
|
|
3490
|
+
} else {
|
|
3491
|
+
arr = parseParamString(selectable);
|
|
3492
|
+
}
|
|
3456
3493
|
if (type == "function") {
|
|
3457
3494
|
type = "function";
|
|
3458
3495
|
} else if (type == "array") {
|
|
@@ -3591,7 +3628,8 @@ function setProps(obj) {
|
|
|
3591
3628
|
"default",
|
|
3592
3629
|
"selectable",
|
|
3593
3630
|
"description",
|
|
3594
|
-
"descriptions"
|
|
3631
|
+
"descriptions",
|
|
3632
|
+
"return"
|
|
3595
3633
|
];
|
|
3596
3634
|
let fobj = getFilter2(obj, arr);
|
|
3597
3635
|
let value = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../../utils/index.cjs");require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");require("@fangzhongya/utils/html/getVueText");const o=require("../../utils/props.cjs"),i={titles:[],propss:[],slots:[],emitss:[],exposes:[]};function x(e,s){let r=e.charAt(0),l=[['"','"'],["'","'"],["`","`"],["(",")"],["{","}"],["[","]"]],a=l.map(p=>p[0]).indexOf(r);if(a!=-1){let n=new RegExp("^"+l[a][0]+"((.|\\n|\\r)+?)"+l[a][1]+(s?"\\s":""),"gi").exec(e);if(n)return n[0]}}function E(e){delete e.problems,delete e.source;let s=e.tag,r=e.name,l=e.description,t=e.default,a="";if(s=="default")r=r.trim(),r=x(r)||r;else if(s=="selectable")r=r.trim();else{if(r.includes("=")){const m=r.split("=");r=m[0];const g=m[1]+" "+l,d=x(g,!0);d?(t=d,l=g.replace(d,"")):t=e.default||m[1]||""}const n=/\s*\((.*)\)\s/gi.exec(l);n&&n.length>0&&(a=n[1],l=l.replace(n[0],""))}return e.name=r,e.default=t||"",e.description=l,e.selectable=a,e}function q(e){let s=["title","text","author","date"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),b(l),r.arr.forEach(t=>{f(t.key,t.value)})}function b(e){i.titles.push(e)}function O(e){let s=["props","name","type","default","selectable","description","descriptions"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"props"),r.arr.forEach(t=>{f(t.key,t.value)})}function T(e){let s=["slot","name","selectable","description","descriptions"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"slot"),r.arr.forEach(t=>{f(t.key,t.value)})}function y(e){let s=["emits","name","selectable","description","descriptions"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"emits"),r.arr.forEach(t=>{f(t.key,t.value)})}function j(e){let s=["expose","name","type","return","selectable","description","descriptions"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"expose"),r.arr.forEach(t=>{f(t.key,t.value)})}function c(e,s){const r=i[s+"name"]||[],l=e.name??e[s]?.name,t=r.indexOf(l);t>=0&&(i[s+"s"].splice(t,1),r.splice(t,1)),i[s+"s"].push(e),r.push(l),i[s+"name"]=r}function w(){Object.keys(i).forEach(e=>{i[e]=[]})}function u(e,s){const r={descriptions:e?.description||""},l=[];return e?.tags&&e.tags?.forEach(t=>{let a=t.tag,p=E(t);if(!r.hasOwnProperty(a))r[a]=p;else{const n={};n[a]=p,l.push({key:a,value:n})}}),{arr:l,obj:r}}function f(e,s){switch(e){case"title":return b(s),!0;case"text":return b(s),!0;case"props":return c(s,"props"),!0;case"slot":return c(s,"slot"),!0;case"emits":return c(s,"emits"),!0;case"expose":return c(s,"expose"),!0;default:return!1}}function k(e,s){switch(e){case"title":return q(s),!0;case"props":return O(s),!0;case"slot":return T(s),!0;case"emits":return y(s),!0;case"expose":return j(s),!0;default:return!1}}function N(e){return w(),e?.forEach(s=>{let r=s?.tags||[],l=r?.length||0;if(l>0)for(let t=0;t<l;t++){const a=r[t]||{};if(k(a.tag,s))break}}),i}function P(e){let s=h.getTextNotes(e);return N(s)}const S=[{label:"属性名",prop:"name",formatter:o.props.name},{label:"说明",prop:"description",formatter:o.props.description},{label:"类型",prop:"type",formatter:o.props.type},{label:"可选值",prop:"selectable",formatter:o.props.selectable},{label:"默认值",prop:"default",formatter:o.props.default}],F=[{label:"事件名",prop:"name",formatter:o.emits.name},{label:"说明",prop:"description",formatter:o.emits.description},{label:"回调参数",prop:"selectable",formatter:o.emits.selectable}],v=[{label:"方法名",prop:"name",formatter:o.expose.name},{label:"说明",prop:"description",formatter:o.expose.description},{label:"参数",prop:"selectable",formatter:o.expose.selectable},{label:"返回值",prop:"type",formatter(e){return o.expose.return(e)??o.expose.type(e)}}],z=[{label:"插槽名",prop:"name",formatter:o.slot.name},{label:"说明",prop:"description",formatter:o.slot.description},{label:"作用域参数",prop:"selectable",formatter:o.slot.selectable}];exports.getNotesText=P;exports.temits=F;exports.texpose=v;exports.tprops=S;exports.tslot=z;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../../utils/index.cjs");require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");require("@fangzhongya/utils/html/getVueText");const o=require("../../utils/props.cjs"),i={titles:[],propss:[],slots:[],emitss:[],exposes:[]};function x(e,s){let r=e.charAt(0),l=[['"','"'],["'","'"],["`","`"],["(",")"],["{","}"],["[","]"]],a=l.map(p=>p[0]).indexOf(r);if(a!=-1){let n=new RegExp("^"+l[a][0]+"((.|\\n|\\r)+?)"+l[a][1]+(s?"\\s":""),"gi").exec(e);if(n)return n[0]}}function E(e){delete e.problems,delete e.source;let s=e.tag,r=e.name,l=e.description,t=e.default,a="";if(s=="default")r=r.trim(),r=x(r)||r;else if(s=="selectable")r=r.trim();else{if(r.includes("=")){const m=r.split("=");r=m[0];const g=m[1]+" "+l,d=x(g,!0);d?(t=d,l=g.replace(d,"")):t=e.default||m[1]||""}const n=/\s*\((.*)\)\s/gi.exec(l);n&&n.length>0&&(a=n[1],l=l.replace(n[0],""))}return e.name=r,e.default=t||"",e.description=l,e.selectable=a,e}function q(e){let s=["title","text","author","date"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),b(l),r.arr.forEach(t=>{f(t.key,t.value)})}function b(e){i.titles.push(e)}function O(e){let s=["props","name","type","default","selectable","description","descriptions","return"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"props"),r.arr.forEach(t=>{f(t.key,t.value)})}function T(e){let s=["slot","name","selectable","description","descriptions"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"slot"),r.arr.forEach(t=>{f(t.key,t.value)})}function y(e){let s=["emits","name","selectable","description","descriptions"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"emits"),r.arr.forEach(t=>{f(t.key,t.value)})}function j(e){let s=["expose","name","type","return","selectable","description","descriptions"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"expose"),r.arr.forEach(t=>{f(t.key,t.value)})}function c(e,s){const r=i[s+"name"]||[],l=e.name??e[s]?.name,t=r.indexOf(l);t>=0&&(i[s+"s"].splice(t,1),r.splice(t,1)),i[s+"s"].push(e),r.push(l),i[s+"name"]=r}function w(){Object.keys(i).forEach(e=>{i[e]=[]})}function u(e,s){const r={descriptions:e?.description||""},l=[];return e?.tags&&e.tags?.forEach(t=>{let a=t.tag,p=E(t);if(!r.hasOwnProperty(a))r[a]=p;else{const n={};n[a]=p,l.push({key:a,value:n})}}),{arr:l,obj:r}}function f(e,s){switch(e){case"title":return b(s),!0;case"text":return b(s),!0;case"props":return c(s,"props"),!0;case"slot":return c(s,"slot"),!0;case"emits":return c(s,"emits"),!0;case"expose":return c(s,"expose"),!0;default:return!1}}function k(e,s){switch(e){case"title":return q(s),!0;case"props":return O(s),!0;case"slot":return T(s),!0;case"emits":return y(s),!0;case"expose":return j(s),!0;default:return!1}}function N(e){return w(),e?.forEach(s=>{let r=s?.tags||[],l=r?.length||0;if(l>0)for(let t=0;t<l;t++){const a=r[t]||{};if(k(a.tag,s))break}}),i}function P(e){let s=h.getTextNotes(e);return N(s)}const S=[{label:"属性名",prop:"name",formatter:o.props.name},{label:"说明",prop:"description",formatter:o.props.description},{label:"类型",prop:"type",formatter:o.props.type},{label:"可选值",prop:"selectable",formatter:o.props.selectable},{label:"默认值",prop:"default",formatter:o.props.default}],F=[{label:"事件名",prop:"name",formatter:o.emits.name},{label:"说明",prop:"description",formatter:o.emits.description},{label:"回调参数",prop:"selectable",formatter:o.emits.selectable}],v=[{label:"方法名",prop:"name",formatter:o.expose.name},{label:"说明",prop:"description",formatter:o.expose.description},{label:"参数",prop:"selectable",formatter:o.expose.selectable},{label:"返回值",prop:"type",formatter(e){return o.expose.return(e)??o.expose.type(e)}}],z=[{label:"插槽名",prop:"name",formatter:o.slot.name},{label:"说明",prop:"description",formatter:o.slot.description},{label:"作用域参数",prop:"selectable",formatter:o.slot.selectable}];exports.getNotesText=P;exports.temits=F;exports.texpose=v;exports.tprops=S;exports.tslot=z;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");const C=require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");const H=require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");const E=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const f=require("./util.cjs"),q=require("../../utils/props.cjs"),J=require("@fangzhongya/utils/basic/string/toFunction"),N=["class"];function j(s,t){return s.filter(e=>e.name==t)[0]}function P(s){return s.map(t=>(t.prop||"...arr")+":"+f.setDataType(t.dataType)).join(",")}function A(s,t,e,o,u,$){const p=[],n=[];let b=!0;const L=q.getPropsValue(t.propss||[]),x=q.getEmitsValue(t.emitss||[]),z=q.getExposeValue(t.exposes||[]),B=q.getSlotValue(t.slots||[]);Object.keys(e).forEach(r=>{let m=e[r];if(/^on[A-Z]/.test(r)&&typeof m=="function"){let i=r.substring(2);const c=r.split(":");let h;if(c.length>1?(h=c[0]+c.slice(1).map(a=>E.firstUpper(a)).join(""),i=H.firstLower(i)):(h=c[0],i=C.humpToLine(i)),c.includes("-")){let a=h.split("-");a=a.map((g,F)=>F!=0?E.firstUpper(g):g),h=a.join("")}p.push(" @"+i+'="'+h+'"');const l=j(x,i)||{},y=l.selectable||"",S=f.parseParamString(y),d=P(S);n.push(`// ${l.description} ${l.name}: (${l.selectable})`),n.push("function "+h+"("+d+") {"),S.forEach(a=>{const g=a.name||"arr";n.push(" console.log('"+a.label+"', "+g+")")}),n.push("}")}else{let i=r;N.includes(r)&&(i=r+"1"),p.push(" :"+r+'="'+i+'"');const c=j(L,r)||{},h=D(c);if(n.push(`// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`),typeof m=="function")n.push("const "+r+" = "+O(m,r,u));else if(b&&(b=!1,n.unshift("import { ref } from 'vue';")),typeof m>"u")if(h.type=="function"){const l=Z(c);n.push("const "+i+" = "+l+";")}else{const l=f.getTypeValue(h.dataType);n.push("const "+i+" = ref("+(l==="undefined"?"":l)+");")}else{let l=T(m,r,u);n.push("const "+i+" = ref("+l+");")}}});const V=Object.values($||{});V.length>0&&(b&&(b=!1,n.unshift("import { ref } from 'vue';")),p.unshift(' ref="refDom"'),n.push("const refDom = ref()"),V.forEach(r=>{const m=j(z,r.name)||{};n.push(`// ${m.description} ${m.name}:(${m.selectable}) ${m.type}`);const i=r.name+"Value",c=f.parseParamString(m?.selectable||""),h=[],l=r.params||[];c.forEach((y,S)=>{const d=y.name;if(d){const a=d+r.name,g=l[S];if(n.push(`// ${y.label}`),typeof g=="function")n.push("const "+a+" = "+O(g,d,r.text));else if(typeof g>"u")n.push("const "+a+" = "+f.getTypeValue(y.dataType)+";");else{let F=T(g,d,r.text);n.push("const "+a+" = "+F+";")}h.push(a)}}),r.type==="function"?n.push(`const ${i} = refDom.value?.${r.name}(${h.join(", ")})`):n.push(`const ${i} = refDom.value?.${r.name}`),n.push(`console.log('"${m.type}"', ${i})`)})),p.length>0&&p.unshift("");const U=M(o,B);return`<!--${s}-->
|
|
2
2
|
<template>
|
|
3
3
|
<div>
|
|
4
|
-
<${s}${
|
|
4
|
+
<${s}${p.join(`
|
|
5
5
|
`)}>${U.join(`
|
|
6
6
|
`)}
|
|
7
7
|
</${s}>
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
${n.join(`
|
|
12
12
|
`)}
|
|
13
13
|
<\/script>
|
|
14
|
-
`}function M(s={},t){const e=[];return Object.keys(s).forEach(o=>{const
|
|
14
|
+
`}function M(s={},t){const e=[];return Object.keys(s).forEach(o=>{const u=j(t,o)||{},$=s[o];if($){const p=` <!-- ${u.description} ${u.name}:(${u.selectable}) -->
|
|
15
15
|
<template #${o}="scope">
|
|
16
|
-
${
|
|
17
|
-
</template>`;e.push(
|
|
18
|
-
${
|
|
19
|
-
}`;return`function (${t.param}) ${e}`}else return"undefined"}function Z(s){const t=
|
|
16
|
+
${f.vueFormat($," ")}
|
|
17
|
+
</template>`;e.push(p)}}),e&&e.length>0&&e.unshift(""),e}function O(s,t,e){const o=e?e[t]:"";return o||w(s.toString())}function w(s){const t=J.getFunctionFormat(f.prettierFormat(s));if(t){let e=`{
|
|
18
|
+
${f.vueFormat(f.getFunBody(t.body)," ")}
|
|
19
|
+
}`;return`function (${t.param}) ${e}`}else return"undefined"}function Z(s){const t=f.parseParamString(s.selectable),e=P(t);let o="";s.return&&(o="return ");let u=`{
|
|
20
|
+
${f.vueFormat(f.getFunBody(o)," ")}
|
|
21
|
+
}`;return`function (${e}) ${u}`}function G(s){const t=s.trim();return/^\(/.test(t)?w(t):JSON.stringify(s)}function T(s,t,e){const o=e?e[t]:"";return o||(typeof s=="string"?G(s+""):JSON.stringify(s))}function D(s){let t=I(s?.type),e="any";t.length==1&&(e=t[0].split("<")[0]);const o=e;let u=(s?.selectable||"").trim(),$=[];return u&&e!="boolean"&&(u.includes("|")?u.split("|").forEach(p=>{if(p){let n=p.split(":");$.push({label:p,prop:n[0].trim()})}}):$=f.parseParamString(u),e=="function"?e="function":e=="array"?e="choice":e="select"),{arr:$,zdtype:o,type:e,dataType:t}}function I(s){let t=[];return(s||"").trim().toLowerCase().split(",").forEach(o=>{o=o.trim(),o&&t.push(o)}),[...new Set(t)].sort()}exports.getHmtl=A;exports.getSpecType=D;exports.setValStringify=T;
|