@fangzhongya/vue-archive 0.0.45 → 0.0.46

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.
@@ -3452,7 +3452,13 @@ ${vueFormat(v, " ")}
3452
3452
  function getFunctionBody(v, key, propsText) {
3453
3453
  const text = propsText ? propsText[key] : "";
3454
3454
  if (text) {
3455
- return text;
3455
+ if (text.includes("=>")) {
3456
+ return text;
3457
+ } else if (text.includes("function")) {
3458
+ return text;
3459
+ } else {
3460
+ return funstr(v.toString());
3461
+ }
3456
3462
  } else {
3457
3463
  return funstr(v.toString());
3458
3464
  }
@@ -3555,22 +3561,33 @@ function getType(value) {
3555
3561
  });
3556
3562
  return [...new Set(arr)].sort();
3557
3563
  }
3558
- function getObjValue(d) {
3564
+ function getObjValue(d, type) {
3559
3565
  try {
3560
- return new Function(`{ return ${d} }`)();
3566
+ if (type?.toLowerCase() == "function") {
3567
+ if (typeof d === "string") {
3568
+ if (/^\((.|\n|\r)*\)$/.test(d)) {
3569
+ d = d.substring(1, d.length - 1);
3570
+ return new Function(`{ return ${d} }`)();
3571
+ }
3572
+ } else {
3573
+ return d;
3574
+ }
3575
+ } else {
3576
+ return new Function(`{ return ${d} }`)();
3577
+ }
3561
3578
  } catch (error) {
3562
3579
  return "" + d;
3563
3580
  }
3564
3581
  }
3565
3582
  function getDefaultValue(obj, is = true) {
3583
+ const vo = getSpecType(obj);
3584
+ const v = getTypeValue(vo.dataType);
3566
3585
  if (is) {
3567
- const vo = getSpecType(obj);
3568
- const v = getTypeValue(vo.dataType);
3569
3586
  const d = (obj.default || "").trim();
3570
- return getObjValue(d || v);
3587
+ return getObjValue(d || v, vo.dataType[0]);
3571
3588
  } else {
3572
3589
  const d = (obj.default || "").trim();
3573
- return getObjValue(d);
3590
+ return getObjValue(d, vo.dataType[0]);
3574
3591
  }
3575
3592
  }
3576
3593
 
@@ -3595,13 +3612,37 @@ function getDefault(ss, iss) {
3595
3612
  const cs = css.map((o) => o[0]);
3596
3613
  let ci = cs.indexOf(c);
3597
3614
  if (ci != -1) {
3598
- let reg = new RegExp(
3599
- "^\\" + css[ci][0] + "(([^\\" + css[ci][1] + "])*)\\" + css[ci][1] + (iss ? "\\s" : ""),
3600
- "gi"
3601
- );
3602
- let rs = reg.exec(ss);
3603
- if (rs) {
3604
- return rs[0];
3615
+ let bracketStack = [c];
3616
+ for (let i = 1; i < ss.length; i++) {
3617
+ const char = ss[i];
3618
+ if (cs.includes(char)) {
3619
+ bracketStack.push(char);
3620
+ } else {
3621
+ let is = false;
3622
+ char === "]" && bracketStack[bracketStack.length - 1] === "[";
3623
+ for (let v of css) {
3624
+ if (char === v[1] && bracketStack[bracketStack.length - 1] === v[0]) {
3625
+ is = true;
3626
+ break;
3627
+ }
3628
+ }
3629
+ if (is) {
3630
+ bracketStack.pop();
3631
+ }
3632
+ }
3633
+ if (bracketStack.length === 0) {
3634
+ if (iss && ss[i + 1] === " ") {
3635
+ return ss.substring(0, i + 1);
3636
+ } else {
3637
+ return ss.substring(0, i + 1);
3638
+ }
3639
+ }
3640
+ }
3641
+ } else {
3642
+ if (iss) {
3643
+ return ss.substring(0, ss.indexOf(" "));
3644
+ } else {
3645
+ return ss;
3605
3646
  }
3606
3647
  }
3607
3648
  }
@@ -3437,7 +3437,13 @@ ${vueFormat(v, " ")}
3437
3437
  function getFunctionBody(v, key, propsText) {
3438
3438
  const text = propsText ? propsText[key] : "";
3439
3439
  if (text) {
3440
- return text;
3440
+ if (text.includes("=>")) {
3441
+ return text;
3442
+ } else if (text.includes("function")) {
3443
+ return text;
3444
+ } else {
3445
+ return funstr(v.toString());
3446
+ }
3441
3447
  } else {
3442
3448
  return funstr(v.toString());
3443
3449
  }
@@ -3540,22 +3546,33 @@ function getType(value) {
3540
3546
  });
3541
3547
  return [...new Set(arr)].sort();
3542
3548
  }
3543
- function getObjValue(d) {
3549
+ function getObjValue(d, type) {
3544
3550
  try {
3545
- return new Function(`{ return ${d} }`)();
3551
+ if (type?.toLowerCase() == "function") {
3552
+ if (typeof d === "string") {
3553
+ if (/^\((.|\n|\r)*\)$/.test(d)) {
3554
+ d = d.substring(1, d.length - 1);
3555
+ return new Function(`{ return ${d} }`)();
3556
+ }
3557
+ } else {
3558
+ return d;
3559
+ }
3560
+ } else {
3561
+ return new Function(`{ return ${d} }`)();
3562
+ }
3546
3563
  } catch (error) {
3547
3564
  return "" + d;
3548
3565
  }
3549
3566
  }
3550
3567
  function getDefaultValue(obj, is = true) {
3568
+ const vo = getSpecType(obj);
3569
+ const v = getTypeValue(vo.dataType);
3551
3570
  if (is) {
3552
- const vo = getSpecType(obj);
3553
- const v = getTypeValue(vo.dataType);
3554
3571
  const d = (obj.default || "").trim();
3555
- return getObjValue(d || v);
3572
+ return getObjValue(d || v, vo.dataType[0]);
3556
3573
  } else {
3557
3574
  const d = (obj.default || "").trim();
3558
- return getObjValue(d);
3575
+ return getObjValue(d, vo.dataType[0]);
3559
3576
  }
3560
3577
  }
3561
3578
 
@@ -3580,13 +3597,37 @@ function getDefault(ss, iss) {
3580
3597
  const cs = css.map((o) => o[0]);
3581
3598
  let ci = cs.indexOf(c);
3582
3599
  if (ci != -1) {
3583
- let reg = new RegExp(
3584
- "^\\" + css[ci][0] + "(([^\\" + css[ci][1] + "])*)\\" + css[ci][1] + (iss ? "\\s" : ""),
3585
- "gi"
3586
- );
3587
- let rs = reg.exec(ss);
3588
- if (rs) {
3589
- return rs[0];
3600
+ let bracketStack = [c];
3601
+ for (let i = 1; i < ss.length; i++) {
3602
+ const char = ss[i];
3603
+ if (cs.includes(char)) {
3604
+ bracketStack.push(char);
3605
+ } else {
3606
+ let is = false;
3607
+ char === "]" && bracketStack[bracketStack.length - 1] === "[";
3608
+ for (let v of css) {
3609
+ if (char === v[1] && bracketStack[bracketStack.length - 1] === v[0]) {
3610
+ is = true;
3611
+ break;
3612
+ }
3613
+ }
3614
+ if (is) {
3615
+ bracketStack.pop();
3616
+ }
3617
+ }
3618
+ if (bracketStack.length === 0) {
3619
+ if (iss && ss[i + 1] === " ") {
3620
+ return ss.substring(0, i + 1);
3621
+ } else {
3622
+ return ss.substring(0, i + 1);
3623
+ }
3624
+ }
3625
+ }
3626
+ } else {
3627
+ if (iss) {
3628
+ return ss.substring(0, ss.indexOf(" "));
3629
+ } else {
3630
+ return ss;
3590
3631
  }
3591
3632
  }
3592
3633
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../../utils/index.cjs");require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");require("@fangzhongya/utils/html/getVueText");const o=require("../../utils/props.cjs"),i={titles:[],propss:[],slots:[],emitss:[],exposes:[]};function x(e,s){let r=e.charAt(0),l=[['"','"'],["'","'"],["`","`"],["(",")"],["{","}"],["[","]"]],a=l.map(p=>p[0]).indexOf(r);if(a!=-1){let n=new RegExp("^\\"+l[a][0]+"(([^\\"+l[a][1]+"])*)\\"+l[a][1]+(s?"\\s":""),"gi").exec(e);if(n)return n[0]}}function E(e){delete e.problems,delete e.source;let s=e.tag,r=e.name,l=e.description,t=e.default,a="";if(s=="default")r=r.trim(),r=x(r)||r;else if(s=="selectable")r=r.trim();else{if(r.includes("=")){const m=r.split("=");r=m[0];const g=m[1]+" "+l,d=x(g,!0);d?(t=d,l=g.replace(d,"")):t=e.default||m[1]||""}const n=/\s*\((.*)\)\s/gi.exec(l);n&&n.length>0&&(a=n[1],l=l.replace(n[0],""))}return e.name=r,e.default=t||"",e.description=l,e.selectable=a,e}function q(e){let s=["title","text","author","date"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),b(l),r.arr.forEach(t=>{f(t.key,t.value)})}function b(e){i.titles.push(e)}function O(e){let s=["props","name","type","default","selectable","description","descriptions","return"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"props"),r.arr.forEach(t=>{f(t.key,t.value)})}function T(e){let s=["slot","name","selectable","description","descriptions"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"slot"),r.arr.forEach(t=>{f(t.key,t.value)})}function y(e){let s=["emits","name","selectable","description","descriptions"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"emits"),r.arr.forEach(t=>{f(t.key,t.value)})}function j(e){let s=["expose","name","type","return","selectable","description","descriptions"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"expose"),r.arr.forEach(t=>{f(t.key,t.value)})}function c(e,s){const r=i[s+"name"]||[],l=e.name??e[s]?.name,t=r.indexOf(l);t>=0&&(i[s+"s"].splice(t,1),r.splice(t,1)),i[s+"s"].push(e),r.push(l),i[s+"name"]=r}function w(){Object.keys(i).forEach(e=>{i[e]=[]})}function u(e,s){const r={descriptions:e?.description||""},l=[];return e?.tags&&e.tags?.forEach(t=>{let a=t.tag,p=E(t);if(!r.hasOwnProperty(a))r[a]=p;else{const n={};n[a]=p,l.push({key:a,value:n})}}),{arr:l,obj:r}}function f(e,s){switch(e){case"title":return b(s),!0;case"text":return b(s),!0;case"props":return c(s,"props"),!0;case"slot":return c(s,"slot"),!0;case"emits":return c(s,"emits"),!0;case"expose":return c(s,"expose"),!0;default:return!1}}function k(e,s){switch(e){case"title":return q(s),!0;case"props":return O(s),!0;case"slot":return T(s),!0;case"emits":return y(s),!0;case"expose":return j(s),!0;default:return!1}}function N(e){return w(),e?.forEach(s=>{let r=s?.tags||[],l=r?.length||0;if(l>0)for(let t=0;t<l;t++){const a=r[t]||{};if(k(a.tag,s))break}}),i}function P(e){let s=h.getTextNotes(e);return N(s)}const S=[{label:"属性名",prop:"name",formatter:o.props.name},{label:"说明",prop:"description",formatter:o.props.description},{label:"类型",prop:"type",formatter:o.props.type},{label:"可选值",prop:"selectable",formatter:o.props.selectable},{label:"默认值",prop:"default",formatter:o.props.default}],F=[{label:"事件名",prop:"name",formatter:o.emits.name},{label:"说明",prop:"description",formatter:o.emits.description},{label:"回调参数",prop:"selectable",formatter:o.emits.selectable}],v=[{label:"方法名",prop:"name",formatter:o.expose.name},{label:"说明",prop:"description",formatter:o.expose.description},{label:"参数",prop:"selectable",formatter:o.expose.selectable},{label:"返回值",prop:"type",formatter(e){return o.expose.return(e)??o.expose.type(e)}}],z=[{label:"插槽名",prop:"name",formatter:o.slot.name},{label:"说明",prop:"description",formatter:o.slot.description},{label:"作用域参数",prop:"selectable",formatter:o.slot.selectable}];exports.getNotesText=P;exports.temits=F;exports.texpose=v;exports.tprops=S;exports.tslot=z;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("../../utils/index.cjs");require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");require("@fangzhongya/utils/html/getVueText");const o=require("../../utils/props.cjs"),c={titles:[],propss:[],slots:[],emitss:[],exposes:[]};function h(e,s){let r=e.charAt(0),l=[['"','"'],["'","'"],["`","`"],["(",")"],["{","}"],["[","]"]];const t=l.map(n=>n[0]);if(t.indexOf(r)!=-1){let n=[r];for(let a=1;a<e.length;a++){const u=e[a];if(t.includes(u))n.push(u);else{let m=!1;for(let f of l)if(u===f[1]&&n[n.length-1]===f[0]){m=!0;break}m&&n.pop()}if(n.length===0)return s&&e[a+1]===" ",e.substring(0,a+1)}}else return s?e.substring(0,e.indexOf(" ")):e}function E(e){delete e.problems,delete e.source;let s=e.tag,r=e.name,l=e.description,t=e.default,i="";if(s=="default")r=r.trim(),r=h(r)||r;else if(s=="selectable")r=r.trim();else{if(r.includes("=")){const u=r.split("=");r=u[0];const m=u[1]+" "+l,f=h(m,!0);f?(t=f,l=m.replace(f,"")):t=e.default||u[1]||""}const a=/\s*\((.*)\)\s/gi.exec(l);a&&a.length>0&&(i=a[1],l=l.replace(a[0],""))}return e.name=r,e.default=t||"",e.description=l,e.selectable=i,e}function q(e){let s=["title","text","author","date"],r=d(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),g(l),r.arr.forEach(t=>{b(t.key,t.value)})}function g(e){c.titles.push(e)}function O(e){let s=["props","name","type","default","selectable","description","descriptions","return"],r=d(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),p(l,"props"),r.arr.forEach(t=>{b(t.key,t.value)})}function T(e){let s=["slot","name","selectable","description","descriptions"],r=d(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),p(l,"slot"),r.arr.forEach(t=>{b(t.key,t.value)})}function y(e){let s=["emits","name","selectable","description","descriptions"],r=d(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),p(l,"emits"),r.arr.forEach(t=>{b(t.key,t.value)})}function k(e){let s=["expose","name","type","return","selectable","description","descriptions"],r=d(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),p(l,"expose"),r.arr.forEach(t=>{b(t.key,t.value)})}function p(e,s){const r=c[s+"name"]||[],l=e.name??e[s]?.name,t=r.indexOf(l);t>=0&&(c[s+"s"].splice(t,1),r.splice(t,1)),c[s+"s"].push(e),r.push(l),c[s+"name"]=r}function j(){Object.keys(c).forEach(e=>{c[e]=[]})}function d(e,s){const r={descriptions:e?.description||""},l=[];return e?.tags&&e.tags?.forEach(t=>{let i=t.tag,n=E(t);if(!r.hasOwnProperty(i))r[i]=n;else{const a={};a[i]=n,l.push({key:i,value:a})}}),{arr:l,obj:r}}function b(e,s){switch(e){case"title":return g(s),!0;case"text":return g(s),!0;case"props":return p(s,"props"),!0;case"slot":return p(s,"slot"),!0;case"emits":return p(s,"emits"),!0;case"expose":return p(s,"expose"),!0;default:return!1}}function S(e,s){switch(e){case"title":return q(s),!0;case"props":return O(s),!0;case"slot":return T(s),!0;case"emits":return y(s),!0;case"expose":return k(s),!0;default:return!1}}function w(e){return j(),e?.forEach(s=>{let r=s?.tags||[],l=r?.length||0;if(l>0)for(let t=0;t<l;t++){const i=r[t]||{};if(S(i.tag,s))break}}),c}function N(e){let s=x.getTextNotes(e);return w(s)}const P=[{label:"属性名",prop:"name",formatter:o.props.name},{label:"说明",prop:"description",formatter:o.props.description},{label:"类型",prop:"type",formatter:o.props.type},{label:"可选值",prop:"selectable",formatter:o.props.selectable},{label:"默认值",prop:"default",formatter:o.props.default}],v=[{label:"事件名",prop:"name",formatter:o.emits.name},{label:"说明",prop:"description",formatter:o.emits.description},{label:"回调参数",prop:"selectable",formatter:o.emits.selectable}],F=[{label:"方法名",prop:"name",formatter:o.expose.name},{label:"说明",prop:"description",formatter:o.expose.description},{label:"参数",prop:"selectable",formatter:o.expose.selectable},{label:"返回值",prop:"type",formatter(e){return o.expose.return(e)??o.expose.type(e)}}],z=[{label:"插槽名",prop:"name",formatter:o.slot.name},{label:"说明",prop:"description",formatter:o.slot.description},{label:"作用域参数",prop:"selectable",formatter:o.slot.selectable}];exports.getNotesText=N;exports.temits=v;exports.texpose=F;exports.tprops=P;exports.tslot=z;
@@ -1,4 +1,4 @@
1
- import { getTextNotes as T } from "../../utils/index.js";
1
+ import { getTextNotes as k } from "../../utils/index.js";
2
2
  import "@fangzhongya/utils/basic/object/mergeObject";
3
3
  import "@fangzhongya/utils/basic/array/toggleArray";
4
4
  import "@fangzhongya/utils/name/humpToLine";
@@ -11,8 +11,8 @@ import "@fangzhongya/utils/basic/string/firstUpper";
11
11
  import "@fangzhongya/utils/urls/getSuffix";
12
12
  import "@fangzhongya/utils/basic/array/replaceAfter";
13
13
  import "@fangzhongya/utils/html/getVueText";
14
- import { props as p, emits as g, expose as f, slot as h } from "../../utils/props.js";
15
- const n = {
14
+ import { props as m, emits as g, expose as d, slot as x } from "../../utils/props.js";
15
+ const i = {
16
16
  titles: [],
17
17
  propss: [],
18
18
  slots: [],
@@ -27,36 +27,49 @@ function O(e, s) {
27
27
  ["(", ")"],
28
28
  ["{", "}"],
29
29
  ["[", "]"]
30
- ], o = l.map((c) => c[0]).indexOf(r);
31
- if (o != -1) {
32
- let a = new RegExp(
33
- "^\\" + l[o][0] + "(([^\\" + l[o][1] + "])*)\\" + l[o][1] + (s ? "\\s" : ""),
34
- "gi"
35
- ).exec(e);
36
- if (a)
37
- return a[0];
38
- }
30
+ ];
31
+ const t = l.map((a) => a[0]);
32
+ if (t.indexOf(r) != -1) {
33
+ let a = [r];
34
+ for (let o = 1; o < e.length; o++) {
35
+ const p = e[o];
36
+ if (t.includes(p))
37
+ a.push(p);
38
+ else {
39
+ let u = !1;
40
+ for (let f of l)
41
+ if (p === f[1] && a[a.length - 1] === f[0]) {
42
+ u = !0;
43
+ break;
44
+ }
45
+ u && a.pop();
46
+ }
47
+ if (a.length === 0)
48
+ return s && e[o + 1] === " ", e.substring(0, o + 1);
49
+ }
50
+ } else
51
+ return s ? e.substring(0, e.indexOf(" ")) : e;
39
52
  }
40
- function y(e) {
53
+ function T(e) {
41
54
  delete e.problems, delete e.source;
42
- let s = e.tag, r = e.name, l = e.description, t = e.default, o = "";
55
+ let s = e.tag, r = e.name, l = e.description, t = e.default, n = "";
43
56
  if (s == "default")
44
57
  r = r.trim(), r = O(r) || r;
45
58
  else if (s == "selectable")
46
59
  r = r.trim();
47
60
  else {
48
61
  if (r.includes("=")) {
49
- const d = r.split("=");
50
- r = d[0];
51
- const E = d[1] + " " + l, b = O(E, !0);
52
- b ? (t = b, l = E.replace(b, "")) : t = e.default || d[1] || "";
62
+ const p = r.split("=");
63
+ r = p[0];
64
+ const u = p[1] + " " + l, f = O(u, !0);
65
+ f ? (t = f, l = u.replace(f, "")) : t = e.default || p[1] || "";
53
66
  }
54
- const a = /\s*\((.*)\)\s/gi.exec(l);
55
- a && a.length > 0 && (o = a[1], l = l.replace(a[0], ""));
67
+ const o = /\s*\((.*)\)\s/gi.exec(l);
68
+ o && o.length > 0 && (n = o[1], l = l.replace(o[0], ""));
56
69
  }
57
- return e.name = r, e.default = t || "", e.description = l, e.selectable = o, e;
70
+ return e.name = r, e.default = t || "", e.description = l, e.selectable = n, e;
58
71
  }
59
- function w(e) {
72
+ function y(e) {
60
73
  let s = [
61
74
  "title",
62
75
  // 'name',
@@ -65,15 +78,15 @@ function w(e) {
65
78
  "date"
66
79
  // 'description',
67
80
  // 'descriptions',
68
- ], r = u(e), l = {};
81
+ ], r = b(e), l = {};
69
82
  s.forEach((t) => {
70
83
  l[t] = r.obj[t];
71
- }), x(l), r.arr.forEach((t) => {
72
- m(t.key, t.value);
84
+ }), E(l), r.arr.forEach((t) => {
85
+ h(t.key, t.value);
73
86
  });
74
87
  }
75
- function x(e) {
76
- n.titles.push(e);
88
+ function E(e) {
89
+ i.titles.push(e);
77
90
  }
78
91
  function j(e) {
79
92
  let s = [
@@ -85,27 +98,27 @@ function j(e) {
85
98
  "description",
86
99
  "descriptions",
87
100
  "return"
88
- ], r = u(e), l = {};
101
+ ], r = b(e), l = {};
89
102
  s.forEach((t) => {
90
103
  l[t] = r.obj[t];
91
- }), i(l, "props"), r.arr.forEach((t) => {
92
- m(t.key, t.value);
104
+ }), c(l, "props"), r.arr.forEach((t) => {
105
+ h(t.key, t.value);
93
106
  });
94
107
  }
95
- function k(e) {
96
- let s = ["slot", "name", "selectable", "description", "descriptions"], r = u(e), l = {};
108
+ function w(e) {
109
+ let s = ["slot", "name", "selectable", "description", "descriptions"], r = b(e), l = {};
97
110
  s.forEach((t) => {
98
111
  l[t] = r.obj[t];
99
- }), i(l, "slot"), r.arr.forEach((t) => {
100
- m(t.key, t.value);
112
+ }), c(l, "slot"), r.arr.forEach((t) => {
113
+ h(t.key, t.value);
101
114
  });
102
115
  }
103
116
  function F(e) {
104
- let s = ["emits", "name", "selectable", "description", "descriptions"], r = u(e), l = {};
117
+ let s = ["emits", "name", "selectable", "description", "descriptions"], r = b(e), l = {};
105
118
  s.forEach((t) => {
106
119
  l[t] = r.obj[t];
107
- }), i(l, "emits"), r.arr.forEach((t) => {
108
- m(t.key, t.value);
120
+ }), c(l, "emits"), r.arr.forEach((t) => {
121
+ h(t.key, t.value);
109
122
  });
110
123
  }
111
124
  function N(e) {
@@ -117,35 +130,35 @@ function N(e) {
117
130
  "selectable",
118
131
  "description",
119
132
  "descriptions"
120
- ], r = u(e), l = {};
133
+ ], r = b(e), l = {};
121
134
  s.forEach((t) => {
122
135
  l[t] = r.obj[t];
123
- }), i(l, "expose"), r.arr.forEach((t) => {
124
- m(t.key, t.value);
136
+ }), c(l, "expose"), r.arr.forEach((t) => {
137
+ h(t.key, t.value);
125
138
  });
126
139
  }
127
- function i(e, s) {
128
- const r = n[s + "name"] || [], l = e.name ?? e[s]?.name, t = r.indexOf(l);
129
- t >= 0 && (n[s + "s"].splice(t, 1), r.splice(t, 1)), n[s + "s"].push(e), r.push(l), n[s + "name"] = r;
140
+ function c(e, s) {
141
+ const r = i[s + "name"] || [], l = e.name ?? e[s]?.name, t = r.indexOf(l);
142
+ t >= 0 && (i[s + "s"].splice(t, 1), r.splice(t, 1)), i[s + "s"].push(e), r.push(l), i[s + "name"] = r;
130
143
  }
131
144
  function P() {
132
- Object.keys(n).forEach((e) => {
133
- n[e] = [];
145
+ Object.keys(i).forEach((e) => {
146
+ i[e] = [];
134
147
  });
135
148
  }
136
- function u(e, s) {
149
+ function b(e, s) {
137
150
  const r = {
138
151
  descriptions: e?.description || ""
139
152
  }, l = [];
140
153
  return e?.tags && e.tags?.forEach((t) => {
141
- let o = t.tag, c = y(t);
142
- if (!r.hasOwnProperty(o))
143
- r[o] = c;
154
+ let n = t.tag, a = T(t);
155
+ if (!r.hasOwnProperty(n))
156
+ r[n] = a;
144
157
  else {
145
- const a = {};
146
- a[o] = c, l.push({
147
- key: o,
148
- value: a
158
+ const o = {};
159
+ o[n] = a, l.push({
160
+ key: n,
161
+ value: o
149
162
  });
150
163
  }
151
164
  }), {
@@ -153,32 +166,32 @@ function u(e, s) {
153
166
  obj: r
154
167
  };
155
168
  }
156
- function m(e, s) {
169
+ function h(e, s) {
157
170
  switch (e) {
158
171
  case "title":
159
- return x(s), !0;
172
+ return E(s), !0;
160
173
  case "text":
161
- return x(s), !0;
174
+ return E(s), !0;
162
175
  case "props":
163
- return i(s, "props"), !0;
176
+ return c(s, "props"), !0;
164
177
  case "slot":
165
- return i(s, "slot"), !0;
178
+ return c(s, "slot"), !0;
166
179
  case "emits":
167
- return i(s, "emits"), !0;
180
+ return c(s, "emits"), !0;
168
181
  case "expose":
169
- return i(s, "expose"), !0;
182
+ return c(s, "expose"), !0;
170
183
  default:
171
184
  return !1;
172
185
  }
173
186
  }
174
- function z(e, s) {
187
+ function S(e, s) {
175
188
  switch (e) {
176
189
  case "title":
177
- return w(s), !0;
190
+ return y(s), !0;
178
191
  case "props":
179
192
  return j(s), !0;
180
193
  case "slot":
181
- return k(s), !0;
194
+ return w(s), !0;
182
195
  case "emits":
183
196
  return F(s), !0;
184
197
  case "expose":
@@ -187,46 +200,46 @@ function z(e, s) {
187
200
  return !1;
188
201
  }
189
202
  }
190
- function A(e) {
203
+ function v(e) {
191
204
  return P(), e?.forEach((s) => {
192
205
  let r = s?.tags || [], l = r?.length || 0;
193
206
  if (l > 0)
194
207
  for (let t = 0; t < l; t++) {
195
- const o = r[t] || {};
196
- if (z(o.tag, s))
208
+ const n = r[t] || {};
209
+ if (S(n.tag, s))
197
210
  break;
198
211
  }
199
- }), n;
212
+ }), i;
200
213
  }
201
- function M(e) {
202
- let s = T(e);
203
- return A(s);
214
+ function Q(e) {
215
+ let s = k(e);
216
+ return v(s);
204
217
  }
205
- const Q = [
218
+ const R = [
206
219
  {
207
220
  label: "属性名",
208
221
  prop: "name",
209
- formatter: p.name
222
+ formatter: m.name
210
223
  },
211
224
  {
212
225
  label: "说明",
213
226
  prop: "description",
214
- formatter: p.description
227
+ formatter: m.description
215
228
  },
216
229
  {
217
230
  label: "类型",
218
231
  prop: "type",
219
- formatter: p.type
232
+ formatter: m.type
220
233
  },
221
234
  {
222
235
  label: "可选值",
223
236
  prop: "selectable",
224
- formatter: p.selectable
237
+ formatter: m.selectable
225
238
  },
226
239
  {
227
240
  label: "默认值",
228
241
  prop: "default",
229
- formatter: p.default
242
+ formatter: m.default
230
243
  }
231
244
  ], U = [
232
245
  {
@@ -248,46 +261,46 @@ const Q = [
248
261
  {
249
262
  label: "方法名",
250
263
  prop: "name",
251
- formatter: f.name
264
+ formatter: d.name
252
265
  },
253
266
  {
254
267
  label: "说明",
255
268
  prop: "description",
256
- formatter: f.description
269
+ formatter: d.description
257
270
  },
258
271
  {
259
272
  label: "参数",
260
273
  prop: "selectable",
261
- formatter: f.selectable
274
+ formatter: d.selectable
262
275
  },
263
276
  {
264
277
  label: "返回值",
265
278
  prop: "type",
266
279
  formatter(e) {
267
- return f.return(e) ?? f.type(e);
280
+ return d.return(e) ?? d.type(e);
268
281
  }
269
282
  }
270
283
  ], W = [
271
284
  {
272
285
  label: "插槽名",
273
286
  prop: "name",
274
- formatter: h.name
287
+ formatter: x.name
275
288
  },
276
289
  {
277
290
  label: "说明",
278
291
  prop: "description",
279
- formatter: h.description
292
+ formatter: x.description
280
293
  },
281
294
  {
282
295
  label: "作用域参数",
283
296
  prop: "selectable",
284
- formatter: h.selectable
297
+ formatter: x.selectable
285
298
  }
286
299
  ];
287
300
  export {
288
- M as getNotesText,
301
+ Q as getNotesText,
289
302
  U as temits,
290
303
  V as texpose,
291
- Q as tprops,
304
+ R as tprops,
292
305
  W as tslot
293
306
  };
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");const H=require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");const J=require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");const D=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const l=require("./util.cjs"),q=require("../../utils/props.cjs"),N=require("@fangzhongya/utils/basic/string/toFunction"),v=["class"];function V(e,n){return e.filter(t=>t.name==n)[0]}function w(e){return e.map(n=>(n.prop||"...arr")+":"+l.setDataType(n.dataType)).join(",")}function A(e,n,t,s,u,h){const p=[],r=[];let b=!0;const x=q.getPropsValue(n.propss||[]),z=q.getEmitsValue(n.emitss||[]),B=q.getExposeValue(n.exposes||[]),U=q.getSlotValue(n.slots||[]);Object.keys(t).forEach(o=>{let m=t[o];if(/^on[A-Z]/.test(o)&&typeof m=="function"){let i=o.substring(2);const c=o.split(":");let g;if(c.length>1?(g=c[0]+c.slice(1).map(f=>D.firstUpper(f)).join(""),i=J.firstLower(i)):(g=c[0],i=H.humpToLine(i)),c.includes("-")){let f=g.split("-");f=f.map(($,F)=>F!=0?D.firstUpper($):$),g=f.join("")}p.push(" @"+i+'="'+g+'"');const a=V(z,i)||{},y=a.selectable||"",S=l.parseParamString(y),d=w(S);r.push(`// ${a.description} ${a.name}: (${a.selectable})`),r.push("function "+g+"("+d+") {"),S.forEach(f=>{const $=f.name||"arr";r.push(" console.log('"+f.label+"', "+$+")")}),r.push("}")}else{let i=o;v.includes(o)&&(i=o+"1"),p.push(" :"+o+'="'+i+'"');const c=V(x,o)||{},g=E(c);if(r.push(`// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`),typeof m=="function")r.push("const "+o+" = "+P(m,o,u));else if(b&&(b=!1,r.unshift("import { ref } from 'vue';")),typeof m>"u")if(g.type=="function"){const a=Z(c);r.push("const "+i+" = "+a+";")}else{const a=l.getTypeValue(g.dataType);r.push("const "+i+" = ref("+(a==="undefined"?"":a)+");")}else{let a=j(m,o,u);r.push("const "+i+" = ref("+a+");")}}});const O=Object.values(h||{});O.length>0&&(b&&(b=!1,r.unshift("import { ref } from 'vue';")),p.unshift(' ref="refDom"'),r.push("const refDom = ref()"),O.forEach(o=>{const m=V(B,o.name)||{};r.push(`// ${m.description} ${m.name}:(${m.selectable}) ${m.type}`);const i=o.name+"Value",c=l.parseParamString(m?.selectable||""),g=[],a=o.params||[];c.forEach((y,S)=>{const d=y.name;if(d){const f=d+o.name,$=a[S];if(r.push(`// ${y.label}`),typeof $=="function")r.push("const "+f+" = "+P($,d,o.text));else if(typeof $>"u")r.push("const "+f+" = "+l.getTypeValue(y.dataType)+";");else{let F=j($,d,o.text);r.push("const "+f+" = "+F+";")}g.push(f)}}),o.type==="function"?r.push(`const ${i} = refDom.value?.${o.name}(${g.join(", ")})`):r.push(`const ${i} = refDom.value?.${o.name}`),r.push(`console.log('"${m.type}"', ${i})`)})),p.length>0&&p.unshift("");const C=M(s,U);return`<!--${e}-->
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");const H=require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");const J=require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");const D=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const l=require("./util.cjs"),T=require("../../utils/props.cjs"),N=require("@fangzhongya/utils/basic/string/toFunction"),A=["class"];function q(e,n){return e.filter(t=>t.name==n)[0]}function L(e){return e.map(n=>(n.prop||"...arr")+":"+l.setDataType(n.dataType)).join(",")}function M(e,n,t,s,o,h){const p=[],r=[];let b=!0;const x=T.getPropsValue(n.propss||[]),z=T.getEmitsValue(n.emitss||[]),B=T.getExposeValue(n.exposes||[]),C=T.getSlotValue(n.slots||[]);Object.keys(t).forEach(i=>{let m=t[i];if(/^on[A-Z]/.test(i)&&typeof m=="function"){let u=i.substring(2);const c=i.split(":");let g;if(c.length>1?(g=c[0]+c.slice(1).map(f=>D.firstUpper(f)).join(""),u=J.firstLower(u)):(g=c[0],u=H.humpToLine(u)),c.includes("-")){let f=g.split("-");f=f.map(($,F)=>F!=0?D.firstUpper($):$),g=f.join("")}p.push(" @"+u+'="'+g+'"');const a=q(z,u)||{},d=a.selectable||"",S=l.parseParamString(d),y=L(S);r.push(`// ${a.description} ${a.name}: (${a.selectable})`),r.push("function "+g+"("+y+") {"),S.forEach(f=>{const $=f.name||"arr";r.push(" console.log('"+f.label+"', "+$+")")}),r.push("}")}else{let u=i;A.includes(i)&&(u=i+"1"),p.push(" :"+i+'="'+u+'"');const c=q(x,i)||{},g=w(c);if(r.push(`// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`),typeof m=="function")r.push("const "+i+" = "+P(m,i,o));else if(b&&(b=!1,r.unshift("import { ref } from 'vue';")),typeof m>"u")if(g.type=="function"){const a=v(c);r.push("const "+u+" = "+a+";")}else{const a=l.getTypeValue(g.dataType);r.push("const "+u+" = ref("+(a==="undefined"?"":a)+");")}else{let a=E(m,i,o);r.push("const "+u+" = ref("+a+");")}}});const O=Object.values(h||{});O.length>0&&(b&&(b=!1,r.unshift("import { ref } from 'vue';")),p.unshift(' ref="refDom"'),r.push("const refDom = ref()"),O.forEach(i=>{const m=q(B,i.name)||{};r.push(`// ${m.description} ${m.name}:(${m.selectable}) ${m.type}`);const u=i.name+"Value",c=l.parseParamString(m?.selectable||""),g=[],a=i.params||[];c.forEach((d,S)=>{const y=d.name;if(y){const f=y+i.name,$=a[S];if(r.push(`// ${d.label}`),typeof $=="function")r.push("const "+f+" = "+P($,y,i.text));else if(typeof $>"u")r.push("const "+f+" = "+l.getTypeValue(d.dataType)+";");else{let F=E($,y,i.text);r.push("const "+f+" = "+F+";")}g.push(f)}}),i.type==="function"?r.push(`const ${u} = refDom.value?.${i.name}(${g.join(", ")})`):r.push(`const ${u} = refDom.value?.${i.name}`),r.push(`console.log('"${m.type}"', ${u})`)})),p.length>0&&p.unshift("");const U=Z(s,C);return`<!--${e}-->
2
2
  <template>
3
3
  <div>
4
4
  <${e}${p.join(`
5
- `)}>${C.join(`
5
+ `)}>${U.join(`
6
6
  `)}
7
7
  </${e}>
8
8
  </div>
@@ -11,11 +11,11 @@
11
11
  ${r.join(`
12
12
  `)}
13
13
  <\/script>
14
- `}function M(e={},n){const t=[];return Object.keys(e).forEach(s=>{const u=V(n,s)||{},h=e[s];if(h){const p=` <!-- ${u.description} ${u.name}:(${u.selectable}) -->
14
+ `}function Z(e={},n){const t=[];return Object.keys(e).forEach(s=>{const o=q(n,s)||{},h=e[s];if(h){const p=` <!-- ${o.description} ${o.name}:(${o.selectable}) -->
15
15
  <template #${s}="scope">
16
16
  ${l.vueFormat(h," ")}
17
- </template>`;t.push(p)}}),t&&t.length>0&&t.unshift(""),t}function P(e,n,t){const s=t?t[n]:"";return s||L(e.toString())}function L(e){const n=N.getFunctionFormat(l.prettierFormat(e));if(n){let t=`{
17
+ </template>`;t.push(p)}}),t&&t.length>0&&t.unshift(""),t}function P(e,n,t){const s=t?t[n]:"";return s&&(s.includes("=>")||s.includes("function"))?s:j(e.toString())}function j(e){const n=N.getFunctionFormat(l.prettierFormat(e));if(n){let t=`{
18
18
  ${l.vueFormat(l.getFunBody(n.body)," ")}
19
- }`;return`function (${n.param}) ${t}`}else return"undefined"}function Z(e){const n=l.parseParamString(e.selectable),t=w(n);let s="";e.return&&(s="return ");let u=`{
19
+ }`;return`function (${n.param}) ${t}`}else return"undefined"}function v(e){const n=l.parseParamString(e.selectable),t=L(n);let s="";e.return&&(s="return ");let o=`{
20
20
  ${l.vueFormat(l.getFunBody(s)," ")}
21
- }`;return`function (${t}) ${u}`}function G(e){const n=e.trim();return/^\(/.test(n)?L(n):JSON.stringify(e)}function j(e,n,t){const s=t?t[n]:"";return s?typeof s=="string"?T(s):s:typeof e=="string"?G(e+""):JSON.stringify(e)}function E(e){let n=I(e?.type),t="any";n.length==1&&(t=n[0].split("<")[0]);const s=t;let u=(e?.selectable||"").trim(),h=[];return u&&t!="boolean"&&(u.includes("|")?u.split("|").forEach(p=>{if(p){let r=p.split(":");h.push({label:p,prop:T(r[0].trim())})}}):h=l.parseParamString(u),t=="function"?t="function":t=="array"?t="choice":h.length>1&&(t="select")),{arr:h,zdtype:s,type:t,dataType:n}}function I(e){let n=[];return(e||"").trim().toLowerCase().split(",").forEach(s=>{s=s.trim(),s&&n.push(s)}),[...new Set(n)].sort()}function T(e){try{return new Function(`{ return ${e} }`)()}catch{return""+e}}function K(e,n=!0){if(n){const t=E(e),s=l.getTypeValue(t.dataType),u=(e.default||"").trim();return T(u||s)}else{const t=(e.default||"").trim();return T(t)}}exports.getDefaultValue=K;exports.getHmtl=A;exports.getSpecType=E;exports.setValStringify=j;
21
+ }`;return`function (${t}) ${o}`}function G(e){const n=e.trim();return/^\(/.test(n)?j(n):JSON.stringify(e)}function E(e,n,t){const s=t?t[n]:"";return s?typeof s=="string"?V(s):s:typeof e=="string"?G(e+""):JSON.stringify(e)}function w(e){let n=I(e?.type),t="any";n.length==1&&(t=n[0].split("<")[0]);const s=t;let o=(e?.selectable||"").trim(),h=[];return o&&t!="boolean"&&(o.includes("|")?o.split("|").forEach(p=>{if(p){let r=p.split(":");h.push({label:p,prop:V(r[0].trim())})}}):h=l.parseParamString(o),t=="function"?t="function":t=="array"?t="choice":h.length>1&&(t="select")),{arr:h,zdtype:s,type:t,dataType:n}}function I(e){let n=[];return(e||"").trim().toLowerCase().split(",").forEach(s=>{s=s.trim(),s&&n.push(s)}),[...new Set(n)].sort()}function V(e,n){try{if(n?.toLowerCase()=="function")if(typeof e=="string"){if(/^\((.|\n|\r)*\)$/.test(e))return e=e.substring(1,e.length-1),new Function(`{ return ${e} }`)()}else return e;else return new Function(`{ return ${e} }`)()}catch{return""+e}}function K(e,n=!0){const t=w(e),s=l.getTypeValue(t.dataType);if(n){const o=(e.default||"").trim();return V(o||s,t.dataType[0])}else{const o=(e.default||"").trim();return V(o,t.dataType[0])}}exports.getDefaultValue=K;exports.getHmtl=M;exports.getSpecType=w;exports.setValStringify=E;
@@ -9,90 +9,90 @@ import "@fangzhongya/utils/basic/array/asyncMergeArray";
9
9
  import { firstUpper as D } from "@fangzhongya/utils/basic/string/firstUpper";
10
10
  import "@fangzhongya/utils/urls/getSuffix";
11
11
  import "@fangzhongya/utils/basic/array/replaceAfter";
12
- import { getTypeValue as F, parseParamString as V, setDataType as q, vueFormat as T, prettierFormat as G, getFunBody as z } from "./util.js";
12
+ import { getTypeValue as E, parseParamString as T, setDataType as q, vueFormat as w, prettierFormat as G, getFunBody as z } from "./util.js";
13
13
  import { getPropsValue as I, getEmitsValue as K, getExposeValue as M, getSlotValue as Q } from "../../utils/props.js";
14
14
  import { getFunctionFormat as R } from "@fangzhongya/utils/basic/string/toFunction";
15
15
  const W = ["class"];
16
16
  function S(t, n) {
17
17
  return t.filter((e) => e.name == n)[0];
18
18
  }
19
- function L(t) {
19
+ function C(t) {
20
20
  return t.map((n) => (n.prop || "...arr") + ":" + q(n.dataType)).join(",");
21
21
  }
22
- function ht(t, n, e, s, c, h) {
22
+ function ht(t, n, e, s, i, h) {
23
23
  const p = [], r = [];
24
- let y = !0;
25
- const C = I(n.propss || []), J = K(n.emitss || []), N = M(n.exposes || []), A = Q(n.slots || []);
24
+ let d = !0;
25
+ const B = I(n.propss || []), J = K(n.emitss || []), N = M(n.exposes || []), A = Q(n.slots || []);
26
26
  Object.keys(e).forEach((o) => {
27
27
  let a = e[o];
28
28
  if (/^on[A-Z]/.test(o) && typeof a == "function") {
29
- let i = o.substring(2);
29
+ let c = o.substring(2);
30
30
  const u = o.split(":");
31
31
  let m;
32
- if (u.length > 1 ? (m = u[0] + u.slice(1).map((f) => D(f)).join(""), i = Z(i)) : (m = u[0], i = U(i)), u.includes("-")) {
32
+ if (u.length > 1 ? (m = u[0] + u.slice(1).map((f) => D(f)).join(""), c = Z(c)) : (m = u[0], c = U(c)), u.includes("-")) {
33
33
  let f = m.split("-");
34
- f = f.map(($, E) => E != 0 ? D($) : $), m = f.join("");
34
+ f = f.map((g, j) => j != 0 ? D(g) : g), m = f.join("");
35
35
  }
36
- p.push(" @" + i + '="' + m + '"');
37
- const l = S(J, i) || {}, d = l.selectable || "", b = V(d), g = L(b);
38
- r.push(`// ${l.description} ${l.name}: (${l.selectable})`), r.push("function " + m + "(" + g + ") {"), b.forEach((f) => {
39
- const $ = f.name || "arr";
40
- r.push(" console.log('" + f.label + "', " + $ + ")");
36
+ p.push(" @" + c + '="' + m + '"');
37
+ const l = S(J, c) || {}, y = l.selectable || "", b = T(y), $ = C(b);
38
+ r.push(`// ${l.description} ${l.name}: (${l.selectable})`), r.push("function " + m + "(" + $ + ") {"), b.forEach((f) => {
39
+ const g = f.name || "arr";
40
+ r.push(" console.log('" + f.label + "', " + g + ")");
41
41
  }), r.push("}");
42
42
  } else {
43
- let i = o;
44
- W.includes(o) && (i = o + "1"), p.push(" :" + o + '="' + i + '"');
45
- const u = S(C, o) || {}, m = B(u);
43
+ let c = o;
44
+ W.includes(o) && (c = o + "1"), p.push(" :" + o + '="' + c + '"');
45
+ const u = S(B, o) || {}, m = P(u);
46
46
  if (r.push(
47
47
  `// ${u.description} ${u.name}: {${u.type}} (${u.selectable})`
48
48
  ), typeof a == "function")
49
49
  r.push(
50
- "const " + o + " = " + w(a, o, c)
50
+ "const " + o + " = " + x(a, o, i)
51
51
  );
52
- else if (y && (y = !1, r.unshift("import { ref } from 'vue';")), typeof a > "u")
52
+ else if (d && (d = !1, r.unshift("import { ref } from 'vue';")), typeof a > "u")
53
53
  if (m.type == "function") {
54
54
  const l = Y(u);
55
- r.push("const " + i + " = " + l + ";");
55
+ r.push("const " + c + " = " + l + ";");
56
56
  } else {
57
- const l = F(m.dataType);
57
+ const l = E(m.dataType);
58
58
  r.push(
59
- "const " + i + " = ref(" + (l === "undefined" ? "" : l) + ");"
59
+ "const " + c + " = ref(" + (l === "undefined" ? "" : l) + ");"
60
60
  );
61
61
  }
62
62
  else {
63
- let l = x(a, o, c);
64
- r.push("const " + i + " = ref(" + l + ");");
63
+ let l = L(a, o, i);
64
+ r.push("const " + c + " = ref(" + l + ");");
65
65
  }
66
66
  }
67
67
  });
68
68
  const O = Object.values(h || {});
69
- O.length > 0 && (y && (y = !1, r.unshift("import { ref } from 'vue';")), p.unshift(' ref="refDom"'), r.push("const refDom = ref()"), O.forEach((o) => {
69
+ O.length > 0 && (d && (d = !1, r.unshift("import { ref } from 'vue';")), p.unshift(' ref="refDom"'), r.push("const refDom = ref()"), O.forEach((o) => {
70
70
  const a = S(N, o.name) || {};
71
71
  r.push(
72
72
  `// ${a.description} ${a.name}:(${a.selectable}) ${a.type}`
73
73
  );
74
- const i = o.name + "Value", u = V(a?.selectable || ""), m = [], l = o.params || [];
75
- u.forEach((d, b) => {
76
- const g = d.name;
77
- if (g) {
78
- const f = g + o.name, $ = l[b];
79
- if (r.push(`// ${d.label}`), typeof $ == "function")
74
+ const c = o.name + "Value", u = T(a?.selectable || ""), m = [], l = o.params || [];
75
+ u.forEach((y, b) => {
76
+ const $ = y.name;
77
+ if ($) {
78
+ const f = $ + o.name, g = l[b];
79
+ if (r.push(`// ${y.label}`), typeof g == "function")
80
80
  r.push(
81
- "const " + f + " = " + w($, g, o.text)
81
+ "const " + f + " = " + x(g, $, o.text)
82
82
  );
83
- else if (typeof $ > "u")
83
+ else if (typeof g > "u")
84
84
  r.push(
85
- "const " + f + " = " + F(d.dataType) + ";"
85
+ "const " + f + " = " + E(y.dataType) + ";"
86
86
  );
87
87
  else {
88
- let E = x($, g, o.text);
89
- r.push("const " + f + " = " + E + ";");
88
+ let j = L(g, $, o.text);
89
+ r.push("const " + f + " = " + j + ";");
90
90
  }
91
91
  m.push(f);
92
92
  }
93
93
  }), o.type === "function" ? r.push(
94
- `const ${i} = refDom.value?.${o.name}(${m.join(", ")})`
95
- ) : r.push(`const ${i} = refDom.value?.${o.name}`), r.push(`console.log('"${a.type}"', ${i})`);
94
+ `const ${c} = refDom.value?.${o.name}(${m.join(", ")})`
95
+ ) : r.push(`const ${c} = refDom.value?.${o.name}`), r.push(`console.log('"${a.type}"', ${c})`);
96
96
  })), p.length > 0 && p.unshift("");
97
97
  const H = X(s, A);
98
98
  return `<!--${t}-->
@@ -113,61 +113,61 @@ ${r.join(`
113
113
  function X(t = {}, n) {
114
114
  const e = [];
115
115
  return Object.keys(t).forEach((s) => {
116
- const c = S(n, s) || {}, h = t[s];
116
+ const i = S(n, s) || {}, h = t[s];
117
117
  if (h) {
118
- const p = ` <!-- ${c.description} ${c.name}:(${c.selectable}) -->
118
+ const p = ` <!-- ${i.description} ${i.name}:(${i.selectable}) -->
119
119
  <template #${s}="scope">
120
- ${T(h, " ")}
120
+ ${w(h, " ")}
121
121
  </template>`;
122
122
  e.push(p);
123
123
  }
124
124
  }), e && e.length > 0 && e.unshift(""), e;
125
125
  }
126
- function w(t, n, e) {
126
+ function x(t, n, e) {
127
127
  const s = e ? e[n] : "";
128
- return s || P(t.toString());
128
+ return s && (s.includes("=>") || s.includes("function")) ? s : F(t.toString());
129
129
  }
130
- function P(t) {
130
+ function F(t) {
131
131
  const n = R(G(t));
132
132
  if (n) {
133
133
  let e = `{
134
- ${T(z(n.body), " ")}
134
+ ${w(z(n.body), " ")}
135
135
  }`;
136
136
  return `function (${n.param}) ${e}`;
137
137
  } else
138
138
  return "undefined";
139
139
  }
140
140
  function Y(t) {
141
- const n = V(t.selectable), e = L(n);
141
+ const n = T(t.selectable), e = C(n);
142
142
  let s = "";
143
143
  t.return && (s = "return ");
144
- let c = `{
145
- ${T(z(s), " ")}
144
+ let i = `{
145
+ ${w(z(s), " ")}
146
146
  }`;
147
- return `function (${e}) ${c}`;
147
+ return `function (${e}) ${i}`;
148
148
  }
149
149
  function _(t) {
150
150
  const n = t.trim();
151
- return /^\(/.test(n) ? P(n) : JSON.stringify(t);
151
+ return /^\(/.test(n) ? F(n) : JSON.stringify(t);
152
152
  }
153
- function x(t, n, e) {
153
+ function L(t, n, e) {
154
154
  const s = e ? e[n] : "";
155
- return s ? typeof s == "string" ? j(s) : s : typeof t == "string" ? _(t + "") : JSON.stringify(t);
155
+ return s ? typeof s == "string" ? V(s) : s : typeof t == "string" ? _(t + "") : JSON.stringify(t);
156
156
  }
157
- function B(t) {
157
+ function P(t) {
158
158
  let n = v(t?.type), e = "any";
159
159
  n.length == 1 && (e = n[0].split("<")[0]);
160
160
  const s = e;
161
- let c = (t?.selectable || "").trim(), h = [];
162
- return c && e != "boolean" && (c.includes("|") ? c.split("|").forEach((p) => {
161
+ let i = (t?.selectable || "").trim(), h = [];
162
+ return i && e != "boolean" && (i.includes("|") ? i.split("|").forEach((p) => {
163
163
  if (p) {
164
164
  let r = p.split(":");
165
165
  h.push({
166
166
  label: p,
167
- prop: j(r[0].trim())
167
+ prop: V(r[0].trim())
168
168
  });
169
169
  }
170
- }) : h = V(c), e == "function" ? e = "function" : e == "array" ? e = "choice" : h.length > 1 && (e = "select")), {
170
+ }) : h = T(i), e == "function" ? e = "function" : e == "array" ? e = "choice" : h.length > 1 && (e = "select")), {
171
171
  arr: h,
172
172
  zdtype: s,
173
173
  type: e,
@@ -180,25 +180,33 @@ function v(t) {
180
180
  s = s.trim(), s && n.push(s);
181
181
  }), [...new Set(n)].sort();
182
182
  }
183
- function j(t) {
183
+ function V(t, n) {
184
184
  try {
185
- return new Function(`{ return ${t} }`)();
185
+ if (n?.toLowerCase() == "function")
186
+ if (typeof t == "string") {
187
+ if (/^\((.|\n|\r)*\)$/.test(t))
188
+ return t = t.substring(1, t.length - 1), new Function(`{ return ${t} }`)();
189
+ } else
190
+ return t;
191
+ else
192
+ return new Function(`{ return ${t} }`)();
186
193
  } catch {
187
194
  return "" + t;
188
195
  }
189
196
  }
190
- function $t(t, n = !0) {
197
+ function gt(t, n = !0) {
198
+ const e = P(t), s = E(e.dataType);
191
199
  if (n) {
192
- const e = B(t), s = F(e.dataType), c = (t.default || "").trim();
193
- return j(c || s);
200
+ const i = (t.default || "").trim();
201
+ return V(i || s, e.dataType[0]);
194
202
  } else {
195
- const e = (t.default || "").trim();
196
- return j(e);
203
+ const i = (t.default || "").trim();
204
+ return V(i, e.dataType[0]);
197
205
  }
198
206
  }
199
207
  export {
200
- $t as getDefaultValue,
208
+ gt as getDefaultValue,
201
209
  ht as getHmtl,
202
- B as getSpecType,
203
- x as setValStringify
210
+ P as getSpecType,
211
+ L as setValStringify
204
212
  };
@@ -1,3 +1,3 @@
1
- "use strict";const o=require("vue"),d=require("../input/index.vue.cjs");;/* empty css */const p=require("../../util.cjs"),v={class:"form-array"},f=o.defineComponent({__name:"index",props:{modelValue:{type:null}},emits:["value","error"],setup(s,{emit:i}){const l=s,t=i,u=o.ref("");o.watch(()=>l.modelValue,()=>{let e=l.modelValue;u.value=a(e)||e},{immediate:!0});function m(e){return new Function("",`{return ${e}}`)}function a(e){let r;if(e)try{const c=m(e)();c instanceof Array?(r=p.prettierArrFormat(e),t("value",c,r),t("error",!1)):(t("error",!0),console.log("error","类型不匹配"))}catch(n){t("error",!0),console.log("error",n)}else r=`[
1
+ "use strict";const n=require("vue"),m=require("../input/index.vue.cjs");;/* empty css */const f=require("../../util.cjs"),d={class:"form-array"},p=n.defineComponent({__name:"index",props:{modelValue:{type:null}},emits:["value","error"],setup(i,{emit:c}){const u=i,o=c,l=n.ref("");n.watch(()=>u.modelValue,()=>{let e=u.modelValue;l.value=a(e)||e},{immediate:!0});function s(e){return new Function("",`{return ${e}}`)}function a(e){let r;if(e)try{let t=e;typeof e=="string"?(t=s(e)(),r=f.prettierArrFormat(e)):r=JSON.stringify(e),t instanceof Array?(o("value",t,r),o("error",!1)):(o("error",!0),console.log("error","类型不匹配"))}catch(t){o("error",!0),console.log("error",t)}else r=`[
2
2
 
3
- ]`,t("value",void 0,r),t("error",!1);return r}return(e,r)=>(o.openBlock(),o.createElementBlock("div",v,[o.createVNode(d,{modelValue:u.value,"onUpdate:modelValue":r[0]||(r[0]=n=>u.value=n),check:a},null,8,["modelValue"])]))}});module.exports=f;
3
+ ]`,o("value",void 0,r),o("error",!1);return r}return(e,r)=>(n.openBlock(),n.createElementBlock("div",d,[n.createVNode(m,{modelValue:l.value,"onUpdate:modelValue":r[0]||(r[0]=t=>l.value=t),check:a},null,8,["modelValue"])]))}});module.exports=p;
@@ -1,8 +1,8 @@
1
- import { defineComponent as s, ref as f, watch as d, createElementBlock as p, openBlock as v, createVNode as _ } from "vue";
2
- import V from "../input/index.vue.js";
1
+ import { defineComponent as c, ref as f, watch as s, createElementBlock as p, openBlock as d, createVNode as v } from "vue";
2
+ import _ from "../input/index.vue.js";
3
3
  /* empty css */
4
- import { prettierArrFormat as g } from "../../util.js";
5
- const h = { class: "form-array" }, A = /* @__PURE__ */ s({
4
+ import { prettierArrFormat as V } from "../../util.js";
5
+ const g = { class: "form-array" }, A = /* @__PURE__ */ c({
6
6
  __name: "index",
7
7
  props: {
8
8
  modelValue: {
@@ -10,9 +10,9 @@ const h = { class: "form-array" }, A = /* @__PURE__ */ s({
10
10
  }
11
11
  },
12
12
  emits: ["value", "error"],
13
- setup(m, { emit: c }) {
14
- const n = m, o = c, l = f("");
15
- d(
13
+ setup(u, { emit: i }) {
14
+ const n = u, t = i, l = f("");
15
+ s(
16
16
  () => n.modelValue,
17
17
  () => {
18
18
  let e = n.modelValue;
@@ -22,28 +22,28 @@ const h = { class: "form-array" }, A = /* @__PURE__ */ s({
22
22
  immediate: !0
23
23
  }
24
24
  );
25
- function i(e) {
25
+ function m(e) {
26
26
  return new Function("", `{return ${e}}`);
27
27
  }
28
28
  function a(e) {
29
29
  let r;
30
30
  if (e)
31
31
  try {
32
- const u = i(e)();
33
- u instanceof Array ? (r = g(e), o("value", u, r), o("error", !1)) : (o("error", !0), console.log("error", "类型不匹配"));
34
- } catch (t) {
35
- o("error", !0), console.log("error", t);
32
+ let o = e;
33
+ typeof e == "string" ? (o = m(e)(), r = V(e)) : r = JSON.stringify(e), o instanceof Array ? (t("value", o, r), t("error", !1)) : (t("error", !0), console.log("error", "类型不匹配"));
34
+ } catch (o) {
35
+ t("error", !0), console.log("error", o);
36
36
  }
37
37
  else
38
38
  r = `[
39
39
 
40
- ]`, o("value", void 0, r), o("error", !1);
40
+ ]`, t("value", void 0, r), t("error", !1);
41
41
  return r;
42
42
  }
43
- return (e, r) => (v(), p("div", h, [
44
- _(V, {
43
+ return (e, r) => (d(), p("div", g, [
44
+ v(_, {
45
45
  modelValue: l.value,
46
- "onUpdate:modelValue": r[0] || (r[0] = (t) => l.value = t),
46
+ "onUpdate:modelValue": r[0] || (r[0] = (o) => l.value = o),
47
47
  check: a
48
48
  }, null, 8, ["modelValue"])
49
49
  ]));
@@ -1,3 +1,3 @@
1
- "use strict";const o=require("vue"),d=require("../input/index.vue.cjs");;/* empty css */const p=require("../../util.cjs"),v={class:"form-object"},f=o.defineComponent({__name:"index",props:{modelValue:{type:null}},emits:["value","error"],setup(a,{emit:i}){const l=a,t=i,u=o.ref("");o.watch(()=>l.modelValue,()=>{let e=l.modelValue;u.value=c(e)||e},{immediate:!0});function m(e){return new Function("",`{ return ${e} }`)}function c(e){let r;if(e)try{const s=m(e)();typeof s=="object"?(r=p.prettierObjFormat(e),t("value",s,r),t("error",!1)):(t("error",!0),console.log("error","类型不匹配"))}catch(n){t("error",!0),console.log("error",n)}else r=`{
1
+ "use strict";const l=require("vue"),m=require("../input/index.vue.cjs");;/* empty css */const f=require("../../util.cjs"),p={class:"form-object"},d=l.defineComponent({__name:"index",props:{modelValue:{type:null}},emits:["value","error"],setup(c,{emit:a}){const u=c,o=a,n=l.ref("");l.watch(()=>u.modelValue,()=>{let e=u.modelValue;n.value=i(e)||e},{immediate:!0});function s(e){return new Function("",`{ return ${e} }`)}function i(e){let r;if(e)try{let t=e;typeof e=="string"?(t=s(e)(),r=f.prettierObjFormat(e)):r=JSON.stringify(e),typeof t=="object"?(o("value",t,r),o("error",!1)):(o("error",!0),console.log("error","类型不匹配"))}catch(t){o("error",!0),console.log("error",t)}else r=`{
2
2
 
3
- }`,t("value",void 0,r),t("error",!1);return r}return(e,r)=>(o.openBlock(),o.createElementBlock("div",v,[o.createVNode(d,{modelValue:u.value,"onUpdate:modelValue":r[0]||(r[0]=n=>u.value=n),check:c},null,8,["modelValue"])]))}});module.exports=f;
3
+ }`,o("value",void 0,r),o("error",!1);return r}return(e,r)=>(l.openBlock(),l.createElementBlock("div",p,[l.createVNode(m,{modelValue:n.value,"onUpdate:modelValue":r[0]||(r[0]=t=>n.value=t),check:i},null,8,["modelValue"])]))}});module.exports=d;
@@ -1,8 +1,8 @@
1
- import { defineComponent as s, ref as f, watch as p, createElementBlock as d, openBlock as v, createVNode as _ } from "vue";
2
- import V from "../input/index.vue.js";
1
+ import { defineComponent as c, ref as f, watch as s, createElementBlock as p, openBlock as d, createVNode as v } from "vue";
2
+ import _ from "../input/index.vue.js";
3
3
  /* empty css */
4
- import { prettierObjFormat as g } from "../../util.js";
5
- const h = { class: "form-object" }, y = /* @__PURE__ */ s({
4
+ import { prettierObjFormat as V } from "../../util.js";
5
+ const g = { class: "form-object" }, x = /* @__PURE__ */ c({
6
6
  __name: "index",
7
7
  props: {
8
8
  modelValue: {
@@ -10,9 +10,9 @@ const h = { class: "form-object" }, y = /* @__PURE__ */ s({
10
10
  }
11
11
  },
12
12
  emits: ["value", "error"],
13
- setup(c, { emit: m }) {
14
- const n = c, o = m, l = f("");
15
- p(
13
+ setup(a, { emit: i }) {
14
+ const n = a, t = i, l = f("");
15
+ s(
16
16
  () => n.modelValue,
17
17
  () => {
18
18
  let e = n.modelValue;
@@ -22,33 +22,33 @@ const h = { class: "form-object" }, y = /* @__PURE__ */ s({
22
22
  immediate: !0
23
23
  }
24
24
  );
25
- function i(e) {
25
+ function m(e) {
26
26
  return new Function("", `{ return ${e} }`);
27
27
  }
28
28
  function u(e) {
29
29
  let r;
30
30
  if (e)
31
31
  try {
32
- const a = i(e)();
33
- typeof a == "object" ? (r = g(e), o("value", a, r), o("error", !1)) : (o("error", !0), console.log("error", "类型不匹配"));
34
- } catch (t) {
35
- o("error", !0), console.log("error", t);
32
+ let o = e;
33
+ typeof e == "string" ? (o = m(e)(), r = V(e)) : r = JSON.stringify(e), typeof o == "object" ? (t("value", o, r), t("error", !1)) : (t("error", !0), console.log("error", "类型不匹配"));
34
+ } catch (o) {
35
+ t("error", !0), console.log("error", o);
36
36
  }
37
37
  else
38
38
  r = `{
39
39
 
40
- }`, o("value", void 0, r), o("error", !1);
40
+ }`, t("value", void 0, r), t("error", !1);
41
41
  return r;
42
42
  }
43
- return (e, r) => (v(), d("div", h, [
44
- _(V, {
43
+ return (e, r) => (d(), p("div", g, [
44
+ v(_, {
45
45
  modelValue: l.value,
46
- "onUpdate:modelValue": r[0] || (r[0] = (t) => l.value = t),
46
+ "onUpdate:modelValue": r[0] || (r[0] = (o) => l.value = o),
47
47
  check: u
48
48
  }, null, 8, ["modelValue"])
49
49
  ]));
50
50
  }
51
51
  });
52
52
  export {
53
- y as default
53
+ x as default
54
54
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fangzhongya/vue-archive",
3
3
  "private": false,
4
- "version": "0.0.45",
4
+ "version": "0.0.46",
5
5
  "type": "module",
6
6
  "description ": "vue 组件注释生成文档",
7
7
  "author": "fangzhongya ",