@fangzhongya/vue-archive 0.0.36 → 0.0.37
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
CHANGED
|
@@ -3157,7 +3157,21 @@ function getTypeValue(arr) {
|
|
|
3157
3157
|
}
|
|
3158
3158
|
}
|
|
3159
3159
|
function setDataType(arr) {
|
|
3160
|
-
|
|
3160
|
+
let ts = "";
|
|
3161
|
+
arr.forEach((v, index) => {
|
|
3162
|
+
v = v.trim();
|
|
3163
|
+
if (v) {
|
|
3164
|
+
if (ts) {
|
|
3165
|
+
ts += " | ";
|
|
3166
|
+
}
|
|
3167
|
+
if (v === "Array") {
|
|
3168
|
+
ts += "Array<any>";
|
|
3169
|
+
} else {
|
|
3170
|
+
ts += v;
|
|
3171
|
+
}
|
|
3172
|
+
}
|
|
3173
|
+
});
|
|
3174
|
+
return ts || "any";
|
|
3161
3175
|
}
|
|
3162
3176
|
var splitIgnoringNesting = (str, delimiter) => {
|
|
3163
3177
|
let bracketStack = [];
|
package/dist/node/index.js
CHANGED
|
@@ -3142,7 +3142,21 @@ function getTypeValue(arr) {
|
|
|
3142
3142
|
}
|
|
3143
3143
|
}
|
|
3144
3144
|
function setDataType(arr) {
|
|
3145
|
-
|
|
3145
|
+
let ts = "";
|
|
3146
|
+
arr.forEach((v, index) => {
|
|
3147
|
+
v = v.trim();
|
|
3148
|
+
if (v) {
|
|
3149
|
+
if (ts) {
|
|
3150
|
+
ts += " | ";
|
|
3151
|
+
}
|
|
3152
|
+
if (v === "Array") {
|
|
3153
|
+
ts += "Array<any>";
|
|
3154
|
+
} else {
|
|
3155
|
+
ts += v;
|
|
3156
|
+
}
|
|
3157
|
+
}
|
|
3158
|
+
});
|
|
3159
|
+
return ts || "any";
|
|
3146
3160
|
}
|
|
3147
3161
|
var splitIgnoringNesting = (str, delimiter) => {
|
|
3148
3162
|
let bracketStack = [];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("@fangzhongya/utils/basic/string/toFunction"),
|
|
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 S=require("@fangzhongya/utils/basic/string/toFunction"),w=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 A(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 b(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?b(r[1]):e}const W=["Boolean","Any","String","Number","Array","Object","Function"];function k(e){return W.includes(e)?w.firstLower(e):e}function v(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=v(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 E(e,n){const t=T(e),r=h(n)[0];return r&&r!="any"?t==r:!0}function q(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 B(e){e=(e+"").replace(/^(\s|\n|r)*/,"").replace(/(\s|\n|r)*$/,"");let n="";return/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e)?n="string":/^\[(.|\n|\r)*\]$/.test(e)?n="array":/^\{(.|\n|\r)*\}$/.test(e)?n="object":/^[0-9]*$/.test(e)?n="number":e==="true"||e==="false"?n="boolean":e=="undefined"?n="undefined":e=="null"?n="null":e&&(n="string"),n}function F(e){switch((e[0]||"any").toLowerCase()){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":let t=F(e.splice(1));return t=t=="undefined"?"":t,`[${t}]`;case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function L(e){let n="";return e.forEach((t,r)=>{t=t.trim(),t&&(n&&(n+=" | "),t==="Array"?n+="Array<any>":n+=t)}),n||"any"}const g=(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},C=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=g(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=g(n,"|");return{type:t[0]||"any",dataType:t}}else return{type:e,dataType:[e]};else return{type:"any",dataType:["any"]}};function M(e){return g(e,",").map(t=>{const r=t.trim(),i=t.match(/^([^:?]+)(\??):/);if(!i)return null;const u=i[1].trim(),s=!i[2],j=i[0].length,c=t.substring(j).trim();let a=[],f="",p="";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!==")"?(f="",p=c.substring(0)):(f=c.substring(0,l+1).trim(),p=c.substring(l+1));break}}const{type:N,dataType:m}=C(f),$=h(m);return{name:u,prop:u,type:$[0],dataType:m,must:s,label:r,description:p}}).filter(Boolean)}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>S.getFunctionFormat});exports.getFunBody=b;exports.getObjType=T;exports.getSonType=h;exports.getString=q;exports.getTypeValue=F;exports.isDefaultType=B;exports.isTypeEqual=E;exports.parseParamString=M;exports.prettierArrFormat=A;exports.prettierFormat=y;exports.prettierObjFormat=O;exports.setDataType=L;exports.vueFormat=x;
|
|
@@ -3,13 +3,13 @@ import { firstLower as $ } from "@fangzhongya/utils/basic/string/firstLower";
|
|
|
3
3
|
function h(e) {
|
|
4
4
|
return e.replace(/\;(\s|\n\r)*$/, "");
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function E(e) {
|
|
7
7
|
return e = "let a = " + e, h(e).replace(/^let a = /, "");
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function v(e) {
|
|
10
10
|
return h(e);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function B(e, n = "") {
|
|
13
13
|
let t = (e + "").trim().split(/\n/);
|
|
14
14
|
return t = t.map((r) => n + r), t.join(`
|
|
15
15
|
`);
|
|
@@ -32,7 +32,7 @@ const S = [
|
|
|
32
32
|
function w(e) {
|
|
33
33
|
return S.includes(e) ? $(e) : e;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function x(e) {
|
|
36
36
|
let t = new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);
|
|
37
37
|
if (t && t.length > 0)
|
|
38
38
|
return {
|
|
@@ -41,7 +41,7 @@ function F(e) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
function m(e, n) {
|
|
44
|
-
let t =
|
|
44
|
+
let t = x(e);
|
|
45
45
|
t ? (n.push(t.own), t.son && m(t.son, n)) : n.push(e);
|
|
46
46
|
}
|
|
47
47
|
function b(e) {
|
|
@@ -49,13 +49,13 @@ function b(e) {
|
|
|
49
49
|
const n = [];
|
|
50
50
|
return e && m(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 = b(n)[0];
|
|
59
59
|
return r && r != "any" ? t == r : !0;
|
|
60
60
|
}
|
|
61
61
|
function C(e) {
|
|
@@ -69,7 +69,7 @@ function N(e) {
|
|
|
69
69
|
let n = "";
|
|
70
70
|
return /^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e) ? n = "string" : /^\[(.|\n|\r)*\]$/.test(e) ? n = "array" : /^\{(.|\n|\r)*\}$/.test(e) ? n = "object" : /^[0-9]*$/.test(e) ? n = "number" : e === "true" || e === "false" ? n = "boolean" : e == "undefined" ? n = "undefined" : e == "null" ? n = "null" : e && (n = "string"), n;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function A(e) {
|
|
73
73
|
switch ((e[0] || "any").toLowerCase()) {
|
|
74
74
|
case "string":
|
|
75
75
|
return '""';
|
|
@@ -78,7 +78,7 @@ function x(e) {
|
|
|
78
78
|
case "number":
|
|
79
79
|
return "0";
|
|
80
80
|
case "array":
|
|
81
|
-
let t =
|
|
81
|
+
let t = A(e.splice(1));
|
|
82
82
|
return t = t == "undefined" ? "" : t, `[${t}]`;
|
|
83
83
|
case "object":
|
|
84
84
|
return "{}";
|
|
@@ -91,12 +91,15 @@ function x(e) {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
function R(e) {
|
|
94
|
-
|
|
94
|
+
let n = "";
|
|
95
|
+
return e.forEach((t, r) => {
|
|
96
|
+
t = t.trim(), t && (n && (n += " | "), t === "Array" ? n += "Array<any>" : n += t);
|
|
97
|
+
}), n || "any";
|
|
95
98
|
}
|
|
96
99
|
const g = (e, n) => {
|
|
97
100
|
let t = [], r = [], i = "";
|
|
98
|
-
for (let
|
|
99
|
-
const s = e[
|
|
101
|
+
for (let u = 0; u < e.length; u++) {
|
|
102
|
+
const s = e[u];
|
|
100
103
|
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;
|
|
101
104
|
}
|
|
102
105
|
return i.trim() !== "" && r.push(i.trim()), r;
|
|
@@ -129,19 +132,19 @@ function q(e) {
|
|
|
129
132
|
return g(e, ",").map((t) => {
|
|
130
133
|
const r = t.trim(), i = t.match(/^([^:?]+)(\??):/);
|
|
131
134
|
if (!i) return null;
|
|
132
|
-
const
|
|
135
|
+
const u = i[1].trim(), s = !i[2], d = i[0].length, c = t.substring(d).trim();
|
|
133
136
|
let l = [], f = "", p = "";
|
|
134
|
-
for (let
|
|
135
|
-
const o = c[
|
|
136
|
-
if (o === "[" || o === "<" || o === "(" ? l.push(o) : (o === "]" && l[l.length - 1] === "[" || o === ">" && l[l.length - 1] === "<" || o === ")" && l[l.length - 1] === "(") && l.pop(), l.length === 0 &&
|
|
137
|
-
|
|
137
|
+
for (let a = 0; a < c.length; a++) {
|
|
138
|
+
const o = c[a];
|
|
139
|
+
if (o === "[" || o === "<" || o === "(" ? l.push(o) : (o === "]" && l[l.length - 1] === "[" || o === ">" && l[l.length - 1] === "<" || o === ")" && l[l.length - 1] === "(") && l.pop(), l.length === 0 && a > 0) {
|
|
140
|
+
a == 1 && o !== "]" && o !== ">" && o !== ")" ? (f = "", p = c.substring(0)) : (f = c.substring(0, a + 1).trim(), p = c.substring(a + 1));
|
|
138
141
|
break;
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
144
|
const { type: k, dataType: y } = W(f), T = b(y);
|
|
142
145
|
return {
|
|
143
|
-
name:
|
|
144
|
-
prop:
|
|
146
|
+
name: u,
|
|
147
|
+
prop: u,
|
|
145
148
|
type: T[0],
|
|
146
149
|
dataType: y,
|
|
147
150
|
must: s,
|
|
@@ -153,16 +156,16 @@ function q(e) {
|
|
|
153
156
|
export {
|
|
154
157
|
j as getFunBody,
|
|
155
158
|
M as getFunctionFormat,
|
|
156
|
-
|
|
159
|
+
F as getObjType,
|
|
157
160
|
b as getSonType,
|
|
158
161
|
C as getString,
|
|
159
|
-
|
|
162
|
+
A as getTypeValue,
|
|
160
163
|
N as isDefaultType,
|
|
161
164
|
L as isTypeEqual,
|
|
162
165
|
q as parseParamString,
|
|
163
|
-
|
|
166
|
+
v as prettierArrFormat,
|
|
164
167
|
h as prettierFormat,
|
|
165
|
-
|
|
168
|
+
E as prettierObjFormat,
|
|
166
169
|
R as setDataType,
|
|
167
|
-
|
|
170
|
+
B as vueFormat
|
|
168
171
|
};
|