@fangzhongya/vue-archive 0.0.76 → 0.0.78

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.
Files changed (33) hide show
  1. package/dist/node/index.cjs +145 -108
  2. package/dist/node/index.js +145 -108
  3. package/dist/packages/components/use/code.cjs +12 -12
  4. package/dist/packages/components/use/code.d.ts +25 -17
  5. package/dist/packages/components/use/code.js +92 -92
  6. package/dist/packages/components/use/edit.cjs +5 -5
  7. package/dist/packages/components/use/edit.js +63 -63
  8. package/dist/packages/components/use/retrie/any/index.vue.cjs +1 -1
  9. package/dist/packages/components/use/retrie/any/index.vue.js +27 -49
  10. package/dist/packages/components/use/retrie/choice/index.d.ts +33 -2
  11. package/dist/packages/components/use/retrie/choice/index.vue.cjs +1 -1
  12. package/dist/packages/components/use/retrie/choice/index.vue.js +24 -27
  13. package/dist/packages/components/use/retrie/index.vue.cjs +1 -1
  14. package/dist/packages/components/use/retrie/index.vue.js +12 -12
  15. package/dist/packages/components/use/retrie/input/codemirror/codemirror.d.ts +41 -0
  16. package/dist/packages/components/use/retrie/input/editor/editor.cjs +1 -1
  17. package/dist/packages/components/use/retrie/input/editor/editor.js +50 -29
  18. package/dist/packages/components/use/retrie/input/editor/getExtraLib.cjs +416 -0
  19. package/dist/packages/components/use/retrie/input/editor/getExtraLib.d.ts +2 -0
  20. package/dist/packages/components/use/retrie/input/editor/getExtraLib.js +427 -0
  21. package/dist/packages/components/use/retrie/other/index.d.ts +13 -12
  22. package/dist/packages/components/use/retrie/other/index.vue.cjs +1 -1
  23. package/dist/packages/components/use/retrie/other/index.vue.js +1 -1
  24. package/dist/packages/components/use/retrie/select/index.d.ts +33 -2
  25. package/dist/packages/components/use/retrie/select/index.vue.cjs +1 -1
  26. package/dist/packages/components/use/retrie/select/index.vue.js +26 -26
  27. package/dist/packages/components/use/set-props.d.ts +1 -1
  28. package/dist/packages/components/use/set-props.vue.cjs +1 -1
  29. package/dist/packages/components/use/set-props.vue.js +21 -24
  30. package/dist/packages/components/use/util.cjs +3 -3
  31. package/dist/packages/components/use/util.d.ts +23 -25
  32. package/dist/packages/components/use/util.js +161 -136
  33. package/package.json +2 -2
@@ -40,5 +40,5 @@ declare const _default: DefineComponent<ExtractPropTypes<{
40
40
  };
41
41
  }>> & Readonly<{
42
42
  onChange?: ((...args: any[]) => any) | undefined;
43
- }>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
43
+ }>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLDivElement>;
44
44
  export default _default;
