@fangzhongya/vue-archive 0.0.52 → 0.0.55

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.
@@ -9,96 +9,102 @@ import "@fangzhongya/utils/basic/array/asyncMergeArray";
9
9
  import { firstUpper as w } 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 T, parseTypeDefinition as q, setDataType as G, vueFormat as D, getFunBody as C, prettierFormat as I } from "./util.js";
13
- import { getPropsValue as K, getEmitsValue as M, getExposeValue as Q, getSlotValue as R } from "../../utils/props.js";
14
- import { getFunctionFormat as W } from "@fangzhongya/utils/basic/string/toFunction";
15
- const X = ["class"];
16
- function S(t, n) {
12
+ import { getTypeValue as V, parseParamString as j, parseTypeDefinition as q, setDataType as v, vueFormat as E, getFunBody as C, prettierFormat as G } from "./util.js";
13
+ import { getPropsValue as I, getEmitsValue as K, getExposeValue as M, getSlotValue as Q } from "../../utils/props.js";
14
+ import { getFunctionFormat as R } from "@fangzhongya/utils/basic/string/toFunction";
15
+ const W = ["class"];
16
+ function T(t, n) {
17
17
  return t.filter((s) => s.name == n)[0];
18
18
  }
19
19
  function P(t) {
20
- return t.map((n) => (n.prop || "...arr") + ":" + G(n.dataType)).join(",");
20
+ return t.map((n) => (n.prop || "...arr") + ":" + v(n.dataType)).join(",");
21
21
  }
22
22
  function ht(t, n, s, e, i, h) {
23
- const p = [], r = [];
23
+ const m = [], r = [];
24
24
  let d = !0;
25
- const B = K(n.propss || []), J = M(n.emitss || []), N = Q(n.exposes || []), A = R(n.slots || []);
25
+ const B = I(n.propss || []), J = K(n.emitss || []), N = M(n.exposes || []), A = Q(n.slots || []);
26
26
  Object.keys(s).forEach((o) => {
27
- let a = s[o];
28
- if (/^on[A-Z]/.test(o) && typeof a == "function") {
29
- let c = o.substring(2);
30
- const u = o.split(":");
31
- let m;
32
- if (u.length > 1 ? (m = u[0] + u.slice(1).map((f) => w(f)).join(""), c = Z(c)) : (m = u[0], c = U(c)), u.includes("-")) {
33
- let f = m.split("-");
34
- f = f.map((g, j) => j != 0 ? w(g) : g), m = f.join("");
27
+ let c = s[o];
28
+ if (/^on[A-Z]/.test(o) && typeof c == "function") {
29
+ let u = o.substring(2);
30
+ const f = o.split(":");
31
+ let l;
32
+ if (f.length > 1 ? (l = f[0] + f.slice(1).map((p) => w(p)).join(""), u = Z(u)) : (l = f[0], u = U(u)), f.includes("-")) {
33
+ let p = l.split("-");
34
+ p = p.map(($, S) => S != 0 ? w($) : $), l = p.join("");
35
35
  }
36
- p.push(" @" + c + '="' + m + '"');
37
- const l = S(J, c) || {}, y = l.selectable || "", b = T(y), $ = P(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 + ")");
36
+ m.push(" @" + u + '="' + l + '"');
37
+ const a = T(J, u) || {}, y = a.selectable || "", b = j(y), g = P(b);
38
+ r.push(`// ${a.description} ${a.name}: (${a.selectable})`), r.push("function " + l + "(" + g + ") {"), b.forEach((p) => {
39
+ const $ = p.name || "arr";
40
+ r.push(" console.log('" + p.label + "', " + $ + ")");
41
41
  }), r.push("}");
42
42
  } else {
43
- let c = o;
44
- X.includes(o) && (c = o + "1"), p.push(" :" + o + '="' + c + '"');
45
- const u = S(B, o) || {}, m = z(u);
43
+ let u = o;
44
+ W.includes(o) && (u = o + "1"), m.push(" :" + o + '="' + u + '"');
45
+ const f = T(B, o) || {}, l = z(f);
46
46
  if (r.push(
47
- `// ${u.description} ${u.name}: {${u.type}} (${u.selectable})`
48
- ), typeof a == "function")
47
+ `// ${f.description} ${f.name}: {${f.type}} (${f.selectable})`
48
+ ), typeof c == "function" || l.dataType.length == 1 && l.type == "function" && c)
49
49
  r.push(
50
- "const " + o + " = " + x(a, o, i)
50
+ "const " + o + " = " + x(
51
+ c,
52
+ o,
53
+ i
54
+ )
51
55
  );
52
- else if (d && (d = !1, r.unshift("import { ref } from 'vue';")), typeof a > "u")
53
- if (m.type == "function") {
54
- const l = _(u);
55
- r.push("const " + c + " = " + l + ";");
56
+ else if (d && (d = !1, r.unshift("import { ref } from 'vue';")), typeof c > "u")
57
+ if (l.type == "function") {
58
+ const a = Y(f);
59
+ r.push("const " + u + " = " + a + ";");
56
60
  } else {
57
- const l = F(m.dataType);
61
+ const a = V(l.dataType);
58
62
  r.push(
59
- "const " + c + " = ref(" + (l === "undefined" ? "" : l) + ");"
63
+ "const " + u + " = ref(" + (a === "undefined" ? "" : a) + ");"
60
64
  );
61
65
  }
62
66
  else {
63
- let l = L(a, o, i);
64
- r.push("const " + c + " = ref(" + l + ");");
67
+ let a = L(c, o, i);
68
+ r.push("const " + u + " = ref(" + a + ");");
65
69
  }
66
70
  }
67
71
  });
68
72
  const O = Object.values(h || {});
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
- const a = S(N, o.name) || {};
73
+ O.length > 0 && (d && (d = !1, r.unshift("import { ref } from 'vue';")), m.unshift(' ref="refDom"'), r.push("const refDom = ref()"), O.forEach((o) => {
74
+ const c = T(N, o.name) || {};
71
75
  r.push(
72
- `// ${a.description} ${a.name}:(${a.selectable}) ${a.type}`
76
+ `// ${c.description} ${c.name}:(${c.selectable}) ${c.type}`
73
77
  );
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")
78
+ const u = o.name + "Value", f = j(c?.selectable || ""), l = [], a = o.params || [];
79
+ f.forEach((y, b) => {
80
+ const g = y.name;
81
+ if (g) {
82
+ const p = g + o.name, $ = a[b];
83
+ if (r.push(`// ${y.label}`), typeof $ == "function")
80
84
  r.push(
81
- "const " + f + " = " + x(g, $, o.text)
85
+ "const " + p + " = " + x($, g, o.text)
82
86
  );
83
- else if (typeof g > "u")
87
+ else if (typeof $ > "u")
84
88
  r.push(
85
- "const " + f + " = " + F(y.dataType) + ";"
89
+ "const " + p + " = " + V(y.dataType) + ";"
86
90
  );
87
91
  else {
88
- let j = L(g, $, o.text);
89
- r.push("const " + f + " = " + j + ";");
92
+ let S = L($, g, o.text);
93
+ r.push("const " + p + " = " + S + ";");
90
94
  }
91
- m.push(f);
95
+ l.push(p);
92
96
  }
93
- }), o.type === "function" ? r.push(
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
- })), p.length > 0 && p.unshift("");
97
- const H = Y(e, A);
97
+ }), o.type === "function" ? (c.return ? r.push(
98
+ `const ${u} = refDom.value?.${o.name}(${l.join(
99
+ ", "
100
+ )})`
101
+ ) : r.push(`refDom.value?.${o.name}(${l.join(", ")})`), c.return && r.push(`console.log('${c.return}', ${u})`)) : (r.push(`const ${u} = refDom.value?.${o.name}`), r.push(`console.log('${c.type || c.name}', ${u})`));
102
+ })), m.length > 0 && m.unshift("");
103
+ const H = X(e, A);
98
104
  return `<!--${t}-->
99
105
  <template>
100
106
  <div>
101
- <${t}${p.join(`
107
+ <${t}${m.join(`
102
108
  `)}>${H.join(`
103
109
  `)}
