@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.
- package/dist/node/index.cjs +84 -36
- package/dist/node/index.js +84 -36
- package/dist/packages/components/compo/index.cjs +1 -1
- package/dist/packages/components/compo/index.js +126 -108
- package/dist/packages/components/use/code.cjs +10 -10
- package/dist/packages/components/use/code.d.ts +1 -1
- package/dist/packages/components/use/code.js +90 -84
- package/dist/packages/components/use/set-props.vue.cjs +1 -1
- package/dist/packages/components/use/set-props.vue.js +22 -22
- package/dist/packages/components/use/util.cjs +3 -3
- package/dist/packages/components/use/util.js +38 -34
- package/dist/packages/utils/props.cjs +1 -1
- package/dist/packages/utils/props.js +30 -27
- package/package.json +1 -1
|
@@ -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
|
|
13
|
-
import { getPropsValue as
|
|
14
|
-
import { getFunctionFormat as
|
|
15
|
-
const
|
|
16
|
-
function
|
|
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") + ":" +
|
|
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
|
|
23
|
+
const m = [], r = [];
|
|
24
24
|
let d = !0;
|
|
25
|
-
const B =
|
|
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
|
|
28
|
-
if (/^on[A-Z]/.test(o) && typeof
|
|
29
|
-
let
|
|
30
|
-
const
|
|
31
|
-
let
|
|
32
|
-
if (
|
|
33
|
-
let
|
|
34
|
-
|
|
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
|
-
|
|
37
|
-
const
|
|
38
|
-
r.push(`// ${
|
|
39
|
-
const
|
|
40
|
-
r.push(" console.log('" +
|
|
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
|
|
44
|
-
|
|
45
|
-
const
|
|
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
|
-
`// ${
|
|
48
|
-
), typeof
|
|
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(
|
|
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
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
r.push("const " +
|
|
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
|
|
61
|
+
const a = V(l.dataType);
|
|
58
62
|
r.push(
|
|
59
|
-
"const " +
|
|
63
|
+
"const " + u + " = ref(" + (a === "undefined" ? "" : a) + ");"
|
|
60
64
|
);
|
|
61
65
|
}
|
|
62
66
|
else {
|
|
63
|
-
let
|
|
64
|
-
r.push("const " +
|
|
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';")),
|
|
70
|
-
const
|
|
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
|
-
`// ${
|
|
76
|
+
`// ${c.description} ${c.name}:(${c.selectable}) ${c.type}`
|
|
73
77
|
);
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
const
|
|
79
|
-
if (r.push(`// ${y.label}`), typeof
|
|
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 " +
|
|
85
|
+
"const " + p + " = " + x($, g, o.text)
|
|
82
86
|
);
|
|
83
|
-
else if (typeof
|
|
87
|
+
else if (typeof $ > "u")
|
|
84
88
|
r.push(
|
|
85
|
-
"const " +
|
|
89
|
+
"const " + p + " = " + V(y.dataType) + ";"
|
|
86
90
|
);
|
|
87
91
|
else {
|
|
88
|
-
let
|
|
89
|
-
r.push("const " +
|
|
92
|
+
let S = L($, g, o.text);
|
|
93
|
+
r.push("const " + p + " = " + S + ";");
|
|
90
94
|
}
|
|
91
|
-
|
|
95
|
+
l.push(p);
|
|
92
96
|
}
|
|
93
|
-
}), o.type === "function" ? r.push(
|
|
94
|
-
`const ${
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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}${
|
|
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
|
|
119
|
+
function X(t = {}, n) {
|
|
114
120
|
const s = [];
|
|
115
121
|
return Object.keys(t).forEach((e) => {
|
|
116
|
-
const i =
|
|
122
|
+
const i = T(n, e) || {}, h = t[e];
|
|
117
123
|
if (h) {
|
|
118
|
-
const
|
|
124
|
+
const m = ` <!-- ${i.description} ${i.name}:(${i.selectable}) -->
|
|
119
125
|
<template #${e}="scope">
|
|
120
|
-
${
|
|
126
|
+
${E(h, " ")}
|
|
121
127
|
</template>`;
|
|
122
|
-
s.push(
|
|
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 :
|
|
134
|
+
return e && (e.includes("=>") || e.includes("function")) ? e : F(t.toString());
|
|
129
135
|
}
|
|
130
|
-
function
|
|
131
|
-
const n =
|
|
136
|
+
function F(t) {
|
|
137
|
+
const n = R(G(t));
|
|
132
138
|
if (n) {
|
|
133
139
|
let s = `{
|
|
134
|
-
${
|
|
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
|
|
141
|
-
const 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
|
-
${
|
|
151
|
+
${E(C(e), " ")}
|
|
146
152
|
}`;
|
|
147
153
|
return `function (${s}) ${i}`;
|
|
148
154
|
}
|
|
149
|
-
function
|
|
155
|
+
function _(t) {
|
|
150
156
|
const n = t.trim();
|
|
151
|
-
return /^\(/.test(n) ?
|
|
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
|
|
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((
|
|
162
|
-
if (
|
|
163
|
-
let r =
|
|
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:
|
|
166
|
-
prop:
|
|
171
|
+
label: m,
|
|
172
|
+
prop: D(r[0].trim())
|
|
167
173
|
});
|
|
168
174
|
}
|
|
169
|
-
}) : h =
|
|
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
|
|
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
|
|
190
|
-
const s = z(t), e =
|
|
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
|
|
199
|
+
return D(i || e, s.dataType[0]);
|
|
194
200
|
} else {
|
|
195
201
|
const i = (t.default || "").trim();
|
|
196
|
-
return
|
|
202
|
+
return D(i, s.dataType[0]);
|
|
197
203
|
}
|
|
198
204
|
}
|
|
199
205
|
export {
|
|
200
|
-
|
|
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
|
|
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(
|
|
16
|
-
const
|
|
17
|
-
function
|
|
18
|
-
|
|
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
|
-
|
|
20
|
+
a.list?.forEach((t) => {
|
|
21
21
|
let e = t.name;
|
|
22
22
|
if (!e.includes(".") && (e = (e.split("/")[0] || "").trim(), e)) {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const { arr: b, type:
|
|
26
|
-
|
|
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:
|
|
28
|
+
label: d(e, t),
|
|
29
29
|
prop: e,
|
|
30
|
-
type:
|
|
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
|
|
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
|
|
42
|
+
function h(s, t) {
|
|
43
43
|
let e = Object.assign({}, s);
|
|
44
|
-
|
|
44
|
+
m("change", e, t);
|
|
45
45
|
}
|
|
46
46
|
let c;
|
|
47
|
-
function
|
|
47
|
+
function _() {
|
|
48
48
|
clearTimeout(c), c = setTimeout(() => {
|
|
49
|
-
|
|
49
|
+
f();
|
|
50
50
|
}, 400);
|
|
51
51
|
}
|
|
52
52
|
return k(
|
|
53
|
-
() =>
|
|
53
|
+
() => a.name,
|
|
54
54
|
() => {
|
|
55
|
-
l.value = [],
|
|
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:
|
|
63
|
-
modelValue:
|
|
62
|
+
refresh: p.value,
|
|
63
|
+
modelValue: o.value,
|
|
64
64
|
selects: r.value,
|
|
65
65
|
list: l.value,
|
|
66
|
-
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
|
|
2
|
-
`)}function
|
|
3
|
-
|\r)+?)\\}[\\s|\\n|\\r]*`,r=new RegExp("^"+n+"$").exec(e);return r&&r.length>0?
|
|
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
|
|
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
|
|
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 ?
|
|
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) ?
|
|
33
|
+
return S.includes(e) ? j(e) : e;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
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
|
|
44
|
-
let t =
|
|
45
|
-
t ? (n.push(t.own), t.son &&
|
|
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
|
|
47
|
+
function m(e) {
|
|
48
48
|
e instanceof Array && (e = e[0]);
|
|
49
49
|
const n = [];
|
|
50
|
-
return e &&
|
|
50
|
+
return e && d(e, n), n;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
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 =
|
|
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
|
|
77
|
-
|
|
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
|
|
86
|
-
|
|
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
|
|
106
|
-
const s = e[
|
|
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
|
-
},
|
|
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
|
|
142
|
-
let
|
|
143
|
-
for (let
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
146
|
-
|
|
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:
|
|
154
|
+
const { type: W, dataType: y } = b(p), $ = m(y);
|
|
151
155
|
return {
|
|
152
|
-
name:
|
|
153
|
-
prop:
|
|
154
|
-
type:
|
|
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
|
-
|
|
167
|
+
x as getFunBody,
|
|
164
168
|
M as getFunctionFormat,
|
|
165
|
-
|
|
166
|
-
|
|
169
|
+
F as getObjType,
|
|
170
|
+
m as getSonType,
|
|
167
171
|
C as getString,
|
|
168
|
-
|
|
172
|
+
O as getTypeValue,
|
|
169
173
|
N as isDefaultType,
|
|
170
174
|
L as isTypeEqual,
|
|
171
175
|
q as parseParamString,
|
|
172
|
-
|
|
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.
|
|
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;
|