@@ -1 +1 @@
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;
1
+ "use strict";const s=require("vue"),T=require("./retrie/index.vue.cjs");;/* empty css */const o=require("./code.cjs"),x={class:"set-props"},j=s.defineComponent({__name:"set-props",props:{name:String,list:Array},emits:["change"],setup(i,{emit:p}){const r=i,f=p,a=s.ref({}),m=s.ref(0),l=s.ref({}),c=s.ref([]);function _(){l.value={};const n=[];r.list?.forEach(t=>{let e=t.name;if(!e.includes(".")&&(e=(e.split("/")[0]||"").trim(),e)){const b=o.getDefaultValue(t,!1);l.value[e]=b;const{arr:g,type:v,dataType:V}=o.getSpecType(t);a.value[e]=g;let q={label:d(e,t),prop:e,type:v,dataType:V,select:e};n.push(q)}}),c.value=n}function d(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 y(){clearTimeout(u),u=setTimeout(()=>{_()},400)}return s.watch(()=>r.name,()=>{c.value=[],y()},{immediate:!0}),(n,t)=>(s.openBlock(),s.createElementBlock("div",x,[s.createVNode(T,{refresh:m.value,modelValue:l.value,selects:a.value,list:c.value,name:r.name,onQuery:h},null,8,["refresh","modelValue","selects","list","name"])]))}});module.exports=j;
@@ -1,11 +1,8 @@
1
- import { defineComponent as T, ref as n, watch as k, createElementBlock as j, createCommentVNode as x, openBlock as B, createVNode as C } from "vue";
1
+ import { defineComponent as T, ref as l, watch as j, createElementBlock as k, openBlock as x, createVNode as B } from "vue";
2
2
  import E from "./retrie/index.vue.js";
3
3
  /* empty css */
4
- import { getDefaultValue as N, getSpecType as S } from "./code.js";
5
- const w = {
6
- key: 0,
7
- class: "set-props"
8
- }, R = /* @__PURE__ */ T({
4
+ import { getDefaultValue as S, getSpecType as w } from "./code.js";
5
+ const A = { class: "set-props" }, Q = /* @__PURE__ */ T({
9
6
  __name: "set-props",
10
7
  props: {
11
8
  name: String,
@@ -13,17 +10,17 @@ const w = {
13
10
  },
14
11
  emits: ["change"],
15
12
  setup(i, { emit: u }) {
16
- const a = i, m = u, r = n({}), p = n(0), o = n({}), l = n([]);
13
+ const n = i, m = u, r = l({}), p = l(0), a = l({}), o = l([]);
17
14
  function f() {
18
- o.value = {};
15
+ a.value = {};
19
16
  const s = [];
20
- a.list?.forEach((t) => {
17
+ n.list?.forEach((t) => {
21
18
  let e = t.name;
22
19
  if (!e.includes(".") && (e = (e.split("/")[0] || "").trim(), e)) {
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;
20
+ const b = S(t, !1);
21
+ a.value[e] = b;
22
+ const { arr: y, type: g, dataType: V } = w(t);
23
+ r.value[e] = y;
27
24
  let v = {
28
25
  label: d(e, t),
29
26
  prop: e,
@@ -33,7 +30,7 @@ const w = {
33
30
  };
34
31
  s.push(v);
35
32
  }
36
- }), l.value = s;
33
+ }), o.value = s;
37
34
  }
38
35
  function d(s, t) {
39
36
  let e = s + ": { " + (t.type || "any") + " } " + t.description;
@@ -49,26 +46,26 @@ const w = {
49
46
  f();
50
47
  }, 400);
51
48
  }
52
- return k(
53
- () => a.name,
49
+ return j(
50
+ () => n.name,
54
51
  () => {
55
- l.value = [], _();
52
+ o.value = [], _();
56
53
  },
57
54
  {
58
55
  immediate: !0
59
56
  }
60
- ), (s, t) => l.value && l.value.length > 0 ? (B(), j("div", w, [
61
- C(E, {
57
+ ), (s, t) => (x(), k("div", A, [
58
+ B(E, {
62
59
  refresh: p.value,
63
- modelValue: o.value,
60
+ modelValue: a.value,
64
61
  selects: r.value,
65
- list: l.value,
66
- name: a.name,
62
+ list: o.value,
63
+ name: n.name,
67
64
  onQuery: h
68
65
  }, null, 8, ["refresh", "modelValue", "selects", "list", "name"])
69
- ])) : x("", !0);
66
+ ]));
70
67
  }
71
68
  });
72
69
  export {
73
- R as default
70
+ Q as default
74
71
  };
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("../../config.cjs"),A=require("@fangzhongya/utils/basic/string/toFunction"),x=require("@fangzhongya/utils/basic/string/firstLower");let c=e=>e;const f=O.getConfig("prettier");f&&Promise.resolve().then(()=>require("./prettier.cjs")).then(e=>{c=e.getFormat});function g(e){return f?c(e,"js"):e.replace(/\;(\s|\n\r)*$/,"")}async function q(e){return e="let a = "+e,(await g(e)).replace(/^let a = /,"")}function W(e){return g(e)}async function k(e){return!/^\s*function/.test(e)&&!/^\s*\([^\)]*\)\s*\=\>/.test(e)?(e="function a"+e,(await g(e)).replace(/^function a/,"")):await g(e)}function C(e){return f?c(e,"html"):e}function E(e){return f?c(e,"ts"):e}function B(e){return f?c(e,"js"):e}function L(e){return f?c(e,"css"):e}function P(e,r=""){let t=(e+"").trim().split(/\n/);return t=t.map(n=>r+n),t.join(`
2
- `)}function F(e=""){e=e.trim();let r=`[\\s|\\n|\\r]*\\{((.|
3
- |\r)+?)\\}[\\s|\\n|\\r]*`,n=new RegExp("^"+r+"$").exec(e);return n&&n.length>0?F(n[1]):e}const H=["Boolean","Any","String","Number","Array","Object","Function"];function J(e){return H.includes(e)?x.firstLower(e):e}function M(e){let t=new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);if(t&&t.length>0)return{own:J(t[1]),son:t[2]}}function j(e,r){let t=M(e);t?(r.push(t.own),t.son&&j(t.son,r)):r.push(e)}function b(e){e instanceof Array&&(e=e[0]);const r=[];return e&&j(e,r),r}function v(e){const r=Object.prototype.toString.call(e);let n=/^\[[O|o]bject (.*)\]$/.exec(r),i=typeof e;return n&&n.length>0&&(i=n[1].toLowerCase()),i}function N(e,r){const t=v(e),n=b(r)[0];return n&&n!="any"?t==n:!0}function R(e){if(typeof e=="string"){let r=!1;return(/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e))&&(r=!0),r&&(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 V(e){const r=typeof e;if(r=="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 r==="object"?e instanceof Array?"array":r===null?"null":r:r}function $(e){const r=e[0]||"any";let t=r.split("<")[0];switch(t=t.trim().toLowerCase(),t){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":let n=r.indexOf("<"),i=r.substring(r.indexOf("<")+1,r.length-1)||"";n==-1&&(i="any");let o=$(d(i).dataType);return o=o=="undefined"?"":o,`[${o}]`;case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function z(e){let r="";return e.forEach((t,n)=>{t=t.trim(),t&&(r&&(r+=" | "),t==="Array"?r+="Array<any>":r+=t)}),r||"any"}const y=(e,r)=>{let t=[],n=[],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===r&&t.length===0?(n.push(i.trim()),i=""):i+=s}return i.trim()!==""&&n.push(i.trim()),n},d=e=>{if(e)if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("(")&&e.endsWith(")")){const r=e.slice(1,-1).trim();if(!r)return{type:"any",dataType:["any"]};const t=y(r,",");return{type:t[0]||"any",dataType:t}}else if(e.startsWith("<")&&e.endsWith(">")){const r=e.slice(1,-1).trim();if(!r)return{type:"any",dataType:["any"]};const t=y(r,"|");return{type:t[0]||"any",dataType:t}}else{const r=y(e,",");return{type:r[0]||"any",dataType:r}}else return{type:"any",dataType:["any"]}};function I(e){return y(e,",").map(t=>{const n=t.trim(),i=t.match(/^([^:?]+)(\??):/);if(!i)return null;const o=i[1].trim(),s=!i[2],S=i[0].length,p=t.substring(S).trim();let a=[],h="",m="";for(let l=0;l<p.length;l++){const u=p[l];if(u==="["||u==="<"||u==="("?a.push(u):(u==="]"&&a[a.length-1]==="["||u===">"&&a[a.length-1]==="<"||u===")"&&a[a.length-1]==="(")&&a.pop(),a.length===0&&l>0){l==1&&u!=="]"&&u!==">"&&u!==")"?(h="",m=p.substring(0)):(h=p.substring(0,l+1).trim(),m=p.substring(l+1));break}}const{type:Z,dataType:T}=d(h),w=b(T);return{name:o,prop:o,type:w[0],dataType:T,must:s,label:n,description:m}}).filter(Boolean)}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>A.getFunctionFormat});exports.getFunBody=F;exports.getObjType=v;exports.getSonType=b;exports.getString=R;exports.getTypeValue=$;exports.isDefaultType=V;exports.isTypeEqual=N;exports.parseParamString=I;exports.parseTypeDefinition=d;exports.prettierArrFormat=W;exports.prettierCss=L;exports.prettierFormat=g;exports.prettierFunFormat=k;exports.prettierHtml=C;exports.prettierJs=B;exports.prettierObjFormat=q;exports.prettierTs=E;exports.setDataType=z;exports.vueFormat=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("../../config.cjs"),W=require("@fangzhongya/utils/basic/string/toFunction"),k=require("@fangzhongya/utils/basic/string/firstLower");let c=e=>e;const f=A.getConfig("prettier");f&&Promise.resolve().then(()=>require("./prettier.cjs")).then(e=>{c=e.getFormat});function g(e){return f?c(e,"js"):e.replace(/\;(\s|\n\r)*$/,"")}async function q(e){return e="let a = "+e,(await g(e)).replace(/^let a = /,"")}function C(e){return g(e)}async function L(e){return!/^\s*function/.test(e)&&!/^\s*\([^\)]*\)\s*\=\>/.test(e)?(e="function a"+e,(await g(e)).replace(/^function a/,"")):await g(e)}function B(e){return f?c(e,"html"):e}function E(e){return f?c(e,"ts"):e}function x(e){return f?c(e,"js"):e}function N(e){return f?c(e,"css"):e}function P(e,t=""){let r=(e+"").trim().split(/\n/);return r=r.map(n=>t+n),r.join(`
2
+ `)}function v(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?v(n[1]):e}const z=["Boolean","Any","String","Number","Array","Object","Function"];function H(e){return z.includes(e)?k.firstLower(e):e}function I(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 J(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 y=(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},M=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:""}},d=e=>{if(e)if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("(")&&e.endsWith(")")){const t=e.slice(1,-1).trim();return t?y(t,","):["any"]}else{if(e.startsWith("{")&&e.endsWith("}"))return["Object"];if(e.startsWith("<")&&e.endsWith(">")){const t=e.slice(1,-1).trim();return t?y(t,"|"):["any"]}else return y(e,",")}else return["any"]};function V(e){return y(e,",").map(r=>{const n=r.trim(),i=r.match(/^([^:?]+)(\??):/);if(!i)return null;const u=i[1].trim(),s=!i[2],w=i[0].length,p=r.substring(w).trim();let l=[],m="",b="";for(let a=0;a<p.length;a++){const o=p[a];if(o==="["||o==="<"||o==="("||o==="{"?l.push(o):(o==="]"&&l[l.length-1]==="["||o===">"&&l[l.length-1]==="<"||o==="}"&&l[l.length-1]==="{"||o===")"&&l[l.length-1]==="(")&&l.pop(),l.length===0&&a>0){a==1&&o!=="]"&&o!==">"&&o!=="}"&&o!==")"?(m="",b=p.substring(0)):(m=p.substring(0,a+1).trim(),b=p.substring(a+1));break}}const O=d(m),F=T(O);return{name:u,prop:u,type:h(F),dataType:F,must:s,label:n,description:b}}).filter(Boolean)}function j(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=j(r.children);return r.value+"<"+n+">"}else{const n=r.value;return n.toLowerCase()==="array"?"Array<any>":n}}).join(" | ")||"any"}function T(e){const t=[];return e.forEach(r=>{const n=M(r);if(n.type){const i=d(n.type),u=T(i);t.push({label:r,value:n.top,children:u})}else t.push(n.top)}),t}function D(e){let t="";return typeof e=="string"?t=e:t=e.value,H(t||"any")}function h(e){const t=e[0]||"any";return D(t)}function $(e){const t=e[0];switch(h(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=$([n[0]]);return i=i=="undefined"?"":i,`[${i}]`}else return"[]"}case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function S(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 R(e,t){const r=S(e),n=h(t);return n&&n!="any"?r==n:!0}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>W.getFunctionFormat});exports.getDataType=T;exports.getDataTypeType=h;exports.getFunBody=v;exports.getObjType=S;exports.getString=I;exports.getTypeValue=$;exports.isDefaultType=J;exports.isTypeEqual=R;exports.parseParamString=V;exports.parseTypeDefinition=d;exports.prettierArrFormat=C;exports.prettierCss=N;exports.prettierFormat=g;exports.prettierFunFormat=L;exports.prettierHtml=B;exports.prettierJs=x;exports.prettierObjFormat=q;exports.prettierTs=E;exports.setDataType=j;exports.vueFormat=P;
@@ -11,25 +11,6 @@ export declare function prettierVue(st: string): any;
11
11
  export declare function vueFormat(st: string, kg?: string): string;
