@fangzhongya/vue-archive 0.1.8 → 0.1.10
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 +2184 -2033
- package/dist/node/index.js +2184 -2033
- package/dist/packages/components/compo/index.cjs +1 -1
- package/dist/packages/components/compo/index.d.ts +0 -1
- package/dist/packages/components/compo/index.js +36 -235
- package/dist/packages/components/compo/info-top.vue.cjs +1 -1
- package/dist/packages/components/compo/info-top.vue.js +1 -1
- package/dist/packages/components/compo/props.vue.cjs +1 -1
- package/dist/packages/components/compo/props.vue.js +12 -11
- package/dist/packages/components/test/index.cjs +1 -1
- package/dist/packages/components/test/index.js +1 -1
- package/dist/packages/components/use/code.cjs +13 -13
- package/dist/packages/components/use/code.d.ts +25 -18
- package/dist/packages/components/use/code.js +6 -5
- package/dist/packages/components/use/retrie/expose/index.vue.cjs +1 -1
- package/dist/packages/components/use/retrie/expose/index.vue.js +1 -1
- package/dist/packages/components/use/util.cjs +3 -3
- package/dist/packages/components/use/util.d.ts +0 -9
- package/dist/packages/components/use/util.js +106 -132
- package/dist/packages/utils/annotat.cjs +1 -0
- package/dist/packages/utils/annotat.d.ts +17 -0
- package/dist/packages/utils/annotat.js +321 -0
- package/dist/packages/utils/index.cjs +1 -1
- package/dist/packages/utils/index.d.ts +0 -1
- package/dist/packages/utils/index.js +6 -12
- package/dist/packages/utils/props.cjs +1 -1
- package/dist/packages/utils/props.js +4 -1
- package/package.json +1 -1
|
@@ -9,8 +9,9 @@ import "@fangzhongya/utils/basic/array/asyncMergeArray";
|
|
|
9
9
|
import { firstUpper as z } 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 E, getDataTypeType as F,
|
|
12
|
+
import { getTypeValue as E, getDataTypeType as F, prettierHtml as q, prettierTs as G, getDataType as I, parseTypeDefinition as K, setDataType as M, vueFormat as x, getFunBody as J, allReservedWords as Q } from "./util.js";
|
|
13
13
|
import { getPropsValue as X, getEmitsValue as Y, getExposeValue as _, getSlotValue as k } from "../../utils/props.js";
|
|
14
|
+
import { parseParamString as j } from "../../utils/annotat.js";
|
|
14
15
|
import { getFunctionFormat as tt } from "@fangzhongya/utils/basic/string/toFunction";
|
|
15
16
|
function T(t, n) {
|
|
16
17
|
return t.filter((e) => e.name == n)[0];
|
|
@@ -18,7 +19,7 @@ function T(t, n) {
|
|
|
18
19
|
function L(t) {
|
|
19
20
|
return t.map((n) => (n.prop || "...arr") + ":" + M(n.dataType)).join(",");
|
|
20
21
|
}
|
|
21
|
-
async function
|
|
22
|
+
async function Tt(t, n, e, s, i, $) {
|
|
22
23
|
const m = [], r = [];
|
|
23
24
|
let d = !0;
|
|
24
25
|
const v = X(n.propss || []), A = Y(n.emitss || []), C = _(n.exposes || []), R = k(n.slots || []);
|
|
@@ -193,7 +194,7 @@ function w(t, n) {
|
|
|
193
194
|
return "" + t;
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
|
-
function
|
|
197
|
+
function jt(t, n = !0) {
|
|
197
198
|
const e = N(t), s = E(e.dataType);
|
|
198
199
|
if (n) {
|
|
199
200
|
const i = (t.default || "").trim();
|
|
@@ -204,8 +205,8 @@ function Tt(t, n = !0) {
|
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
207
|
export {
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
jt as getDefaultValue,
|
|
209
|
+
Tt as getHmtl,
|
|
209
210
|
N as getSpecType,
|
|
210
211
|
H as setValStringify
|
|
211
212
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("vue"),d=require("
|
|
1
|
+
"use strict";const e=require("vue"),d=require("../../../../utils/annotat.cjs"),g=require("../index.vue.cjs");;/* empty css */const y={class:"expose"},h={class:"expose-label"},x={class:"expose-return"},S=e.defineComponent({__name:"index",props:{getRef:{type:Function},name:String,value:{type:Object}},emits:["change"],setup(p,{emit:m}){const s=p,v=m,c=e.ref(""),o=e.ref(""),i=e.ref([]),f=e.computed(()=>{i.value=[];const n=s.value;if(n&&n.name){let l=(n.selectable+"").trim();if(c.value=n.name+": "+n.description+" 入参=("+l+") 返回值: "+n.type,l){let a=d.parseParamString(l);return a.forEach(t=>{t.prop=t.name,i.value.push(t.name)}),a}}return[]});function _(n,l){let a=s.getRef?s.getRef():void 0,t=s.value?.name;if(t){let u=i.value.map(r=>n[r]);if(a&&a[t]){if(typeof a[t]=="function"){let r=a[t](...u);o.value=JSON.stringify(r)}else{let r=a[t];r instanceof HTMLDivElement?o.value=r.outerHTML:o.value=JSON.stringify(r)}v("change",t,u,typeof a[t],l)}}else console.log("请选择方法")}return(n,l)=>(e.openBlock(),e.createElementBlock("div",y,[e.createElementVNode("div",h,e.toDisplayString(c.value||"请选择方法"),1),e.createVNode(g,{list:f.value,name:s.name,queryName:"调用",onQuery:_},null,8,["list","name"]),e.createElementVNode("div",x,e.toDisplayString(s.value?.type)+"返回值:"+e.toDisplayString(o.value),1)]))}});module.exports=S;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as y, ref as i, computed as h, createElementBlock as x, openBlock as b, createElementVNode as p, createVNode as N, toDisplayString as c } from "vue";
|
|
2
|
-
import { parseParamString as S } from "
|
|
2
|
+
import { parseParamString as S } from "../../../../utils/annotat.js";
|
|
3
3
|
import E from "../index.vue.js";
|
|
4
4
|
/* empty css */
|
|
5
5
|
const O = { class: "expose" }, R = { class: "expose-label" }, j = { class: "expose-return" }, J = /* @__PURE__ */ y({
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`)}function
|
|
3
|
-
|\r)+?)\\}[\\s|\\n|\\r]*`,n=new RegExp("^"+t+"$").exec(e);return n&&n.length>0?
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../../config.cjs"),v=require("@fangzhongya/utils/basic/string/toFunction"),T=require("@fangzhongya/utils/basic/string/firstLower");let o=e=>e;const l=b.getConfig("prettier");l&&Promise.resolve().then(()=>require("./prettier.cjs")).then(e=>{o=e.getFormat});function a(e){return l?o(e,"js"):e.replace(/\;(\s|\n\r)*$/,"")}async function F(e){return e="let a = "+e,(await a(e)).replace(/^let a = /,"")}function j(e){return a(e)}async function w(e){return!/^\s*function/.test(e)&&!/^\s*\([^\)]*\)\s*\=\>/.test(e)?(e="function a"+e,(await a(e)).replace(/^function a/,"")):await a(e)}function $(e){return l?o(e,"html"):e}function O(e){return l?o(e,"ts"):e}function W(e){return l?o(e,"js"):e}function A(e){return l?o(e,"css"):e}function S(e,t=""){let r=(e+"").trim().split(/\n/);return r=r.map(n=>t+n),r.join(`
|
|
2
|
+
`)}function p(e=""){e=e.trim();let t=`[\\s|\\n|\\r]*\\{((.|
|
|
3
|
+
|\r)+?)\\}[\\s|\\n|\\r]*`,n=new RegExp("^"+t+"$").exec(e);return n&&n.length>0?p(n[1]):e}const k=["Boolean","Any","String","Number","Array","Object","Function"];function q(e){return k.includes(e)?T.firstLower(e):e}function C(e){if(typeof e=="string"){let t=!1;return(/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e))&&(t=!0),t&&(e=e.substring(1,e.length-1)),e+""}else return typeof e=="object"&&e?e.toString():typeof e>"u"||typeof e=="object"&&!e?"":e+""}function x(e){const t=typeof e;if(t=="string"){e=(e+"").replace(/^(\s|\n|r)*/,"").replace(/(\s|\n|r)*$/,"");let r="";return/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e)?r="string":/^\[(.|\n|\r)*\]$/.test(e)?r="array":/^\{(.|\n|\r)*\}$/.test(e)?r="object":/^[0-9]*$/.test(e)?r="number":e==="true"||e==="false"?r="boolean":e=="undefined"?r="undefined":e=="null"?r="null":e&&(r="string"),r}else return t==="object"?e instanceof Array?"array":t===null?"null":t:t}const c=(e,t)=>{let r=[],n=[],i="";for(let u=0;u<e.length;u++){const s=e[u];s==="["||s==="<"||s==="("?(r.push(s),i+=s):s==="]"&&r.length>0&&r[r.length-1]==="["||s===">"&&r.length>0&&r[r.length-1]==="<"||s===")"&&r.length>0&&r[r.length-1]==="("?(r.pop(),i+=s):s===t&&r.length===0?(n.push(i.trim()),i=""):i+=s}return i.trim()!==""&&n.push(i.trim()),n},L=e=>{let t=[],r=!1,n=!1,i=0;for(let u=0;u<e.length;u++){const s=e[u];if(s==="["||s==="<"||s==="("?(n=!0,t.push(s),s=="["&&(r=!0),i==0&&(i=u)):(s==="]"&&t[t.length-1]==="["||s===">"&&t[t.length-1]==="<"||s===")"&&t[t.length-1]==="(")&&t.pop(),n&&t.length===0)return r&&i+1==u?{top:"Array",type:e.substring(0,i)}:{top:e.substring(0,i),type:e.substring(i+1,u)}}return{top:e,type:""}},g=e=>{if(e)if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("(")&&e.endsWith(")")){const t=e.slice(1,-1).trim();return t?c(t,","):["any"]}else{if(e.startsWith("{")&&e.endsWith("}"))return["Object"];if(e.startsWith("<")&&e.endsWith(">")){const t=e.slice(1,-1).trim();return t?c(t,"|"):["any"]}else return c(e,",")}else return["any"]};function y(e){return e.map(r=>{if(typeof r=="string")return r.toLowerCase()==="array"?"Array<any>":r;if(r.children&&r.children.length>0){const n=y(r.children);return r.value+"<"+n+">"}else{const n=r.value;return n.toLowerCase()==="array"?"Array<any>":n}}).join(" | ")||"any"}function h(e){const t=[];return e.forEach(r=>{const n=L(r);if(n.type){const i=g(n.type),u=h(i);t.push({label:r,value:n.top,children:u})}else t.push(n.top)}),t}function E(e){let t="";return typeof e=="string"?t=e:t=e.value,q(t||"any")}function f(e){const t=e[0]||"any";return E(t)}function d(e){const t=e[0];switch(f(e)){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":if(typeof t=="string")return"[]";{let n=t.children;if(n&&n.length>0){let i=d([n[0]]);return i=i=="undefined"?"":i,`[${i}]`}else return"[]"}case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function m(e){const t=Object.prototype.toString.call(e);let n=/^\[[O|o]bject (.*)\]$/.exec(t),i=typeof e;return n&&n.length>0&&(i=n[1].toLowerCase()),i}function B(e,t){const r=m(e),n=f(t);return n&&n!="any"?r==n:!0}const N=["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","implements","interface","let","package","private","protected","public","static","true","false","null","undefined","any","boolean","number","string","object","symbol","unknown","never","void","undefined","null","type","interface","enum","as","is","infer","unique","abstract","readonly","namespace","module","declare","require","get","set","async","await","from","of","package"];Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>v.getFunctionFormat});exports.allReservedWords=N;exports.getDataType=h;exports.getDataTypeType=f;exports.getFunBody=p;exports.getObjType=m;exports.getString=C;exports.getTypeValue=d;exports.isDefaultType=x;exports.isTypeEqual=B;exports.parseTypeDefinition=g;exports.prettierArrFormat=j;exports.prettierCss=A;exports.prettierFormat=a;exports.prettierFunFormat=w;exports.prettierHtml=$;exports.prettierJs=W;exports.prettierObjFormat=F;exports.prettierTs=O;exports.setDataType=y;exports.vueFormat=S;
|
|
@@ -27,15 +27,6 @@ export type DataType = string | {
|
|
|
27
27
|
value: string;
|
|
28
28
|
children?: DataType[];
|
|
29
29
|
};
|
|
30
|
-
export declare function parseParamString(input: string): Array<{
|
|
31
|
-
name: string;
|
|
32
|
-
prop: string;
|
|
33
|
-
type: string;
|
|
34
|
-
dataType: DataType[];
|
|
35
|
-
must: boolean;
|
|
36
|
-
label: string;
|
|
37
|
-
description: string;
|
|
38
|
-
}>;
|
|
39
30
|
export declare function setDataType(arr: DataType[]): string;
|
|
40
31
|
export declare function getDataType(arr: string[]): DataType[];
|
|
41
32
|
export declare function getDataTypeType(dataType: DataType[]): string;
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { getConfig as
|
|
2
|
-
import { getFunctionFormat as
|
|
3
|
-
import { firstLower as
|
|
4
|
-
let
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { getConfig as p } from "../../config.js";
|
|
2
|
+
import { getFunctionFormat as H } from "@fangzhongya/utils/basic/string/toFunction";
|
|
3
|
+
import { firstLower as g } from "@fangzhongya/utils/basic/string/firstLower";
|
|
4
|
+
let l = (e) => e;
|
|
5
|
+
const o = p("prettier");
|
|
6
|
+
o && import("./prettier.js").then((e) => {
|
|
7
|
+
l = e.getFormat;
|
|
8
8
|
});
|
|
9
|
-
function
|
|
10
|
-
return
|
|
9
|
+
function a(e) {
|
|
10
|
+
return o ? l(e, "js") : e.replace(/\;(\s|\n\r)*$/, "");
|
|
11
11
|
}
|
|
12
|
-
async function
|
|
13
|
-
return e = "let a = " + e, (await
|
|
12
|
+
async function k(e) {
|
|
13
|
+
return e = "let a = " + e, (await a(e)).replace(/^let a = /, "");
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
function A(e) {
|
|
16
|
+
return a(e);
|
|
17
17
|
}
|
|
18
|
-
async function
|
|
19
|
-
return !/^\s*function/.test(e) && !/^\s*\([^\)]*\)\s*\=\>/.test(e) ? (e = "function a" + e, (await
|
|
18
|
+
async function x(e) {
|
|
19
|
+
return !/^\s*function/.test(e) && !/^\s*\([^\)]*\)\s*\=\>/.test(e) ? (e = "function a" + e, (await a(e)).replace(/^function a/, "")) : await a(e);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
21
|
+
function O(e) {
|
|
22
|
+
return o ? l(e, "html") : e;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
24
|
+
function S(e) {
|
|
25
|
+
return o ? l(e, "ts") : e;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return
|
|
27
|
+
function C(e) {
|
|
28
|
+
return o ? l(e, "js") : e;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
return
|
|
30
|
+
function L(e) {
|
|
31
|
+
return o ? l(e, "css") : e;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
let
|
|
35
|
-
return
|
|
33
|
+
function q(e, t = "") {
|
|
34
|
+
let r = (e + "").trim().split(/\n/);
|
|
35
|
+
return r = r.map((n) => t + n), r.join(`
|
|
36
36
|
`);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function y(e = "") {
|
|
39
39
|
e = e.trim();
|
|
40
40
|
let t = `[\\s|\\n|\\r]*\\{((.|
|
|
41
|
-
|\r)+?)\\}[\\s|\\n|\\r]*`,
|
|
42
|
-
return
|
|
41
|
+
|\r)+?)\\}[\\s|\\n|\\r]*`, n = new RegExp("^" + t + "$").exec(e);
|
|
42
|
+
return n && n.length > 0 ? y(n[1]) : e;
|
|
43
43
|
}
|
|
44
|
-
const
|
|
44
|
+
const h = [
|
|
45
45
|
"Boolean",
|
|
46
46
|
"Any",
|
|
47
47
|
"String",
|
|
@@ -50,128 +50,103 @@ const S = [
|
|
|
50
50
|
"Object",
|
|
51
51
|
"Function"
|
|
52
52
|
];
|
|
53
|
-
function
|
|
54
|
-
return
|
|
53
|
+
function d(e) {
|
|
54
|
+
return h.includes(e) ? g(e) : e;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function E(e) {
|
|
57
57
|
if (typeof e == "string") {
|
|
58
58
|
let t = !1;
|
|
59
59
|
return (/^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e)) && (t = !0), t && (e = e.substring(1, e.length - 1)), e + "";
|
|
60
60
|
} else return typeof e == "object" && e ? e.toString() : typeof e > "u" || typeof e == "object" && !e ? "" : e + "";
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function N(e) {
|
|
63
63
|
const t = typeof e;
|
|
64
64
|
if (t == "string") {
|
|
65
65
|
e = (e + "").replace(/^(\s|\n|r)*/, "").replace(/(\s|\n|r)*$/, "");
|
|
66
|
-
let
|
|
67
|
-
return /^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e) ?
|
|
66
|
+
let r = "";
|
|
67
|
+
return /^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e) ? r = "string" : /^\[(.|\n|\r)*\]$/.test(e) ? r = "array" : /^\{(.|\n|\r)*\}$/.test(e) ? r = "object" : /^[0-9]*$/.test(e) ? r = "number" : e === "true" || e === "false" ? r = "boolean" : e == "undefined" ? r = "undefined" : e == "null" ? r = "null" : e && (r = "string"), r;
|
|
68
68
|
} else
|
|
69
69
|
return t === "object" ? e instanceof Array ? "array" : t === null ? "null" : t : t;
|
|
70
70
|
}
|
|
71
|
-
const
|
|
72
|
-
let
|
|
73
|
-
for (let
|
|
74
|
-
const s = e[
|
|
75
|
-
s === "[" || s === "<" || s === "(" ? (
|
|
71
|
+
const c = (e, t) => {
|
|
72
|
+
let r = [], n = [], i = "";
|
|
73
|
+
for (let u = 0; u < e.length; u++) {
|
|
74
|
+
const s = e[u];
|
|
75
|
+
s === "[" || s === "<" || s === "(" ? (r.push(s), i += s) : s === "]" && r.length > 0 && r[r.length - 1] === "[" || s === ">" && r.length > 0 && r[r.length - 1] === "<" || s === ")" && r.length > 0 && r[r.length - 1] === "(" ? (r.pop(), i += s) : s === t && r.length === 0 ? (n.push(i.trim()), i = "") : i += s;
|
|
76
76
|
}
|
|
77
|
-
return i.trim() !== "" &&
|
|
78
|
-
},
|
|
79
|
-
let t = [],
|
|
80
|
-
for (let
|
|
81
|
-
const s = e[
|
|
82
|
-
if (s === "[" || s === "<" || s === "(" ? (
|
|
83
|
-
return
|
|
77
|
+
return i.trim() !== "" && n.push(i.trim()), n;
|
|
78
|
+
}, m = (e) => {
|
|
79
|
+
let t = [], r = !1, n = !1, i = 0;
|
|
80
|
+
for (let u = 0; u < e.length; u++) {
|
|
81
|
+
const s = e[u];
|
|
82
|
+
if (s === "[" || s === "<" || s === "(" ? (n = !0, t.push(s), s == "[" && (r = !0), i == 0 && (i = u)) : (s === "]" && t[t.length - 1] === "[" || s === ">" && t[t.length - 1] === "<" || s === ")" && t[t.length - 1] === "(") && t.pop(), n && t.length === 0)
|
|
83
|
+
return r && i + 1 == u ? {
|
|
84
84
|
top: "Array",
|
|
85
85
|
type: e.substring(0, i)
|
|
86
86
|
} : {
|
|
87
87
|
top: e.substring(0, i),
|
|
88
|
-
type: e.substring(i + 1,
|
|
88
|
+
type: e.substring(i + 1, u)
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
return {
|
|
92
92
|
top: e,
|
|
93
93
|
type: ""
|
|
94
94
|
};
|
|
95
|
-
},
|
|
95
|
+
}, b = (e) => {
|
|
96
96
|
if (e)
|
|
97
97
|
if (e.startsWith("[") && e.endsWith("]") || e.startsWith("(") && e.endsWith(")")) {
|
|
98
98
|
const t = e.slice(1, -1).trim();
|
|
99
|
-
return t ?
|
|
99
|
+
return t ? c(t, ",") : ["any"];
|
|
100
100
|
} else {
|
|
101
101
|
if (e.startsWith("{") && e.endsWith("}"))
|
|
102
102
|
return ["Object"];
|
|
103
103
|
if (e.startsWith("<") && e.endsWith(">")) {
|
|
104
104
|
const t = e.slice(1, -1).trim();
|
|
105
|
-
return t ?
|
|
105
|
+
return t ? c(t, "|") : ["any"];
|
|
106
106
|
} else
|
|
107
|
-
return
|
|
107
|
+
return c(e, ",");
|
|
108
108
|
}
|
|
109
109
|
else return ["any"];
|
|
110
110
|
};
|
|
111
|
-
function
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
if (!i) return null;
|
|
115
|
-
const l = i[1].trim(), s = !i[2], w = i[0].length, p = n.substring(w).trim();
|
|
116
|
-
let u = [], h = "", d = "";
|
|
117
|
-
for (let a = 0; a < p.length; a++) {
|
|
118
|
-
const o = p[a];
|
|
119
|
-
if (o === "[" || o === "<" || o === "(" || o === "{" ? u.push(o) : (o === "]" && u[u.length - 1] === "[" || o === ">" && u[u.length - 1] === "<" || o === "}" && u[u.length - 1] === "{" || o === ")" && u[u.length - 1] === "(") && u.pop(), u.length === 0 && a > 0) {
|
|
120
|
-
a == 1 && o !== "]" && o !== ">" && o !== "}" && o !== ")" ? (h = "", d = p.substring(0)) : (h = p.substring(0, a + 1).trim(), d = p.substring(a + 1));
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
const T = v(h), b = j(T);
|
|
125
|
-
return {
|
|
126
|
-
name: l,
|
|
127
|
-
prop: l,
|
|
128
|
-
type: m(b),
|
|
129
|
-
dataType: b,
|
|
130
|
-
must: s,
|
|
131
|
-
label: r,
|
|
132
|
-
description: d
|
|
133
|
-
};
|
|
134
|
-
}).filter(Boolean);
|
|
135
|
-
}
|
|
136
|
-
function x(e) {
|
|
137
|
-
return e.map((n) => {
|
|
138
|
-
if (typeof n == "string")
|
|
139
|
-
return n.toLowerCase() === "array" ? "Array<any>" : n;
|
|
140
|
-
if (n.children && n.children.length > 0) {
|
|
141
|
-
const r = x(n.children);
|
|
142
|
-
return n.value + "<" + r + ">";
|
|
143
|
-
} else {
|
|
144
|
-
const r = n.value;
|
|
111
|
+
function v(e) {
|
|
112
|
+
return e.map((r) => {
|
|
113
|
+
if (typeof r == "string")
|
|
145
114
|
return r.toLowerCase() === "array" ? "Array<any>" : r;
|
|
115
|
+
if (r.children && r.children.length > 0) {
|
|
116
|
+
const n = v(r.children);
|
|
117
|
+
return r.value + "<" + n + ">";
|
|
118
|
+
} else {
|
|
119
|
+
const n = r.value;
|
|
120
|
+
return n.toLowerCase() === "array" ? "Array<any>" : n;
|
|
146
121
|
}
|
|
147
122
|
}).join(" | ") || "any";
|
|
148
123
|
}
|
|
149
124
|
function j(e) {
|
|
150
125
|
const t = [];
|
|
151
|
-
return e.forEach((
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
154
|
-
const i =
|
|
126
|
+
return e.forEach((r) => {
|
|
127
|
+
const n = m(r);
|
|
128
|
+
if (n.type) {
|
|
129
|
+
const i = b(n.type), u = j(i);
|
|
155
130
|
t.push({
|
|
156
|
-
label:
|
|
157
|
-
value:
|
|
158
|
-
children:
|
|
131
|
+
label: r,
|
|
132
|
+
value: n.top,
|
|
133
|
+
children: u
|
|
159
134
|
});
|
|
160
135
|
} else
|
|
161
|
-
t.push(
|
|
136
|
+
t.push(n.top);
|
|
162
137
|
}), t;
|
|
163
138
|
}
|
|
164
|
-
function
|
|
139
|
+
function w(e) {
|
|
165
140
|
let t = "";
|
|
166
|
-
return typeof e == "string" ? t = e : t = e.value,
|
|
141
|
+
return typeof e == "string" ? t = e : t = e.value, d(t || "any");
|
|
167
142
|
}
|
|
168
|
-
function
|
|
143
|
+
function f(e) {
|
|
169
144
|
const t = e[0] || "any";
|
|
170
|
-
return
|
|
145
|
+
return w(t);
|
|
171
146
|
}
|
|
172
|
-
function
|
|
147
|
+
function T(e) {
|
|
173
148
|
const t = e[0];
|
|
174
|
-
switch (
|
|
149
|
+
switch (f(e)) {
|
|
175
150
|
case "string":
|
|
176
151
|
return '""';
|
|
177
152
|
case "boolean":
|
|
@@ -182,9 +157,9 @@ function C(e) {
|
|
|
182
157
|
if (typeof t == "string")
|
|
183
158
|
return "[]";
|
|
184
159
|
{
|
|
185
|
-
let
|
|
186
|
-
if (
|
|
187
|
-
let i =
|
|
160
|
+
let n = t.children;
|
|
161
|
+
if (n && n.length > 0) {
|
|
162
|
+
let i = T([n[0]]);
|
|
188
163
|
return i = i == "undefined" ? "" : i, `[${i}]`;
|
|
189
164
|
} else
|
|
190
165
|
return "[]";
|
|
@@ -199,16 +174,16 @@ function C(e) {
|
|
|
199
174
|
return "undefined";
|
|
200
175
|
}
|
|
201
176
|
}
|
|
202
|
-
function
|
|
177
|
+
function $(e) {
|
|
203
178
|
const t = Object.prototype.toString.call(e);
|
|
204
|
-
let
|
|
205
|
-
return
|
|
179
|
+
let n = /^\[[O|o]bject (.*)\]$/.exec(t), i = typeof e;
|
|
180
|
+
return n && n.length > 0 && (i = n[1].toLowerCase()), i;
|
|
206
181
|
}
|
|
207
|
-
function
|
|
208
|
-
const
|
|
209
|
-
return
|
|
182
|
+
function z(e, t) {
|
|
183
|
+
const r = $(e), n = f(t);
|
|
184
|
+
return n && n != "any" ? r == n : !0;
|
|
210
185
|
}
|
|
211
|
-
const
|
|
186
|
+
const B = [
|
|
212
187
|
// JavaScript 基本关键字
|
|
213
188
|
"break",
|
|
214
189
|
"case",
|
|
@@ -295,26 +270,25 @@ const U = [
|
|
|
295
270
|
"package"
|
|
296
271
|
];
|
|
297
272
|
export {
|
|
298
|
-
|
|
273
|
+
B as allReservedWords,
|
|
299
274
|
j as getDataType,
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
M as vueFormat
|
|
275
|
+
f as getDataTypeType,
|
|
276
|
+
y as getFunBody,
|
|
277
|
+
H as getFunctionFormat,
|
|
278
|
+
$ as getObjType,
|
|
279
|
+
E as getString,
|
|
280
|
+
T as getTypeValue,
|
|
281
|
+
N as isDefaultType,
|
|
282
|
+
z as isTypeEqual,
|
|
283
|
+
b as parseTypeDefinition,
|
|
284
|
+
A as prettierArrFormat,
|
|
285
|
+
L as prettierCss,
|
|
286
|
+
a as prettierFormat,
|
|
287
|
+
x as prettierFunFormat,
|
|
288
|
+
O as prettierHtml,
|
|
289
|
+
C as prettierJs,
|
|
290
|
+
k as prettierObjFormat,
|
|
291
|
+
S as prettierTs,
|
|
292
|
+
v as setDataType,
|
|
293
|
+
q as vueFormat
|
|
320
294
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("comment-parser"),q=require("@fangzhongya/utils/basic/string/firstLower"),p={titles:[],propss:[],slots:[],emitss:[],exposes:[]};function w(){Object.keys(p).forEach(e=>{p[e]=[]})}function S(e,r){let t=e.charAt(0),n=[['"','"'],["'","'"],["`","`"],["(",")"],["{","}"],["[","]"]];const s=n.map(i=>i[0]);let l=s.indexOf(t);if(l!=-1){let i=[t];for(let o=1;o<e.length;o++){if(t=e[o],l=s.indexOf(t),l!=-1)l>2?i.push(t):i[i.length-1]===t?i.pop():i.push(t);else{let u=!1;for(let a of n)if(t===a[1]&&i[i.length-1]===a[0]){u=!0;break}u&&i.pop()}if(i.length===0)return r&&e[o+1]===" ",e.substring(0,o+1)}}else return r?e.substring(0,e.indexOf(" ")):e}function A(e){delete e.problems,delete e.source;let r=e.tag,t=e.name,n=e.description,s=e.default,l="",i="";if(r=="default")t=t.trim(),t=S(t)||t;else if(r=="selectable")t=t.trim();else{const o=e.name.indexOf("=");if(o!=-1){const m=t.substring(0,o),d=t.substring(o+1);t=m;const T=d+" "+n,f=S(T,!0);f?(n=T.replace(f,""),f.startsWith("(")?s=f.substring(1,f.length-1):s=f):s=e.default||d||""}const a=/\s*\((.*)\)\s*/gi.exec(n);a&&a.length>0&&(l=a[1],n=n.replace(a[0],""))}return t.endsWith("*")&&(i="*",t=t.substring(0,t.length-1)),e.name=t,e.required=i,e.default=s||"",e.description=n,e.selectable=l,e}function P(e){let r=["title","text","author","date"],t=b(e),n={};r.forEach(s=>{n[s]=t.obj[s]}),E(n),t.arr.forEach(s=>{y(s.key,s.value)})}function E(e){p.titles.push(e)}function v(e){let r=["props","name","type","default","required","selectable","description","descriptions","model","return"],t=b(e),n={};r.forEach(s=>{n[s]=t.obj[s]}),g(n,"props"),t.arr.forEach(s=>{y(s.key,s.value)})}function F(e){let r=["slot","name","selectable","description","descriptions"],t=b(e),n={};r.forEach(s=>{n[s]=t.obj[s]}),g(n,"slot"),t.arr.forEach(s=>{y(s.key,s.value)})}function B(e){let r=["emits","name","selectable","description","descriptions"],t=b(e),n={};r.forEach(s=>{n[s]=t.obj[s]}),g(n,"emits"),t.arr.forEach(s=>{y(s.key,s.value)})}function I(e){let r=["expose","name","type","return","selectable","description","descriptions"],t=b(e),n={};r.forEach(s=>{n[s]=t.obj[s]}),g(n,"expose"),t.arr.forEach(s=>{y(s.key,s.value)})}function g(e,r){const t=p[r+"name"]||[],n=e.name??e[r]?.name,s=t.indexOf(n);s>=0&&(p[r+"s"].splice(s,1),t.splice(s,1)),p[r+"s"].push(e),t.push(n),p[r+"name"]=t}function b(e,r){const t={descriptions:e?.description||""},n=[];return e?.tags&&e.tags?.forEach(s=>{let l=s.tag,i=A(s);if(!t.hasOwnProperty(l))t[l]=i;else{const o={};o[l]=i,n.push({key:l,value:o})}}),{arr:n,obj:t}}function y(e,r){switch(e){case"title":return E(r),!0;case"text":return E(r),!0;case"props":return g(r,"props"),!0;case"slot":return g(r,"slot"),!0;case"emits":return g(r,"emits"),!0;case"expose":return g(r,"expose"),!0;default:return!1}}function J(e,r){switch(e){case"title":return P(r),!0;case"props":return v(r),!0;case"slot":return F(r),!0;case"emits":return B(r),!0;case"expose":return I(r),!0;default:return!1}}function L(e){return w(),e?.forEach(r=>{let t=r?.tags||[],n=t?.length||0;if(n>0)for(let s=0;s<n;s++){const l=t[s]||{};if(J(l.tag,r))break}}),JSON.parse(JSON.stringify(p))}function W(e){if(e)return j.parse(e)}function M(e){let r=W(e);return L(r)}const z=["Boolean","Any","String","Number","Array","Object","Function"];function _(e){return z.includes(e)?q.firstLower(e):e}const C=e=>{let r=[],t=!1,n=!1,s=0;for(let l=0;l<e.length;l++){const i=e[l];if(i==="["||i==="<"||i==="("?(n=!0,r.push(i),i=="["&&(t=!0),s==0&&(s=l)):(i==="]"&&r[r.length-1]==="["||i===">"&&r[r.length-1]==="<"||i===")"&&r[r.length-1]==="(")&&r.pop(),n&&r.length===0)return t&&s+1==l?{top:"Array",type:e.substring(0,s)}:{top:e.substring(0,s),type:e.substring(s+1,l)}}return{top:e,type:""}},x=(e,r)=>{let t=[],n=[],s="";for(let l=0;l<e.length;l++){const i=e[l];i==="["||i==="<"||i==="("?(t.push(i),s+=i):i==="]"&&t.length>0&&t[t.length-1]==="["||i===">"&&t.length>0&&t[t.length-1]==="<"||i===")"&&t.length>0&&t[t.length-1]==="("?(t.pop(),s+=i):i===r&&t.length===0?(n.push(s.trim()),s=""):s+=i}return s.trim()!==""&&n.push(s.trim()),n};function G(e){let r="";return typeof e=="string"?r=e:r=e.value,_(r||"any")}function N(e){const r=e[0]||"any";return G(r)}const O=e=>{if(e)if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("(")&&e.endsWith(")")){const r=e.slice(1,-1).trim();return r?x(r,","):["any"]}else{if(e.startsWith("{")&&e.endsWith("}"))return["Object"];if(e.startsWith("<")&&e.endsWith(">")){const r=e.slice(1,-1).trim();return r?x(r,"|"):["any"]}else return x(e,",")}else return["any"]};function k(e){const r=[];return e.forEach(t=>{const n=C(t);if(n.type){const s=O(n.type),l=k(s);r.push({label:t,value:n.top,children:l})}else r.push(n.top)}),r}function H(e){return x(e,",").map(t=>{const n=t.trim(),s=t.match(/^([^:?]+)(\??):/);if(!s)return null;const l=s[1].trim(),i=!s[2],o=s[0].length,u=t.substring(o).trim();let a=[],m="",d="";for(let h=0;h<u.length;h++){const c=u[h];if(c==="["||c==="<"||c==="("||c==="{"?a.push(c):(c==="]"&&a[a.length-1]==="["||c===">"&&a[a.length-1]==="<"||c==="}"&&a[a.length-1]==="{"||c===")"&&a[a.length-1]==="(")&&a.pop(),a.length===0&&h>0){h==1&&c!=="]"&&c!==">"&&c!=="}"&&c!==")"?(m="",d=u.substring(0)):(m=u.substring(0,h+1).trim(),d=u.substring(h+1));break}}const T=O(m),f=k(T);return{name:l,prop:l,type:N(f),dataType:f,must:i,label:n,description:d}}).filter(Boolean)}exports.getDataType=k;exports.getDataTypeType=N;exports.getNotesText=M;exports.getTextNotes=W;exports.parseParamString=H;exports.parseTypeDefinition=O;
|
|
@@ -34,4 +34,21 @@ type NotesObj = {
|
|
|
34
34
|
};
|
|
35
35
|
export declare function getTextNotes(text: string): Block[] | undefined;
|
|
36
36
|
export declare function getNotesText(text: string): NotesObj;
|
|
37
|
+
type DataType = string | {
|
|
38
|
+
label: string;
|
|
39
|
+
value: string;
|
|
40
|
+
children?: DataType[];
|
|
41
|
+
};
|
|
42
|
+
export declare function getDataTypeType(dataType: DataType[]): string;
|
|
43
|
+
export declare const parseTypeDefinition: (typeDef: string) => string[];
|
|
44
|
+
export declare function getDataType(arr: string[]): DataType[];
|
|
45
|
+
export declare function parseParamString(input: string): Array<{
|
|
46
|
+
name: string;
|
|
47
|
+
prop: string;
|
|
48
|
+
type: string;
|
|
49
|
+
dataType: DataType[];
|
|
50
|
+
must: boolean;
|
|
51
|
+
label: string;
|
|
52
|
+
description: string;
|
|
53
|
+
}>;
|
|
37
54
|
export {};
|