104
110
  </${t}>
@@ -110,69 +116,69 @@ ${r.join(`
110
116
  <\/script>
111
117
  `;
112
118
  }
113
- function Y(t = {}, n) {
119
+ function X(t = {}, n) {
114
120
  const s = [];
115
121
  return Object.keys(t).forEach((e) => {
116
- const i = S(n, e) || {}, h = t[e];
122
+ const i = T(n, e) || {}, h = t[e];
117
123
  if (h) {
118
- const p = ` <!-- ${i.description} ${i.name}:(${i.selectable}) -->
124
+ const m = ` <!-- ${i.description} ${i.name}:(${i.selectable}) -->
119
125
  <template #${e}="scope">
120
- ${D(h, " ")}
126
+ ${E(h, " ")}
121
127
  </template>`;
122
- s.push(p);
128
+ s.push(m);
123
129
  }
124
130
  }), s && s.length > 0 && s.unshift(""), s;
125
131
  }
126
132
  function x(t, n, s) {
127
133
  const e = s ? s[n] : "";
128
- return e && (e.includes("=>") || e.includes("function")) ? e : E(t.toString());
134
+ return e && (e.includes("=>") || e.includes("function")) ? e : F(t.toString());
129
135
  }
130
- function E(t) {
131
- const n = W(I(t));
136
+ function F(t) {
137
+ const n = R(G(t));
132
138
  if (n) {
133
139
  let s = `{
134
- ${D(C(n.body), " ")}
140
+ ${E(C(n.body), " ")}
135
141
  }`;
136
- return `function (${n.param}) ${s}`;
142
+ return `function (${n.param.split(",").map((e) => e + ":any").join(",")}) ${s}`;
137
143
  } else
138
144
  return "undefined";
139
145
  }
140
- function _(t) {
141
- const n = T(t.selectable), s = P(n);
146
+ function Y(t) {
147
+ const n = j(t.selectable), s = P(n);
142
148
  let e = "";
143
149
  t.return && (e = "return ");
144
150
  let i = `{
145
- ${D(C(e), " ")}
151
+ ${E(C(e), " ")}
146
152
  }`;
147
153
  return `function (${s}) ${i}`;
148
154
  }
149
- function v(t) {
155
+ function _(t) {
150
156
  const n = t.trim();
151
- return /^\(/.test(n) ? E(n) : JSON.stringify(t);
157
+ return /^\(/.test(n) ? F(n) : JSON.stringify(t);
152
158
  }
153
159
  function L(t, n, s) {
154
160
  const e = s ? s[n] : "";
155
- return e ? typeof e == "string" ? V(e) : e : typeof t == "string" ? v(t + "") : JSON.stringify(t);
161
+ return e || (typeof t == "string" ? _(t + "") : JSON.stringify(t));
156
162
  }
157
163
  function z(t) {
158
164
  let n = q(t?.type), s = n.dataType, e = n.type;
159
165
  e = e.split("<")[0], e = e.trim().toLowerCase(), s.length > 1 && (e = "any");
160
166
  let i = (t?.selectable || "").trim(), h = [];
161
- return i && e != "boolean" && (i.includes("|") ? i.split("|").forEach((p) => {
162
- if (p) {
163
- let r = p.split(":");
167
+ return i && e != "boolean" && (i.includes("|") ? i.split("|").forEach((m) => {
168
+ if (m) {
169
+ let r = m.split(":");
164
170
  h.push({
165
- label: p,
166
- prop: V(r[0].trim())
171
+ label: m,
172
+ prop: D(r[0].trim())
167
173
  });
168
174
  }
169
- }) : h = T(i), e == "array" ? e = "choice" : e != "function" && h.length > 1 && (console.log("type1", e, t), e = "select")), {
175
+ }) : h = j(i), e == "array" ? e = "choice" : e != "function" && h.length > 1 && (e = "select")), {
170
176
  arr: h,
171
177
  type: e,
172
178
  dataType: s
173
179
  };
174
180
  }
175
- function V(t, n) {
181
+ function D(t, n) {
176
182
  try {
177
183
  if (n?.toLowerCase() == "function")
178
184
  if (typeof t == "string") {
@@ -186,18 +192,18 @@ function V(t, n) {
186
192
  return "" + t;
187
193
  }
188
194
  }
189
- function gt(t, n = !0) {
190
- const s = z(t), e = F(s.dataType);
195
+ function $t(t, n = !0) {
196
+ const s = z(t), e = V(s.dataType);
191
197
  if (n) {
192
198
  const i = (t.default || "").trim();
193
- return V(i || e, s.dataType[0]);
199
+ return D(i || e, s.dataType[0]);
194
200
  } else {
195
201
  const i = (t.default || "").trim();
196
- return V(i, s.dataType[0]);
202
+ return D(i, s.dataType[0]);
197
203
  }
198
204
  }
199
205
  export {
200
- gt as getDefaultValue,
206
+ $t as getDefaultValue,
201
207
  ht as getHmtl,
202
208
  z as getSpecType,
203
209
  L as setValStringify
@@ -1 +1 @@
1
- "use strict";const s=require("vue"),T=require("./retrie/index.vue.cjs");;/* empty css */const i=require("./code.cjs"),k={key:0,class:"set-props"},x=s.defineComponent({__name:"set-props",props:{name:String,list:Array},emits:["change"],setup(p,{emit:f}){const l=p,m=f,o=s.ref({}),d=s.ref(0),c=s.ref({}),r=s.ref([]);function _(){c.value={};const n=[];l.list?.forEach(t=>{let e=t.name;if(!e.includes(".")&&(e=(e.split("/")[0]||"").trim(),e)){const v=i.getDefaultValue(t,!1);c.value[e]=v;const{arr:b,type:u,dataType:V}=i.getSpecType(t);console.log("type",u),o.value[e]=b;let q={label:h(e,t),prop:e,type:u,dataType:V,select:e};n.push(q)}}),r.value=n}function h(n,t){let e=n+": { "+(t.type||"any")+" } "+t.description;return t.default&&(e+=" 默认值="+t.default),t.selectable&&(e+=" 可选值="+t.selectable),e}function y(n,t){let e=Object.assign({},n);m("change",e,t)}let a;function g(){clearTimeout(a),a=setTimeout(()=>{_()},400)}return s.watch(()=>l.name,()=>{r.value=[],g()},{immediate:!0}),(n,t)=>r.value&&r.value.length>0?(s.openBlock(),s.createElementBlock("div",k,[s.createVNode(T,{refresh:d.value,modelValue:c.value,selects:o.value,list:r.value,name:l.name,onQuery:y},null,8,["refresh","modelValue","selects","list","name"])])):s.createCommentVNode("",!0)}});module.exports=x;
1
+ "use strict";const s=require("vue"),T=require("./retrie/index.vue.cjs");;/* empty css */const o=require("./code.cjs"),k={key:0,class:"set-props"},x=s.defineComponent({__name:"set-props",props:{name:String,list:Array},emits:["change"],setup(i,{emit:p}){const l=i,f=p,a=s.ref({}),m=s.ref(0),c=s.ref({}),r=s.ref([]);function d(){c.value={};const n=[];l.list?.forEach(t=>{let e=t.name;if(!e.includes(".")&&(e=(e.split("/")[0]||"").trim(),e)){const y=o.getDefaultValue(t,!1);c.value[e]=y;const{arr:g,type:b,dataType:V}=o.getSpecType(t);a.value[e]=g;let q={label:_(e,t),prop:e,type:b,dataType:V,select:e};n.push(q)}}),r.value=n}function _(n,t){let e=n+": { "+(t.type||"any")+" } "+t.description;return t.default&&(e+=" 默认值="+t.default),t.selectable&&(e+=" 可选值="+t.selectable),e}function h(n,t){let e=Object.assign({},n);f("change",e,t)}let u;function v(){clearTimeout(u),u=setTimeout(()=>{d()},400)}return s.watch(()=>l.name,()=>{r.value=[],v()},{immediate:!0}),(n,t)=>r.value&&r.value.length>0?(s.openBlock(),s.createElementBlock("div",k,[s.createVNode(T,{refresh:m.value,modelValue:c.value,selects:a.value,list:r.value,name:l.name,onQuery:h},null,8,["refresh","modelValue","selects","list","name"])])):s.createCommentVNode("",!0)}});module.exports=x;
@@ -12,22 +12,22 @@ const w = {
12
12
  list: Array
13
13
  },
14
14
  emits: ["change"],
15
- setup(u, { emit: m }) {
16
- const o = u, p = m, r = n({}), f = n(0), a = n({}), l = n([]);
17
- function d() {
18
- a.value = {};
15
+ setup(i, { emit: u }) {
16
+ const a = i, m = u, r = n({}), p = n(0), o = n({}), l = n([]);
17
+ function f() {
18
+ o.value = {};
19
19
  const s = [];
20
- o.list?.forEach((t) => {
20
+ a.list?.forEach((t) => {
21
21
  let e = t.name;
22
22
  if (!e.includes(".") && (e = (e.split("/")[0] || "").trim(), e)) {
23
- const g = N(t, !1);
24
- a.value[e] = g;
25
- const { arr: b, type: i, dataType: V } = S(t);
26
- console.log("type", i), r.value[e] = b;
23
+ const y = N(t, !1);
24
+ o.value[e] = y;
25
+ const { arr: b, type: g, dataType: V } = S(t);
26
+ r.value[e] = b;
27
27
  let v = {
28
- label: h(e, t),
28
+ label: d(e, t),
29
29
  prop: e,
30
- type: i,
30
+ type: g,
31
31
  dataType: V,
32
32
  select: e
33
33
  };
@@ -35,36 +35,36 @@ const w = {
35
35
  }
36
36
  }), l.value = s;
37
37
  }
38
- function h(s, t) {
38
+ function d(s, t) {
39
39
  let e = s + ": { " + (t.type || "any") + " } " + t.description;
40
40
  return t.default && (e += " 默认值=" + t.default), t.selectable && (e += " 可选值=" + t.selectable), e;
41
41
  }
42
- function _(s, t) {
42
+ function h(s, t) {
43
43
  let e = Object.assign({}, s);
44
- p("change", e, t);
44
+ m("change", e, t);
45
45
  }
46
46
  let c;
47
- function y() {
47
+ function _() {
48
48
  clearTimeout(c), c = setTimeout(() => {
49
- d();
49
+ f();
50
50
  }, 400);
51
51
  }
52
52
  return k(
53
- () => o.name,
53
+ () => a.name,
54
54
  () => {
55
- l.value = [], y();
55
+ l.value = [], _();
56
56
  },
57
57
  {
58
58
  immediate: !0
59
59
  }
60
60
  ), (s, t) => l.value && l.value.length > 0 ? (B(), j("div", w, [
61
61
  C(E, {
62
- refresh: f.value,
63
- modelValue: a.value,
62
+ refresh: p.value,
63
+ modelValue: o.value,
64
64
  selects: r.value,
65
65
  list: l.value,
66
- name: o.name,
67
- onQuery: _
66
+ name: a.name,
67
+ onQuery: h
68
68
  }, null, 8, ["refresh", "modelValue", "selects", "list", "name"])
69
69
  ])) : x("", !0);
70
70
  }
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("@fangzhongya/utils/basic/string/toFunction"),A=require("@fangzhongya/utils/basic/string/firstLower");function y(e){return e.replace(/\;(\s|\n\r)*$/,"")}function O(e){return e="let a = "+e,y(e).replace(/^let a = /,"")}function v(e){return y(e)}function x(e,n=""){let t=(e+"").trim().split(/\n/);return t=t.map(r=>n+r),t.join(`
2
- `)}function m(e=""){e=e.trim();let n=`[\\s|\\n|\\r]*\\{((.|
3
- |\r)+?)\\}[\\s|\\n|\\r]*`,r=new RegExp("^"+n+"$").exec(e);return r&&r.length>0?m(r[1]):e}const W=["Boolean","Any","String","Number","Array","Object","Function"];function k(e){return W.includes(e)?A.firstLower(e):e}function E(e){let t=new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);if(t&&t.length>0)return{own:k(t[1]),son:t[2]}}function d(e,n){let t=E(e);t?(n.push(t.own),t.son&&d(t.son,n)):n.push(e)}function h(e){e instanceof Array&&(e=e[0]);const n=[];return e&&d(e,n),n}function T(e){const n=Object.prototype.toString.call(e);let r=/^\[[O|o]bject (.*)\]$/.exec(n),i=typeof e;return r&&r.length>0&&(i=r[1].toLowerCase()),i}function q(e,n){const t=T(e),r=h(n)[0];return r&&r!="any"?t==r:!0}function B(e){if(typeof e=="string"){let n=!1;return(/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e))&&(n=!0),n&&(e=e.substring(1,e.length-1)),e+""}else return typeof e=="object"&&e?e.toString():typeof e>"u"||typeof e=="object"&&!e?"":e+""}function L(e){const n=typeof e;if(n=="string"){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}else return n==="object"?e instanceof Array?"array":n===null?"null":n:n}function j(e){switch((e[0]||"any").toLowerCase()){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":let t=j(e.splice(1));return t=t=="undefined"?"":t,`[${t}]`;case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function C(e){let n="";return e.forEach((t,r)=>{t=t.trim(),t&&(n&&(n+=" | "),t==="Array"?n+="Array<any>":n+=t)}),n||"any"}const f=(e,n)=>{let t=[],r=[],i="";for(let u=0;u<e.length;u++){const s=e[u];s==="["||s==="<"||s==="("?(t.push(s),i+=s):s==="]"&&t.length>0&&t[t.length-1]==="["||s===">"&&t.length>0&&t[t.length-1]==="<"||s===")"&&t.length>0&&t[t.length-1]==="("?(t.pop(),i+=s):s===n&&t.length===0?(r.push(i.trim()),i=""):i+=s}return i.trim()!==""&&r.push(i.trim()),r},F=e=>{if(e)if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("(")&&e.endsWith(")")){const n=e.slice(1,-1).trim();if(!n)return{type:"any",dataType:["any"]};const t=f(n,",");return{type:t[0]||"any",dataType:t}}else if(e.startsWith("<")&&e.endsWith(">")){const n=e.slice(1,-1).trim();if(!n)return{type:"any",dataType:["any"]};const t=f(n,"|");return{type:t[0]||"any",dataType:t}}else{const n=f(e,",");return{type:n[0]||"any",dataType:n}}else return{type:"any",dataType:["any"]}};function M(e){return f(e,",").map(t=>{const r=t.trim(),i=t.match(/^([^:?]+)(\??):/);if(!i)return null;const u=i[1].trim(),s=!i[2],$=i[0].length,c=t.substring($).trim();let a=[],p="",g="";for(let l=0;l<c.length;l++){const o=c[l];if(o==="["||o==="<"||o==="("?a.push(o):(o==="]"&&a[a.length-1]==="["||o===">"&&a[a.length-1]==="<"||o===")"&&a[a.length-1]==="(")&&a.pop(),a.length===0&&l>0){l==1&&o!=="]"&&o!==">"&&o!==")"?(p="",g=c.substring(0)):(p=c.substring(0,l+1).trim(),g=c.substring(l+1));break}}const{type:N,dataType:b}=F(p),S=h(b);return{name:u,prop:u,type:S[0],dataType:b,must:s,label:r,description:g}}).filter(Boolean)}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>w.getFunctionFormat});exports.getFunBody=m;exports.getObjType=T;exports.getSonType=h;exports.getString=B;exports.getTypeValue=j;exports.isDefaultType=L;exports.isTypeEqual=q;exports.parseParamString=M;exports.parseTypeDefinition=F;exports.prettierArrFormat=v;exports.prettierFormat=y;exports.prettierObjFormat=O;exports.setDataType=C;exports.vueFormat=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("@fangzhongya/utils/basic/string/toFunction"),w=require("@fangzhongya/utils/basic/string/firstLower");function y(e){return e.replace(/\;(\s|\n\r)*$/,"")}function A(e){return e="let a = "+e,y(e).replace(/^let a = /,"")}function x(e){return y(e)}function v(e,n=""){let t=(e+"").trim().split(/\n/);return t=t.map(r=>n+r),t.join(`
2
+ `)}function d(e=""){e=e.trim();let n=`[\\s|\\n|\\r]*\\{((.|
3
+ |\r)+?)\\}[\\s|\\n|\\r]*`,r=new RegExp("^"+n+"$").exec(e);return r&&r.length>0?d(r[1]):e}const W=["Boolean","Any","String","Number","Array","Object","Function"];function k(e){return W.includes(e)?w.firstLower(e):e}function E(e){let t=new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);if(t&&t.length>0)return{own:k(t[1]),son:t[2]}}function T(e,n){let t=E(e);t?(n.push(t.own),t.son&&T(t.son,n)):n.push(e)}function h(e){e instanceof Array&&(e=e[0]);const n=[];return e&&T(e,n),n}function j(e){const n=Object.prototype.toString.call(e);let r=/^\[[O|o]bject (.*)\]$/.exec(n),i=typeof e;return r&&r.length>0&&(i=r[1].toLowerCase()),i}function q(e,n){const t=j(e),r=h(n)[0];return r&&r!="any"?t==r:!0}function B(e){if(typeof e=="string"){let n=!1;return(/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e))&&(n=!0),n&&(e=e.substring(1,e.length-1)),e+""}else return typeof e=="object"&&e?e.toString():typeof e>"u"||typeof e=="object"&&!e?"":e+""}function L(e){const n=typeof e;if(n=="string"){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}else return n==="object"?e instanceof Array?"array":n===null?"null":n:n}function F(e){const n=e[0]||"any";let t=n.split("<")[0];switch(t=t.trim().toLowerCase(),t){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":let r=n.indexOf("<"),i=n.substring(n.indexOf("<")+1,n.length-1)||"";r==-1&&(i="any");let o=F(b(i).dataType);return o=o=="undefined"?"":o,`[${o}]`;case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function C(e){let n="";return e.forEach((t,r)=>{t=t.trim(),t&&(n&&(n+=" | "),t==="Array"?n+="Array<any>":n+=t)}),n||"any"}const f=(e,n)=>{let t=[],r=[],i="";for(let o=0;o<e.length;o++){const s=e[o];s==="["||s==="<"||s==="("?(t.push(s),i+=s):s==="]"&&t.length>0&&t[t.length-1]==="["||s===">"&&t.length>0&&t[t.length-1]==="<"||s===")"&&t.length>0&&t[t.length-1]==="("?(t.pop(),i+=s):s===n&&t.length===0?(r.push(i.trim()),i=""):i+=s}return i.trim()!==""&&r.push(i.trim()),r},b=e=>{if(e)if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("(")&&e.endsWith(")")){const n=e.slice(1,-1).trim();if(!n)return{type:"any",dataType:["any"]};const t=f(n,",");return{type:t[0]||"any",dataType:t}}else if(e.startsWith("<")&&e.endsWith(">")){const n=e.slice(1,-1).trim();if(!n)return{type:"any",dataType:["any"]};const t=f(n,"|");return{type:t[0]||"any",dataType:t}}else{const n=f(e,",");return{type:n[0]||"any",dataType:n}}else return{type:"any",dataType:["any"]}};function M(e){return f(e,",").map(t=>{const r=t.trim(),i=t.match(/^([^:?]+)(\??):/);if(!i)return null;const o=i[1].trim(),s=!i[2],$=i[0].length,c=t.substring($).trim();let l=[],p="",g="";for(let u=0;u<c.length;u++){const a=c[u];if(a==="["||a==="<"||a==="("?l.push(a):(a==="]"&&l[l.length-1]==="["||a===">"&&l[l.length-1]==="<"||a===")"&&l[l.length-1]==="(")&&l.pop(),l.length===0&&u>0){u==1&&a!=="]"&&a!==">"&&a!==")"?(p="",g=c.substring(0)):(p=c.substring(0,u+1).trim(),g=c.substring(u+1));break}}const{type:N,dataType:m}=b(p),S=h(m);return{name:o,prop:o,type:S[0],dataType:m,must:s,label:r,description:g}}).filter(Boolean)}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>O.getFunctionFormat});exports.getFunBody=d;exports.getObjType=j;exports.getSonType=h;exports.getString=B;exports.getTypeValue=F;exports.isDefaultType=L;exports.isTypeEqual=q;exports.parseParamString=M;exports.parseTypeDefinition=b;exports.prettierArrFormat=x;exports.prettierFormat=y;exports.prettierObjFormat=A;exports.setDataType=C;exports.vueFormat=v;
@@ -1,5 +1,5 @@
1
1
  import { getFunctionFormat as M } from "@fangzhongya/utils/basic/string/toFunction";
2
- import { firstLower as $ } from "@fangzhongya/utils/basic/string/firstLower";
2
+ import { firstLower as j } from "@fangzhongya/utils/basic/string/firstLower";
3
3
  function h(e) {
4
4
  return e.replace(/\;(\s|\n\r)*$/, "");
5
5
  }
@@ -14,11 +14,11 @@ function B(e, n = "") {
14
14
  return t = t.map((r) => n + r), t.join(`
15
15
  `);
16
16
  }
17
- function j(e = "") {
17
+ function x(e = "") {
18
18
  e = e.trim();
19
19
  let n = `[\\s|\\n|\\r]*\\{((.|
20
20
  |\r)+?)\\}[\\s|\\n|\\r]*`, r = new RegExp("^" + n + "$").exec(e);
21
- return r && r.length > 0 ? j(r[1]) : e;
21
+ return r && r.length > 0 ? x(r[1]) : e;
22
22
  }
23
23
  const S = [
24
24
  "Boolean",
@@ -30,9 +30,9 @@ const S = [
30
30
  "Function"
31
31
  ];
32
32
  function w(e) {
33
- return S.includes(e) ? $(e) : e;
33
+ return S.includes(e) ? j(e) : e;
34
34
  }
35
- function x(e) {
35
+ function A(e) {
36
36
  let t = new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);
37
37
  if (t && t.length > 0)
38
38
  return {
@@ -40,22 +40,22 @@ function x(e) {
40
40
  son: t[2]
41
41
  };
42
42
  }
43
- function m(e, n) {
44
- let t = x(e);
45
- t ? (n.push(t.own), t.son && m(t.son, n)) : n.push(e);
43
+ function d(e, n) {
44
+ let t = A(e);
45
+ t ? (n.push(t.own), t.son && d(t.son, n)) : n.push(e);
46
46
  }
47
- function b(e) {
47
+ function m(e) {
48
48
  e instanceof Array && (e = e[0]);
49
49
  const n = [];
50
- return e && m(e, n), n;
50
+ return e && d(e, n), n;
51
51
  }
52
- function A(e) {
52
+ function F(e) {
53
53
  const n = Object.prototype.toString.call(e);
54
54
  let r = /^\[[O|o]bject (.*)\]$/.exec(n), i = typeof e;
55
55
  return r && r.length > 0 && (i = r[1].toLowerCase()), i;
56
56
  }
57
57
  function L(e, n) {
58
- const t = A(e), r = b(n)[0];
58
+ const t = F(e), r = m(n)[0];
59
59
  return r && r != "any" ? t == r : !0;
60
60
  }
61
61
  function C(e) {
@@ -73,8 +73,10 @@ function N(e) {
73
73
  } else
74
74
  return n === "object" ? e instanceof Array ? "array" : n === null ? "null" : n : n;
75
75
  }
76
- function F(e) {
77
- switch ((e[0] || "any").toLowerCase()) {
76
+ function O(e) {
77
+ const n = e[0] || "any";
78
+ let t = n.split("<")[0];
79
+ switch (t = t.trim().toLowerCase(), t) {
78
80
  case "string":
79
81
  return '""';
80
82
  case "boolean":
@@ -82,8 +84,10 @@ function F(e) {
82
84
  case "number":
83
85
  return "0";
84
86
  case "array":
85
- let t = F(e.splice(1));
86
- return t = t == "undefined" ? "" : t, `[${t}]`;
87
+ let r = n.indexOf("<"), i = n.substring(n.indexOf("<") + 1, n.length - 1) || "";
88
+ r == -1 && (i = "any");
89
+ let l = O(b(i).dataType);
90
+ return l = l == "undefined" ? "" : l, `[${l}]`;
87
91
  case "object":
88
92
  return "{}";
89
93
  case "function":
@@ -102,12 +106,12 @@ function R(e) {
102
106
  }
103
107
  const f = (e, n) => {
104
108
  let t = [], r = [], i = "";
105
- for (let u = 0; u < e.length; u++) {
106
- const s = e[u];
109
+ for (let l = 0; l < e.length; l++) {
110
+ const s = e[l];
107
111
  s === "[" || s === "<" || s === "(" ? (t.push(s), i += s) : s === "]" && t.length > 0 && t[t.length - 1] === "[" || s === ">" && t.length > 0 && t[t.length - 1] === "<" || s === ")" && t.length > 0 && t[t.length - 1] === "(" ? (t.pop(), i += s) : s === n && t.length === 0 ? (r.push(i.trim()), i = "") : i += s;
108
112
  }
109
113
  return i.trim() !== "" && r.push(i.trim()), r;
110
- }, W = (e) => {
114
+ }, b = (e) => {
111
115
  if (e)
112
116
  if (e.startsWith("[") && e.endsWith("]") || e.startsWith("(") && e.endsWith(")")) {
113
117
  const n = e.slice(1, -1).trim();
@@ -138,20 +142,20 @@ function q(e) {
138
142
  return f(e, ",").map((t) => {
139
143
  const r = t.trim(), i = t.match(/^([^:?]+)(\??):/);
140
144
  if (!i) return null;
141
- const u = i[1].trim(), s = !i[2], d = i[0].length, c = t.substring(d).trim();
142
- let o = [], p = "", g = "";
143
- for (let a = 0; a < c.length; a++) {
144
- const l = c[a];
145
- if (l === "[" || l === "<" || l === "(" ? o.push(l) : (l === "]" && o[o.length - 1] === "[" || l === ">" && o[o.length - 1] === "<" || l === ")" && o[o.length - 1] === "(") && o.pop(), o.length === 0 && a > 0) {
146
- a == 1 && l !== "]" && l !== ">" && l !== ")" ? (p = "", g = c.substring(0)) : (p = c.substring(0, a + 1).trim(), g = c.substring(a + 1));
145
+ const l = i[1].trim(), s = !i[2], T = i[0].length, c = t.substring(T).trim();
146
+ let a = [], p = "", g = "";
147
+ for (let u = 0; u < c.length; u++) {
148
+ const o = c[u];
149
+ if (o === "[" || o === "<" || o === "(" ? a.push(o) : (o === "]" && a[a.length - 1] === "[" || o === ">" && a[a.length - 1] === "<" || o === ")" && a[a.length - 1] === "(") && a.pop(), a.length === 0 && u > 0) {
150
+ u == 1 && o !== "]" && o !== ">" && o !== ")" ? (p = "", g = c.substring(0)) : (p = c.substring(0, u + 1).trim(), g = c.substring(u + 1));
147
151
  break;
148
152
  }
149
153
  }
150
- const { type: k, dataType: y } = W(p), T = b(y);
154
+ const { type: W, dataType: y } = b(p), $ = m(y);
151
155
  return {
152
- name: u,
153
- prop: u,
154
- type: T[0],
156
+ name: l,
157
+ prop: l,
158
+ type: $[0],
155
159
  dataType: y,
156
160
  must: s,
157
161
  label: r,
@@ -160,16 +164,16 @@ function q(e) {
160
164
  }).filter(Boolean);
161
165
  }
162
166
  export {
163
- j as getFunBody,
167
+ x as getFunBody,
164
168
  M as getFunctionFormat,
165
- A as getObjType,
166
- b as getSonType,
169
+ F as getObjType,
170
+ m as getSonType,
167
171
  C as getString,
168
- F as getTypeValue,
172
+ O as getTypeValue,
169
173
  N as isDefaultType,
170
174
  L as isTypeEqual,
171
175
  q as parseParamString,
172
- W as parseTypeDefinition,
176
+ b as parseTypeDefinition,
173
177
  E as prettierArrFormat,
174
178
  h as prettierFormat,
175
179
  v as prettierObjFormat,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s={name(e){return e.name?e.name.name:e.props?e.props.name:""},description(e){return e.description&&e.description.name?e.description.name:e.descriptions?e.descriptions:e.props?e.props.description:""},type(e){return e.type?e.type.name:e.props?e.props.type:""},selectable(e){return e.selectable?e.selectable.description||e.selectable.name:e.props?e.props.selectable:""},default(e){return e.default?e.default.description||e.default.name:e.props&&e.props.default||""},return(e){if(e.return){let r=e.return.type;return r&&(r=`[${r}]`),r+(e.return.description||e.return.name)}else return e.props?e.props.return:""}},i={name(e){return e.name?e.name.name:e.emits?e.emits.name:""},description(e){return e.description&&e.description.name?e.description.name:e.descriptions?e.descriptions:e.emits?e.emits.description:""},selectable(e){return e.selectable?e.selectable.description||e.selectable.name:e.emits?e.emits.selectable:""}},l={name(e){return e.name?e.name.name:e.expose?e.expose.name:""},description(e){return e.description&&e.description.name?e.description.name:e.descriptions?e.descriptions:e.expose?e.expose.description:""},selectable(e){return e.selectable?e.selectable.description||e.selectable.name:e.expose?e.expose.selectable:""},type(e){return e.type?e.type.description||e.type.name:e.expose?e.expose.type:""},return(e){if(e.return){let r=e.return.type;return r&&(r=`[${r}]`),r+(e.return.description||e.return.name)}else return e.expose?e.expose.return:""}},p={name(e){return e.name?e.name.name:e.slot?e.slot.name:""},description(e){return e.description&&e.description.name?e.description.name:e.descriptions?e.descriptions:e.slot?e.slot.description:""},selectable(e){return e.selectable?e.selectable.description||e.selectable.name:e.slot?e.slot.selectable:""}};function u(e){return e.map(r=>{const t={};return Object.keys(s).forEach(n=>{t[n]=s[n](r)}),t})}function a(e){return e.map(r=>{const t={};return Object.keys(i).forEach(n=>{t[n]=i[n](r)}),t})}function c(e){return e.map(r=>{const t={};return Object.keys(l).forEach(n=>{t[n]=l[n](r)}),t})}function f(e){return e.map(r=>{const t={};return Object.keys(p).forEach(n=>{t[n]=p[n](r)}),t})}exports.emits=i;exports.expose=l;exports.getEmitsValue=a;exports.getExposeValue=c;exports.getPropsValue=u;exports.getSlotValue=f;exports.props=s;exports.slot=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s={name(e){return e.name?e.name.name+e.name.description:e.props?e.props.name:""},description(e){return e.description&&e.description.name?e.description.name+e.description.description:e.descriptions?e.descriptions:e.props?e.props.description:""},type(e){return e.type?e.type.type||e.type.name+e.type.description:e.props?e.props.type:""},selectable(e){return e.selectable?e.selectable.name+e.selectable.description:e.props?e.props.selectable:""},default(e){return e.default?e.default.name+e.default.description:e.props&&e.props.default||""},return(e){if(e.return){let r=e.return.type;return r&&(r=`[${r}]`),r+(e.return.name+e.return.description)}else return e.props?e.props.return:""},required(e){return e.required?e.required.name+e.required.description:e.props?e.props.required:""}},i={name(e){return e.name?e.name.name+e.name.description:e.emits?e.emits.name:""},description(e){return e.description&&e.description.name?e.description.name+e.description.description:e.descriptions?e.descriptions:e.emits?e.emits.description:""},selectable(e){return e.selectable?e.selectable.name+e.selectable.description:e.emits?e.emits.selectable:""}},p={name(e){return e.name?e.name.name+e.name.description:e.expose?e.expose.name:""},description(e){return e.description&&e.description.name?e.description.name+e.description.description:e.descriptions?e.descriptions:e.expose?e.expose.description:""},selectable(e){return e.selectable?e.selectable.name+e.selectable.description:e.expose?e.expose.selectable:""},type(e){return e.type?e.type.type||e.type.name+e.type.description:e.expose?e.expose.type:""},return(e){if(e.return){let r=e.return.type;return r&&(r=`[${r}]`),r+(e.return.name+e.return.description)}else return e.expose?e.expose.return:""}},l={name(e){return e.name?e.name.name+e.name.description:e.slot?e.slot.name:""},description(e){return e.description&&e.description.name?e.description.name+e.description.description:e.descriptions?e.descriptions:e.slot?e.slot.description:""},selectable(e){return e.selectable?e.selectable.name+e.selectable.description:e.slot?e.slot.selectable:""}};function u(e){return e.map(r=>{const t={};return Object.keys(s).forEach(n=>{t[n]=s[n](r)}),t})}function c(e){return e.map(r=>{const t={};return Object.keys(i).forEach(n=>{t[n]=i[n](r)}),t})}function a(e){return e.map(r=>{const t={};return Object.keys(p).forEach(n=>{t[n]=p[n](r)}),t})}function d(e){return e.map(r=>{const t={};return Object.keys(l).forEach(n=>{t[n]=l[n](r)}),t})}exports.emits=i;exports.expose=p;exports.getEmitsValue=c;exports.getExposeValue=a;exports.getPropsValue=u;exports.getSlotValue=d;exports.props=s;exports.slot=l;