12
12
  export declare function getFunBody(sr?: string): string;
13
13
  export { getFunctionFormat } from '@fangzhongya/utils/basic/string/toFunction';
14
- /**
15
- * 解析array<string> 类型数组
16
- * @param {*} type
17
- * @returns
18
- */
19
- export declare function getSonType(type: Array<string> | string): string[];
20
- /**
21
- * 获取当前对象的类型
22
- * @param {*} obj
23
- * @returns
24
- */
25
- export declare function getObjType(obj: unknown): string;
26
- /**
27
- * 配置类型是否匹配
28
- * @param {*} obj
29
- * @param {*} type
30
- * @returns
31
- */
32
- export declare function isTypeEqual(obj: unknown, type: string[] | string): boolean;
33
14
  /**
34
15
  * 获取字符串, 去掉头尾''标识
35
16
  * @param {*} st
@@ -40,18 +21,35 @@ export declare function getString(st: unknown): string;
40
21
  * 配置字符串的类型
41
22
  */
42
23
  export declare function isDefaultType(st: any): string;
43
- export declare function getTypeValue(arr: string[]): string;
44
- export declare function setDataType(arr: string[]): string;
45
- export declare const parseTypeDefinition: (typeDef: string) => {
46
- type: string;
47
- dataType: string[];
24
+ export declare const parseTypeDefinition: (typeDef: string) => string[];
25
+ export type DataType = string | {
26
+ label: string;
27
+ value: string;
28
+ children?: DataType[];
48
29
  };
49
30
  export declare function parseParamString(input: string): Array<{
50
31
  name: string;
51
32
  prop: string;
52
33
  type: string;
53
- dataType: string[];
34
+ dataType: DataType[];
54
35
  must: boolean;
55
36
  label: string;
56
37
  description: string;
57
38
  }>;
39
+ export declare function setDataType(arr: DataType[]): string;
40
+ export declare function getDataType(arr: string[]): DataType[];
41
+ export declare function getDataTypeType(dataType: DataType[]): string;
42
+ export declare function getTypeValue(arr: DataType[]): string;
43
+ /**
44
+ * 获取当前对象的类型
45
+ * @param {*} obj
46
+ * @returns
47
+ */
48
+ export declare function getObjType(obj: unknown): string;
49
+ /**
50
+ * 配置类型是否匹配
51
+ * @param {*} obj
52
+ * @param {*} type
53
+ * @returns
54
+ */
55
+ export declare function isTypeEqual(obj: unknown, dataType: DataType[]): boolean;
@@ -1,5 +1,5 @@
1
1
  import { getConfig as F } from "../../config.js";
2
- import { getFunctionFormat as X } from "@fangzhongya/utils/basic/string/toFunction";
2
+ import { getFunctionFormat as Y } from "@fangzhongya/utils/basic/string/toFunction";
3
3
  import { firstLower as w } from "@fangzhongya/utils/basic/string/firstLower";
4
4
  let c = (e) => e;
5
5
  const f = F("prettier");
@@ -9,39 +9,39 @@ f && import("./prettier.js").then((e) => {
9
9
  function y(e) {
10
10
  return f ? c(e, "js") : e.replace(/\;(\s|\n\r)*$/, "");
11
11
  }
12
- async function L(e) {
12
+ async function N(e) {
13
13
  return e = "let a = " + e, (await y(e)).replace(/^let a = /, "");
14
14
  }
15
- function N(e) {
15
+ function z(e) {
16
16
  return y(e);
17
17
  }
18
- async function R(e) {
18
+ async function I(e) {
19
19
  return !/^\s*function/.test(e) && !/^\s*\([^\)]*\)\s*\=\>/.test(e) ? (e = "function a" + e, (await y(e)).replace(/^function a/, "")) : await y(e);
20
20
  }
21
21
  function q(e) {
22
22
  return f ? c(e, "html") : e;
23
23
  }
24
- function z(e) {
24
+ function H(e) {
25
25
  return f ? c(e, "ts") : e;
26
26
  }
27
- function H(e) {
27
+ function J(e) {
28
28
  return f ? c(e, "js") : e;
29
29
  }
30
- function I(e) {
30
+ function M(e) {
31
31
  return f ? c(e, "css") : e;
32
32
  }
33
- function J(e, n = "") {
34
- let t = (e + "").trim().split(/\n/);
35
- return t = t.map((r) => n + r), t.join(`
33
+ function R(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 x(e = "") {
38
+ function S(e = "") {
39
39
  e = e.trim();
40
- let n = `[\\s|\\n|\\r]*\\{((.|
41
- |\r)+?)\\}[\\s|\\n|\\r]*`, r = new RegExp("^" + n + "$").exec(e);
42
- return r && r.length > 0 ? x(r[1]) : e;
40
+ let t = `[\\s|\\n|\\r]*\\{((.|
41
+ |\r)+?)\\}[\\s|\\n|\\r]*`, n = new RegExp("^" + t + "$").exec(e);
42
+ return n && n.length > 0 ? S(n[1]) : e;
43
43
  }
44
- const S = [
44
+ const A = [
45
45
  "Boolean",
46
46
  "Any",
47
47
  "String",
@@ -50,159 +50,184 @@ const S = [
50
50
  "Object",
51
51
  "Function"
52
52
  ];
53
- function A(e) {
54
- return S.includes(e) ? w(e) : e;
55
- }
56
- function O(e) {
57
- let t = new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);
58
- if (t && t.length > 0)
59
- return {
60
- own: A(t[1]),
61
- son: t[2]
62
- };
63
- }
64
- function b(e, n) {
65
- let t = O(e);
66
- t ? (n.push(t.own), t.son && b(t.son, n)) : n.push(e);
67
- }
68
- function T(e) {
69
- e instanceof Array && (e = e[0]);
70
- const n = [];
71
- return e && b(e, n), n;
72
- }
73
53
  function W(e) {
74
- const n = Object.prototype.toString.call(e);
75
- let r = /^\[[O|o]bject (.*)\]$/.exec(n), i = typeof e;
76
- return r && r.length > 0 && (i = r[1].toLowerCase()), i;
77
- }
78
- function M(e, n) {
79
- const t = W(e), r = T(n)[0];
80
- return r && r != "any" ? t == r : !0;
54
+ return A.includes(e) ? w(e) : e;
81
55
  }
82
56
  function V(e) {
83
57
  if (typeof e == "string") {
84
- let n = !1;
85
- return (/^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e)) && (n = !0), n && (e = e.substring(1, e.length - 1)), e + "";
58
+ let t = !1;
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 + "";
86
60
  } else return typeof e == "object" && e ? e.toString() : typeof e > "u" || typeof e == "object" && !e ? "" : e + "";
87
61
  }
88
- function Z(e) {
89
- const n = typeof e;
90
- if (n == "string") {
62
+ function G(e) {
63
+ const t = typeof e;
64
+ if (t == "string") {
91
65
  e = (e + "").replace(/^(\s|\n|r)*/, "").replace(/(\s|\n|r)*$/, "");
92
- let t = "";
93
- 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;
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;
94
68
  } else
95
- return n === "object" ? e instanceof Array ? "array" : n === null ? "null" : n : n;
69
+ return t === "object" ? e instanceof Array ? "array" : t === null ? "null" : t : t;
96
70
  }
97
- function k(e) {
98
- const n = e[0] || "any";
99
- let t = n.split("<")[0];
100
- switch (t = t.trim().toLowerCase(), t) {
101
- case "string":
102
- return '""';
103
- case "boolean":
104
- return "false";
105
- case "number":
106
- return "0";
107
- case "array":
108
- let r = n.indexOf("<"), i = n.substring(n.indexOf("<") + 1, n.length - 1) || "";
109
- r == -1 && (i = "any");
110
- let o = k($(i).dataType);
111
- return o = o == "undefined" ? "" : o, `[${o}]`;
112
- case "object":
113
- return "{}";
114
- case "function":
115
- return "()=>{}";
116
- case "any":
117
- return '""';
118
- default:
119
- return "undefined";
71
+ const g = (e, t) => {
72
+ let r = [], n = [], i = "";
73
+ for (let l = 0; l < e.length; l++) {
74
+ const s = e[l];
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;
120
76
  }
121
- }
122
- function G(e) {
123
- let n = "";
124
- return e.forEach((t, r) => {
125
- t = t.trim(), t && (n && (n += " | "), t === "Array" ? n += "Array<any>" : n += t);
126
- }), n || "any";
127
- }
128
- const g = (e, n) => {
129
- let t = [], r = [], i = "";
130
- for (let o = 0; o < e.length; o++) {
131
- const s = e[o];
132
- 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;
77
+ return i.trim() !== "" && n.push(i.trim()), n;
78
+ }, k = (e) => {
79
+ let t = [], r = !1, n = !1, i = 0;
80
+ for (let l = 0; l < e.length; l++) {
81
+ const s = e[l];
82
+ if (s === "[" || s === "<" || s === "(" ? (n = !0, t.push(s), s == "[" && (r = !0), i == 0 && (i = l)) : (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 == l ? {
84
+ top: "Array",
85
+ type: e.substring(0, i)
86
+ } : {
87
+ top: e.substring(0, i),
88
+ type: e.substring(i + 1, l)
89
+ };
133
90
  }
134
- return i.trim() !== "" && r.push(i.trim()), r;
135
- }, $ = (e) => {
91
+ return {
92
+ top: e,
93
+ type: ""
94
+ };
95
+ }, v = (e) => {
136
96
  if (e)
137
97
  if (e.startsWith("[") && e.endsWith("]") || e.startsWith("(") && e.endsWith(")")) {
138
- const n = e.slice(1, -1).trim();
139
- if (!n) return { type: "any", dataType: ["any"] };
140
- const t = g(n, ",");
141
- return {
142
- type: t[0] || "any",
143
- dataType: t
144
- };
145
- } else if (e.startsWith("<") && e.endsWith(">")) {
146
- const n = e.slice(1, -1).trim();
147
- if (!n) return { type: "any", dataType: ["any"] };
148
- const t = g(n, "|");
149
- return {
150
- type: t[0] || "any",
151
- dataType: t
152
- };
98
+ const t = e.slice(1, -1).trim();
99
+ return t ? g(t, ",") : ["any"];
153
100
  } else {
154
- const n = g(e, ",");
155
- return {
156
- type: n[0] || "any",
157
- dataType: n
158
- };
101
+ if (e.startsWith("{") && e.endsWith("}"))
102
+ return ["Object"];
103
+ if (e.startsWith("<") && e.endsWith(">")) {
104
+ const t = e.slice(1, -1).trim();
105
+ return t ? g(t, "|") : ["any"];
106
+ } else
107
+ return g(e, ",");
159
108
  }
160
- else return { type: "any", dataType: ["any"] };
109
+ else return ["any"];
161
110
  };
162
111
  function K(e) {
163
- return g(e, ",").map((t) => {
164
- const r = t.trim(), i = t.match(/^([^:?]+)(\??):/);
112
+ return g(e, ",").map((r) => {
113
+ const n = r.trim(), i = r.match(/^([^:?]+)(\??):/);
165
114
  if (!i) return null;
166
- const o = i[1].trim(), s = !i[2], j = i[0].length, p = t.substring(j).trim();
167
- let l = [], h = "", m = "";
115
+ const l = i[1].trim(), s = !i[2], j = i[0].length, p = r.substring(j).trim();
116
+ let u = [], h = "", m = "";
168
117
  for (let a = 0; a < p.length; a++) {
169
- const u = p[a];
170
- if (u === "[" || u === "<" || u === "(" ? l.push(u) : (u === "]" && l[l.length - 1] === "[" || u === ">" && l[l.length - 1] === "<" || u === ")" && l[l.length - 1] === "(") && l.pop(), l.length === 0 && a > 0) {
171
- a == 1 && u !== "]" && u !== ">" && u !== ")" ? (h = "", m = p.substring(0)) : (h = p.substring(0, a + 1).trim(), m = p.substring(a + 1));
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 = "", m = p.substring(0)) : (h = p.substring(0, a + 1).trim(), m = p.substring(a + 1));
172
121
  break;
173
122
  }
174
123
  }
175
- const { type: C, dataType: d } = $(h), v = T(d);
124
+ const $ = v(h), d = T($);
176
125
  return {
177
- name: o,
178
- prop: o,
179
- type: v[0],
126
+ name: l,
127
+ prop: l,
128
+ type: b(d),
180
129
  dataType: d,
181
130
  must: s,
182
- label: r,
131
+ label: n,
183
132
  description: m
184
133
  };
185
134
  }).filter(Boolean);
186
135
  }
136
+ function O(e) {
137
+ return e.map((r) => {
138
+ if (typeof r == "string")
139
+ return r.toLowerCase() === "array" ? "Array<any>" : r;
140
+ if (r.children && r.children.length > 0) {
141
+ const n = O(r.children);
142
+ return r.value + "<" + n + ">";
143
+ } else {
144
+ const n = r.value;
145
+ return n.toLowerCase() === "array" ? "Array<any>" : n;
146
+ }
147
+ }).join(" | ") || "any";
148
+ }
149
+ function T(e) {
150
+ const t = [];
151
+ return e.forEach((r) => {
152
+ const n = k(r);
153
+ if (n.type) {
154
+ const i = v(n.type), l = T(i);
155
+ t.push({
156
+ label: r,
157
+ value: n.top,
158
+ children: l
159
+ });
160
+ } else
161
+ t.push(n.top);
162
+ }), t;
163
+ }
164
+ function x(e) {
165
+ let t = "";
166
+ return typeof e == "string" ? t = e : t = e.value, W(t || "any");
167
+ }
168
+ function b(e) {
169
+ const t = e[0] || "any";
170
+ return x(t);
171
+ }
172
+ function C(e) {
173
+ const t = e[0];
174
+ switch (b(e)) {
175
+ case "string":
176
+ return '""';
177
+ case "boolean":
178
+ return "false";
179
+ case "number":
180
+ return "0";
181
+ case "array":
182
+ if (typeof t == "string")
183
+ return "[]";
184
+ {
185
+ let n = t.children;
186
+ if (n && n.length > 0) {
187
+ let i = C([n[0]]);
188
+ return i = i == "undefined" ? "" : i, `[${i}]`;
189
+ } else
190
+ return "[]";
191
+ }
192
+ case "object":
193
+ return "{}";
194
+ case "function":
195
+ return "()=>{}";
196
+ case "any":
197
+ return '""';
198
+ default:
199
+ return "undefined";
200
+ }
201
+ }
202
+ function L(e) {
203
+ const t = Object.prototype.toString.call(e);
204
+ let n = /^\[[O|o]bject (.*)\]$/.exec(t), i = typeof e;
205
+ return n && n.length > 0 && (i = n[1].toLowerCase()), i;
206
+ }
207
+ function Q(e, t) {
208
+ const r = L(e), n = b(t);
209
+ return n && n != "any" ? r == n : !0;
210
+ }
187
211
  export {
188
- x as getFunBody,
189
- X as getFunctionFormat,
190
- W as getObjType,
191
- T as getSonType,
212
+ T as getDataType,
213
+ b as getDataTypeType,
214
+ S as getFunBody,
215
+ Y as getFunctionFormat,
216
+ L as getObjType,
192
217
  V as getString,
193
- k as getTypeValue,
194
- Z as isDefaultType,
195
- M as isTypeEqual,
218
+ C as getTypeValue,
219
+ G as isDefaultType,
220
+ Q as isTypeEqual,
196
221
  K as parseParamString,
197
- $ as parseTypeDefinition,
198
- N as prettierArrFormat,
199
- I as prettierCss,
222
+ v as parseTypeDefinition,
223
+ z as prettierArrFormat,
224
+ M as prettierCss,
200
225
  y as prettierFormat,
201
- R as prettierFunFormat,
226
+ I as prettierFunFormat,
202
227
  q as prettierHtml,
203
- H as prettierJs,
204
- L as prettierObjFormat,
205
- z as prettierTs,
206
- G as setDataType,
207
- J as vueFormat
228
+ J as prettierJs,
229
+ N as prettierObjFormat,
230
+ H as prettierTs,
231
+ O as setDataType,
232
+ R as vueFormat
208
233
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fangzhongya/vue-archive",
3
3
  "private": false,
4
- "version": "0.0.76",
4
+ "version": "0.0.78",
5
5
  "type": "module",
6
6
  "description ": "vue 组件注释生成文档",
7
7
  "author": "fangzhongya ",
@@ -30,7 +30,7 @@
30
30
  "tsup": "^8.5.0",
31
31
  "typescript": "^5.9.2",
32
32
  "unplugin-vue-components": "^29.0.0",
33
- "vite": "^7.1.2",
33
+ "vite": "^7.1.3",
34
34
  "vite-plugin-dts": "4.5.4",
35
35
  "vitest": "^3.2.4",
36
36
  "vue-router": "^4.5.1",