@fangzhongya/vue-archive 0.0.30 → 0.0.32
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 +39 -21
- package/dist/node/index.js +39 -21
- 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 +71 -62
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -3161,30 +3161,47 @@ function getType(str) {
|
|
|
3161
3161
|
return arr.map((o) => conversionType(o));
|
|
3162
3162
|
}
|
|
3163
3163
|
function setDataType(arr) {
|
|
3164
|
-
return arr.join("|");
|
|
3165
|
-
}
|
|
3166
|
-
function
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3164
|
+
return arr.join("|") || "any";
|
|
3165
|
+
}
|
|
3166
|
+
function parseParamString(input) {
|
|
3167
|
+
return input.split(",").map((part) => {
|
|
3168
|
+
const trimmedPart = part.trim();
|
|
3169
|
+
const label = trimmedPart;
|
|
3170
|
+
const nameMatch = trimmedPart.match(/^([^:?]+)(\??):/);
|
|
3171
|
+
if (!nameMatch) return null;
|
|
3172
|
+
const name = nameMatch[1].trim();
|
|
3173
|
+
const must = !nameMatch[2];
|
|
3174
|
+
const typeDefStart = nameMatch[0].length;
|
|
3175
|
+
const typeDef = trimmedPart.substring(typeDefStart).trim();
|
|
3176
|
+
let bracketStack = [];
|
|
3177
|
+
let endIndex = -1;
|
|
3178
|
+
let t = "";
|
|
3179
|
+
let description = "";
|
|
3180
|
+
for (let i = 0; i < typeDef.length; i++) {
|
|
3181
|
+
const char = typeDef[i];
|
|
3182
|
+
if (char === "[" || char === "<" || char === "(") {
|
|
3183
|
+
bracketStack.push(char);
|
|
3184
|
+
} else if (char === "]" && bracketStack[bracketStack.length - 1] === "[" || char === ">" && bracketStack[bracketStack.length - 1] === "<" || char === ")" && bracketStack[bracketStack.length - 1] === "(") {
|
|
3185
|
+
bracketStack.pop();
|
|
3186
|
+
}
|
|
3187
|
+
if (bracketStack.length === 0 && i > 0) {
|
|
3188
|
+
endIndex = i == 1 ? 0 : i;
|
|
3189
|
+
t = typeDef.substring(0, endIndex + 1).trim();
|
|
3190
|
+
description = typeDef.substring(endIndex + 1);
|
|
3191
|
+
break;
|
|
3192
|
+
}
|
|
3176
3193
|
}
|
|
3177
|
-
let t = vs[1] || "";
|
|
3178
3194
|
let tarr = getSonType(getType(t));
|
|
3179
3195
|
return {
|
|
3180
|
-
|
|
3196
|
+
name,
|
|
3181
3197
|
prop: name,
|
|
3182
|
-
must,
|
|
3183
3198
|
type: tarr[0],
|
|
3184
3199
|
dataType: tarr,
|
|
3185
|
-
|
|
3200
|
+
must,
|
|
3201
|
+
label,
|
|
3202
|
+
description
|
|
3186
3203
|
};
|
|
3187
|
-
});
|
|
3204
|
+
}).filter(Boolean);
|
|
3188
3205
|
}
|
|
3189
3206
|
|
|
3190
3207
|
// packages/components/use/code.ts
|
|
@@ -3233,12 +3250,13 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3233
3250
|
tarr.push(" @" + name + '="' + strs + '"');
|
|
3234
3251
|
const sp = getSpecObjs(es, name) || {};
|
|
3235
3252
|
const s = sp.selectable || "";
|
|
3236
|
-
const css =
|
|
3253
|
+
const css = parseParamString(s);
|
|
3254
|
+
console.log(css);
|
|
3237
3255
|
const cs = getParameStr(css);
|
|
3238
3256
|
sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
|
|
3239
3257
|
sarr.push("function " + strs + "(" + cs + ") {");
|
|
3240
3258
|
css.forEach((o) => {
|
|
3241
|
-
const name2 = o.
|
|
3259
|
+
const name2 = o.name || "arr";
|
|
3242
3260
|
sarr.push(" console.log('" + o.label + "', " + name2 + ")");
|
|
3243
3261
|
});
|
|
3244
3262
|
sarr.push("}");
|
|
@@ -3292,11 +3310,11 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3292
3310
|
`// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
|
|
3293
3311
|
);
|
|
3294
3312
|
const m = v.name + "Value";
|
|
3295
|
-
const css =
|
|
3313
|
+
const css = parseParamString(s?.selectable || "");
|
|
3296
3314
|
const cs = [];
|
|
3297
3315
|
const ps2 = v.params || [];
|
|
3298
3316
|
css.forEach((c, index) => {
|
|
3299
|
-
const prop = c.
|
|
3317
|
+
const prop = c.name;
|
|
3300
3318
|
if (prop) {
|
|
3301
3319
|
const key = prop + v.name;
|
|
3302
3320
|
const val = ps2[index];
|
package/dist/node/index.js
CHANGED
|
@@ -3146,30 +3146,47 @@ function getType(str) {
|
|
|
3146
3146
|
return arr.map((o) => conversionType(o));
|
|
3147
3147
|
}
|
|
3148
3148
|
function setDataType(arr) {
|
|
3149
|
-
return arr.join("|");
|
|
3150
|
-
}
|
|
3151
|
-
function
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3149
|
+
return arr.join("|") || "any";
|
|
3150
|
+
}
|
|
3151
|
+
function parseParamString(input) {
|
|
3152
|
+
return input.split(",").map((part) => {
|
|
3153
|
+
const trimmedPart = part.trim();
|
|
3154
|
+
const label = trimmedPart;
|
|
3155
|
+
const nameMatch = trimmedPart.match(/^([^:?]+)(\??):/);
|
|
3156
|
+
if (!nameMatch) return null;
|
|
3157
|
+
const name = nameMatch[1].trim();
|
|
3158
|
+
const must = !nameMatch[2];
|
|
3159
|
+
const typeDefStart = nameMatch[0].length;
|
|
3160
|
+
const typeDef = trimmedPart.substring(typeDefStart).trim();
|
|
3161
|
+
let bracketStack = [];
|
|
3162
|
+
let endIndex = -1;
|
|
3163
|
+
let t = "";
|
|
3164
|
+
let description = "";
|
|
3165
|
+
for (let i = 0; i < typeDef.length; i++) {
|
|
3166
|
+
const char = typeDef[i];
|
|
3167
|
+
if (char === "[" || char === "<" || char === "(") {
|
|
3168
|
+
bracketStack.push(char);
|
|
3169
|
+
} else if (char === "]" && bracketStack[bracketStack.length - 1] === "[" || char === ">" && bracketStack[bracketStack.length - 1] === "<" || char === ")" && bracketStack[bracketStack.length - 1] === "(") {
|
|
3170
|
+
bracketStack.pop();
|
|
3171
|
+
}
|
|
3172
|
+
if (bracketStack.length === 0 && i > 0) {
|
|
3173
|
+
endIndex = i == 1 ? 0 : i;
|
|
3174
|
+
t = typeDef.substring(0, endIndex + 1).trim();
|
|
3175
|
+
description = typeDef.substring(endIndex + 1);
|
|
3176
|
+
break;
|
|
3177
|
+
}
|
|
3161
3178
|
}
|
|
3162
|
-
let t = vs[1] || "";
|
|
3163
3179
|
let tarr = getSonType(getType(t));
|
|
3164
3180
|
return {
|
|
3165
|
-
|
|
3181
|
+
name,
|
|
3166
3182
|
prop: name,
|
|
3167
|
-
must,
|
|
3168
3183
|
type: tarr[0],
|
|
3169
3184
|
dataType: tarr,
|
|
3170
|
-
|
|
3185
|
+
must,
|
|
3186
|
+
label,
|
|
3187
|
+
description
|
|
3171
3188
|
};
|
|
3172
|
-
});
|
|
3189
|
+
}).filter(Boolean);
|
|
3173
3190
|
}
|
|
3174
3191
|
|
|
3175
3192
|
// packages/components/use/code.ts
|
|
@@ -3218,12 +3235,13 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3218
3235
|
tarr.push(" @" + name + '="' + strs + '"');
|
|
3219
3236
|
const sp = getSpecObjs(es, name) || {};
|
|
3220
3237
|
const s = sp.selectable || "";
|
|
3221
|
-
const css =
|
|
3238
|
+
const css = parseParamString(s);
|
|
3239
|
+
console.log(css);
|
|
3222
3240
|
const cs = getParameStr(css);
|
|
3223
3241
|
sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
|
|
3224
3242
|
sarr.push("function " + strs + "(" + cs + ") {");
|
|
3225
3243
|
css.forEach((o) => {
|
|
3226
|
-
const name2 = o.
|
|
3244
|
+
const name2 = o.name || "arr";
|
|
3227
3245
|
sarr.push(" console.log('" + o.label + "', " + name2 + ")");
|
|
3228
3246
|
});
|
|
3229
3247
|
sarr.push("}");
|
|
@@ -3277,11 +3295,11 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3277
3295
|
`// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
|
|
3278
3296
|
);
|
|
3279
3297
|
const m = v.name + "Value";
|
|
3280
|
-
const css =
|
|
3298
|
+
const css = parseParamString(s?.selectable || "");
|
|
3281
3299
|
const cs = [];
|
|
3282
3300
|
const ps2 = v.params || [];
|
|
3283
3301
|
css.forEach((c, index) => {
|
|
3284
|
-
const prop = c.
|
|
3302
|
+
const prop = c.name;
|
|
3285
3303
|
if (prop) {
|
|
3286
3304
|
const key = prop + v.name;
|
|
3287
3305
|
const val = ps2[index];
|
|
@@ -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 S=require("@fangzhongya/utils/basic/string/toFunction"),O=require("@fangzhongya/utils/basic/string/firstLower");function c(e){return e.replace(/\;(\s|\n\r)*$/,"")}function v(e){return e="let a = "+e,c(e).replace(/^let a = /,"")}function w(e){return c(e)}function x(e,t=""){let n=(e+"").trim().split(/\n/);return n=n.map(r=>t+r),n.join(`
|
|
2
|
+
`)}function b(e=""){e=e.trim();let t=`[\\s|\\n|\\r]*\\{((.|
|
|
3
|
+
|\r)+?)\\}[\\s|\\n|\\r]*`,r=new RegExp("^"+t+"$").exec(e);return r&&r.length>0?b(r[1]):e}const A=["Boolean","Any","String","Number","Array","Object","Function"];function d(e){return A.includes(e)?O.firstLower(e):e}function D(e){let n=new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);if(n&&n.length>0)return{own:d(n[1]),son:n[2]}}function h(e,t){let n=D(e);n?(t.push(n.own),n.son&&h(n.son,t)):t.push(e)}function f(e){e instanceof Array&&(e=e[0]);const t=[];return e&&h(e,t),t}function T(e){const t=Object.prototype.toString.call(e);let r=/^\[[O|o]bject (.*)\]$/.exec(t),o=typeof e;return r&&r.length>0&&(o=r[1].toLowerCase()),o}function P(e,t){const n=T(e),r=f(t)[0];return r&&r!="any"?n==r:!0}function q(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 B(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 j(e){switch((e[0]||"any").toLowerCase()){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":let n=j(e.splice(1));return n=n=="undefined"?"":n,`[${n}]`;case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function E(e){let t=[];if(e)if(e=(e+"").trim(),e.startsWith("["))e=e.substring(1,e.lastIndexOf("]")),t=e.split(",");else{let r=/^\<([a-z|\<|\>|\|]+)\>/.exec(e);r&&r.length>0?t=r[1].split("|"):t=["any"]}else t=["any"];return t.map(n=>d(n))}function L(e){return e.join("|")||"any"}function k(e){return e.split(",").map(t=>{const n=t.trim(),r=n,o=n.match(/^([^:?]+)(\??):/);if(!o)return null;const p=o[1].trim(),F=!o[2],$=o[0].length,s=n.substring($).trim();let i=[],a=-1,g="",y="";for(let u=0;u<s.length;u++){const l=s[u];if(l==="["||l==="<"||l==="("?i.push(l):(l==="]"&&i[i.length-1]==="["||l===">"&&i[i.length-1]==="<"||l===")"&&i[i.length-1]==="(")&&i.pop(),i.length===0&&u>0){a=u==1?0:u,g=s.substring(0,a+1).trim(),y=s.substring(a+1);break}}let m=f(E(g));return{name:p,prop:p,type:m[0],dataType:m,must:F,label:r,description:y}}).filter(Boolean)}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>S.getFunctionFormat});exports.getFunBody=b;exports.getObjType=T;exports.getSonType=f;exports.getString=q;exports.getTypeValue=j;exports.isDefaultType=B;exports.isTypeEqual=P;exports.parseParamString=k;exports.prettierArrFormat=w;exports.prettierFormat=c;exports.prettierObjFormat=v;exports.setDataType=L;exports.vueFormat=x;
|
|
@@ -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 R } from "@fangzhongya/utils/basic/string/toFunction";
|
|
2
|
+
import { firstLower as j } from "@fangzhongya/utils/basic/string/firstLower";
|
|
3
|
+
function y(e) {
|
|
4
4
|
return e.replace(/\;(\s|\n\r)*$/, "");
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
return e = "let a = " + e,
|
|
6
|
+
function A(e) {
|
|
7
|
+
return e = "let a = " + e, y(e).replace(/^let a = /, "");
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return
|
|
9
|
+
function D(e) {
|
|
10
|
+
return y(e);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function k(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 T(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 ? T(r[1]) : e;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const x = [
|
|
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 f(e) {
|
|
33
|
-
return y.includes(e) ? p(e) : e;
|
|
34
|
-
}
|
|
35
32
|
function m(e) {
|
|
33
|
+
return x.includes(e) ? j(e) : e;
|
|
34
|
+
}
|
|
35
|
+
function w(e) {
|
|
36
36
|
let n = new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);
|
|
37
37
|
if (n && n.length > 0)
|
|
38
38
|
return {
|
|
39
|
-
own:
|
|
39
|
+
own: m(n[1]),
|
|
40
40
|
son: n[2]
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
let n =
|
|
45
|
-
n ? (t.push(n.own), n.son &&
|
|
43
|
+
function b(e, t) {
|
|
44
|
+
let n = w(e);
|
|
45
|
+
n ? (t.push(n.own), n.son && b(n.son, t)) : t.push(e);
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function d(e) {
|
|
48
48
|
e instanceof Array && (e = e[0]);
|
|
49
49
|
const t = [];
|
|
50
|
-
return e &&
|
|
50
|
+
return e && b(e, t), t;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function F(e) {
|
|
53
53
|
const t = Object.prototype.toString.call(e);
|
|
54
|
-
let r = /^\[[O|o]bject (.*)\]$/.exec(t),
|
|
55
|
-
return r && r.length > 0 && (
|
|
54
|
+
let r = /^\[[O|o]bject (.*)\]$/.exec(t), o = typeof e;
|
|
55
|
+
return r && r.length > 0 && (o = r[1].toLowerCase()), o;
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
const n =
|
|
57
|
+
function B(e, t) {
|
|
58
|
+
const n = F(e), r = d(t)[0];
|
|
59
59
|
return r && r != "any" ? n == r : !0;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function E(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 + "";
|
|
65
65
|
} else return typeof e == "object" && e ? e.toString() : typeof e > "u" || typeof e == "object" && !e ? "" : e + "";
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function L(e) {
|
|
68
68
|
e = (e + "").replace(/^(\s|\n|r)*/, "").replace(/(\s|\n|r)*$/, "");
|
|
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 S(e) {
|
|
73
73
|
switch ((e[0] || "any").toLowerCase()) {
|
|
74
74
|
case "string":
|
|
75
75
|
return '""';
|
|
@@ -78,7 +78,7 @@ function d(e) {
|
|
|
78
78
|
case "number":
|
|
79
79
|
return "0";
|
|
80
80
|
case "array":
|
|
81
|
-
let n =
|
|
81
|
+
let n = S(e.splice(1));
|
|
82
82
|
return n = n == "undefined" ? "" : n, `[${n}]`;
|
|
83
83
|
case "object":
|
|
84
84
|
return "{}";
|
|
@@ -90,7 +90,7 @@ function d(e) {
|
|
|
90
90
|
return "undefined";
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function v(e) {
|
|
94
94
|
let t = [];
|
|
95
95
|
if (e)
|
|
96
96
|
if (e = (e + "").trim(), e.startsWith("["))
|
|
@@ -101,40 +101,49 @@ function $(e) {
|
|
|
101
101
|
}
|
|
102
102
|
else
|
|
103
103
|
t = ["any"];
|
|
104
|
-
return t.map((n) =>
|
|
105
|
-
}
|
|
106
|
-
function
|
|
107
|
-
return e.join("|");
|
|
108
|
-
}
|
|
109
|
-
function
|
|
110
|
-
return e.split(",").map((
|
|
111
|
-
n =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
let
|
|
104
|
+
return t.map((n) => m(n));
|
|
105
|
+
}
|
|
106
|
+
function z(e) {
|
|
107
|
+
return e.join("|") || "any";
|
|
108
|
+
}
|
|
109
|
+
function C(e) {
|
|
110
|
+
return e.split(",").map((t) => {
|
|
111
|
+
const n = t.trim(), r = n, o = n.match(/^([^:?]+)(\??):/);
|
|
112
|
+
if (!o) return null;
|
|
113
|
+
const a = o[1].trim(), h = !o[2], $ = o[0].length, s = n.substring($).trim();
|
|
114
|
+
let i = [], f = -1, c = "", p = "";
|
|
115
|
+
for (let u = 0; u < s.length; u++) {
|
|
116
|
+
const l = s[u];
|
|
117
|
+
if (l === "[" || l === "<" || l === "(" ? i.push(l) : (l === "]" && i[i.length - 1] === "[" || l === ">" && i[i.length - 1] === "<" || l === ")" && i[i.length - 1] === "(") && i.pop(), i.length === 0 && u > 0) {
|
|
118
|
+
f = u == 1 ? 0 : u, c = s.substring(0, f + 1).trim(), p = s.substring(f + 1);
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
let g = d(v(c));
|
|
115
123
|
return {
|
|
116
|
-
|
|
117
|
-
prop:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
name: a,
|
|
125
|
+
prop: a,
|
|
126
|
+
type: g[0],
|
|
127
|
+
dataType: g,
|
|
128
|
+
must: h,
|
|
129
|
+
label: r,
|
|
130
|
+
description: p
|
|
122
131
|
};
|
|
123
|
-
});
|
|
132
|
+
}).filter(Boolean);
|
|
124
133
|
}
|
|
125
134
|
export {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
135
|
+
T as getFunBody,
|
|
136
|
+
R as getFunctionFormat,
|
|
137
|
+
F as getObjType,
|
|
138
|
+
d as getSonType,
|
|
139
|
+
E as getString,
|
|
140
|
+
S as getTypeValue,
|
|
141
|
+
L as isDefaultType,
|
|
142
|
+
B as isTypeEqual,
|
|
143
|
+
C as parseParamString,
|
|
144
|
+
D as prettierArrFormat,
|
|
145
|
+
y as prettierFormat,
|
|
146
|
+
A as prettierObjFormat,
|
|
147
|
+
z as setDataType,
|
|
148
|
+
k as vueFormat
|
|
140
149
|
};
|