@fangzhongya/vue-archive 0.0.21 → 0.0.23

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.
@@ -3166,13 +3166,19 @@ function setDataType(arr) {
3166
3166
  function getParametersObj(cs) {
3167
3167
  let arrs = cs.split(",");
3168
3168
  return arrs.map((key) => {
3169
+ let must = true;
3169
3170
  let vs = key.split(":");
3170
3171
  let name = vs[0].trim();
3172
+ if (name.endsWith("?")) {
3173
+ must = false;
3174
+ name = name.substring(0, -1);
3175
+ }
3171
3176
  let t = vs[1] || "";
3172
3177
  let tarr = getSonType(getType(t));
3173
3178
  return {
3174
3179
  label: key,
3175
3180
  prop: name,
3181
+ must,
3176
3182
  type: tarr[0],
3177
3183
  dataType: tarr,
3178
3184
  description: t.substring(t.lastIndexOf("]") + 1)
@@ -3248,7 +3254,6 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3248
3254
  sarr.push(
3249
3255
  `// ${sp.description} ${sp.name}: {${sp.type}} (${sp.selectable})`
3250
3256
  );
3251
- console.log("val", val);
3252
3257
  if (typeof val == "function") {
3253
3258
  sarr.push(
3254
3259
  "const " + key + " = " + getFunctionBody(val, key, propsText)
@@ -3151,13 +3151,19 @@ function setDataType(arr) {
3151
3151
  function getParametersObj(cs) {
3152
3152
  let arrs = cs.split(",");
3153
3153
  return arrs.map((key) => {
3154
+ let must = true;
3154
3155
  let vs = key.split(":");
3155
3156
  let name = vs[0].trim();
3157
+ if (name.endsWith("?")) {
3158
+ must = false;
3159
+ name = name.substring(0, -1);
3160
+ }
3156
3161
  let t = vs[1] || "";
3157
3162
  let tarr = getSonType(getType(t));
3158
3163
  return {
3159
3164
  label: key,
3160
3165
  prop: name,
3166
+ must,
3161
3167
  type: tarr[0],
3162
3168
  dataType: tarr,
3163
3169
  description: t.substring(t.lastIndexOf("]") + 1)
@@ -3233,7 +3239,6 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3233
3239
  sarr.push(
3234
3240
  `// ${sp.description} ${sp.name}: {${sp.type}} (${sp.selectable})`
3235
3241
  );
3236
- console.log("val", val);
3237
3242
  if (typeof val == "function") {
3238
3243
  sarr.push(
3239
3244
  "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 p=[],n=[];let b=!0;const L=S.getPropsValue(t.propss||[]),P=S.getEmitsValue(t.emitss||[]),x=S.getExposeValue(t.exposes||[]),z=S.getSlotValue(t.slots||[]);Object.keys(e).forEach(r=>{let c=e[r];if(/^on[A-Z]/.test(r)&&typeof c=="function"){let i=r.substring(2);const u=r.split(":");let a;if(u.length>1?(a=u[0]+u.slice(1).map(f=>V.firstUpper(f)).join(""),i=C.firstLower(i)):(a=u[0],i=B.humpToLine(i)),u.includes("-")){let f=a.split("-");f=f.map((m,T)=>T!=0?V.firstUpper(m):m),a=f.join("")}p.push(" @"+i+'="'+a+'"');const l=j(P,i),y=l.selectable||"",q=g.getParametersObj(y),d=N(q);n.push(`// ${l.description} ${l.name}: (${l.selectable})`),n.push("function "+a+"("+d+") {"),q.forEach(f=>{const m=f.prop||"arr";n.push(" console.log('"+f.description+m+"', "+m+")")}),n.push("}")}else{let i=r;J.includes(r)&&(i=r+"1"),p.push(" :"+r+'="'+i+'"');const u=j(L,r),a=D(u);if(n.push(`// ${u.description} ${u.name}: {${u.type}} (${u.selectable})`),console.log("val",c),typeof c=="function")n.push("const "+r+" = "+F(c,r,h));else if(b&&(b=!1,n.unshift("import { ref } from 'vue';")),typeof c>"u"){const l=g.getTypeValue(a.dataType);l=="()=>{}"?n.push("const "+i+" = "+l+";"):n.push("const "+i+" = ref("+(l==="undefined"?"":l)+");")}else{let l=E(c,r,h);n.push("const "+i+" = ref("+l+");")}}});const O=Object.values($||{});O.length>0&&(b&&(b=!1,n.unshift("import { ref } from 'vue';")),p.unshift(' ref="refDom"'),n.push("const refDom = ref()"),O.forEach(r=>{const c=j(x,r.name);n.push(`// ${c.description} ${c.name}:(${c.selectable}) ${c.type}`);const i=r.name+"Value",u=g.getParametersObj(c?.selectable||""),a=[],l=r.params||[];u.forEach((y,q)=>{const d=y.prop;if(d){const f=d+r.name,m=l[q];if(n.push(`// ${y.label}`),typeof m=="function")n.push("const "+f+" = "+F(m,d,r.text));else if(typeof m>"u")n.push("const "+f+" = "+g.getTypeValue(y.dataType)+";");else{let T=E(m,d,r.text);n.push("const "+f+" = "+T+";")}a.push(f)}}),r.type==="function"?n.push(`const ${i} = refDom.value?.${r.name}(${a.join(", ")})`):n.push(`const ${i} = refDom.value?.${r.name}`),n.push(`console.log('"${c.type}"', ${i})`)})),p.length>0&&p.unshift("");const U=M(o,z);return`<!--${s}-->
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}${p.join(`
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 p=` <!-- ${h.description} ${h.name}:(${h.selectable}) -->
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(p)}}),e&&e.length>0&&e.unshift(""),e}function F(s,t,e){const o=e?e[t]:"";return o||w(s.toString())}function w(s){const t=H.getFunctionFormat(g.prettierFormat(s));if(t){let e=`{
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(p=>{if(p){let n=p.split(":");$.push({label:p,prop:n[0].trim()})}}),e=="function"?e="function":e=="array"?e="choice":e="select"),{arr:$,zdtype:o,type:e,dataType:t}}function G(s){let t=[];return(s||"").trim().toLowerCase().split(",").forEach(o=>{o=o.trim(),o&&t.push(o)}),[...new Set(t)].sort()}exports.getHmtl=A;exports.getSpecType=D;exports.setValStringify=E;
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 u = [], n = [];
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 c = t[o];
28
- if (/^on[A-Z]/.test(o) && typeof c == "function") {
27
+ let u = t[o];
28
+ if (/^on[A-Z]/.test(o) && typeof u == "function") {
29
29
  let i = o.substring(2);
30
- const l = o.split(":");
30
+ const c = o.split(":");
31
31
  let a;
32
- if (l.length > 1 ? (a = l[0] + l.slice(1).map((f) => O(f)).join(""), i = N(i)) : (a = l[0], i = J(i)), l.includes("-")) {
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
- u.push(" @" + i + '="' + a + '"');
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"), u.push(" :" + o + '="' + i + '"');
47
- const l = j(z, o), a = X(l);
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
- `// ${l.description} ${l.name}: {${l.type}} (${l.selectable})`
50
- ), console.log("val", c), typeof c == "function")
49
+ `// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`
50
+ ), typeof u == "function")
51
51
  n.push(
52
- "const " + o + " = " + T(c, o, h)
52
+ "const " + o + " = " + T(u, o, h)
53
53
  );
54
- else if (y && (y = !1, n.unshift("import { ref } from 'vue';")), typeof c > "u") {
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(c, o, h);
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';")), u.unshift(' ref="refDom"'), n.push("const refDom = ref()"), E.forEach((o) => {
67
- const c = j(P, o.name);
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
- `// ${c.description} ${c.name}:(${c.selectable}) ${c.type}`
69
+ `// ${u.description} ${u.name}:(${u.selectable}) ${u.type}`
70
70
  );
71
- const i = o.name + "Value", l = V(c?.selectable || ""), a = [], p = o.params || [];
72
- l.forEach((d, b) => {
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('"${c.type}"', ${i})`);
93
- })), u.length > 0 && u.unshift("");
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}${u.join(`
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 u = ` <!-- ${h.description} ${h.name}:(${h.selectable}) -->
115
+ const l = ` <!-- ${h.description} ${h.name}:(${h.selectable}) -->
116
116
  <template #${r}="scope">
117
117
  ${w($, " ")}
118
118
  </template>`;
119
- t.push(u);
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((u) => {
151
- if (u) {
152
- let n = u.split(":");
150
+ return h && t != "boolean" && (h.split(",").forEach((l) => {
151
+ if (l) {
152
+ let n = l.split(":");
153
153
  $.push({
154
- label: u,
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 l=p,m=v,c=e.ref(""),a=e.ref(""),i=e.ref([]),f=e.computed(()=>{i.value=[];const n=l.value;if(n&&n.name){let o=(n.selectable+"").trim();if(c.value=n.name+": "+n.description+" 入参=("+o+") 返回值: "+n.type,o){let t=d.getParametersObj(o);return t.forEach(r=>{i.value.push(r.prop)}),console.log("arrs",t),t}}return[]});function _(n,o){let t=l.getRef?l.getRef():void 0,r=l.value?.name;if(r){let u=i.value.map(s=>n[s]);if(t&&t[r]){if(typeof t[r]=="function"){let s=t[r](...u);a.value=JSON.stringify(s)}else{let s=t[r];s instanceof HTMLDivElement?a.value=s.outerHTML:a.value=JSON.stringify(s)}m("change",r,u,typeof t[r],o)}}else console.log("请选择方法")}return(n,o)=>(e.openBlock(),e.createElementBlock("div",y,[e.createElementVNode("div",h,e.toDisplayString(c.value||"请选择方法"),1),e.createVNode(g,{list:f.value,name:l.name,queryName:"调用",onQuery:_},null,8,["list","name"]),e.createElementVNode("div",x,e.toDisplayString(l.value?.type)+"返回值:"+e.toDisplayString(a.value),1)]))}});module.exports=b;
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 t = a.value;
21
- if (t && t.name) {
22
- let l = (t.selectable + "").trim();
23
- if (u.value = t.name + ": " + t.description + " 入参=(" + l + ") 返回值: " + t.type, l) {
24
- let e = E(l);
25
- return e.forEach((n) => {
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
- }), console.log("arrs", e), e;
27
+ }), t;
28
28
  }
29
29
  }
30
30
  return [];
31
31
  });
32
- function g(t, l) {
33
- let e = a.getRef ? a.getRef() : void 0, n = a.value?.name;
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) => t[o]);
36
- if (e && e[n]) {
37
- if (typeof e[n] == "function") {
38
- let o = e[n](...m);
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 = e[n];
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 e[n], l);
44
+ d("change", n, m, typeof t[n], l);
45
45
  }
46
46
  } else
47
47
  console.log("请选择方法");
48
48
  }
49
- return (t, l) => (x(), b("div", S, [
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
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@fangzhongya/utils/basic/string/toFunction"),b=require("@fangzhongya/utils/basic/string/firstLower");function u(e){return e.replace(/\;(\s|\n\r)*$/,"")}function m(e){return e="let a = "+e,u(e).replace(/^let a = /,"")}function d(e){return u(e)}function j(e,t=""){let r=(e+"").trim().split(/\n/);return r=r.map(n=>t+n),r.join(`
2
- `)}function a(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?a(n[1]):e}const T=["Boolean","Any","String","Number","Array","Object","Function"];function f(e){return T.includes(e)?b.firstLower(e):e}function F(e){let r=new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);if(r&&r.length>0)return{own:f(r[1]),son:r[2]}}function c(e,t){let r=F(e);r?(t.push(r.own),r.son&&c(r.son,t)):t.push(e)}function l(e){e instanceof Array&&(e=e[0]);const t=[];return e&&c(e,t),t}function p(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 $(e,t){const r=p(e),n=l(t)[0];return n&&n!="any"?r==n:!0}function O(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 g(e){switch((e[0]||"any").toLowerCase()){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":let r=g(e.splice(1));return r=r=="undefined"?"":r,`[${r}]`;case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function h(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=>f(r))}function w(e){return e.join("|")}function S(e){return e.split(",").map(r=>{let n=r.split(":"),i=n[0].trim(),o=n[1]||"",s=l(h(o));return{label:r,prop:i,type:s[0],dataType:s,description:o.substring(o.lastIndexOf("]")+1)}})}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>y.getFunctionFormat});exports.getFunBody=a;exports.getObjType=p;exports.getParametersObj=S;exports.getSonType=l;exports.getString=O;exports.getTypeValue=g;exports.isDefaultType=v;exports.isTypeEqual=$;exports.prettierArrFormat=d;exports.prettierFormat=u;exports.prettierObjFormat=m;exports.setDataType=w;exports.vueFormat=j;
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
+ `)}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(":"),u=i[0].trim();u.endsWith("?")&&(n=!1,u=u.substring(0,-1));let o=i[1]||"",a=s(w(o));return{label:r,prop:u,must:n,type:a[0],dataType:a,description:o.substring(o.lastIndexOf("]")+1)}})}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>b.getFunctionFormat});exports.getFunBody=f;exports.getObjType=g;exports.getParametersObj=x;exports.getSonType=s;exports.getString=h;exports.getTypeValue=y;exports.isDefaultType=v;exports.isTypeEqual=O;exports.prettierArrFormat=j;exports.prettierFormat=l;exports.prettierObjFormat=d;exports.setDataType=S;exports.vueFormat=T;
@@ -40,6 +40,7 @@ export declare function setDataType(arr: string[]): string;
40
40
  export declare function getParametersObj(cs: string): {
41
41
  label: string;
42
42
  prop: string;
43
+ must: boolean;
43
44
  type: string;
44
45
  dataType: string[];
45
46
  description: string;
@@ -1,26 +1,26 @@
1
- import { getFunctionFormat as E } from "@fangzhongya/utils/basic/string/toFunction";
2
- import { firstLower as c } from "@fangzhongya/utils/basic/string/firstLower";
3
- function u(e) {
1
+ import { getFunctionFormat as L } from "@fangzhongya/utils/basic/string/toFunction";
2
+ import { firstLower as p } from "@fangzhongya/utils/basic/string/firstLower";
3
+ function s(e) {
4
4
  return e.replace(/\;(\s|\n\r)*$/, "");
5
5
  }
6
- function j(e) {
7
- return e = "let a = " + e, u(e).replace(/^let a = /, "");
8
- }
9
6
  function T(e) {
10
- return u(e);
7
+ return e = "let a = " + e, s(e).replace(/^let a = /, "");
8
+ }
9
+ function h(e) {
10
+ return s(e);
11
11
  }
12
12
  function x(e, t = "") {
13
13
  let n = (e + "").trim().split(/\n/);
14
14
  return n = n.map((r) => t + r), n.join(`
15
15
  `);
16
16
  }
17
- function p(e = "") {
17
+ function g(e = "") {
18
18
  e = e.trim();
19
19
  let t = `[\\s|\\n|\\r]*\\{((.|
20
20
  |\r)+?)\\}[\\s|\\n|\\r]*`, r = new RegExp("^" + t + "$").exec(e);
21
- return r && r.length > 0 ? p(r[1]) : e;
21
+ return r && r.length > 0 ? g(r[1]) : e;
22
22
  }
23
- const g = [
23
+ const y = [
24
24
  "Boolean",
25
25
  "Any",
26
26
  "String",
@@ -29,47 +29,47 @@ const g = [
29
29
  "Object",
30
30
  "Function"
31
31
  ];
32
- function s(e) {
33
- return g.includes(e) ? c(e) : e;
32
+ function f(e) {
33
+ return y.includes(e) ? p(e) : e;
34
34
  }
35
- function y(e) {
35
+ function b(e) {
36
36
  let n = new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);
37
37
  if (n && n.length > 0)
38
38
  return {
39
- own: s(n[1]),
39
+ own: f(n[1]),
40
40
  son: n[2]
41
41
  };
42
42
  }
43
- function f(e, t) {
44
- let n = y(e);
45
- n ? (t.push(n.own), n.son && f(n.son, t)) : t.push(e);
43
+ function a(e, t) {
44
+ let n = b(e);
45
+ n ? (t.push(n.own), n.son && a(n.son, t)) : t.push(e);
46
46
  }
47
- function a(e) {
47
+ function c(e) {
48
48
  e instanceof Array && (e = e[0]);
49
49
  const t = [];
50
- return e && f(e, t), t;
50
+ return e && a(e, t), t;
51
51
  }
52
- function b(e) {
52
+ function m(e) {
53
53
  const t = Object.prototype.toString.call(e);
54
54
  let r = /^\[[O|o]bject (.*)\]$/.exec(t), i = typeof e;
55
55
  return r && r.length > 0 && (i = r[1].toLowerCase()), i;
56
56
  }
57
- function h(e, t) {
58
- const n = b(e), r = a(t)[0];
57
+ function v(e, t) {
58
+ const n = m(e), r = c(t)[0];
59
59
  return r && r != "any" ? n == r : !0;
60
60
  }
61
- function v(e) {
61
+ function w(e) {
62
62
  if (typeof e == "string") {
63
63
  let t = !1;
64
64
  return (/^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e)) && (t = !0), t && (e = e.substring(1, e.length - 1)), e + "";
65
65
  } else return typeof e == "object" && e ? e.toString() : typeof e > "u" || typeof e == "object" && !e ? "" : e + "";
66
66
  }
67
- function w(e) {
67
+ function F(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 m(e) {
72
+ function d(e) {
73
73
  switch ((e[0] || "any").toLowerCase()) {
74
74
  case "string":
75
75
  return '""';
@@ -78,7 +78,7 @@ function m(e) {
78
78
  case "number":
79
79
  return "0";
80
80
  case "array":
81
- let n = m(e.splice(1));
81
+ let n = d(e.splice(1));
82
82
  return n = n == "undefined" ? "" : n, `[${n}]`;
83
83
  case "object":
84
84
  return "{}";
@@ -90,7 +90,7 @@ function m(e) {
90
90
  return "undefined";
91
91
  }
92
92
  }
93
- function d(e) {
93
+ function $(e) {
94
94
  let t = [];
95
95
  if (e)
96
96
  if (e = (e + "").trim(), e.startsWith("["))
@@ -101,36 +101,39 @@ function d(e) {
101
101
  }
102
102
  else
103
103
  t = ["any"];
104
- return t.map((n) => s(n));
104
+ return t.map((n) => f(n));
105
105
  }
106
- function F(e) {
106
+ function O(e) {
107
107
  return e.join("|");
108
108
  }
109
- function O(e) {
109
+ function A(e) {
110
110
  return e.split(",").map((n) => {
111
- let r = n.split(":"), i = r[0].trim(), l = r[1] || "", o = a(d(l));
111
+ let r = !0, i = n.split(":"), l = i[0].trim();
112
+ l.endsWith("?") && (r = !1, l = l.substring(0, -1));
113
+ let u = i[1] || "", o = c($(u));
112
114
  return {
113
115
  label: n,
114
- prop: i,
116
+ prop: l,
117
+ must: r,
115
118
  type: o[0],
116
119
  dataType: o,
117
- description: l.substring(l.lastIndexOf("]") + 1)
120
+ description: u.substring(u.lastIndexOf("]") + 1)
118
121
  };
119
122
  });
120
123
  }
121
124
  export {
122
- p as getFunBody,
123
- E as getFunctionFormat,
124
- b as getObjType,
125
- O as getParametersObj,
126
- a as getSonType,
127
- v as getString,
128
- m as getTypeValue,
129
- w as isDefaultType,
130
- h as isTypeEqual,
131
- T as prettierArrFormat,
132
- u as prettierFormat,
133
- j as prettierObjFormat,
134
- F as setDataType,
125
+ g as getFunBody,
126
+ L as getFunctionFormat,
127
+ m as getObjType,
128
+ A as getParametersObj,
129
+ c as getSonType,
130
+ w as getString,
131
+ d as getTypeValue,
132
+ F as isDefaultType,
133
+ v as isTypeEqual,
134
+ h as prettierArrFormat,
135
+ s as prettierFormat,
136
+ T as prettierObjFormat,
137
+ O as setDataType,
135
138
  x as vueFormat
136
139
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fangzhongya/vue-archive",
3
3
  "private": false,
4
- "version": "0.0.21",
4
+ "version": "0.0.23",
5
5
  "type": "module",
6
6
  "description ": "vue 组件注释生成文档",
7
7
  "author": "fangzhongya ",