@fangzhongya/vue-archive 0.0.31 → 0.0.33
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 +91 -44
- package/dist/node/index.js +91 -44
- package/dist/packages/components/use/code.cjs +2 -2
- package/dist/packages/components/use/code.js +39 -37
- package/dist/packages/components/use/retrie/expose/index.vue.cjs +1 -1
- package/dist/packages/components/use/retrie/expose/index.vue.js +29 -29
- package/dist/packages/components/use/util.cjs +3 -3
- package/dist/packages/components/use/util.d.ts +9 -0
- package/dist/packages/components/use/util.js +112 -84
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -3138,53 +3138,99 @@ function getTypeValue(arr) {
|
|
|
3138
3138
|
return "undefined";
|
|
3139
3139
|
}
|
|
3140
3140
|
}
|
|
3141
|
-
function
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3141
|
+
function setDataType(arr) {
|
|
3142
|
+
return arr.join("|") || "any";
|
|
3143
|
+
}
|
|
3144
|
+
var splitIgnoringNesting = (str, delimiter) => {
|
|
3145
|
+
let bracketStack = [];
|
|
3146
|
+
let parts = [];
|
|
3147
|
+
let current = "";
|
|
3148
|
+
for (let i = 0; i < str.length; i++) {
|
|
3149
|
+
const char = str[i];
|
|
3150
|
+
if (char === "[" || char === "<" || char === "(") {
|
|
3151
|
+
bracketStack.push(char);
|
|
3152
|
+
current += char;
|
|
3153
|
+
} else if (char === "]" && bracketStack.length > 0 && bracketStack[bracketStack.length - 1] === "[" || char === ">" && bracketStack.length > 0 && bracketStack[bracketStack.length - 1] === "<" || char === ")" && bracketStack.length > 0 && bracketStack[bracketStack.length - 1] === "(") {
|
|
3154
|
+
bracketStack.pop();
|
|
3155
|
+
current += char;
|
|
3156
|
+
} else if (char === delimiter && bracketStack.length === 0) {
|
|
3157
|
+
parts.push(current.trim());
|
|
3158
|
+
current = "";
|
|
3148
3159
|
} else {
|
|
3149
|
-
|
|
3150
|
-
let rts = reg.exec(str);
|
|
3151
|
-
if (rts && rts.length > 0) {
|
|
3152
|
-
let ass = rts[1];
|
|
3153
|
-
arr = ass.split("|");
|
|
3154
|
-
} else {
|
|
3155
|
-
arr = ["any"];
|
|
3156
|
-
}
|
|
3160
|
+
current += char;
|
|
3157
3161
|
}
|
|
3162
|
+
}
|
|
3163
|
+
if (current.trim() !== "") {
|
|
3164
|
+
parts.push(current.trim());
|
|
3165
|
+
}
|
|
3166
|
+
return parts;
|
|
3167
|
+
};
|
|
3168
|
+
var parseTypeDefinition = (typeDef) => {
|
|
3169
|
+
if (!typeDef || typeDef === "[]") {
|
|
3170
|
+
return { type: "any", dataType: ["any"] };
|
|
3171
|
+
} else if (typeDef.startsWith("[") && typeDef.endsWith("]")) {
|
|
3172
|
+
const inner = typeDef.slice(1, -1).trim();
|
|
3173
|
+
if (!inner) return { type: "any", dataType: ["any"] };
|
|
3174
|
+
const types = splitIgnoringNesting(inner, ",");
|
|
3175
|
+
return {
|
|
3176
|
+
type: types[0] || "any",
|
|
3177
|
+
dataType: types
|
|
3178
|
+
};
|
|
3179
|
+
} else if (typeDef.startsWith("<") && typeDef.endsWith(">")) {
|
|
3180
|
+
const inner = typeDef.slice(1, -1).trim();
|
|
3181
|
+
if (!inner) return { type: "any", dataType: ["any"] };
|
|
3182
|
+
const types = splitIgnoringNesting(inner, "|");
|
|
3183
|
+
return {
|
|
3184
|
+
type: types[0] || "any",
|
|
3185
|
+
dataType: types
|
|
3186
|
+
};
|
|
3158
3187
|
} else {
|
|
3159
|
-
|
|
3188
|
+
return {
|
|
3189
|
+
type: typeDef,
|
|
3190
|
+
dataType: [typeDef]
|
|
3191
|
+
};
|
|
3160
3192
|
}
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
return
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
let
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3193
|
+
};
|
|
3194
|
+
function parseParamString(input) {
|
|
3195
|
+
const parts = splitIgnoringNesting(input, ",");
|
|
3196
|
+
return parts.map((trimmedPart) => {
|
|
3197
|
+
const label = trimmedPart.trim();
|
|
3198
|
+
const nameMatch = trimmedPart.match(/^([^:?]+)(\??):/);
|
|
3199
|
+
if (!nameMatch) return null;
|
|
3200
|
+
const name = nameMatch[1].trim();
|
|
3201
|
+
const must = !nameMatch[2];
|
|
3202
|
+
const typeDefStart = nameMatch[0].length;
|
|
3203
|
+
const typeDef = trimmedPart.substring(typeDefStart).trim();
|
|
3204
|
+
let bracketStack = [];
|
|
3205
|
+
let endIndex = -1;
|
|
3206
|
+
let t = "";
|
|
3207
|
+
let description = "";
|
|
3208
|
+
for (let i = 0; i < typeDef.length; i++) {
|
|
3209
|
+
const char = typeDef[i];
|
|
3210
|
+
if (char === "[" || char === "<" || char === "(") {
|
|
3211
|
+
bracketStack.push(char);
|
|
3212
|
+
} else if (char === "]" && bracketStack[bracketStack.length - 1] === "[" || char === ">" && bracketStack[bracketStack.length - 1] === "<" || char === ")" && bracketStack[bracketStack.length - 1] === "(") {
|
|
3213
|
+
bracketStack.pop();
|
|
3214
|
+
}
|
|
3215
|
+
if (bracketStack.length === 0 && i > 0) {
|
|
3216
|
+
endIndex = i == 1 ? 0 : i;
|
|
3217
|
+
t = typeDef.substring(0, endIndex + 1).trim();
|
|
3218
|
+
description = typeDef.substring(endIndex + 1);
|
|
3219
|
+
break;
|
|
3220
|
+
}
|
|
3176
3221
|
}
|
|
3177
|
-
|
|
3178
|
-
|
|
3222
|
+
const { type, dataType } = parseTypeDefinition(t);
|
|
3223
|
+
const tarr = getSonType(dataType);
|
|
3179
3224
|
return {
|
|
3180
|
-
|
|
3225
|
+
name,
|
|
3181
3226
|
prop: name,
|
|
3182
|
-
must,
|
|
3183
3227
|
type: tarr[0],
|
|
3184
|
-
dataType
|
|
3185
|
-
|
|
3228
|
+
dataType,
|
|
3229
|
+
must,
|
|
3230
|
+
label,
|
|
3231
|
+
description
|
|
3186
3232
|
};
|
|
3187
|
-
});
|
|
3233
|
+
}).filter(Boolean);
|
|
3188
3234
|
}
|
|
3189
3235
|
|
|
3190
3236
|
// packages/components/use/code.ts
|
|
@@ -3233,12 +3279,13 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3233
3279
|
tarr.push(" @" + name + '="' + strs + '"');
|
|
3234
3280
|
const sp = getSpecObjs(es, name) || {};
|
|
3235
3281
|
const s = sp.selectable || "";
|
|
3236
|
-
const css =
|
|
3282
|
+
const css = parseParamString(s);
|
|
3283
|
+
console.log(css);
|
|
3237
3284
|
const cs = getParameStr(css);
|
|
3238
3285
|
sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
|
|
3239
3286
|
sarr.push("function " + strs + "(" + cs + ") {");
|
|
3240
3287
|
css.forEach((o) => {
|
|
3241
|
-
const name2 = o.
|
|
3288
|
+
const name2 = o.name || "arr";
|
|
3242
3289
|
sarr.push(" console.log('" + o.label + "', " + name2 + ")");
|
|
3243
3290
|
});
|
|
3244
3291
|
sarr.push("}");
|
|
@@ -3292,11 +3339,11 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3292
3339
|
`// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
|
|
3293
3340
|
);
|
|
3294
3341
|
const m = v.name + "Value";
|
|
3295
|
-
const css =
|
|
3342
|
+
const css = parseParamString(s?.selectable || "");
|
|
3296
3343
|
const cs = [];
|
|
3297
3344
|
const ps2 = v.params || [];
|
|
3298
3345
|
css.forEach((c, index) => {
|
|
3299
|
-
const prop = c.
|
|
3346
|
+
const prop = c.name;
|
|
3300
3347
|
if (prop) {
|
|
3301
3348
|
const key = prop + v.name;
|
|
3302
3349
|
const val = ps2[index];
|
|
@@ -3403,7 +3450,7 @@ function setValStringify(v, key, propsText) {
|
|
|
3403
3450
|
}
|
|
3404
3451
|
}
|
|
3405
3452
|
function getSpecType(val) {
|
|
3406
|
-
let tarr =
|
|
3453
|
+
let tarr = getType(val?.type);
|
|
3407
3454
|
let type = "any";
|
|
3408
3455
|
if (tarr.length == 1) {
|
|
3409
3456
|
type = tarr[0].split("<")[0];
|
|
@@ -3436,7 +3483,7 @@ function getSpecType(val) {
|
|
|
3436
3483
|
dataType: tarr
|
|
3437
3484
|
};
|
|
3438
3485
|
}
|
|
3439
|
-
function
|
|
3486
|
+
function getType(value) {
|
|
3440
3487
|
let arr = [];
|
|
3441
3488
|
let str = (value || "").trim().toLowerCase();
|
|
3442
3489
|
str.split(",").forEach((v) => {
|
package/dist/node/index.js
CHANGED
|
@@ -3123,53 +3123,99 @@ function getTypeValue(arr) {
|
|
|
3123
3123
|
return "undefined";
|
|
3124
3124
|
}
|
|
3125
3125
|
}
|
|
3126
|
-
function
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3126
|
+
function setDataType(arr) {
|
|
3127
|
+
return arr.join("|") || "any";
|
|
3128
|
+
}
|
|
3129
|
+
var splitIgnoringNesting = (str, delimiter) => {
|
|
3130
|
+
let bracketStack = [];
|
|
3131
|
+
let parts = [];
|
|
3132
|
+
let current = "";
|
|
3133
|
+
for (let i = 0; i < str.length; i++) {
|
|
3134
|
+
const char = str[i];
|
|
3135
|
+
if (char === "[" || char === "<" || char === "(") {
|
|
3136
|
+
bracketStack.push(char);
|
|
3137
|
+
current += char;
|
|
3138
|
+
} else if (char === "]" && bracketStack.length > 0 && bracketStack[bracketStack.length - 1] === "[" || char === ">" && bracketStack.length > 0 && bracketStack[bracketStack.length - 1] === "<" || char === ")" && bracketStack.length > 0 && bracketStack[bracketStack.length - 1] === "(") {
|
|
3139
|
+
bracketStack.pop();
|
|
3140
|
+
current += char;
|
|
3141
|
+
} else if (char === delimiter && bracketStack.length === 0) {
|
|
3142
|
+
parts.push(current.trim());
|
|
3143
|
+
current = "";
|
|
3133
3144
|
} else {
|
|
3134
|
-
|
|
3135
|
-
let rts = reg.exec(str);
|
|
3136
|
-
if (rts && rts.length > 0) {
|
|
3137
|
-
let ass = rts[1];
|
|
3138
|
-
arr = ass.split("|");
|
|
3139
|
-
} else {
|
|
3140
|
-
arr = ["any"];
|
|
3141
|
-
}
|
|
3145
|
+
current += char;
|
|
3142
3146
|
}
|
|
3147
|
+
}
|
|
3148
|
+
if (current.trim() !== "") {
|
|
3149
|
+
parts.push(current.trim());
|
|
3150
|
+
}
|
|
3151
|
+
return parts;
|
|
3152
|
+
};
|
|
3153
|
+
var parseTypeDefinition = (typeDef) => {
|
|
3154
|
+
if (!typeDef || typeDef === "[]") {
|
|
3155
|
+
return { type: "any", dataType: ["any"] };
|
|
3156
|
+
} else if (typeDef.startsWith("[") && typeDef.endsWith("]")) {
|
|
3157
|
+
const inner = typeDef.slice(1, -1).trim();
|
|
3158
|
+
if (!inner) return { type: "any", dataType: ["any"] };
|
|
3159
|
+
const types = splitIgnoringNesting(inner, ",");
|
|
3160
|
+
return {
|
|
3161
|
+
type: types[0] || "any",
|
|
3162
|
+
dataType: types
|
|
3163
|
+
};
|
|
3164
|
+
} else if (typeDef.startsWith("<") && typeDef.endsWith(">")) {
|
|
3165
|
+
const inner = typeDef.slice(1, -1).trim();
|
|
3166
|
+
if (!inner) return { type: "any", dataType: ["any"] };
|
|
3167
|
+
const types = splitIgnoringNesting(inner, "|");
|
|
3168
|
+
return {
|
|
3169
|
+
type: types[0] || "any",
|
|
3170
|
+
dataType: types
|
|
3171
|
+
};
|
|
3143
3172
|
} else {
|
|
3144
|
-
|
|
3173
|
+
return {
|
|
3174
|
+
type: typeDef,
|
|
3175
|
+
dataType: [typeDef]
|
|
3176
|
+
};
|
|
3145
3177
|
}
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
return
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
let
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3178
|
+
};
|
|
3179
|
+
function parseParamString(input) {
|
|
3180
|
+
const parts = splitIgnoringNesting(input, ",");
|
|
3181
|
+
return parts.map((trimmedPart) => {
|
|
3182
|
+
const label = trimmedPart.trim();
|
|
3183
|
+
const nameMatch = trimmedPart.match(/^([^:?]+)(\??):/);
|
|
3184
|
+
if (!nameMatch) return null;
|
|
3185
|
+
const name = nameMatch[1].trim();
|
|
3186
|
+
const must = !nameMatch[2];
|
|
3187
|
+
const typeDefStart = nameMatch[0].length;
|
|
3188
|
+
const typeDef = trimmedPart.substring(typeDefStart).trim();
|
|
3189
|
+
let bracketStack = [];
|
|
3190
|
+
let endIndex = -1;
|
|
3191
|
+
let t = "";
|
|
3192
|
+
let description = "";
|
|
3193
|
+
for (let i = 0; i < typeDef.length; i++) {
|
|
3194
|
+
const char = typeDef[i];
|
|
3195
|
+
if (char === "[" || char === "<" || char === "(") {
|
|
3196
|
+
bracketStack.push(char);
|
|
3197
|
+
} else if (char === "]" && bracketStack[bracketStack.length - 1] === "[" || char === ">" && bracketStack[bracketStack.length - 1] === "<" || char === ")" && bracketStack[bracketStack.length - 1] === "(") {
|
|
3198
|
+
bracketStack.pop();
|
|
3199
|
+
}
|
|
3200
|
+
if (bracketStack.length === 0 && i > 0) {
|
|
3201
|
+
endIndex = i == 1 ? 0 : i;
|
|
3202
|
+
t = typeDef.substring(0, endIndex + 1).trim();
|
|
3203
|
+
description = typeDef.substring(endIndex + 1);
|
|
3204
|
+
break;
|
|
3205
|
+
}
|
|
3161
3206
|
}
|
|
3162
|
-
|
|
3163
|
-
|
|
3207
|
+
const { type, dataType } = parseTypeDefinition(t);
|
|
3208
|
+
const tarr = getSonType(dataType);
|
|
3164
3209
|
return {
|
|
3165
|
-
|
|
3210
|
+
name,
|
|
3166
3211
|
prop: name,
|
|
3167
|
-
must,
|
|
3168
3212
|
type: tarr[0],
|
|
3169
|
-
dataType
|
|
3170
|
-
|
|
3213
|
+
dataType,
|
|
3214
|
+
must,
|
|
3215
|
+
label,
|
|
3216
|
+
description
|
|
3171
3217
|
};
|
|
3172
|
-
});
|
|
3218
|
+
}).filter(Boolean);
|
|
3173
3219
|
}
|
|
3174
3220
|
|
|
3175
3221
|
// packages/components/use/code.ts
|
|
@@ -3218,12 +3264,13 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3218
3264
|
tarr.push(" @" + name + '="' + strs + '"');
|
|
3219
3265
|
const sp = getSpecObjs(es, name) || {};
|
|
3220
3266
|
const s = sp.selectable || "";
|
|
3221
|
-
const css =
|
|
3267
|
+
const css = parseParamString(s);
|
|
3268
|
+
console.log(css);
|
|
3222
3269
|
const cs = getParameStr(css);
|
|
3223
3270
|
sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
|
|
3224
3271
|
sarr.push("function " + strs + "(" + cs + ") {");
|
|
3225
3272
|
css.forEach((o) => {
|
|
3226
|
-
const name2 = o.
|
|
3273
|
+
const name2 = o.name || "arr";
|
|
3227
3274
|
sarr.push(" console.log('" + o.label + "', " + name2 + ")");
|
|
3228
3275
|
});
|
|
3229
3276
|
sarr.push("}");
|
|
@@ -3277,11 +3324,11 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3277
3324
|
`// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
|
|
3278
3325
|
);
|
|
3279
3326
|
const m = v.name + "Value";
|
|
3280
|
-
const css =
|
|
3327
|
+
const css = parseParamString(s?.selectable || "");
|
|
3281
3328
|
const cs = [];
|
|
3282
3329
|
const ps2 = v.params || [];
|
|
3283
3330
|
css.forEach((c, index) => {
|
|
3284
|
-
const prop = c.
|
|
3331
|
+
const prop = c.name;
|
|
3285
3332
|
if (prop) {
|
|
3286
3333
|
const key = prop + v.name;
|
|
3287
3334
|
const val = ps2[index];
|
|
@@ -3388,7 +3435,7 @@ function setValStringify(v, key, propsText) {
|
|
|
3388
3435
|
}
|
|
3389
3436
|
}
|
|
3390
3437
|
function getSpecType(val) {
|
|
3391
|
-
let tarr =
|
|
3438
|
+
let tarr = getType(val?.type);
|
|
3392
3439
|
let type = "any";
|
|
3393
3440
|
if (tarr.length == 1) {
|
|
3394
3441
|
type = tarr[0].split("<")[0];
|
|
@@ -3421,7 +3468,7 @@ function getSpecType(val) {
|
|
|
3421
3468
|
dataType: tarr
|
|
3422
3469
|
};
|
|
3423
3470
|
}
|
|
3424
|
-
function
|
|
3471
|
+
function getType(value) {
|
|
3425
3472
|
let arr = [];
|
|
3426
3473
|
let str = (value || "").trim().toLowerCase();
|
|
3427
3474
|
str.split(",").forEach((v) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
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
|
|
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 F=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const g=require("./util.cjs"),q=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,m,$){const f=[],n=[];let S=!0;const L=q.getPropsValue(t.propss||[]),P=q.getEmitsValue(t.emitss||[]),x=q.getExposeValue(t.exposes||[]),z=q.getSlotValue(t.slots||[]);Object.keys(e).forEach(r=>{let a=e[r];if(/^on[A-Z]/.test(r)&&typeof a=="function"){let i=r.substring(2);const c=r.split(":");let p;if(c.length>1?(p=c[0]+c.slice(1).map(l=>F.firstUpper(l)).join(""),i=C.firstLower(i)):(p=c[0],i=B.humpToLine(i)),c.includes("-")){let l=p.split("-");l=l.map((h,T)=>T!=0?F.firstUpper(h):h),p=l.join("")}f.push(" @"+i+'="'+p+'"');const u=j(P,i)||{},y=u.selectable||"",b=g.parseParamString(y);console.log(b);const d=N(b);n.push(`// ${u.description} ${u.name}: (${u.selectable})`),n.push("function "+p+"("+d+") {"),b.forEach(l=>{const h=l.name||"arr";n.push(" console.log('"+l.label+"', "+h+")")}),n.push("}")}else{let i=r;J.includes(r)&&(i=r+"1"),f.push(" :"+r+'="'+i+'"');const c=j(L,r)||{},p=D(c);if(n.push(`// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`),typeof a=="function")n.push("const "+r+" = "+O(a,r,m));else if(S&&(S=!1,n.unshift("import { ref } from 'vue';")),typeof a>"u"){const u=g.getTypeValue(p.dataType);u=="()=>{}"?n.push("const "+i+" = "+u+";"):n.push("const "+i+" = ref("+(u==="undefined"?"":u)+");")}else{let u=E(a,r,m);n.push("const "+i+" = ref("+u+");")}}});const V=Object.values($||{});V.length>0&&(S&&(S=!1,n.unshift("import { ref } from 'vue';")),f.unshift(' ref="refDom"'),n.push("const refDom = ref()"),V.forEach(r=>{const a=j(x,r.name)||{};n.push(`// ${a.description} ${a.name}:(${a.selectable}) ${a.type}`);const i=r.name+"Value",c=g.parseParamString(a?.selectable||""),p=[],u=r.params||[];c.forEach((y,b)=>{const d=y.name;if(d){const l=d+r.name,h=u[b];if(n.push(`// ${y.label}`),typeof h=="function")n.push("const "+l+" = "+O(h,d,r.text));else if(typeof h>"u")n.push("const "+l+" = "+g.getTypeValue(y.dataType)+";");else{let T=E(h,d,r.text);n.push("const "+l+" = "+T+";")}p.push(l)}}),r.type==="function"?n.push(`const ${i} = refDom.value?.${r.name}(${p.join(", ")})`):n.push(`const ${i} = refDom.value?.${r.name}`),n.push(`console.log('"${a.type}"', ${i})`)})),f.length>0&&f.unshift("");const U=M(o,z);return`<!--${s}-->
|
|
2
2
|
<template>
|
|
3
3
|
<div>
|
|
4
4
|
<${s}${f.join(`
|
|
@@ -14,6 +14,6 @@ ${n.join(`
|
|
|
14
14
|
`}function M(s={},t){const e=[];return Object.keys(s).forEach(o=>{const m=j(t,o)||{},$=s[o];if($){const f=` <!-- ${m.description} ${m.name}:(${m.selectable}) -->
|
|
15
15
|
<template #${o}="scope">
|
|
16
16
|
${g.vueFormat($," ")}
|
|
17
|
-
</template>`;e.push(f)}}),e&&e.length>0&&e.unshift(""),e}function
|
|
17
|
+
</template>`;e.push(f)}}),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=H.getFunctionFormat(g.prettierFormat(s));if(t){let e=`{
|
|
18
18
|
${g.vueFormat(g.getFunBody(t.body)," ")}
|
|
19
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 m=(s?.selectable||"").trim(),$=[];return m&&e!="boolean"&&(m.split(",").forEach(f=>{if(f){let n=f.split(":");$.push({label:f,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;
|
|
@@ -6,22 +6,22 @@ import "@fangzhongya/utils/basic/string/appearNum";
|
|
|
6
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 V } from "@fangzhongya/utils/basic/string/firstUpper";
|
|
10
10
|
import "@fangzhongya/utils/urls/getSuffix";
|
|
11
11
|
import "@fangzhongya/utils/basic/array/replaceAfter";
|
|
12
|
-
import {
|
|
12
|
+
import { parseParamString as F, getTypeValue as O, setDataType as A, vueFormat as w, prettierFormat as H, getFunBody as U } from "./util.js";
|
|
13
13
|
import { getPropsValue as Z, getEmitsValue as q, getExposeValue as G, getSlotValue as I } from "../../utils/props.js";
|
|
14
14
|
import { getFunctionFormat as K } from "@fangzhongya/utils/basic/string/toFunction";
|
|
15
15
|
const M = ["class"];
|
|
16
|
-
function
|
|
16
|
+
function S(s, e) {
|
|
17
17
|
return s.filter((t) => t.name == e)[0];
|
|
18
18
|
}
|
|
19
19
|
function Q(s) {
|
|
20
20
|
return s.map((e) => (e.prop || "...arr") + ":" + A(e.dataType)).join(",");
|
|
21
21
|
}
|
|
22
22
|
function at(s, e, t, r, m, $) {
|
|
23
|
-
const
|
|
24
|
-
let
|
|
23
|
+
const p = [], n = [];
|
|
24
|
+
let b = !0;
|
|
25
25
|
const z = Z(e.propss || []), L = q(e.emitss || []), P = G(e.exposes || []), B = I(e.slots || []);
|
|
26
26
|
Object.keys(t).forEach((o) => {
|
|
27
27
|
let u = t[o];
|
|
@@ -29,28 +29,30 @@ function at(s, e, t, r, m, $) {
|
|
|
29
29
|
let i = o.substring(2);
|
|
30
30
|
const c = o.split(":");
|
|
31
31
|
let a;
|
|
32
|
-
if (c.length > 1 ? (a = c[0] + c.slice(1).map((
|
|
33
|
-
let
|
|
34
|
-
|
|
32
|
+
if (c.length > 1 ? (a = c[0] + c.slice(1).map((f) => V(f)).join(""), i = N(i)) : (a = c[0], i = J(i)), c.includes("-")) {
|
|
33
|
+
let f = a.split("-");
|
|
34
|
+
f = f.map((h, j) => j != 0 ? V(h) : h), a = f.join("");
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
const l =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
p.push(" @" + i + '="' + a + '"');
|
|
37
|
+
const l = S(L, i) || {}, d = l.selectable || "", y = F(d);
|
|
38
|
+
console.log(y);
|
|
39
|
+
const g = Q(y);
|
|
40
|
+
n.push(`// ${l.description} ${l.name}: (${l.selectable})`), n.push("function " + a + "(" + g + ") {"), y.forEach((f) => {
|
|
41
|
+
const h = f.name || "arr";
|
|
42
|
+
n.push(" console.log('" + f.label + "', " + h + ")");
|
|
41
43
|
}), n.push("}");
|
|
42
44
|
} else {
|
|
43
45
|
let i = o;
|
|
44
|
-
M.includes(o) && (i = o + "1"),
|
|
45
|
-
const c =
|
|
46
|
+
M.includes(o) && (i = o + "1"), p.push(" :" + o + '="' + i + '"');
|
|
47
|
+
const c = S(z, o) || {}, a = X(c);
|
|
46
48
|
if (n.push(
|
|
47
49
|
`// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`
|
|
48
50
|
), typeof u == "function")
|
|
49
51
|
n.push(
|
|
50
52
|
"const " + o + " = " + T(u, o, m)
|
|
51
53
|
);
|
|
52
|
-
else if (
|
|
53
|
-
const l =
|
|
54
|
+
else if (b && (b = !1, n.unshift("import { ref } from 'vue';")), typeof u > "u") {
|
|
55
|
+
const l = O(a.dataType);
|
|
54
56
|
l == "()=>{}" ? n.push("const " + i + " = " + l + ";") : n.push(
|
|
55
57
|
"const " + i + " = ref(" + (l === "undefined" ? "" : l) + ");"
|
|
56
58
|
);
|
|
@@ -61,39 +63,39 @@ function at(s, e, t, r, m, $) {
|
|
|
61
63
|
}
|
|
62
64
|
});
|
|
63
65
|
const E = Object.values($ || {});
|
|
64
|
-
E.length > 0 && (
|
|
65
|
-
const u =
|
|
66
|
+
E.length > 0 && (b && (b = !1, n.unshift("import { ref } from 'vue';")), p.unshift(' ref="refDom"'), n.push("const refDom = ref()"), E.forEach((o) => {
|
|
67
|
+
const u = S(P, o.name) || {};
|
|
66
68
|
n.push(
|
|
67
69
|
`// ${u.description} ${u.name}:(${u.selectable}) ${u.type}`
|
|
68
70
|
);
|
|
69
|
-
const i = o.name + "Value", c =
|
|
70
|
-
c.forEach((d,
|
|
71
|
-
const g = d.
|
|
71
|
+
const i = o.name + "Value", c = F(u?.selectable || ""), a = [], l = o.params || [];
|
|
72
|
+
c.forEach((d, y) => {
|
|
73
|
+
const g = d.name;
|
|
72
74
|
if (g) {
|
|
73
|
-
const
|
|
75
|
+
const f = g + o.name, h = l[y];
|
|
74
76
|
if (n.push(`// ${d.label}`), typeof h == "function")
|
|
75
77
|
n.push(
|
|
76
|
-
"const " +
|
|
78
|
+
"const " + f + " = " + T(h, g, o.text)
|
|
77
79
|
);
|
|
78
80
|
else if (typeof h > "u")
|
|
79
81
|
n.push(
|
|
80
|
-
"const " +
|
|
82
|
+
"const " + f + " = " + O(d.dataType) + ";"
|
|
81
83
|
);
|
|
82
84
|
else {
|
|
83
|
-
let
|
|
84
|
-
n.push("const " +
|
|
85
|
+
let j = D(h, g, o.text);
|
|
86
|
+
n.push("const " + f + " = " + j + ";");
|
|
85
87
|
}
|
|
86
|
-
a.push(
|
|
88
|
+
a.push(f);
|
|
87
89
|
}
|
|
88
90
|
}), o.type === "function" ? n.push(
|
|
89
91
|
`const ${i} = refDom.value?.${o.name}(${a.join(", ")})`
|
|
90
92
|
) : n.push(`const ${i} = refDom.value?.${o.name}`), n.push(`console.log('"${u.type}"', ${i})`);
|
|
91
|
-
})),
|
|
93
|
+
})), p.length > 0 && p.unshift("");
|
|
92
94
|
const C = R(r, B);
|
|
93
95
|
return `<!--${s}-->
|
|
94
96
|
<template>
|
|
95
97
|
<div>
|
|
96
|
-
<${s}${
|
|
98
|
+
<${s}${p.join(`
|
|
97
99
|
`)}>${C.join(`
|
|
98
100
|
`)}
|
|
99
101
|
</${s}>
|
|
@@ -108,13 +110,13 @@ ${n.join(`
|
|
|
108
110
|
function R(s = {}, e) {
|
|
109
111
|
const t = [];
|
|
110
112
|
return Object.keys(s).forEach((r) => {
|
|
111
|
-
const m =
|
|
113
|
+
const m = S(e, r) || {}, $ = s[r];
|
|
112
114
|
if ($) {
|
|
113
|
-
const
|
|
115
|
+
const p = ` <!-- ${m.description} ${m.name}:(${m.selectable}) -->
|
|
114
116
|
<template #${r}="scope">
|
|
115
117
|
${w($, " ")}
|
|
116
118
|
</template>`;
|
|
117
|
-
t.push(
|
|
119
|
+
t.push(p);
|
|
118
120
|
}
|
|
119
121
|
}), t && t.length > 0 && t.unshift(""), t;
|
|
120
122
|
}
|
|
@@ -145,11 +147,11 @@ function X(s) {
|
|
|
145
147
|
e.length == 1 && (t = e[0].split("<")[0]);
|
|
146
148
|
const r = t;
|
|
147
149
|
let m = (s?.selectable || "").trim(), $ = [];
|
|
148
|
-
return m && t != "boolean" && (m.split(",").forEach((
|
|
149
|
-
if (
|
|
150
|
-
let n =
|
|
150
|
+
return m && t != "boolean" && (m.split(",").forEach((p) => {
|
|
151
|
+
if (p) {
|
|
152
|
+
let n = p.split(":");
|
|
151
153
|
$.push({
|
|
152
|
-
label:
|
|
154
|
+
label: p,
|
|
153
155
|
prop: n[0].trim()
|
|
154
156
|
});
|
|
155
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("vue"),d=require("../../util.cjs"),g=require("../index.vue.cjs");;/* empty css */const y={class:"expose"},h={class:"expose-label"},x={class:"expose-return"},
|
|
1
|
+
"use strict";const e=require("vue"),d=require("../../util.cjs"),g=require("../index.vue.cjs");;/* empty css */const y={class:"expose"},h={class:"expose-label"},x={class:"expose-return"},S=e.defineComponent({__name:"index",props:{getRef:{type:Function},name:String,value:{type:Object}},emits:["change"],setup(p,{emit:m}){const s=p,v=m,c=e.ref(""),i=e.ref(""),o=e.ref([]),f=e.computed(()=>{o.value=[];const n=s.value;if(n&&n.name){let l=(n.selectable+"").trim();if(c.value=n.name+": "+n.description+" 入参=("+l+") 返回值: "+n.type,l){let r=d.parseParamString(l);return r.forEach(t=>{t.prop=t.name,o.value.push(t.name)}),r}}return[]});function _(n,l){let r=s.getRef?s.getRef():void 0,t=s.value?.name;if(t){let u=o.value.map(a=>n[a]);if(r&&r[t]){if(typeof r[t]=="function"){let a=r[t](...u);i.value=JSON.stringify(a)}else{let a=r[t];a instanceof HTMLDivElement?i.value=a.outerHTML:i.value=JSON.stringify(a)}v("change",t,u,typeof r[t],l)}}else console.log("请选择方法")}return(n,l)=>(e.openBlock(),e.createElementBlock("div",y,[e.createElementVNode("div",h,e.toDisplayString(c.value||"请选择方法"),1),e.createVNode(g,{list:f.value,name:s.name,queryName:"调用",onQuery:_},null,8,["list","name"]),e.createElementVNode("div",x,e.toDisplayString(s.value?.type)+"返回值:"+e.toDisplayString(i.value),1)]))}});module.exports=S;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as y, ref as i, computed as h, createElementBlock as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { defineComponent as y, ref as i, computed as h, createElementBlock as x, openBlock as b, createElementVNode as p, createVNode as N, toDisplayString as c } from "vue";
|
|
2
|
+
import { parseParamString as S } from "../../util.js";
|
|
3
|
+
import E from "../index.vue.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
const
|
|
5
|
+
const O = { class: "expose" }, R = { class: "expose-label" }, j = { class: "expose-return" }, J = /* @__PURE__ */ y({
|
|
6
6
|
__name: "index",
|
|
7
7
|
props: {
|
|
8
8
|
getRef: {
|
|
@@ -15,46 +15,46 @@ const S = { class: "expose" }, j = { class: "expose-label" }, R = { class: "expo
|
|
|
15
15
|
},
|
|
16
16
|
emits: ["change"],
|
|
17
17
|
setup(f, { emit: v }) {
|
|
18
|
-
const
|
|
18
|
+
const o = f, d = v, m = i(""), r = i(""), s = i([]), _ = h(() => {
|
|
19
19
|
s.value = [];
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
let l = (
|
|
23
|
-
if (
|
|
24
|
-
let
|
|
25
|
-
return
|
|
26
|
-
s.value.push(
|
|
27
|
-
}),
|
|
20
|
+
const t = o.value;
|
|
21
|
+
if (t && t.name) {
|
|
22
|
+
let l = (t.selectable + "").trim();
|
|
23
|
+
if (m.value = t.name + ": " + t.description + " 入参=(" + l + ") 返回值: " + t.type, l) {
|
|
24
|
+
let n = S(l);
|
|
25
|
+
return n.forEach((e) => {
|
|
26
|
+
e.prop = e.name, s.value.push(e.name);
|
|
27
|
+
}), n;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
return [];
|
|
31
31
|
});
|
|
32
|
-
function g(
|
|
33
|
-
let
|
|
34
|
-
if (
|
|
35
|
-
let
|
|
36
|
-
if (
|
|
37
|
-
if (typeof
|
|
38
|
-
let
|
|
39
|
-
r.value = JSON.stringify(
|
|
32
|
+
function g(t, l) {
|
|
33
|
+
let n = o.getRef ? o.getRef() : void 0, e = o.value?.name;
|
|
34
|
+
if (e) {
|
|
35
|
+
let u = s.value.map((a) => t[a]);
|
|
36
|
+
if (n && n[e]) {
|
|
37
|
+
if (typeof n[e] == "function") {
|
|
38
|
+
let a = n[e](...u);
|
|
39
|
+
r.value = JSON.stringify(a);
|
|
40
40
|
} else {
|
|
41
|
-
let
|
|
42
|
-
|
|
41
|
+
let a = n[e];
|
|
42
|
+
a instanceof HTMLDivElement ? r.value = a.outerHTML : r.value = JSON.stringify(a);
|
|
43
43
|
}
|
|
44
|
-
d("change",
|
|
44
|
+
d("change", e, u, typeof n[e], l);
|
|
45
45
|
}
|
|
46
46
|
} else
|
|
47
47
|
console.log("请选择方法");
|
|
48
48
|
}
|
|
49
|
-
return (
|
|
50
|
-
p("div",
|
|
51
|
-
N(
|
|
49
|
+
return (t, l) => (b(), x("div", O, [
|
|
50
|
+
p("div", R, c(m.value || "请选择方法"), 1),
|
|
51
|
+
N(E, {
|
|
52
52
|
list: _.value,
|
|
53
|
-
name:
|
|
53
|
+
name: o.name,
|
|
54
54
|
queryName: "调用",
|
|
55
55
|
onQuery: g
|
|
56
56
|
}, null, 8, ["list", "name"]),
|
|
57
|
-
p("div",
|
|
57
|
+
p("div", j, c(o.value?.type) + "返回值:" + c(r.value), 1)
|
|
58
58
|
]));
|
|
59
59
|
}
|
|
60
60
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`)}function
|
|
3
|
-
|\r)+?)\\}[\\s|\\n|\\r]*`,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("@fangzhongya/utils/basic/string/toFunction"),w=require("@fangzhongya/utils/basic/string/firstLower");function g(e){return e.replace(/\;(\s|\n\r)*$/,"")}function O(e){return e="let a = "+e,g(e).replace(/^let a = /,"")}function x(e){return g(e)}function A(e,n=""){let t=(e+"").trim().split(/\n/);return t=t.map(r=>n+r),t.join(`
|
|
2
|
+
`)}function d(e=""){e=e.trim();let n=`[\\s|\\n|\\r]*\\{((.|
|
|
3
|
+
|\r)+?)\\}[\\s|\\n|\\r]*`,r=new RegExp("^"+n+"$").exec(e);return r&&r.length>0?d(r[1]):e}const k=["Boolean","Any","String","Number","Array","Object","Function"];function q(e){return k.includes(e)?w.firstLower(e):e}function B(e){let t=new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);if(t&&t.length>0)return{own:q(t[1]),son:t[2]}}function T(e,n){let t=B(e);t?(n.push(t.own),t.son&&T(t.son,n)):n.push(e)}function y(e){e instanceof Array&&(e=e[0]);const n=[];return e&&T(e,n),n}function j(e){const n=Object.prototype.toString.call(e);let r=/^\[[O|o]bject (.*)\]$/.exec(n),i=typeof e;return r&&r.length>0&&(i=r[1].toLowerCase()),i}function E(e,n){const t=j(e),r=y(n)[0];return r&&r!="any"?t==r:!0}function L(e){if(typeof e=="string"){let n=!1;return(/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e))&&(n=!0),n&&(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 W(e){e=(e+"").replace(/^(\s|\n|r)*/,"").replace(/(\s|\n|r)*$/,"");let n="";return/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e)?n="string":/^\[(.|\n|\r)*\]$/.test(e)?n="array":/^\{(.|\n|\r)*\}$/.test(e)?n="object":/^[0-9]*$/.test(e)?n="number":e==="true"||e==="false"?n="boolean":e=="undefined"?n="undefined":e=="null"?n="null":e&&(n="string"),n}function F(e){switch((e[0]||"any").toLowerCase()){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":let t=F(e.splice(1));return t=t=="undefined"?"":t,`[${t}]`;case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function C(e){return e.join("|")||"any"}const p=(e,n)=>{let t=[],r=[],i="";for(let a=0;a<e.length;a++){const o=e[a];o==="["||o==="<"||o==="("?(t.push(o),i+=o):o==="]"&&t.length>0&&t[t.length-1]==="["||o===">"&&t.length>0&&t[t.length-1]==="<"||o===")"&&t.length>0&&t[t.length-1]==="("?(t.pop(),i+=o):o===n&&t.length===0?(r.push(i.trim()),i=""):i+=o}return i.trim()!==""&&r.push(i.trim()),r},I=e=>{if(!e||e==="[]")return{type:"any",dataType:["any"]};if(e.startsWith("[")&&e.endsWith("]")){const n=e.slice(1,-1).trim();if(!n)return{type:"any",dataType:["any"]};const t=p(n,",");return{type:t[0]||"any",dataType:t}}else if(e.startsWith("<")&&e.endsWith(">")){const n=e.slice(1,-1).trim();if(!n)return{type:"any",dataType:["any"]};const t=p(n,"|");return{type:t[0]||"any",dataType:t}}else return{type:e,dataType:[e]}};function M(e){return p(e,",").map(t=>{const r=t.trim(),i=t.match(/^([^:?]+)(\??):/);if(!i)return null;const a=i[1].trim(),o=!i[2],$=i[0].length,c=t.substring($).trim();let s=[],f=-1,h="",m="";for(let u=0;u<c.length;u++){const l=c[u];if(l==="["||l==="<"||l==="("?s.push(l):(l==="]"&&s[s.length-1]==="["||l===">"&&s[s.length-1]==="<"||l===")"&&s[s.length-1]==="(")&&s.pop(),s.length===0&&u>0){f=u==1?0:u,h=c.substring(0,f+1).trim(),m=c.substring(f+1);break}}const{type:N,dataType:b}=I(h),S=y(b);return{name:a,prop:a,type:S[0],dataType:b,must:o,label:r,description:m}}).filter(Boolean)}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>v.getFunctionFormat});exports.getFunBody=d;exports.getObjType=j;exports.getSonType=y;exports.getString=L;exports.getTypeValue=F;exports.isDefaultType=W;exports.isTypeEqual=E;exports.parseParamString=M;exports.prettierArrFormat=x;exports.prettierFormat=g;exports.prettierObjFormat=O;exports.setDataType=C;exports.vueFormat=A;
|
|
@@ -45,3 +45,12 @@ export declare function getParametersObj(cs: string): {
|
|
|
45
45
|
dataType: string[];
|
|
46
46
|
description: string;
|
|
47
47
|
}[];
|
|
48
|
+
export declare function parseParamString(input: string): Array<{
|
|
49
|
+
name: string;
|
|
50
|
+
prop: string;
|
|
51
|
+
type: string;
|
|
52
|
+
dataType: string[];
|
|
53
|
+
must: boolean;
|
|
54
|
+
label: string;
|
|
55
|
+
description: string;
|
|
56
|
+
}>;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { getFunctionFormat as
|
|
2
|
-
import { firstLower as
|
|
3
|
-
function
|
|
1
|
+
import { getFunctionFormat as V } from "@fangzhongya/utils/basic/string/toFunction";
|
|
2
|
+
import { firstLower as j } from "@fangzhongya/utils/basic/string/firstLower";
|
|
3
|
+
function m(e) {
|
|
4
4
|
return e.replace(/\;(\s|\n\r)*$/, "");
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
return e = "let a = " + e,
|
|
6
|
+
function B(e) {
|
|
7
|
+
return e = "let a = " + e, m(e).replace(/^let a = /, "");
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return
|
|
9
|
+
function E(e) {
|
|
10
|
+
return m(e);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
let
|
|
14
|
-
return
|
|
12
|
+
function L(e, n = "") {
|
|
13
|
+
let t = (e + "").trim().split(/\n/);
|
|
14
|
+
return t = t.map((r) => n + r), t.join(`
|
|
15
15
|
`);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function S(e = "") {
|
|
18
18
|
e = e.trim();
|
|
19
|
-
let
|
|
20
|
-
|\r)+?)\\}[\\s|\\n|\\r]*`, r = new RegExp("^" +
|
|
21
|
-
return r && r.length > 0 ?
|
|
19
|
+
let n = `[\\s|\\n|\\r]*\\{((.|
|
|
20
|
+
|\r)+?)\\}[\\s|\\n|\\r]*`, r = new RegExp("^" + n + "$").exec(e);
|
|
21
|
+
return r && r.length > 0 ? S(r[1]) : e;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const w = [
|
|
24
24
|
"Boolean",
|
|
25
25
|
"Any",
|
|
26
26
|
"String",
|
|
@@ -29,47 +29,47 @@ const y = [
|
|
|
29
29
|
"Object",
|
|
30
30
|
"Function"
|
|
31
31
|
];
|
|
32
|
-
function
|
|
33
|
-
return
|
|
32
|
+
function x(e) {
|
|
33
|
+
return w.includes(e) ? j(e) : e;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
let
|
|
37
|
-
if (
|
|
35
|
+
function F(e) {
|
|
36
|
+
let t = new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);
|
|
37
|
+
if (t && t.length > 0)
|
|
38
38
|
return {
|
|
39
|
-
own:
|
|
40
|
-
son:
|
|
39
|
+
own: x(t[1]),
|
|
40
|
+
son: t[2]
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
let
|
|
45
|
-
|
|
43
|
+
function d(e, n) {
|
|
44
|
+
let t = F(e);
|
|
45
|
+
t ? (n.push(t.own), t.son && d(t.son, n)) : n.push(e);
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function b(e) {
|
|
48
48
|
e instanceof Array && (e = e[0]);
|
|
49
|
-
const
|
|
50
|
-
return e &&
|
|
49
|
+
const n = [];
|
|
50
|
+
return e && d(e, n), n;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
let r = /^\[[O|o]bject (.*)\]$/.exec(
|
|
52
|
+
function v(e) {
|
|
53
|
+
const n = Object.prototype.toString.call(e);
|
|
54
|
+
let r = /^\[[O|o]bject (.*)\]$/.exec(n), i = typeof e;
|
|
55
55
|
return r && r.length > 0 && (i = r[1].toLowerCase()), i;
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
const
|
|
59
|
-
return r && r != "any" ?
|
|
57
|
+
function C(e, n) {
|
|
58
|
+
const t = v(e), r = b(n)[0];
|
|
59
|
+
return r && r != "any" ? t == r : !0;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function I(e) {
|
|
62
62
|
if (typeof e == "string") {
|
|
63
|
-
let
|
|
64
|
-
return (/^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e)) && (
|
|
63
|
+
let n = !1;
|
|
64
|
+
return (/^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e)) && (n = !0), n && (e = e.substring(1, e.length - 1)), e + "";
|
|
65
65
|
} else return typeof e == "object" && e ? e.toString() : typeof e > "u" || typeof e == "object" && !e ? "" : e + "";
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function N(e) {
|
|
68
68
|
e = (e + "").replace(/^(\s|\n|r)*/, "").replace(/(\s|\n|r)*$/, "");
|
|
69
|
-
let
|
|
70
|
-
return /^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e) ?
|
|
69
|
+
let n = "";
|
|
70
|
+
return /^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e) ? n = "string" : /^\[(.|\n|\r)*\]$/.test(e) ? n = "array" : /^\{(.|\n|\r)*\}$/.test(e) ? n = "object" : /^[0-9]*$/.test(e) ? n = "number" : e === "true" || e === "false" ? n = "boolean" : e == "undefined" ? n = "undefined" : e == "null" ? n = "null" : e && (n = "string"), n;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function k(e) {
|
|
73
73
|
switch ((e[0] || "any").toLowerCase()) {
|
|
74
74
|
case "string":
|
|
75
75
|
return '""';
|
|
@@ -78,8 +78,8 @@ function d(e) {
|
|
|
78
78
|
case "number":
|
|
79
79
|
return "0";
|
|
80
80
|
case "array":
|
|
81
|
-
let
|
|
82
|
-
return
|
|
81
|
+
let t = k(e.splice(1));
|
|
82
|
+
return t = t == "undefined" ? "" : t, `[${t}]`;
|
|
83
83
|
case "object":
|
|
84
84
|
return "{}";
|
|
85
85
|
case "function":
|
|
@@ -90,51 +90,79 @@ function d(e) {
|
|
|
90
90
|
return "undefined";
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
let t = [];
|
|
95
|
-
if (e)
|
|
96
|
-
if (e = (e + "").trim(), e.startsWith("["))
|
|
97
|
-
e = e.substring(1, e.lastIndexOf("]")), t = e.split(",");
|
|
98
|
-
else {
|
|
99
|
-
let r = /^\<([a-z|\<|\>|\|]+)\>/.exec(e);
|
|
100
|
-
r && r.length > 0 ? t = r[1].split("|") : t = ["any"];
|
|
101
|
-
}
|
|
102
|
-
else
|
|
103
|
-
t = ["any"];
|
|
104
|
-
return t.map((n) => f(n));
|
|
105
|
-
}
|
|
106
|
-
function O(e) {
|
|
93
|
+
function R(e) {
|
|
107
94
|
return e.join("|") || "any";
|
|
108
95
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
96
|
+
const p = (e, n) => {
|
|
97
|
+
let t = [], r = [], i = "";
|
|
98
|
+
for (let u = 0; u < e.length; u++) {
|
|
99
|
+
const s = e[u];
|
|
100
|
+
s === "[" || s === "<" || s === "(" ? (t.push(s), i += s) : s === "]" && t.length > 0 && t[t.length - 1] === "[" || s === ">" && t.length > 0 && t[t.length - 1] === "<" || s === ")" && t.length > 0 && t[t.length - 1] === "(" ? (t.pop(), i += s) : s === n && t.length === 0 ? (r.push(i.trim()), i = "") : i += s;
|
|
101
|
+
}
|
|
102
|
+
return i.trim() !== "" && r.push(i.trim()), r;
|
|
103
|
+
}, A = (e) => {
|
|
104
|
+
if (!e || e === "[]")
|
|
105
|
+
return { type: "any", dataType: ["any"] };
|
|
106
|
+
if (e.startsWith("[") && e.endsWith("]")) {
|
|
107
|
+
const n = e.slice(1, -1).trim();
|
|
108
|
+
if (!n) return { type: "any", dataType: ["any"] };
|
|
109
|
+
const t = p(n, ",");
|
|
110
|
+
return {
|
|
111
|
+
type: t[0] || "any",
|
|
112
|
+
dataType: t
|
|
113
|
+
};
|
|
114
|
+
} else if (e.startsWith("<") && e.endsWith(">")) {
|
|
115
|
+
const n = e.slice(1, -1).trim();
|
|
116
|
+
if (!n) return { type: "any", dataType: ["any"] };
|
|
117
|
+
const t = p(n, "|");
|
|
118
|
+
return {
|
|
119
|
+
type: t[0] || "any",
|
|
120
|
+
dataType: t
|
|
121
|
+
};
|
|
122
|
+
} else
|
|
123
|
+
return {
|
|
124
|
+
type: e,
|
|
125
|
+
dataType: [e]
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
function q(e) {
|
|
129
|
+
return p(e, ",").map((t) => {
|
|
130
|
+
const r = t.trim(), i = t.match(/^([^:?]+)(\??):/);
|
|
131
|
+
if (!i) return null;
|
|
132
|
+
const u = i[1].trim(), s = !i[2], T = i[0].length, c = t.substring(T).trim();
|
|
133
|
+
let o = [], f = -1, g = "", y = "";
|
|
134
|
+
for (let a = 0; a < c.length; a++) {
|
|
135
|
+
const l = c[a];
|
|
136
|
+
if (l === "[" || l === "<" || l === "(" ? o.push(l) : (l === "]" && o[o.length - 1] === "[" || l === ">" && o[o.length - 1] === "<" || l === ")" && o[o.length - 1] === "(") && o.pop(), o.length === 0 && a > 0) {
|
|
137
|
+
f = a == 1 ? 0 : a, g = c.substring(0, f + 1).trim(), y = c.substring(f + 1);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const { type: O, dataType: h } = A(g), $ = b(h);
|
|
115
142
|
return {
|
|
116
|
-
|
|
117
|
-
prop:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
143
|
+
name: u,
|
|
144
|
+
prop: u,
|
|
145
|
+
type: $[0],
|
|
146
|
+
dataType: h,
|
|
147
|
+
must: s,
|
|
148
|
+
label: r,
|
|
149
|
+
description: y
|
|
122
150
|
};
|
|
123
|
-
});
|
|
151
|
+
}).filter(Boolean);
|
|
124
152
|
}
|
|
125
153
|
export {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
154
|
+
S as getFunBody,
|
|
155
|
+
V as getFunctionFormat,
|
|
156
|
+
v as getObjType,
|
|
157
|
+
b as getSonType,
|
|
158
|
+
I as getString,
|
|
159
|
+
k as getTypeValue,
|
|
160
|
+
N as isDefaultType,
|
|
161
|
+
C as isTypeEqual,
|
|
162
|
+
q as parseParamString,
|
|
163
|
+
E as prettierArrFormat,
|
|
164
|
+
m as prettierFormat,
|
|
165
|
+
B as prettierObjFormat,
|
|
166
|
+
R as setDataType,
|
|
167
|
+
L as vueFormat
|
|
140
168
|
};
|