@fangzhongya/vue-archive 0.0.22 → 0.0.24
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 +2 -2
- package/dist/node/index.js +2 -2
- package/dist/packages/components/use/code.cjs +5 -5
- package/dist/packages/components/use/code.js +27 -27
- package/dist/packages/components/use/retrie/expose/index.vue.cjs +1 -1
- package/dist/packages/components/use/retrie/expose/index.vue.js +16 -16
- package/dist/packages/components/use/util.cjs +1 -1
- package/dist/packages/components/use/util.js +14 -14
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -3171,7 +3171,8 @@ function getParametersObj(cs) {
|
|
|
3171
3171
|
let name = vs[0].trim();
|
|
3172
3172
|
if (name.endsWith("?")) {
|
|
3173
3173
|
must = false;
|
|
3174
|
-
name = name.substring(0, -1);
|
|
3174
|
+
name = name.substring(0, name.length - 1);
|
|
3175
|
+
console.log("name", name);
|
|
3175
3176
|
}
|
|
3176
3177
|
let t = vs[1] || "";
|
|
3177
3178
|
let tarr = getSonType(getType(t));
|
|
@@ -3254,7 +3255,6 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3254
3255
|
sarr.push(
|
|
3255
3256
|
`// ${sp.description} ${sp.name}: {${sp.type}} (${sp.selectable})`
|
|
3256
3257
|
);
|
|
3257
|
-
console.log("val", val);
|
|
3258
3258
|
if (typeof val == "function") {
|
|
3259
3259
|
sarr.push(
|
|
3260
3260
|
"const " + key + " = " + getFunctionBody(val, key, propsText)
|
package/dist/node/index.js
CHANGED
|
@@ -3156,7 +3156,8 @@ function getParametersObj(cs) {
|
|
|
3156
3156
|
let name = vs[0].trim();
|
|
3157
3157
|
if (name.endsWith("?")) {
|
|
3158
3158
|
must = false;
|
|
3159
|
-
name = name.substring(0, -1);
|
|
3159
|
+
name = name.substring(0, name.length - 1);
|
|
3160
|
+
console.log("name", name);
|
|
3160
3161
|
}
|
|
3161
3162
|
let t = vs[1] || "";
|
|
3162
3163
|
let tarr = getSonType(getType(t));
|
|
@@ -3239,7 +3240,6 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3239
3240
|
sarr.push(
|
|
3240
3241
|
`// ${sp.description} ${sp.name}: {${sp.type}} (${sp.selectable})`
|
|
3241
3242
|
);
|
|
3242
|
-
console.log("val", val);
|
|
3243
3243
|
if (typeof val == "function") {
|
|
3244
3244
|
sarr.push(
|
|
3245
3245
|
"const " + key + " = " + getFunctionBody(val, key, propsText)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");const 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
|
|
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 f=[],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 p=e[r];if(/^on[A-Z]/.test(r)&&typeof p=="function"){let i=r.substring(2);const c=r.split(":");let a;if(c.length>1?(a=c[0]+c.slice(1).map(l=>V.firstUpper(l)).join(""),i=C.firstLower(i)):(a=c[0],i=B.humpToLine(i)),c.includes("-")){let l=a.split("-");l=l.map((m,T)=>T!=0?V.firstUpper(m):m),a=l.join("")}f.push(" @"+i+'="'+a+'"');const u=j(P,i),y=u.selectable||"",q=g.getParametersObj(y),d=N(q);n.push(`// ${u.description} ${u.name}: (${u.selectable})`),n.push("function "+a+"("+d+") {"),q.forEach(l=>{const m=l.prop||"arr";n.push(" console.log('"+l.description+m+"', "+m+")")}),n.push("}")}else{let i=r;J.includes(r)&&(i=r+"1"),f.push(" :"+r+'="'+i+'"');const c=j(L,r),a=D(c);if(n.push(`// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`),typeof p=="function")n.push("const "+r+" = "+F(p,r,h));else if(b&&(b=!1,n.unshift("import { ref } from 'vue';")),typeof p>"u"){const u=g.getTypeValue(a.dataType);u=="()=>{}"?n.push("const "+i+" = "+u+";"):n.push("const "+i+" = ref("+(u==="undefined"?"":u)+");")}else{let u=E(p,r,h);n.push("const "+i+" = ref("+u+");")}}});const O=Object.values($||{});O.length>0&&(b&&(b=!1,n.unshift("import { ref } from 'vue';")),f.unshift(' ref="refDom"'),n.push("const refDom = ref()"),O.forEach(r=>{const p=j(x,r.name);n.push(`// ${p.description} ${p.name}:(${p.selectable}) ${p.type}`);const i=r.name+"Value",c=g.getParametersObj(p?.selectable||""),a=[],u=r.params||[];c.forEach((y,q)=>{const d=y.prop;if(d){const l=d+r.name,m=u[q];if(n.push(`// ${y.label}`),typeof m=="function")n.push("const "+l+" = "+F(m,d,r.text));else if(typeof m>"u")n.push("const "+l+" = "+g.getTypeValue(y.dataType)+";");else{let T=E(m,d,r.text);n.push("const "+l+" = "+T+";")}a.push(l)}}),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('"${p.type}"', ${i})`)})),f.length>0&&f.unshift("");const U=M(o,z);return`<!--${s}-->
|
|
2
2
|
<template>
|
|
3
3
|
<div>
|
|
4
|
-
<${s}${
|
|
4
|
+
<${s}${f.join(`
|
|
5
5
|
`)}>${U.join(`
|
|
6
6
|
`)}
|
|
7
7
|
</${s}>
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
${n.join(`
|
|
12
12
|
`)}
|
|
13
13
|
<\/script>
|
|
14
|
-
`}function M(s={},t){const e=[];return Object.keys(s).forEach(o=>{const h=j(t,o),$=s[o];if($){const
|
|
14
|
+
`}function M(s={},t){const e=[];return Object.keys(s).forEach(o=>{const h=j(t,o),$=s[o];if($){const f=` <!-- ${h.description} ${h.name}:(${h.selectable}) -->
|
|
15
15
|
<template #${o}="scope">
|
|
16
16
|
${g.vueFormat($," ")}
|
|
17
|
-
</template>`;e.push(
|
|
17
|
+
</template>`;e.push(f)}}),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
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(
|
|
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(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;
|
|
@@ -20,20 +20,20 @@ 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, h, $) {
|
|
23
|
-
const
|
|
23
|
+
const l = [], n = [];
|
|
24
24
|
let y = !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
|
-
let
|
|
28
|
-
if (/^on[A-Z]/.test(o) && typeof
|
|
27
|
+
let u = t[o];
|
|
28
|
+
if (/^on[A-Z]/.test(o) && typeof u == "function") {
|
|
29
29
|
let i = o.substring(2);
|
|
30
|
-
const
|
|
30
|
+
const c = o.split(":");
|
|
31
31
|
let a;
|
|
32
|
-
if (
|
|
32
|
+
if (c.length > 1 ? (a = c[0] + c.slice(1).map((f) => O(f)).join(""), i = N(i)) : (a = c[0], i = J(i)), c.includes("-")) {
|
|
33
33
|
let f = a.split("-");
|
|
34
34
|
f = f.map((m, S) => S != 0 ? O(m) : m), a = f.join("");
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
l.push(" @" + i + '="' + a + '"');
|
|
37
37
|
const p = j(L, i), d = p.selectable || "", b = V(d), g = Q(b);
|
|
38
38
|
n.push(`// ${p.description} ${p.name}: (${p.selectable})`), n.push("function " + a + "(" + g + ") {"), b.forEach((f) => {
|
|
39
39
|
const m = f.prop || "arr";
|
|
@@ -43,33 +43,33 @@ function at(s, e, t, r, h, $) {
|
|
|
43
43
|
}), n.push("}");
|
|
44
44
|
} else {
|
|
45
45
|
let i = o;
|
|
46
|
-
M.includes(o) && (i = o + "1"),
|
|
47
|
-
const
|
|
46
|
+
M.includes(o) && (i = o + "1"), l.push(" :" + o + '="' + i + '"');
|
|
47
|
+
const c = j(z, o), a = X(c);
|
|
48
48
|
if (n.push(
|
|
49
|
-
`// ${
|
|
50
|
-
),
|
|
49
|
+
`// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`
|
|
50
|
+
), typeof u == "function")
|
|
51
51
|
n.push(
|
|
52
|
-
"const " + o + " = " + T(
|
|
52
|
+
"const " + o + " = " + T(u, o, h)
|
|
53
53
|
);
|
|
54
|
-
else if (y && (y = !1, n.unshift("import { ref } from 'vue';")), typeof
|
|
54
|
+
else if (y && (y = !1, n.unshift("import { ref } from 'vue';")), typeof u > "u") {
|
|
55
55
|
const p = F(a.dataType);
|
|
56
56
|
p == "()=>{}" ? n.push("const " + i + " = " + p + ";") : n.push(
|
|
57
57
|
"const " + i + " = ref(" + (p === "undefined" ? "" : p) + ");"
|
|
58
58
|
);
|
|
59
59
|
} else {
|
|
60
|
-
let p = D(
|
|
60
|
+
let p = D(u, o, h);
|
|
61
61
|
n.push("const " + i + " = ref(" + p + ");");
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
const E = Object.values($ || {});
|
|
66
|
-
E.length > 0 && (y && (y = !1, n.unshift("import { ref } from 'vue';")),
|
|
67
|
-
const
|
|
66
|
+
E.length > 0 && (y && (y = !1, n.unshift("import { ref } from 'vue';")), l.unshift(' ref="refDom"'), n.push("const refDom = ref()"), E.forEach((o) => {
|
|
67
|
+
const u = j(P, o.name);
|
|
68
68
|
n.push(
|
|
69
|
-
`// ${
|
|
69
|
+
`// ${u.description} ${u.name}:(${u.selectable}) ${u.type}`
|
|
70
70
|
);
|
|
71
|
-
const i = o.name + "Value",
|
|
72
|
-
|
|
71
|
+
const i = o.name + "Value", c = V(u?.selectable || ""), a = [], p = o.params || [];
|
|
72
|
+
c.forEach((d, b) => {
|
|
73
73
|
const g = d.prop;
|
|
74
74
|
if (g) {
|
|
75
75
|
const f = g + o.name, m = p[b];
|
|
@@ -89,13 +89,13 @@ function at(s, e, t, r, h, $) {
|
|
|
89
89
|
}
|
|
90
90
|
}), o.type === "function" ? n.push(
|
|
91
91
|
`const ${i} = refDom.value?.${o.name}(${a.join(", ")})`
|
|
92
|
-
) : n.push(`const ${i} = refDom.value?.${o.name}`), n.push(`console.log('"${
|
|
93
|
-
})),
|
|
92
|
+
) : n.push(`const ${i} = refDom.value?.${o.name}`), n.push(`console.log('"${u.type}"', ${i})`);
|
|
93
|
+
})), l.length > 0 && l.unshift("");
|
|
94
94
|
const C = R(r, B);
|
|
95
95
|
return `<!--${s}-->
|
|
96
96
|
<template>
|
|
97
97
|
<div>
|
|
98
|
-
<${s}${
|
|
98
|
+
<${s}${l.join(`
|
|
99
99
|
`)}>${C.join(`
|
|
100
100
|
`)}
|
|
101
101
|
</${s}>
|
|
@@ -112,11 +112,11 @@ function R(s = {}, e) {
|
|
|
112
112
|
return Object.keys(s).forEach((r) => {
|
|
113
113
|
const h = j(e, r), $ = s[r];
|
|
114
114
|
if ($) {
|
|
115
|
-
const
|
|
115
|
+
const l = ` <!-- ${h.description} ${h.name}:(${h.selectable}) -->
|
|
116
116
|
<template #${r}="scope">
|
|
117
117
|
${w($, " ")}
|
|
118
118
|
</template>`;
|
|
119
|
-
t.push(
|
|
119
|
+
t.push(l);
|
|
120
120
|
}
|
|
121
121
|
}), t && t.length > 0 && t.unshift(""), t;
|
|
122
122
|
}
|
|
@@ -147,11 +147,11 @@ function X(s) {
|
|
|
147
147
|
e.length == 1 && (t = e[0].split("<")[0]);
|
|
148
148
|
const r = t;
|
|
149
149
|
let h = (s.selectable || "").trim(), $ = [];
|
|
150
|
-
return h && t != "boolean" && (h.split(",").forEach((
|
|
151
|
-
if (
|
|
152
|
-
let n =
|
|
150
|
+
return h && t != "boolean" && (h.split(",").forEach((l) => {
|
|
151
|
+
if (l) {
|
|
152
|
+
let n = l.split(":");
|
|
153
153
|
$.push({
|
|
154
|
-
label:
|
|
154
|
+
label: l,
|
|
155
155
|
prop: n[0].trim()
|
|
156
156
|
});
|
|
157
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"},b=e.defineComponent({__name:"index",props:{getRef:{type:Function},name:String,value:{type:Object}},emits:["change"],setup(p,{emit:v}){const
|
|
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"},b=e.defineComponent({__name:"index",props:{getRef:{type:Function},name:String,value:{type:Object}},emits:["change"],setup(p,{emit:v}){const a=p,m=v,c=e.ref(""),o=e.ref(""),i=e.ref([]),f=e.computed(()=>{i.value=[];const t=a.value;if(t&&t.name){let l=(t.selectable+"").trim();if(c.value=t.name+": "+t.description+" 入参=("+l+") 返回值: "+t.type,l){let n=d.getParametersObj(l);return n.forEach(r=>{i.value.push(r.prop)}),n}}return[]});function _(t,l){let n=a.getRef?a.getRef():void 0,r=a.value?.name;if(r){let u=i.value.map(s=>t[s]);if(n&&n[r]){if(typeof n[r]=="function"){let s=n[r](...u);o.value=JSON.stringify(s)}else{let s=n[r];s instanceof HTMLDivElement?o.value=s.outerHTML:o.value=JSON.stringify(s)}m("change",r,u,typeof n[r],l)}}else console.log("请选择方法")}return(t,l)=>(e.openBlock(),e.createElementBlock("div",y,[e.createElementVNode("div",h,e.toDisplayString(c.value||"请选择方法"),1),e.createVNode(g,{list:f.value,name:a.name,queryName:"调用",onQuery:_},null,8,["list","name"]),e.createElementVNode("div",x,e.toDisplayString(a.value?.type)+"返回值:"+e.toDisplayString(o.value),1)]))}});module.exports=b;
|
|
@@ -17,36 +17,36 @@ const S = { class: "expose" }, j = { class: "expose-label" }, R = { class: "expo
|
|
|
17
17
|
setup(f, { emit: v }) {
|
|
18
18
|
const a = f, d = v, u = i(""), r = i(""), s = i([]), _ = h(() => {
|
|
19
19
|
s.value = [];
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
let l = (
|
|
23
|
-
if (u.value =
|
|
24
|
-
let
|
|
25
|
-
return
|
|
20
|
+
const e = a.value;
|
|
21
|
+
if (e && e.name) {
|
|
22
|
+
let l = (e.selectable + "").trim();
|
|
23
|
+
if (u.value = e.name + ": " + e.description + " 入参=(" + l + ") 返回值: " + e.type, l) {
|
|
24
|
+
let t = E(l);
|
|
25
|
+
return t.forEach((n) => {
|
|
26
26
|
s.value.push(n.prop);
|
|
27
|
-
}),
|
|
27
|
+
}), t;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
return [];
|
|
31
31
|
});
|
|
32
|
-
function g(
|
|
33
|
-
let
|
|
32
|
+
function g(e, l) {
|
|
33
|
+
let t = a.getRef ? a.getRef() : void 0, n = a.value?.name;
|
|
34
34
|
if (n) {
|
|
35
|
-
let m = s.value.map((o) =>
|
|
36
|
-
if (
|
|
37
|
-
if (typeof
|
|
38
|
-
let o =
|
|
35
|
+
let m = s.value.map((o) => e[o]);
|
|
36
|
+
if (t && t[n]) {
|
|
37
|
+
if (typeof t[n] == "function") {
|
|
38
|
+
let o = t[n](...m);
|
|
39
39
|
r.value = JSON.stringify(o);
|
|
40
40
|
} else {
|
|
41
|
-
let o =
|
|
41
|
+
let o = t[n];
|
|
42
42
|
o instanceof HTMLDivElement ? r.value = o.outerHTML : r.value = JSON.stringify(o);
|
|
43
43
|
}
|
|
44
|
-
d("change", n, m, typeof
|
|
44
|
+
d("change", n, m, typeof t[n], l);
|
|
45
45
|
}
|
|
46
46
|
} else
|
|
47
47
|
console.log("请选择方法");
|
|
48
48
|
}
|
|
49
|
-
return (
|
|
49
|
+
return (e, l) => (x(), b("div", S, [
|
|
50
50
|
p("div", j, c(u.value || "请选择方法"), 1),
|
|
51
51
|
N(O, {
|
|
52
52
|
list: _.value,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
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 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(":"),
|
|
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(":"),o=i[0].trim();o.endsWith("?")&&(n=!1,o=o.substring(0,o.length-1),console.log("name",o));let u=i[1]||"",a=s(w(u));return{label:r,prop:o,must:n,type:a[0],dataType:a,description:u.substring(u.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;
|
|
@@ -3,10 +3,10 @@ import { firstLower as p } from "@fangzhongya/utils/basic/string/firstLower";
|
|
|
3
3
|
function s(e) {
|
|
4
4
|
return e.replace(/\;(\s|\n\r)*$/, "");
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function h(e) {
|
|
7
7
|
return e = "let a = " + e, s(e).replace(/^let a = /, "");
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function T(e) {
|
|
10
10
|
return s(e);
|
|
11
11
|
}
|
|
12
12
|
function x(e, t = "") {
|
|
@@ -32,7 +32,7 @@ const y = [
|
|
|
32
32
|
function f(e) {
|
|
33
33
|
return y.includes(e) ? p(e) : e;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function m(e) {
|
|
36
36
|
let n = new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);
|
|
37
37
|
if (n && n.length > 0)
|
|
38
38
|
return {
|
|
@@ -41,7 +41,7 @@ function b(e) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
function a(e, t) {
|
|
44
|
-
let n =
|
|
44
|
+
let n = m(e);
|
|
45
45
|
n ? (t.push(n.own), n.son && a(n.son, t)) : t.push(e);
|
|
46
46
|
}
|
|
47
47
|
function c(e) {
|
|
@@ -49,13 +49,13 @@ function c(e) {
|
|
|
49
49
|
const t = [];
|
|
50
50
|
return e && a(e, t), t;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function b(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
57
|
function v(e, t) {
|
|
58
|
-
const n =
|
|
58
|
+
const n = b(e), r = c(t)[0];
|
|
59
59
|
return r && r != "any" ? n == r : !0;
|
|
60
60
|
}
|
|
61
61
|
function w(e) {
|
|
@@ -109,31 +109,31 @@ function O(e) {
|
|
|
109
109
|
function A(e) {
|
|
110
110
|
return e.split(",").map((n) => {
|
|
111
111
|
let r = !0, i = n.split(":"), l = i[0].trim();
|
|
112
|
-
l.endsWith("?") && (r = !1, l = l.substring(0, -1));
|
|
113
|
-
let
|
|
112
|
+
l.endsWith("?") && (r = !1, l = l.substring(0, l.length - 1), console.log("name", l));
|
|
113
|
+
let o = i[1] || "", u = c($(o));
|
|
114
114
|
return {
|
|
115
115
|
label: n,
|
|
116
116
|
prop: l,
|
|
117
117
|
must: r,
|
|
118
|
-
type:
|
|
119
|
-
dataType:
|
|
120
|
-
description:
|
|
118
|
+
type: u[0],
|
|
119
|
+
dataType: u,
|
|
120
|
+
description: o.substring(o.lastIndexOf("]") + 1)
|
|
121
121
|
};
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
export {
|
|
125
125
|
g as getFunBody,
|
|
126
126
|
L as getFunctionFormat,
|
|
127
|
-
|
|
127
|
+
b as getObjType,
|
|
128
128
|
A as getParametersObj,
|
|
129
129
|
c as getSonType,
|
|
130
130
|
w as getString,
|
|
131
131
|
d as getTypeValue,
|
|
132
132
|
F as isDefaultType,
|
|
133
133
|
v as isTypeEqual,
|
|
134
|
-
|
|
134
|
+
T as prettierArrFormat,
|
|
135
135
|
s as prettierFormat,
|
|
136
|
-
|
|
136
|
+
h as prettierObjFormat,
|
|
137
137
|
O as setDataType,
|
|
138
138
|
x as vueFormat
|
|
139
139
|
};
|