@fangzhongya/vue-archive 0.0.20 → 0.0.22
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 +107 -51
- package/dist/node/index.js +107 -51
- package/dist/packages/components/use/code.cjs +11 -10
- package/dist/packages/components/use/code.js +126 -110
- package/dist/packages/components/use/util.cjs +2 -2
- package/dist/packages/components/use/util.d.ts +2 -0
- package/dist/packages/components/use/util.js +59 -34
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -2475,6 +2475,15 @@ function getExposeValue(arr) {
|
|
|
2475
2475
|
return v;
|
|
2476
2476
|
});
|
|
2477
2477
|
}
|
|
2478
|
+
function getSlotValue(arr) {
|
|
2479
|
+
return arr.map((obj) => {
|
|
2480
|
+
const v = {};
|
|
2481
|
+
Object.keys(slot).forEach((key) => {
|
|
2482
|
+
v[key] = slot[key](obj);
|
|
2483
|
+
});
|
|
2484
|
+
return v;
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2478
2487
|
|
|
2479
2488
|
// packages/components/test/index.ts
|
|
2480
2489
|
function getObj(v) {
|
|
@@ -3106,6 +3115,29 @@ function getSonType(type) {
|
|
|
3106
3115
|
}
|
|
3107
3116
|
return arr;
|
|
3108
3117
|
}
|
|
3118
|
+
function getTypeValue(arr) {
|
|
3119
|
+
const type = (arr[0] || "any").toLowerCase();
|
|
3120
|
+
switch (type) {
|
|
3121
|
+
case "string":
|
|
3122
|
+
return '""';
|
|
3123
|
+
case "boolean":
|
|
3124
|
+
return "false";
|
|
3125
|
+
case "number":
|
|
3126
|
+
return "0";
|
|
3127
|
+
case "array":
|
|
3128
|
+
let v = getTypeValue(arr.splice(1));
|
|
3129
|
+
v = v == "undefined" ? "" : v;
|
|
3130
|
+
return `[${v}]`;
|
|
3131
|
+
case "object":
|
|
3132
|
+
return "{}";
|
|
3133
|
+
case "function":
|
|
3134
|
+
return "()=>{}";
|
|
3135
|
+
case "any":
|
|
3136
|
+
return '""';
|
|
3137
|
+
default:
|
|
3138
|
+
return "undefined";
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3109
3141
|
function getType(str) {
|
|
3110
3142
|
let arr = [];
|
|
3111
3143
|
if (str) {
|
|
@@ -3134,13 +3166,19 @@ function setDataType(arr) {
|
|
|
3134
3166
|
function getParametersObj(cs) {
|
|
3135
3167
|
let arrs = cs.split(",");
|
|
3136
3168
|
return arrs.map((key) => {
|
|
3169
|
+
let must = true;
|
|
3137
3170
|
let vs = key.split(":");
|
|
3138
|
-
let name = vs[0];
|
|
3171
|
+
let name = vs[0].trim();
|
|
3172
|
+
if (name.endsWith("?")) {
|
|
3173
|
+
must = false;
|
|
3174
|
+
name = name.substring(0, -1);
|
|
3175
|
+
}
|
|
3139
3176
|
let t = vs[1] || "";
|
|
3140
3177
|
let tarr = getSonType(getType(t));
|
|
3141
3178
|
return {
|
|
3142
3179
|
label: key,
|
|
3143
3180
|
prop: name,
|
|
3181
|
+
must,
|
|
3144
3182
|
type: tarr[0],
|
|
3145
3183
|
dataType: tarr,
|
|
3146
3184
|
description: t.substring(t.lastIndexOf("]") + 1)
|
|
@@ -3163,8 +3201,10 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3163
3201
|
const tarr = [];
|
|
3164
3202
|
const sarr = [];
|
|
3165
3203
|
let is = true;
|
|
3204
|
+
const ps = getPropsValue2(param.propss || []);
|
|
3166
3205
|
const es = getEmitsValue(param.emitss || []);
|
|
3167
3206
|
const res = getExposeValue(param.exposes || []);
|
|
3207
|
+
const ss = getSlotValue(param.slots || []);
|
|
3168
3208
|
Object.keys(value).forEach((key) => {
|
|
3169
3209
|
let val = value[key];
|
|
3170
3210
|
if (/^on[A-Z]/.test(key) && typeof val == "function") {
|
|
@@ -3190,9 +3230,11 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3190
3230
|
strs = arr.join("");
|
|
3191
3231
|
}
|
|
3192
3232
|
tarr.push(" @" + name + '="' + strs + '"');
|
|
3193
|
-
const
|
|
3233
|
+
const sp = getSpecObjs(es, name);
|
|
3234
|
+
const s = sp.selectable || "";
|
|
3194
3235
|
const css = getParametersObj(s);
|
|
3195
3236
|
const cs = getParameStr(css);
|
|
3237
|
+
sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
|
|
3196
3238
|
sarr.push("function " + strs + "(" + cs + ") {");
|
|
3197
3239
|
css.forEach((o) => {
|
|
3198
3240
|
const name2 = o.prop || "arr";
|
|
@@ -3207,6 +3249,12 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3207
3249
|
z = key + "1";
|
|
3208
3250
|
}
|
|
3209
3251
|
tarr.push(" :" + key + '="' + z + '"');
|
|
3252
|
+
const sp = getSpecObjs(ps, key);
|
|
3253
|
+
const t = getSpecType(sp);
|
|
3254
|
+
sarr.push(
|
|
3255
|
+
`// ${sp.description} ${sp.name}: {${sp.type}} (${sp.selectable})`
|
|
3256
|
+
);
|
|
3257
|
+
console.log("val", val);
|
|
3210
3258
|
if (typeof val == "function") {
|
|
3211
3259
|
sarr.push(
|
|
3212
3260
|
"const " + key + " = " + getFunctionBody(val, key, propsText)
|
|
@@ -3217,7 +3265,14 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3217
3265
|
sarr.unshift("import { ref } from 'vue';");
|
|
3218
3266
|
}
|
|
3219
3267
|
if (typeof val == "undefined") {
|
|
3220
|
-
|
|
3268
|
+
const tv = getTypeValue(t.dataType);
|
|
3269
|
+
if (tv == "()=>{}") {
|
|
3270
|
+
sarr.push("const " + z + " = " + tv + ";");
|
|
3271
|
+
} else {
|
|
3272
|
+
sarr.push(
|
|
3273
|
+
"const " + z + " = ref(" + (tv === "undefined" ? "" : tv) + ");"
|
|
3274
|
+
);
|
|
3275
|
+
}
|
|
3221
3276
|
} else {
|
|
3222
3277
|
let st2 = setValStringify(val, key, propsText);
|
|
3223
3278
|
sarr.push("const " + z + " = ref(" + st2 + ");");
|
|
@@ -3234,27 +3289,36 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3234
3289
|
tarr.unshift(' ref="refDom"');
|
|
3235
3290
|
sarr.push("const refDom = ref()");
|
|
3236
3291
|
ev.forEach((v) => {
|
|
3237
|
-
sarr.push(`-------${v.name}--------`);
|
|
3238
3292
|
const s = getSpecObjs(res, v.name);
|
|
3293
|
+
sarr.push(
|
|
3294
|
+
`// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
|
|
3295
|
+
);
|
|
3239
3296
|
const m = v.name + "Value";
|
|
3240
3297
|
const css = getParametersObj(s?.selectable || "");
|
|
3241
3298
|
const cs = [];
|
|
3242
|
-
v.params
|
|
3243
|
-
|
|
3244
|
-
const
|
|
3245
|
-
if (
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
);
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3299
|
+
const ps2 = v.params || [];
|
|
3300
|
+
css.forEach((c, index) => {
|
|
3301
|
+
const prop = c.prop;
|
|
3302
|
+
if (prop) {
|
|
3303
|
+
const key = prop + v.name;
|
|
3304
|
+
const val = ps2[index];
|
|
3305
|
+
sarr.push(`// ${c.label}`);
|
|
3306
|
+
if (typeof val == "function") {
|
|
3307
|
+
sarr.push(
|
|
3308
|
+
"const " + key + " = " + getFunctionBody(val, prop, v.text)
|
|
3309
|
+
);
|
|
3252
3310
|
} else {
|
|
3253
|
-
|
|
3254
|
-
|
|
3311
|
+
if (typeof val == "undefined") {
|
|
3312
|
+
sarr.push(
|
|
3313
|
+
"const " + key + " = " + getTypeValue(c.dataType) + ";"
|
|
3314
|
+
);
|
|
3315
|
+
} else {
|
|
3316
|
+
let st2 = setValStringify(val, prop, v.text);
|
|
3317
|
+
sarr.push("const " + key + " = " + st2 + ";");
|
|
3318
|
+
}
|
|
3255
3319
|
}
|
|
3320
|
+
cs.push(key);
|
|
3256
3321
|
}
|
|
3257
|
-
cs.push(key);
|
|
3258
3322
|
});
|
|
3259
3323
|
if (v.type === "function") {
|
|
3260
3324
|
sarr.push(
|
|
@@ -3263,13 +3327,13 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3263
3327
|
} else {
|
|
3264
3328
|
sarr.push(`const ${m} = refDom.value?.${v.name}`);
|
|
3265
3329
|
}
|
|
3266
|
-
sarr.push(`console.log('"${s.
|
|
3330
|
+
sarr.push(`console.log('"${s.type}"', ${m})`);
|
|
3267
3331
|
});
|
|
3268
3332
|
}
|
|
3269
3333
|
if (tarr.length > 0) {
|
|
3270
3334
|
tarr.unshift("");
|
|
3271
3335
|
}
|
|
3272
|
-
const slots = getSlots(slotValue);
|
|
3336
|
+
const slots = getSlots(slotValue, ss);
|
|
3273
3337
|
const st = `<!--${propsname}-->
|
|
3274
3338
|
<template>
|
|
3275
3339
|
<div>
|
|
@@ -3283,12 +3347,14 @@ ${sarr.join("\n")}
|
|
|
3283
3347
|
`;
|
|
3284
3348
|
return st;
|
|
3285
3349
|
}
|
|
3286
|
-
function getSlots(obj = {}) {
|
|
3350
|
+
function getSlots(obj = {}, ss) {
|
|
3287
3351
|
const arr = [];
|
|
3288
3352
|
Object.keys(obj).forEach((key) => {
|
|
3353
|
+
const sp = getSpecObjs(ss, key);
|
|
3289
3354
|
const v = obj[key];
|
|
3290
3355
|
if (v) {
|
|
3291
|
-
const st = `
|
|
3356
|
+
const st = ` <!-- ${sp.description} ${sp.name}\uFF1A(${sp.selectable}) -->
|
|
3357
|
+
<template #${key}="scope">
|
|
3292
3358
|
${vueFormat(v, " ")}
|
|
3293
3359
|
</template>`;
|
|
3294
3360
|
arr.push(st);
|
|
@@ -3313,7 +3379,7 @@ function funstr(v) {
|
|
|
3313
3379
|
let body = `{
|
|
3314
3380
|
${vueFormat(getFunBody(st.body), " ")}
|
|
3315
3381
|
}`;
|
|
3316
|
-
return `function ${st.param} ${body}`;
|
|
3382
|
+
return `function (${st.param}) ${body}`;
|
|
3317
3383
|
} else {
|
|
3318
3384
|
return "undefined";
|
|
3319
3385
|
}
|
|
@@ -3837,15 +3903,6 @@ function gettests(obj, arr, n) {
|
|
|
3837
3903
|
}
|
|
3838
3904
|
}
|
|
3839
3905
|
}
|
|
3840
|
-
function getFFParam(str) {
|
|
3841
|
-
str = str.trim();
|
|
3842
|
-
if (str && str.length > 2) {
|
|
3843
|
-
return str.substring(1, str.length - 1).split(",").map((k) => {
|
|
3844
|
-
return (k.split(":")[0] || "").trim();
|
|
3845
|
-
});
|
|
3846
|
-
}
|
|
3847
|
-
return [];
|
|
3848
|
-
}
|
|
3849
3906
|
function getObjValue(d) {
|
|
3850
3907
|
try {
|
|
3851
3908
|
return new Function(`{ return ${d} }`)();
|
|
@@ -3854,29 +3911,16 @@ function getObjValue(d) {
|
|
|
3854
3911
|
}
|
|
3855
3912
|
}
|
|
3856
3913
|
function getDefaultValue(obj) {
|
|
3857
|
-
const vo = getSpecType(obj)
|
|
3914
|
+
const vo = getSpecType(obj);
|
|
3915
|
+
const v = getTypeValue(vo.dataType);
|
|
3858
3916
|
const d = (obj.default || "").trim();
|
|
3859
|
-
|
|
3860
|
-
let fb = getFunctionFormat(d);
|
|
3861
|
-
if (fb) {
|
|
3862
|
-
return new Function(...getFFParam(fb.param), fb.body);
|
|
3863
|
-
}
|
|
3864
|
-
return new Function("{}");
|
|
3865
|
-
} else if (vo == "array") {
|
|
3866
|
-
return getObjValue(d || "[]");
|
|
3867
|
-
} else if (vo == "object") {
|
|
3868
|
-
return getObjValue(d || "{}");
|
|
3869
|
-
} else if (vo == "number") {
|
|
3870
|
-
return getObjValue(d || "1");
|
|
3871
|
-
} else if (vo == "boolean") {
|
|
3872
|
-
return getObjValue(d || "true");
|
|
3873
|
-
} else {
|
|
3874
|
-
return d;
|
|
3875
|
-
}
|
|
3917
|
+
return getObjValue(d || v);
|
|
3876
3918
|
}
|
|
3877
3919
|
function setVue(propsname, param, url) {
|
|
3878
3920
|
const ps = getPropsValue2(param.propss || []);
|
|
3879
3921
|
const es = getEmitsValue(param.emitss || []);
|
|
3922
|
+
const res = getExposeValue(param.exposes || []);
|
|
3923
|
+
const ss = getSlotValue(param.slots || []);
|
|
3880
3924
|
const propsObj = {};
|
|
3881
3925
|
ps.forEach((val) => {
|
|
3882
3926
|
let name = val.name;
|
|
@@ -3884,7 +3928,8 @@ function setVue(propsname, param, url) {
|
|
|
3884
3928
|
let arr = name.split("/");
|
|
3885
3929
|
name = (arr[0] || "").trim();
|
|
3886
3930
|
if (name) {
|
|
3887
|
-
|
|
3931
|
+
const dv = getDefaultValue(val);
|
|
3932
|
+
propsObj[name] = dv;
|
|
3888
3933
|
if (arr && arr.length > 1) {
|
|
3889
3934
|
es.push({
|
|
3890
3935
|
name: "update:" + name,
|
|
@@ -3910,7 +3955,18 @@ function setVue(propsname, param, url) {
|
|
|
3910
3955
|
propsObj[name] = () => {
|
|
3911
3956
|
};
|
|
3912
3957
|
});
|
|
3913
|
-
const
|
|
3958
|
+
const slotValue = {};
|
|
3959
|
+
ss.forEach((v) => {
|
|
3960
|
+
slotValue[v.name] = " ";
|
|
3961
|
+
});
|
|
3962
|
+
const exposeText = {};
|
|
3963
|
+
res.forEach((v) => {
|
|
3964
|
+
exposeText[v.name] = {
|
|
3965
|
+
name: v.name,
|
|
3966
|
+
type: "function"
|
|
3967
|
+
};
|
|
3968
|
+
});
|
|
3969
|
+
const html = getHmtl(propsname, param, propsObj, slotValue, {}, exposeText);
|
|
3914
3970
|
Fang.fileOpen(url, html);
|
|
3915
3971
|
}
|
|
3916
3972
|
function getMdurl(obj) {
|
package/dist/node/index.js
CHANGED
|
@@ -2460,6 +2460,15 @@ function getExposeValue(arr) {
|
|
|
2460
2460
|
return v;
|
|
2461
2461
|
});
|
|
2462
2462
|
}
|
|
2463
|
+
function getSlotValue(arr) {
|
|
2464
|
+
return arr.map((obj) => {
|
|
2465
|
+
const v = {};
|
|
2466
|
+
Object.keys(slot).forEach((key) => {
|
|
2467
|
+
v[key] = slot[key](obj);
|
|
2468
|
+
});
|
|
2469
|
+
return v;
|
|
2470
|
+
});
|
|
2471
|
+
}
|
|
2463
2472
|
|
|
2464
2473
|
// packages/components/test/index.ts
|
|
2465
2474
|
function getObj(v) {
|
|
@@ -3091,6 +3100,29 @@ function getSonType(type) {
|
|
|
3091
3100
|
}
|
|
3092
3101
|
return arr;
|
|
3093
3102
|
}
|
|
3103
|
+
function getTypeValue(arr) {
|
|
3104
|
+
const type = (arr[0] || "any").toLowerCase();
|
|
3105
|
+
switch (type) {
|
|
3106
|
+
case "string":
|
|
3107
|
+
return '""';
|
|
3108
|
+
case "boolean":
|
|
3109
|
+
return "false";
|
|
3110
|
+
case "number":
|
|
3111
|
+
return "0";
|
|
3112
|
+
case "array":
|
|
3113
|
+
let v = getTypeValue(arr.splice(1));
|
|
3114
|
+
v = v == "undefined" ? "" : v;
|
|
3115
|
+
return `[${v}]`;
|
|
3116
|
+
case "object":
|
|
3117
|
+
return "{}";
|
|
3118
|
+
case "function":
|
|
3119
|
+
return "()=>{}";
|
|
3120
|
+
case "any":
|
|
3121
|
+
return '""';
|
|
3122
|
+
default:
|
|
3123
|
+
return "undefined";
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3094
3126
|
function getType(str) {
|
|
3095
3127
|
let arr = [];
|
|
3096
3128
|
if (str) {
|
|
@@ -3119,13 +3151,19 @@ function setDataType(arr) {
|
|
|
3119
3151
|
function getParametersObj(cs) {
|
|
3120
3152
|
let arrs = cs.split(",");
|
|
3121
3153
|
return arrs.map((key) => {
|
|
3154
|
+
let must = true;
|
|
3122
3155
|
let vs = key.split(":");
|
|
3123
|
-
let name = vs[0];
|
|
3156
|
+
let name = vs[0].trim();
|
|
3157
|
+
if (name.endsWith("?")) {
|
|
3158
|
+
must = false;
|
|
3159
|
+
name = name.substring(0, -1);
|
|
3160
|
+
}
|
|
3124
3161
|
let t = vs[1] || "";
|
|
3125
3162
|
let tarr = getSonType(getType(t));
|
|
3126
3163
|
return {
|
|
3127
3164
|
label: key,
|
|
3128
3165
|
prop: name,
|
|
3166
|
+
must,
|
|
3129
3167
|
type: tarr[0],
|
|
3130
3168
|
dataType: tarr,
|
|
3131
3169
|
description: t.substring(t.lastIndexOf("]") + 1)
|
|
@@ -3148,8 +3186,10 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3148
3186
|
const tarr = [];
|
|
3149
3187
|
const sarr = [];
|
|
3150
3188
|
let is = true;
|
|
3189
|
+
const ps = getPropsValue2(param.propss || []);
|
|
3151
3190
|
const es = getEmitsValue(param.emitss || []);
|
|
3152
3191
|
const res = getExposeValue(param.exposes || []);
|
|
3192
|
+
const ss = getSlotValue(param.slots || []);
|
|
3153
3193
|
Object.keys(value).forEach((key) => {
|
|
3154
3194
|
let val = value[key];
|
|
3155
3195
|
if (/^on[A-Z]/.test(key) && typeof val == "function") {
|
|
@@ -3175,9 +3215,11 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3175
3215
|
strs = arr.join("");
|
|
3176
3216
|
}
|
|
3177
3217
|
tarr.push(" @" + name + '="' + strs + '"');
|
|
3178
|
-
const
|
|
3218
|
+
const sp = getSpecObjs(es, name);
|
|
3219
|
+
const s = sp.selectable || "";
|
|
3179
3220
|
const css = getParametersObj(s);
|
|
3180
3221
|
const cs = getParameStr(css);
|
|
3222
|
+
sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
|
|
3181
3223
|
sarr.push("function " + strs + "(" + cs + ") {");
|
|
3182
3224
|
css.forEach((o) => {
|
|
3183
3225
|
const name2 = o.prop || "arr";
|
|
@@ -3192,6 +3234,12 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3192
3234
|
z = key + "1";
|
|
3193
3235
|
}
|
|
3194
3236
|
tarr.push(" :" + key + '="' + z + '"');
|
|
3237
|
+
const sp = getSpecObjs(ps, key);
|
|
3238
|
+
const t = getSpecType(sp);
|
|
3239
|
+
sarr.push(
|
|
3240
|
+
`// ${sp.description} ${sp.name}: {${sp.type}} (${sp.selectable})`
|
|
3241
|
+
);
|
|
3242
|
+
console.log("val", val);
|
|
3195
3243
|
if (typeof val == "function") {
|
|
3196
3244
|
sarr.push(
|
|
3197
3245
|
"const " + key + " = " + getFunctionBody(val, key, propsText)
|
|
@@ -3202,7 +3250,14 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3202
3250
|
sarr.unshift("import { ref } from 'vue';");
|
|
3203
3251
|
}
|
|
3204
3252
|
if (typeof val == "undefined") {
|
|
3205
|
-
|
|
3253
|
+
const tv = getTypeValue(t.dataType);
|
|
3254
|
+
if (tv == "()=>{}") {
|
|
3255
|
+
sarr.push("const " + z + " = " + tv + ";");
|
|
3256
|
+
} else {
|
|
3257
|
+
sarr.push(
|
|
3258
|
+
"const " + z + " = ref(" + (tv === "undefined" ? "" : tv) + ");"
|
|
3259
|
+
);
|
|
3260
|
+
}
|
|
3206
3261
|
} else {
|
|
3207
3262
|
let st2 = setValStringify(val, key, propsText);
|
|
3208
3263
|
sarr.push("const " + z + " = ref(" + st2 + ");");
|
|
@@ -3219,27 +3274,36 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3219
3274
|
tarr.unshift(' ref="refDom"');
|
|
3220
3275
|
sarr.push("const refDom = ref()");
|
|
3221
3276
|
ev.forEach((v) => {
|
|
3222
|
-
sarr.push(`-------${v.name}--------`);
|
|
3223
3277
|
const s = getSpecObjs(res, v.name);
|
|
3278
|
+
sarr.push(
|
|
3279
|
+
`// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
|
|
3280
|
+
);
|
|
3224
3281
|
const m = v.name + "Value";
|
|
3225
3282
|
const css = getParametersObj(s?.selectable || "");
|
|
3226
3283
|
const cs = [];
|
|
3227
|
-
v.params
|
|
3228
|
-
|
|
3229
|
-
const
|
|
3230
|
-
if (
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
);
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3284
|
+
const ps2 = v.params || [];
|
|
3285
|
+
css.forEach((c, index) => {
|
|
3286
|
+
const prop = c.prop;
|
|
3287
|
+
if (prop) {
|
|
3288
|
+
const key = prop + v.name;
|
|
3289
|
+
const val = ps2[index];
|
|
3290
|
+
sarr.push(`// ${c.label}`);
|
|
3291
|
+
if (typeof val == "function") {
|
|
3292
|
+
sarr.push(
|
|
3293
|
+
"const " + key + " = " + getFunctionBody(val, prop, v.text)
|
|
3294
|
+
);
|
|
3237
3295
|
} else {
|
|
3238
|
-
|
|
3239
|
-
|
|
3296
|
+
if (typeof val == "undefined") {
|
|
3297
|
+
sarr.push(
|
|
3298
|
+
"const " + key + " = " + getTypeValue(c.dataType) + ";"
|
|
3299
|
+
);
|
|
3300
|
+
} else {
|
|
3301
|
+
let st2 = setValStringify(val, prop, v.text);
|
|
3302
|
+
sarr.push("const " + key + " = " + st2 + ";");
|
|
3303
|
+
}
|
|
3240
3304
|
}
|
|
3305
|
+
cs.push(key);
|
|
3241
3306
|
}
|
|
3242
|
-
cs.push(key);
|
|
3243
3307
|
});
|
|
3244
3308
|
if (v.type === "function") {
|
|
3245
3309
|
sarr.push(
|
|
@@ -3248,13 +3312,13 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3248
3312
|
} else {
|
|
3249
3313
|
sarr.push(`const ${m} = refDom.value?.${v.name}`);
|
|
3250
3314
|
}
|
|
3251
|
-
sarr.push(`console.log('"${s.
|
|
3315
|
+
sarr.push(`console.log('"${s.type}"', ${m})`);
|
|
3252
3316
|
});
|
|
3253
3317
|
}
|
|
3254
3318
|
if (tarr.length > 0) {
|
|
3255
3319
|
tarr.unshift("");
|
|
3256
3320
|
}
|
|
3257
|
-
const slots = getSlots(slotValue);
|
|
3321
|
+
const slots = getSlots(slotValue, ss);
|
|
3258
3322
|
const st = `<!--${propsname}-->
|
|
3259
3323
|
<template>
|
|
3260
3324
|
<div>
|
|
@@ -3268,12 +3332,14 @@ ${sarr.join("\n")}
|
|
|
3268
3332
|
`;
|
|
3269
3333
|
return st;
|
|
3270
3334
|
}
|
|
3271
|
-
function getSlots(obj = {}) {
|
|
3335
|
+
function getSlots(obj = {}, ss) {
|
|
3272
3336
|
const arr = [];
|
|
3273
3337
|
Object.keys(obj).forEach((key) => {
|
|
3338
|
+
const sp = getSpecObjs(ss, key);
|
|
3274
3339
|
const v = obj[key];
|
|
3275
3340
|
if (v) {
|
|
3276
|
-
const st = `
|
|
3341
|
+
const st = ` <!-- ${sp.description} ${sp.name}\uFF1A(${sp.selectable}) -->
|
|
3342
|
+
<template #${key}="scope">
|
|
3277
3343
|
${vueFormat(v, " ")}
|
|
3278
3344
|
</template>`;
|
|
3279
3345
|
arr.push(st);
|
|
@@ -3298,7 +3364,7 @@ function funstr(v) {
|
|
|
3298
3364
|
let body = `{
|
|
3299
3365
|
${vueFormat(getFunBody(st.body), " ")}
|
|
3300
3366
|
}`;
|
|
3301
|
-
return `function ${st.param} ${body}`;
|
|
3367
|
+
return `function (${st.param}) ${body}`;
|
|
3302
3368
|
} else {
|
|
3303
3369
|
return "undefined";
|
|
3304
3370
|
}
|
|
@@ -3822,15 +3888,6 @@ function gettests(obj, arr, n) {
|
|
|
3822
3888
|
}
|
|
3823
3889
|
}
|
|
3824
3890
|
}
|
|
3825
|
-
function getFFParam(str) {
|
|
3826
|
-
str = str.trim();
|
|
3827
|
-
if (str && str.length > 2) {
|
|
3828
|
-
return str.substring(1, str.length - 1).split(",").map((k) => {
|
|
3829
|
-
return (k.split(":")[0] || "").trim();
|
|
3830
|
-
});
|
|
3831
|
-
}
|
|
3832
|
-
return [];
|
|
3833
|
-
}
|
|
3834
3891
|
function getObjValue(d) {
|
|
3835
3892
|
try {
|
|
3836
3893
|
return new Function(`{ return ${d} }`)();
|
|
@@ -3839,29 +3896,16 @@ function getObjValue(d) {
|
|
|
3839
3896
|
}
|
|
3840
3897
|
}
|
|
3841
3898
|
function getDefaultValue(obj) {
|
|
3842
|
-
const vo = getSpecType(obj)
|
|
3899
|
+
const vo = getSpecType(obj);
|
|
3900
|
+
const v = getTypeValue(vo.dataType);
|
|
3843
3901
|
const d = (obj.default || "").trim();
|
|
3844
|
-
|
|
3845
|
-
let fb = getFunctionFormat(d);
|
|
3846
|
-
if (fb) {
|
|
3847
|
-
return new Function(...getFFParam(fb.param), fb.body);
|
|
3848
|
-
}
|
|
3849
|
-
return new Function("{}");
|
|
3850
|
-
} else if (vo == "array") {
|
|
3851
|
-
return getObjValue(d || "[]");
|
|
3852
|
-
} else if (vo == "object") {
|
|
3853
|
-
return getObjValue(d || "{}");
|
|
3854
|
-
} else if (vo == "number") {
|
|
3855
|
-
return getObjValue(d || "1");
|
|
3856
|
-
} else if (vo == "boolean") {
|
|
3857
|
-
return getObjValue(d || "true");
|
|
3858
|
-
} else {
|
|
3859
|
-
return d;
|
|
3860
|
-
}
|
|
3902
|
+
return getObjValue(d || v);
|
|
3861
3903
|
}
|
|
3862
3904
|
function setVue(propsname, param, url) {
|
|
3863
3905
|
const ps = getPropsValue2(param.propss || []);
|
|
3864
3906
|
const es = getEmitsValue(param.emitss || []);
|
|
3907
|
+
const res = getExposeValue(param.exposes || []);
|
|
3908
|
+
const ss = getSlotValue(param.slots || []);
|
|
3865
3909
|
const propsObj = {};
|
|
3866
3910
|
ps.forEach((val) => {
|
|
3867
3911
|
let name = val.name;
|
|
@@ -3869,7 +3913,8 @@ function setVue(propsname, param, url) {
|
|
|
3869
3913
|
let arr = name.split("/");
|
|
3870
3914
|
name = (arr[0] || "").trim();
|
|
3871
3915
|
if (name) {
|
|
3872
|
-
|
|
3916
|
+
const dv = getDefaultValue(val);
|
|
3917
|
+
propsObj[name] = dv;
|
|
3873
3918
|
if (arr && arr.length > 1) {
|
|
3874
3919
|
es.push({
|
|
3875
3920
|
name: "update:" + name,
|
|
@@ -3895,7 +3940,18 @@ function setVue(propsname, param, url) {
|
|
|
3895
3940
|
propsObj[name] = () => {
|
|
3896
3941
|
};
|
|
3897
3942
|
});
|
|
3898
|
-
const
|
|
3943
|
+
const slotValue = {};
|
|
3944
|
+
ss.forEach((v) => {
|
|
3945
|
+
slotValue[v.name] = " ";
|
|
3946
|
+
});
|
|
3947
|
+
const exposeText = {};
|
|
3948
|
+
res.forEach((v) => {
|
|
3949
|
+
exposeText[v.name] = {
|
|
3950
|
+
name: v.name,
|
|
3951
|
+
type: "function"
|
|
3952
|
+
};
|
|
3953
|
+
});
|
|
3954
|
+
const html = getHmtl(propsname, param, propsObj, slotValue, {}, exposeText);
|
|
3899
3955
|
Fang.fileOpen(url, html);
|
|
3900
3956
|
}
|
|
3901
3957
|
function getMdurl(obj) {
|
|
@@ -1,18 +1,19 @@
|
|
|
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 B=require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");const C=require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");const V=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const g=require("./util.cjs"),S=require("../../utils/props.cjs"),H=require("@fangzhongya/utils/basic/string/toFunction"),J=["class"];function j(s,t){return s.filter(e=>e.name==t)[0]}function N(s){return s.map(t=>(t.prop||"...arr")+":"+g.setDataType(t.dataType)).join(",")}function A(s,t,e,o,h,$){const p=[],n=[];let b=!0;const L=S.getPropsValue(t.propss||[]),P=S.getEmitsValue(t.emitss||[]),x=S.getExposeValue(t.exposes||[]),z=S.getSlotValue(t.slots||[]);Object.keys(e).forEach(r=>{let c=e[r];if(/^on[A-Z]/.test(r)&&typeof c=="function"){let i=r.substring(2);const u=r.split(":");let a;if(u.length>1?(a=u[0]+u.slice(1).map(f=>V.firstUpper(f)).join(""),i=C.firstLower(i)):(a=u[0],i=B.humpToLine(i)),u.includes("-")){let f=a.split("-");f=f.map((m,T)=>T!=0?V.firstUpper(m):m),a=f.join("")}p.push(" @"+i+'="'+a+'"');const l=j(P,i),y=l.selectable||"",q=g.getParametersObj(y),d=N(q);n.push(`// ${l.description} ${l.name}: (${l.selectable})`),n.push("function "+a+"("+d+") {"),q.forEach(f=>{const m=f.prop||"arr";n.push(" console.log('"+f.description+m+"', "+m+")")}),n.push("}")}else{let i=r;J.includes(r)&&(i=r+"1"),p.push(" :"+r+'="'+i+'"');const u=j(L,r),a=D(u);if(n.push(`// ${u.description} ${u.name}: {${u.type}} (${u.selectable})`),console.log("val",c),typeof c=="function")n.push("const "+r+" = "+F(c,r,h));else if(b&&(b=!1,n.unshift("import { ref } from 'vue';")),typeof c>"u"){const l=g.getTypeValue(a.dataType);l=="()=>{}"?n.push("const "+i+" = "+l+";"):n.push("const "+i+" = ref("+(l==="undefined"?"":l)+");")}else{let l=E(c,r,h);n.push("const "+i+" = ref("+l+");")}}});const O=Object.values($||{});O.length>0&&(b&&(b=!1,n.unshift("import { ref } from 'vue';")),p.unshift(' ref="refDom"'),n.push("const refDom = ref()"),O.forEach(r=>{const c=j(x,r.name);n.push(`// ${c.description} ${c.name}:(${c.selectable}) ${c.type}`);const i=r.name+"Value",u=g.getParametersObj(c?.selectable||""),a=[],l=r.params||[];u.forEach((y,q)=>{const d=y.prop;if(d){const f=d+r.name,m=l[q];if(n.push(`// ${y.label}`),typeof m=="function")n.push("const "+f+" = "+F(m,d,r.text));else if(typeof m>"u")n.push("const "+f+" = "+g.getTypeValue(y.dataType)+";");else{let T=E(m,d,r.text);n.push("const "+f+" = "+T+";")}a.push(f)}}),r.type==="function"?n.push(`const ${i} = refDom.value?.${r.name}(${a.join(", ")})`):n.push(`const ${i} = refDom.value?.${r.name}`),n.push(`console.log('"${c.type}"', ${i})`)})),p.length>0&&p.unshift("");const U=M(o,z);return`<!--${s}-->
|
|
2
2
|
<template>
|
|
3
3
|
<div>
|
|
4
|
-
<${
|
|
5
|
-
`)}>${
|
|
4
|
+
<${s}${p.join(`
|
|
5
|
+
`)}>${U.join(`
|
|
6
6
|
`)}
|
|
7
|
-
</${
|
|
7
|
+
</${s}>
|
|
8
8
|
</div>
|
|
9
9
|
</template>
|
|
10
10
|
<script lang="ts" setup>
|
|
11
|
-
${
|
|
11
|
+
${n.join(`
|
|
12
12
|
`)}
|
|
13
13
|
<\/script>
|
|
14
|
-
`}function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
`}function M(s={},t){const e=[];return Object.keys(s).forEach(o=>{const h=j(t,o),$=s[o];if($){const p=` <!-- ${h.description} ${h.name}:(${h.selectable}) -->
|
|
15
|
+
<template #${o}="scope">
|
|
16
|
+
${g.vueFormat($," ")}
|
|
17
|
+
</template>`;e.push(p)}}),e&&e.length>0&&e.unshift(""),e}function F(s,t,e){const o=e?e[t]:"";return o||w(s.toString())}function w(s){const t=H.getFunctionFormat(g.prettierFormat(s));if(t){let e=`{
|
|
18
|
+
${g.vueFormat(g.getFunBody(t.body)," ")}
|
|
19
|
+
}`;return`function (${t.param}) ${e}`}else return"undefined"}function Z(s){const t=s.trim();return/^\(/.test(t)?w(t):JSON.stringify(s)}function E(s,t,e){const o=e?e[t]:"";return o||(typeof s=="string"?Z(s+""):JSON.stringify(s))}function D(s){let t=G(s.type),e="any";t.length==1&&(e=t[0].split("<")[0]);const o=e;let h=(s.selectable||"").trim(),$=[];return h&&e!="boolean"&&(h.split(",").forEach(p=>{if(p){let n=p.split(":");$.push({label:p,prop:n[0].trim()})}}),e=="function"?e="function":e=="array"?e="choice":e="select"),{arr:$,zdtype:o,type:e,dataType:t}}function G(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=E;
|
|
@@ -1,159 +1,175 @@
|
|
|
1
1
|
import "@fangzhongya/utils/basic/object/mergeObject";
|
|
2
2
|
import "@fangzhongya/utils/basic/array/toggleArray";
|
|
3
|
-
import { humpToLine as
|
|
3
|
+
import { humpToLine as J } from "@fangzhongya/utils/name/humpToLine";
|
|
4
4
|
import "@fangzhongya/utils/name/lineToLargeHump";
|
|
5
5
|
import "@fangzhongya/utils/basic/string/appearNum";
|
|
6
|
-
import { firstLower as
|
|
6
|
+
import { firstLower as N } from "@fangzhongya/utils/basic/string/firstLower";
|
|
7
7
|
import "@fangzhongya/utils/basic/array/duplicateRemoval";
|
|
8
8
|
import "@fangzhongya/utils/basic/array/asyncMergeArray";
|
|
9
|
-
import { firstUpper as
|
|
9
|
+
import { firstUpper as O } from "@fangzhongya/utils/basic/string/firstUpper";
|
|
10
10
|
import "@fangzhongya/utils/urls/getSuffix";
|
|
11
11
|
import "@fangzhongya/utils/basic/array/replaceAfter";
|
|
12
|
-
import { getParametersObj as
|
|
13
|
-
import { getEmitsValue as
|
|
14
|
-
import { getFunctionFormat as
|
|
15
|
-
const
|
|
16
|
-
function
|
|
17
|
-
return
|
|
12
|
+
import { getParametersObj as V, getTypeValue as F, setDataType as A, vueFormat as w, prettierFormat as H, getFunBody as U } from "./util.js";
|
|
13
|
+
import { getPropsValue as Z, getEmitsValue as q, getExposeValue as G, getSlotValue as I } from "../../utils/props.js";
|
|
14
|
+
import { getFunctionFormat as K } from "@fangzhongya/utils/basic/string/toFunction";
|
|
15
|
+
const M = ["class"];
|
|
16
|
+
function j(s, e) {
|
|
17
|
+
return s.filter((t) => t.name == e)[0];
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function Q(s) {
|
|
20
|
+
return s.map((e) => (e.prop || "...arr") + ":" + A(e.dataType)).join(",");
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
let
|
|
25
|
-
const
|
|
26
|
-
Object.keys(
|
|
27
|
-
let
|
|
28
|
-
if (/^on[A-Z]/.test(
|
|
29
|
-
let i =
|
|
30
|
-
const
|
|
31
|
-
let
|
|
32
|
-
if (
|
|
33
|
-
let f =
|
|
34
|
-
f = f.map((m,
|
|
22
|
+
function at(s, e, t, r, h, $) {
|
|
23
|
+
const u = [], n = [];
|
|
24
|
+
let y = !0;
|
|
25
|
+
const z = Z(e.propss || []), L = q(e.emitss || []), P = G(e.exposes || []), B = I(e.slots || []);
|
|
26
|
+
Object.keys(t).forEach((o) => {
|
|
27
|
+
let c = t[o];
|
|
28
|
+
if (/^on[A-Z]/.test(o) && typeof c == "function") {
|
|
29
|
+
let i = o.substring(2);
|
|
30
|
+
const l = o.split(":");
|
|
31
|
+
let a;
|
|
32
|
+
if (l.length > 1 ? (a = l[0] + l.slice(1).map((f) => O(f)).join(""), i = N(i)) : (a = l[0], i = J(i)), l.includes("-")) {
|
|
33
|
+
let f = a.split("-");
|
|
34
|
+
f = f.map((m, S) => S != 0 ? O(m) : m), a = f.join("");
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
36
|
+
u.push(" @" + i + '="' + a + '"');
|
|
37
|
+
const p = j(L, i), d = p.selectable || "", b = V(d), g = Q(b);
|
|
38
|
+
n.push(`// ${p.description} ${p.name}: (${p.selectable})`), n.push("function " + a + "(" + g + ") {"), b.forEach((f) => {
|
|
39
39
|
const m = f.prop || "arr";
|
|
40
|
-
|
|
40
|
+
n.push(
|
|
41
41
|
" console.log('" + f.description + m + "', " + m + ")"
|
|
42
42
|
);
|
|
43
|
-
}),
|
|
43
|
+
}), n.push("}");
|
|
44
44
|
} else {
|
|
45
|
-
let i =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
let i = o;
|
|
46
|
+
M.includes(o) && (i = o + "1"), u.push(" :" + o + '="' + i + '"');
|
|
47
|
+
const l = j(z, o), a = X(l);
|
|
48
|
+
if (n.push(
|
|
49
|
+
`// ${l.description} ${l.name}: {${l.type}} (${l.selectable})`
|
|
50
|
+
), console.log("val", c), typeof c == "function")
|
|
51
|
+
n.push(
|
|
52
|
+
"const " + o + " = " + T(c, o, h)
|
|
49
53
|
);
|
|
50
|
-
else if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
else if (y && (y = !1, n.unshift("import { ref } from 'vue';")), typeof c > "u") {
|
|
55
|
+
const p = F(a.dataType);
|
|
56
|
+
p == "()=>{}" ? n.push("const " + i + " = " + p + ";") : n.push(
|
|
57
|
+
"const " + i + " = ref(" + (p === "undefined" ? "" : p) + ");"
|
|
58
|
+
);
|
|
59
|
+
} else {
|
|
60
|
+
let p = D(c, o, h);
|
|
61
|
+
n.push("const " + i + " = ref(" + p + ");");
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
64
|
});
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
const E = Object.values($ || {});
|
|
66
|
+
E.length > 0 && (y && (y = !1, n.unshift("import { ref } from 'vue';")), u.unshift(' ref="refDom"'), n.push("const refDom = ref()"), E.forEach((o) => {
|
|
67
|
+
const c = j(P, o.name);
|
|
68
|
+
n.push(
|
|
69
|
+
`// ${c.description} ${c.name}:(${c.selectable}) ${c.type}`
|
|
70
|
+
);
|
|
71
|
+
const i = o.name + "Value", l = V(c?.selectable || ""), a = [], p = o.params || [];
|
|
72
|
+
l.forEach((d, b) => {
|
|
73
|
+
const g = d.prop;
|
|
74
|
+
if (g) {
|
|
75
|
+
const f = g + o.name, m = p[b];
|
|
76
|
+
if (n.push(`// ${d.label}`), typeof m == "function")
|
|
77
|
+
n.push(
|
|
78
|
+
"const " + f + " = " + T(m, g, o.text)
|
|
79
|
+
);
|
|
80
|
+
else if (typeof m > "u")
|
|
81
|
+
n.push(
|
|
82
|
+
"const " + f + " = " + F(d.dataType) + ";"
|
|
83
|
+
);
|
|
84
|
+
else {
|
|
85
|
+
let S = D(m, g, o.text);
|
|
86
|
+
n.push("const " + f + " = " + S + ";");
|
|
87
|
+
}
|
|
88
|
+
a.push(f);
|
|
73
89
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return `<!--${n}-->
|
|
90
|
+
}), o.type === "function" ? n.push(
|
|
91
|
+
`const ${i} = refDom.value?.${o.name}(${a.join(", ")})`
|
|
92
|
+
) : n.push(`const ${i} = refDom.value?.${o.name}`), n.push(`console.log('"${c.type}"', ${i})`);
|
|
93
|
+
})), u.length > 0 && u.unshift("");
|
|
94
|
+
const C = R(r, B);
|
|
95
|
+
return `<!--${s}-->
|
|
81
96
|
<template>
|
|
82
97
|
<div>
|
|
83
|
-
<${
|
|
84
|
-
`)}>${
|
|
98
|
+
<${s}${u.join(`
|
|
99
|
+
`)}>${C.join(`
|
|
85
100
|
`)}
|
|
86
|
-
</${
|
|
101
|
+
</${s}>
|
|
87
102
|
</div>
|
|
88
103
|
</template>
|
|
89
104
|
<script lang="ts" setup>
|
|
90
|
-
${
|
|
105
|
+
${n.join(`
|
|
91
106
|
`)}
|
|
92
107
|
<\/script>
|
|
93
108
|
`;
|
|
94
109
|
}
|
|
95
|
-
function
|
|
110
|
+
function R(s = {}, e) {
|
|
96
111
|
const t = [];
|
|
97
|
-
return Object.keys(
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
const
|
|
101
|
-
|
|
112
|
+
return Object.keys(s).forEach((r) => {
|
|
113
|
+
const h = j(e, r), $ = s[r];
|
|
114
|
+
if ($) {
|
|
115
|
+
const u = ` <!-- ${h.description} ${h.name}:(${h.selectable}) -->
|
|
116
|
+
<template #${r}="scope">
|
|
117
|
+
${w($, " ")}
|
|
102
118
|
</template>`;
|
|
103
|
-
t.push(
|
|
119
|
+
t.push(u);
|
|
104
120
|
}
|
|
105
121
|
}), t && t.length > 0 && t.unshift(""), t;
|
|
106
122
|
}
|
|
107
|
-
function
|
|
108
|
-
const
|
|
109
|
-
return
|
|
123
|
+
function T(s, e, t) {
|
|
124
|
+
const r = t ? t[e] : "";
|
|
125
|
+
return r || x(s.toString());
|
|
110
126
|
}
|
|
111
|
-
function
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
let
|
|
115
|
-
${
|
|
127
|
+
function x(s) {
|
|
128
|
+
const e = K(H(s));
|
|
129
|
+
if (e) {
|
|
130
|
+
let t = `{
|
|
131
|
+
${w(U(e.body), " ")}
|
|
116
132
|
}`;
|
|
117
|
-
return `function ${
|
|
133
|
+
return `function (${e.param}) ${t}`;
|
|
118
134
|
} else
|
|
119
135
|
return "undefined";
|
|
120
136
|
}
|
|
121
|
-
function
|
|
122
|
-
const
|
|
123
|
-
return /^\(/.test(
|
|
137
|
+
function W(s) {
|
|
138
|
+
const e = s.trim();
|
|
139
|
+
return /^\(/.test(e) ? x(e) : JSON.stringify(s);
|
|
124
140
|
}
|
|
125
|
-
function
|
|
126
|
-
const
|
|
127
|
-
return
|
|
141
|
+
function D(s, e, t) {
|
|
142
|
+
const r = t ? t[e] : "";
|
|
143
|
+
return r || (typeof s == "string" ? W(s + "") : JSON.stringify(s));
|
|
128
144
|
}
|
|
129
|
-
function
|
|
130
|
-
let
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
let
|
|
134
|
-
return
|
|
135
|
-
if (
|
|
136
|
-
let
|
|
137
|
-
|
|
138
|
-
label:
|
|
139
|
-
prop:
|
|
145
|
+
function X(s) {
|
|
146
|
+
let e = Y(s.type), t = "any";
|
|
147
|
+
e.length == 1 && (t = e[0].split("<")[0]);
|
|
148
|
+
const r = t;
|
|
149
|
+
let h = (s.selectable || "").trim(), $ = [];
|
|
150
|
+
return h && t != "boolean" && (h.split(",").forEach((u) => {
|
|
151
|
+
if (u) {
|
|
152
|
+
let n = u.split(":");
|
|
153
|
+
$.push({
|
|
154
|
+
label: u,
|
|
155
|
+
prop: n[0].trim()
|
|
140
156
|
});
|
|
141
157
|
}
|
|
142
|
-
}),
|
|
143
|
-
arr:
|
|
144
|
-
zdtype:
|
|
145
|
-
type:
|
|
146
|
-
dataType:
|
|
158
|
+
}), t == "function" ? t = "function" : t == "array" ? t = "choice" : t = "select"), {
|
|
159
|
+
arr: $,
|
|
160
|
+
zdtype: r,
|
|
161
|
+
type: t,
|
|
162
|
+
dataType: e
|
|
147
163
|
};
|
|
148
164
|
}
|
|
149
|
-
function
|
|
150
|
-
let
|
|
151
|
-
return (
|
|
152
|
-
|
|
153
|
-
}), [...new Set(
|
|
165
|
+
function Y(s) {
|
|
166
|
+
let e = [];
|
|
167
|
+
return (s || "").trim().toLowerCase().split(",").forEach((r) => {
|
|
168
|
+
r = r.trim(), r && e.push(r);
|
|
169
|
+
}), [...new Set(e)].sort();
|
|
154
170
|
}
|
|
155
171
|
export {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
172
|
+
at as getHmtl,
|
|
173
|
+
X as getSpecType,
|
|
174
|
+
D as setValStringify
|
|
159
175
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("@fangzhongya/utils/basic/string/toFunction"),m=require("@fangzhongya/utils/basic/string/firstLower");function l(e){return e.replace(/\;(\s|\n\r)*$/,"")}function d(e){return e="let a = "+e,l(e).replace(/^let a = /,"")}function j(e){return l(e)}function T(e,t=""){let r=(e+"").trim().split(/\n/);return r=r.map(n=>t+n),r.join(`
|
|
2
2
|
`)}function f(e=""){e=e.trim();let t=`[\\s|\\n|\\r]*\\{((.|
|
|
3
|
-
|\r)+?)\\}[\\s|\\n|\\r]*`,n=new RegExp("^"+t+"$").exec(e);return n&&n.length>0?f(n[1]):e}const
|
|
3
|
+
|\r)+?)\\}[\\s|\\n|\\r]*`,n=new RegExp("^"+t+"$").exec(e);return n&&n.length>0?f(n[1]):e}const F=["Boolean","Any","String","Number","Array","Object","Function"];function c(e){return F.includes(e)?m.firstLower(e):e}function $(e){let r=new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);if(r&&r.length>0)return{own:c(r[1]),son:r[2]}}function p(e,t){let r=$(e);r?(t.push(r.own),r.son&&p(r.son,t)):t.push(e)}function s(e){e instanceof Array&&(e=e[0]);const t=[];return e&&p(e,t),t}function g(e){const t=Object.prototype.toString.call(e);let n=/^\[[O|o]bject (.*)\]$/.exec(t),i=typeof e;return n&&n.length>0&&(i=n[1].toLowerCase()),i}function O(e,t){const r=g(e),n=s(t)[0];return n&&n!="any"?r==n:!0}function h(e){if(typeof e=="string"){let t=!1;return(/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e))&&(t=!0),t&&(e=e.substring(1,e.length-1)),e+""}else return typeof e=="object"&&e?e.toString():typeof e>"u"||typeof e=="object"&&!e?"":e+""}function v(e){e=(e+"").replace(/^(\s|\n|r)*/,"").replace(/(\s|\n|r)*$/,"");let t="";return/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e)?t="string":/^\[(.|\n|\r)*\]$/.test(e)?t="array":/^\{(.|\n|\r)*\}$/.test(e)?t="object":/^[0-9]*$/.test(e)?t="number":e==="true"||e==="false"?t="boolean":e=="undefined"?t="undefined":e=="null"?t="null":e&&(t="string"),t}function y(e){switch((e[0]||"any").toLowerCase()){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":let r=y(e.splice(1));return r=r=="undefined"?"":r,`[${r}]`;case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function w(e){let t=[];if(e)if(e=(e+"").trim(),e.startsWith("["))e=e.substring(1,e.lastIndexOf("]")),t=e.split(",");else{let n=/^\<([a-z|\<|\>|\|]+)\>/.exec(e);n&&n.length>0?t=n[1].split("|"):t=["any"]}else t=["any"];return t.map(r=>c(r))}function S(e){return e.join("|")}function x(e){return e.split(",").map(r=>{let n=!0,i=r.split(":"),u=i[0].trim();u.endsWith("?")&&(n=!1,u=u.substring(0,-1));let o=i[1]||"",a=s(w(o));return{label:r,prop:u,must:n,type:a[0],dataType:a,description:o.substring(o.lastIndexOf("]")+1)}})}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>b.getFunctionFormat});exports.getFunBody=f;exports.getObjType=g;exports.getParametersObj=x;exports.getSonType=s;exports.getString=h;exports.getTypeValue=y;exports.isDefaultType=v;exports.isTypeEqual=O;exports.prettierArrFormat=j;exports.prettierFormat=l;exports.prettierObjFormat=d;exports.setDataType=S;exports.vueFormat=T;
|
|
@@ -35,10 +35,12 @@ export declare function getString(st: unknown): string;
|
|
|
35
35
|
* 配置字符串的类型
|
|
36
36
|
*/
|
|
37
37
|
export declare function isDefaultType(st: string): string;
|
|
38
|
+
export declare function getTypeValue(arr: string[]): string;
|
|
38
39
|
export declare function setDataType(arr: string[]): string;
|
|
39
40
|
export declare function getParametersObj(cs: string): {
|
|
40
41
|
label: string;
|
|
41
42
|
prop: string;
|
|
43
|
+
must: boolean;
|
|
42
44
|
type: string;
|
|
43
45
|
dataType: string[];
|
|
44
46
|
description: string;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { getFunctionFormat as
|
|
2
|
-
import { firstLower as
|
|
3
|
-
function
|
|
1
|
+
import { getFunctionFormat as L } from "@fangzhongya/utils/basic/string/toFunction";
|
|
2
|
+
import { firstLower as p } from "@fangzhongya/utils/basic/string/firstLower";
|
|
3
|
+
function s(e) {
|
|
4
4
|
return e.replace(/\;(\s|\n\r)*$/, "");
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
return e = "let a = " + e,
|
|
6
|
+
function T(e) {
|
|
7
|
+
return e = "let a = " + e, s(e).replace(/^let a = /, "");
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return
|
|
9
|
+
function h(e) {
|
|
10
|
+
return s(e);
|
|
11
11
|
}
|
|
12
12
|
function x(e, t = "") {
|
|
13
13
|
let n = (e + "").trim().split(/\n/);
|
|
14
14
|
return n = n.map((r) => t + r), n.join(`
|
|
15
15
|
`);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function g(e = "") {
|
|
18
18
|
e = e.trim();
|
|
19
19
|
let t = `[\\s|\\n|\\r]*\\{((.|
|
|
20
20
|
|\r)+?)\\}[\\s|\\n|\\r]*`, r = new RegExp("^" + t + "$").exec(e);
|
|
21
|
-
return r && r.length > 0 ?
|
|
21
|
+
return r && r.length > 0 ? g(r[1]) : e;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const y = [
|
|
24
24
|
"Boolean",
|
|
25
25
|
"Any",
|
|
26
26
|
"String",
|
|
@@ -30,9 +30,9 @@ const g = [
|
|
|
30
30
|
"Function"
|
|
31
31
|
];
|
|
32
32
|
function f(e) {
|
|
33
|
-
return
|
|
33
|
+
return y.includes(e) ? p(e) : e;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function b(e) {
|
|
36
36
|
let n = new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);
|
|
37
37
|
if (n && n.length > 0)
|
|
38
38
|
return {
|
|
@@ -40,25 +40,25 @@ function y(e) {
|
|
|
40
40
|
son: n[2]
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
let n =
|
|
45
|
-
n ? (t.push(n.own), n.son &&
|
|
43
|
+
function a(e, t) {
|
|
44
|
+
let n = b(e);
|
|
45
|
+
n ? (t.push(n.own), n.son && a(n.son, t)) : t.push(e);
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function c(e) {
|
|
48
48
|
e instanceof Array && (e = e[0]);
|
|
49
49
|
const t = [];
|
|
50
|
-
return e &&
|
|
50
|
+
return e && a(e, t), t;
|
|
51
51
|
}
|
|
52
52
|
function m(e) {
|
|
53
53
|
const t = Object.prototype.toString.call(e);
|
|
54
54
|
let r = /^\[[O|o]bject (.*)\]$/.exec(t), i = typeof e;
|
|
55
55
|
return r && r.length > 0 && (i = r[1].toLowerCase()), i;
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
const n = m(e), r =
|
|
57
|
+
function v(e, t) {
|
|
58
|
+
const n = m(e), r = c(t)[0];
|
|
59
59
|
return r && r != "any" ? n == r : !0;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function w(e) {
|
|
62
62
|
if (typeof e == "string") {
|
|
63
63
|
let t = !1;
|
|
64
64
|
return (/^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e)) && (t = !0), t && (e = e.substring(1, e.length - 1)), e + "";
|
|
@@ -69,7 +69,28 @@ function F(e) {
|
|
|
69
69
|
let t = "";
|
|
70
70
|
return /^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e) ? t = "string" : /^\[(.|\n|\r)*\]$/.test(e) ? t = "array" : /^\{(.|\n|\r)*\}$/.test(e) ? t = "object" : /^[0-9]*$/.test(e) ? t = "number" : e === "true" || e === "false" ? t = "boolean" : e == "undefined" ? t = "undefined" : e == "null" ? t = "null" : e && (t = "string"), t;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function d(e) {
|
|
73
|
+
switch ((e[0] || "any").toLowerCase()) {
|
|
74
|
+
case "string":
|
|
75
|
+
return '""';
|
|
76
|
+
case "boolean":
|
|
77
|
+
return "false";
|
|
78
|
+
case "number":
|
|
79
|
+
return "0";
|
|
80
|
+
case "array":
|
|
81
|
+
let n = d(e.splice(1));
|
|
82
|
+
return n = n == "undefined" ? "" : n, `[${n}]`;
|
|
83
|
+
case "object":
|
|
84
|
+
return "{}";
|
|
85
|
+
case "function":
|
|
86
|
+
return "()=>{}";
|
|
87
|
+
case "any":
|
|
88
|
+
return '""';
|
|
89
|
+
default:
|
|
90
|
+
return "undefined";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function $(e) {
|
|
73
94
|
let t = [];
|
|
74
95
|
if (e)
|
|
75
96
|
if (e = (e + "").trim(), e.startsWith("["))
|
|
@@ -85,30 +106,34 @@ function b(e) {
|
|
|
85
106
|
function O(e) {
|
|
86
107
|
return e.join("|");
|
|
87
108
|
}
|
|
88
|
-
function
|
|
109
|
+
function A(e) {
|
|
89
110
|
return e.split(",").map((n) => {
|
|
90
|
-
let r = n.split(":"),
|
|
111
|
+
let r = !0, i = n.split(":"), l = i[0].trim();
|
|
112
|
+
l.endsWith("?") && (r = !1, l = l.substring(0, -1));
|
|
113
|
+
let u = i[1] || "", o = c($(u));
|
|
91
114
|
return {
|
|
92
115
|
label: n,
|
|
93
|
-
prop:
|
|
116
|
+
prop: l,
|
|
117
|
+
must: r,
|
|
94
118
|
type: o[0],
|
|
95
119
|
dataType: o,
|
|
96
|
-
description:
|
|
120
|
+
description: u.substring(u.lastIndexOf("]") + 1)
|
|
97
121
|
};
|
|
98
122
|
});
|
|
99
123
|
}
|
|
100
124
|
export {
|
|
101
|
-
|
|
102
|
-
|
|
125
|
+
g as getFunBody,
|
|
126
|
+
L as getFunctionFormat,
|
|
103
127
|
m as getObjType,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
128
|
+
A as getParametersObj,
|
|
129
|
+
c as getSonType,
|
|
130
|
+
w as getString,
|
|
131
|
+
d as getTypeValue,
|
|
107
132
|
F as isDefaultType,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
133
|
+
v as isTypeEqual,
|
|
134
|
+
h as prettierArrFormat,
|
|
135
|
+
s as prettierFormat,
|
|
136
|
+
T as prettierObjFormat,
|
|
112
137
|
O as setDataType,
|
|
113
138
|
x as vueFormat
|
|
114
139
|
};
|