gant-core 0.2.17 → 0.2.19
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/lib/cli/config/index.js +1 -1
- package/lib/cli/create/module/index.js +1 -1
- package/lib/cli/helper/index.d.ts +17 -0
- package/lib/cli/utils/index.d.ts +18 -0
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/request/index.js.map +1 -1
- package/lib/core/store/index.js +1 -1
- package/lib/core/store/index.js.map +1 -1
- package/lib/core/theme/index.js +1 -1
- package/lib/core/theme/index.js.map +1 -1
- package/lib/helper/acorn-BmLbFX50.js +19 -0
- package/lib/helper/angular-DGof4p_D.js +7 -0
- package/lib/helper/babel-Nwboghbx.js +22 -0
- package/lib/helper/estree-CSMrPe9Y.js +44 -0
- package/lib/helper/flow-h7wrzCJb.js +27 -0
- package/lib/helper/glimmer-Bew2Vz0Y.js +38 -0
- package/lib/helper/graphql-BRv4I30B.js +38 -0
- package/lib/helper/html-uZad-YZz.js +28 -0
- package/lib/helper/index.js +27848 -0
- package/lib/helper/markdown-iwdpU9Ia.js +68 -0
- package/lib/helper/meriyah-UktrHj4H.js +11 -0
- package/lib/helper/postcss-H_0MYJut.js +58 -0
- package/lib/helper/typescript-CqdW0_wW.js +31 -0
- package/lib/helper/yaml-DXNEs-hZ.js +170 -0
- package/lib/types/index.d.ts +6 -4
- package/package.json +1 -1
package/lib/cli/config/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var t=require("path"),e=require("fs"),r=require("../utils/index.js"),n=require("./defineConfig.js"),o=require("../utils/getJavascriptfile.js"),i="object"==typeof global&&global&&global.Object===Object&&global,u="object"==typeof self&&self&&self.Object===Object&&self,c=i||u||Function("return this")(),a=c.Symbol,f=Object.prototype,s=f.hasOwnProperty,l=f.toString,p=a?a.toStringTag:void 0;var v=Object.prototype.toString;var h="[object Null]",g="[object Undefined]",b=a?a.toStringTag:void 0;function y(t){return null==t?void 0===t?g:h:b&&b in Object(t)?function(t){var e=s.call(t,p),r=t[p];try{t[p]=void 0;var n=!0}catch(t){}var o=l.call(t);return n&&(e?t[p]=r:delete t[p]),o}(t):function(t){return v.call(t)}(t)}function d(t){return null!=t&&"object"==typeof t}var j="[object Symbol]";function _(t){return"symbol"==typeof t||d(t)&&y(t)==j}function w(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}var m=Array.isArray,O=1/0,C=a?a.prototype:void 0,A=C?C.toString:void 0;function F(t){if("string"==typeof t)return t;if(m(t))return w(t,F)+"";if(_(t))return A?A.call(t):"";var e=t+"";return"0"==e&&1/t==-O?"-0":e}function x(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function S(t){return t}var P="[object AsyncFunction]",z="[object Function]",U="[object GeneratorFunction]",M="[object Proxy]";function k(t){if(!x(t))return!1;var e=y(t);return e==z||e==U||e==P||e==M}var E,I=c["__core-js_shared__"],B=(E=/[^.]+$/.exec(I&&I.keys&&I.keys.IE_PROTO||""))?"Symbol(src)_1."+E:"";var D=Function.prototype.toString;function T(t){if(null!=t){try{return D.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var $=/^\[object .+?Constructor\]$/,q=Function.prototype,L=Object.prototype,V=q.toString,N=L.hasOwnProperty,R=RegExp("^"+V.call(N).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function W(t){return!(!x(t)||(e=t,B&&B in e))&&(k(t)?R:$).test(T(t));var e}function G(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return W(r)?r:void 0}var J=G(c,"WeakMap"),H=Object.create,K=function(){function t(){}return function(e){if(!x(e))return{};if(H)return H(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Q(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}var X=Date.now;var Y,Z,tt,et=function(){try{var t=G(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),rt=et?function(t,e){return et(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:S,nt=(Y=rt,Z=0,tt=0,function(){var t=X(),e=16-(t-tt);if(tt=t,e>0){if(++Z>=800)return arguments[0]}else Z=0;return Y.apply(void 0,arguments)});function ot(t){return t!=t}function it(t,e){return!!(null==t?0:t.length)&&function(t,e,r){return e==e?function(t,e,r){for(var n=r-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1}(t,e,r):function(t,e,r,n){for(var o=t.length,i=r+(n?1:-1);n?i--:++i<o;)if(e(t[i],i,t))return i;return-1}(t,ot,r)}(t,e,0)>-1}var ut=9007199254740991,ct=/^(?:0|[1-9]\d*)$/;function at(t,e){var r=typeof t;return!!(e=null==e?ut:e)&&("number"==r||"symbol"!=r&&ct.test(t))&&t>-1&&t%1==0&&t<e}function ft(t,e,r){"__proto__"==e&&et?et(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function st(t,e){return t===e||t!=t&&e!=e}var lt=Object.prototype.hasOwnProperty;function pt(t,e,r){var n=t[e];lt.call(t,e)&&st(n,r)&&(void 0!==r||e in t)||ft(t,e,r)}function vt(t,e,r,n){var o=!r;r||(r={});for(var i=-1,u=e.length;++i<u;){var c=e[i],a=n?n(r[c],t[c],c,r,t):void 0;void 0===a&&(a=t[c]),o?ft(r,c,a):pt(r,c,a)}return r}var ht=Math.max;function gt(t,e,r){return e=ht(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=ht(n.length-e,0),u=Array(i);++o<i;)u[o]=n[e+o];o=-1;for(var c=Array(e+1);++o<e;)c[o]=n[o];return c[e]=r(u),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,c)}}function bt(t,e){return nt(gt(t,e,S),t+"")}var yt=9007199254740991;function dt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=yt}function jt(t){return null!=t&&dt(t.length)&&!k(t)}var _t=Object.prototype;function wt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||_t)}function mt(t){return d(t)&&"[object Arguments]"==y(t)}var Ot=Object.prototype,Ct=Ot.hasOwnProperty,At=Ot.propertyIsEnumerable,Ft=mt(function(){return arguments}())?mt:function(t){return d(t)&&Ct.call(t,"callee")&&!At.call(t,"callee")};var xt="object"==typeof exports&&exports&&!exports.nodeType&&exports,St=xt&&"object"==typeof module&&module&&!module.nodeType&&module,Pt=St&&St.exports===xt?c.Buffer:void 0,zt=(Pt?Pt.isBuffer:void 0)||function(){return!1},Ut={};function Mt(t){return function(e){return t(e)}}Ut["[object Float32Array]"]=Ut["[object Float64Array]"]=Ut["[object Int8Array]"]=Ut["[object Int16Array]"]=Ut["[object Int32Array]"]=Ut["[object Uint8Array]"]=Ut["[object Uint8ClampedArray]"]=Ut["[object Uint16Array]"]=Ut["[object Uint32Array]"]=!0,Ut["[object Arguments]"]=Ut["[object Array]"]=Ut["[object ArrayBuffer]"]=Ut["[object Boolean]"]=Ut["[object DataView]"]=Ut["[object Date]"]=Ut["[object Error]"]=Ut["[object Function]"]=Ut["[object Map]"]=Ut["[object Number]"]=Ut["[object Object]"]=Ut["[object RegExp]"]=Ut["[object Set]"]=Ut["[object String]"]=Ut["[object WeakMap]"]=!1;var kt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Et=kt&&"object"==typeof module&&module&&!module.nodeType&&module,It=Et&&Et.exports===kt&&i.process,Bt=function(){try{var t=Et&&Et.require&&Et.require("util").types;return t||It&&It.binding&&It.binding("util")}catch(t){}}(),Dt=Bt&&Bt.isTypedArray,Tt=Dt?Mt(Dt):function(t){return d(t)&&dt(t.length)&&!!Ut[y(t)]},$t=Object.prototype.hasOwnProperty;function qt(t,e){var r=m(t),n=!r&&Ft(t),o=!r&&!n&&zt(t),i=!r&&!n&&!o&&Tt(t),u=r||n||o||i,c=u?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],a=c.length;for(var f in t)!e&&!$t.call(t,f)||u&&("length"==f||o&&("offset"==f||"parent"==f)||i&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||at(f,a))||c.push(f);return c}function Lt(t,e){return function(r){return t(e(r))}}var Vt=Lt(Object.keys,Object),Nt=Object.prototype.hasOwnProperty;function Rt(t){if(!wt(t))return Vt(t);var e=[];for(var r in Object(t))Nt.call(t,r)&&"constructor"!=r&&e.push(r);return e}function Wt(t){return jt(t)?qt(t):Rt(t)}var Gt=Object.prototype.hasOwnProperty;function Jt(t){if(!x(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=wt(t),r=[];for(var n in t)("constructor"!=n||!e&&Gt.call(t,n))&&r.push(n);return r}function Ht(t){return jt(t)?qt(t,!0):Jt(t)}var Kt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qt=/^\w*$/;function Xt(t,e){if(m(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!_(t))||(Qt.test(t)||!Kt.test(t)||null!=e&&t in Object(e))}var Yt=G(Object,"create");var Zt=Object.prototype.hasOwnProperty;var te=Object.prototype.hasOwnProperty;function ee(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function re(t,e){for(var r=t.length;r--;)if(st(t[r][0],e))return r;return-1}ee.prototype.clear=function(){this.__data__=Yt?Yt(null):{},this.size=0},ee.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},ee.prototype.get=function(t){var e=this.__data__;if(Yt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return Zt.call(e,t)?e[t]:void 0},ee.prototype.has=function(t){var e=this.__data__;return Yt?void 0!==e[t]:te.call(e,t)},ee.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Yt&&void 0===e?"__lodash_hash_undefined__":e,this};var ne=Array.prototype.splice;function oe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}oe.prototype.clear=function(){this.__data__=[],this.size=0},oe.prototype.delete=function(t){var e=this.__data__,r=re(e,t);return!(r<0)&&(r==e.length-1?e.pop():ne.call(e,r,1),--this.size,!0)},oe.prototype.get=function(t){var e=this.__data__,r=re(e,t);return r<0?void 0:e[r][1]},oe.prototype.has=function(t){return re(this.__data__,t)>-1},oe.prototype.set=function(t,e){var r=this.__data__,n=re(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ie=G(c,"Map");function ue(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function ce(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ce.prototype.clear=function(){this.size=0,this.__data__={hash:new ee,map:new(ie||oe),string:new ee}},ce.prototype.delete=function(t){var e=ue(this,t).delete(t);return this.size-=e?1:0,e},ce.prototype.get=function(t){return ue(this,t).get(t)},ce.prototype.has=function(t){return ue(this,t).has(t)},ce.prototype.set=function(t,e){var r=ue(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};var ae="Expected a function";function fe(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError(ae);var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var u=t.apply(this,n);return r.cache=i.set(o,u)||i,u};return r.cache=new(fe.Cache||ce),r}fe.Cache=ce;var se=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,le=/\\(\\)?/g,pe=function(t){var e=fe(t,(function(t){return 500===r.size&&r.clear(),t})),r=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(se,(function(t,r,n,o){e.push(n?o.replace(le,"$1"):r||t)})),e}));function ve(t,e){return m(t)?t:Xt(t,e)?[t]:pe(function(t){return null==t?"":F(t)}(t))}var he=1/0;function ge(t){if("string"==typeof t||_(t))return t;var e=t+"";return"0"==e&&1/t==-he?"-0":e}function be(t,e){for(var r=0,n=(e=ve(e,t)).length;null!=t&&r<n;)t=t[ge(e[r++])];return r&&r==n?t:void 0}function ye(t,e,r){var n=null==t?void 0:be(t,e);return void 0===n?r:n}function de(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}var je=a?a.isConcatSpreadable:void 0;function _e(t){return m(t)||Ft(t)||!!(je&&t&&t[je])}function we(t,e,r,n,o){var i=-1,u=t.length;for(r||(r=_e),o||(o=[]);++i<u;){var c=t[i];e>0&&r(c)?e>1?we(c,e-1,r,n,o):de(o,c):n||(o[o.length]=c)}return o}function me(t){return(null==t?0:t.length)?we(t,1):[]}function Oe(t){return nt(gt(t,void 0,me),t+"")}var Ce=Lt(Object.getPrototypeOf,Object),Ae="[object Object]",Fe=Function.prototype,xe=Object.prototype,Se=Fe.toString,Pe=xe.hasOwnProperty,ze=Se.call(Object);function Ue(t){if(!d(t)||y(t)!=Ae)return!1;var e=Ce(t);if(null===e)return!0;var r=Pe.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Se.call(r)==ze}function Me(t){var e=this.__data__=new oe(t);this.size=e.size}Me.prototype.clear=function(){this.__data__=new oe,this.size=0},Me.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Me.prototype.get=function(t){return this.__data__.get(t)},Me.prototype.has=function(t){return this.__data__.has(t)},Me.prototype.set=function(t,e){var r=this.__data__;if(r instanceof oe){var n=r.__data__;if(!ie||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new ce(n)}return r.set(t,e),this.size=r.size,this};var ke="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ee=ke&&"object"==typeof module&&module&&!module.nodeType&&module,Ie=Ee&&Ee.exports===ke?c.Buffer:void 0,Be=Ie?Ie.allocUnsafe:void 0;function De(t,e){if(e)return t.slice();var r=t.length,n=Be?Be(r):new t.constructor(r);return t.copy(n),n}function Te(){return[]}var $e=Object.prototype.propertyIsEnumerable,qe=Object.getOwnPropertySymbols,Le=qe?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var u=t[r];e(u,r,t)&&(i[o++]=u)}return i}(qe(t),(function(e){return $e.call(t,e)})))}:Te;var Ve=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)de(e,Le(t)),t=Ce(t);return e}:Te;function Ne(t,e,r){var n=e(t);return m(t)?n:de(n,r(t))}function Re(t){return Ne(t,Wt,Le)}function We(t){return Ne(t,Ht,Ve)}var Ge=G(c,"DataView"),Je=G(c,"Promise"),He=G(c,"Set"),Ke="[object Map]",Qe="[object Promise]",Xe="[object Set]",Ye="[object WeakMap]",Ze="[object DataView]",tr=T(Ge),er=T(ie),rr=T(Je),nr=T(He),or=T(J),ir=y;(Ge&&ir(new Ge(new ArrayBuffer(1)))!=Ze||ie&&ir(new ie)!=Ke||Je&&ir(Je.resolve())!=Qe||He&&ir(new He)!=Xe||J&&ir(new J)!=Ye)&&(ir=function(t){var e=y(t),r="[object Object]"==e?t.constructor:void 0,n=r?T(r):"";if(n)switch(n){case tr:return Ze;case er:return Ke;case rr:return Qe;case nr:return Xe;case or:return Ye}return e});var ur=ir,cr=Object.prototype.hasOwnProperty;var ar=c.Uint8Array;function fr(t){var e=new t.constructor(t.byteLength);return new ar(e).set(new ar(t)),e}var sr=/\w*$/;var lr=a?a.prototype:void 0,pr=lr?lr.valueOf:void 0;function vr(t,e){var r=e?fr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var hr="[object Boolean]",gr="[object Date]",br="[object Map]",yr="[object Number]",dr="[object RegExp]",jr="[object Set]",_r="[object String]",wr="[object Symbol]",mr="[object ArrayBuffer]",Or="[object DataView]",Cr="[object Float32Array]",Ar="[object Float64Array]",Fr="[object Int8Array]",xr="[object Int16Array]",Sr="[object Int32Array]",Pr="[object Uint8Array]",zr="[object Uint8ClampedArray]",Ur="[object Uint16Array]",Mr="[object Uint32Array]";function kr(t,e,r){var n,o,i,u=t.constructor;switch(e){case mr:return fr(t);case hr:case gr:return new u(+t);case Or:return function(t,e){var r=e?fr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case Cr:case Ar:case Fr:case xr:case Sr:case Pr:case zr:case Ur:case Mr:return vr(t,r);case br:return new u;case yr:case _r:return new u(t);case dr:return(i=new(o=t).constructor(o.source,sr.exec(o))).lastIndex=o.lastIndex,i;case jr:return new u;case wr:return n=t,pr?Object(pr.call(n)):{}}}function Er(t){return"function"!=typeof t.constructor||wt(t)?{}:K(Ce(t))}var Ir=Bt&&Bt.isMap,Br=Ir?Mt(Ir):function(t){return d(t)&&"[object Map]"==ur(t)};var Dr=Bt&&Bt.isSet,Tr=Dr?Mt(Dr):function(t){return d(t)&&"[object Set]"==ur(t)},$r=1,qr=2,Lr=4,Vr="[object Arguments]",Nr="[object Function]",Rr="[object GeneratorFunction]",Wr="[object Object]",Gr={};function Jr(t,e,r,n,o,i){var u,c=e&$r,a=e&qr,f=e&Lr;if(r&&(u=o?r(t,n,o,i):r(t)),void 0!==u)return u;if(!x(t))return t;var s=m(t);if(s){if(u=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&cr.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!c)return Q(t,u)}else{var l=ur(t),p=l==Nr||l==Rr;if(zt(t))return De(t,c);if(l==Wr||l==Vr||p&&!o){if(u=a||p?{}:Er(t),!c)return a?function(t,e){return vt(t,Ve(t),e)}(t,function(t,e){return t&&vt(e,Ht(e),t)}(u,t)):function(t,e){return vt(t,Le(t),e)}(t,function(t,e){return t&&vt(e,Wt(e),t)}(u,t))}else{if(!Gr[l])return o?t:{};u=kr(t,l,c)}}i||(i=new Me);var v=i.get(t);if(v)return v;i.set(t,u),Tr(t)?t.forEach((function(n){u.add(Jr(n,e,r,n,t,i))})):Br(t)&&t.forEach((function(n,o){u.set(o,Jr(n,e,r,o,t,i))}));var h=s?void 0:(f?a?We:Re:a?Ht:Wt)(t);return function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););}(h||t,(function(n,o){h&&(n=t[o=n]),pt(u,o,Jr(n,e,r,o,t,i))})),u}Gr[Vr]=Gr["[object Array]"]=Gr["[object ArrayBuffer]"]=Gr["[object DataView]"]=Gr["[object Boolean]"]=Gr["[object Date]"]=Gr["[object Float32Array]"]=Gr["[object Float64Array]"]=Gr["[object Int8Array]"]=Gr["[object Int16Array]"]=Gr["[object Int32Array]"]=Gr["[object Map]"]=Gr["[object Number]"]=Gr[Wr]=Gr["[object RegExp]"]=Gr["[object Set]"]=Gr["[object String]"]=Gr["[object Symbol]"]=Gr["[object Uint8Array]"]=Gr["[object Uint8ClampedArray]"]=Gr["[object Uint16Array]"]=Gr["[object Uint32Array]"]=!0,Gr["[object Error]"]=Gr[Nr]=Gr["[object WeakMap]"]=!1;function Hr(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new ce;++e<r;)this.add(t[e])}function Kr(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function Qr(t,e){return t.has(e)}Hr.prototype.add=Hr.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Hr.prototype.has=function(t){return this.__data__.has(t)};var Xr=1,Yr=2;function Zr(t,e,r,n,o,i){var u=r&Xr,c=t.length,a=e.length;if(c!=a&&!(u&&a>c))return!1;var f=i.get(t),s=i.get(e);if(f&&s)return f==e&&s==t;var l=-1,p=!0,v=r&Yr?new Hr:void 0;for(i.set(t,e),i.set(e,t);++l<c;){var h=t[l],g=e[l];if(n)var b=u?n(g,h,l,e,t,i):n(h,g,l,t,e,i);if(void 0!==b){if(b)continue;p=!1;break}if(v){if(!Kr(e,(function(t,e){if(!Qr(v,e)&&(h===t||o(h,t,r,n,i)))return v.push(e)}))){p=!1;break}}else if(h!==g&&!o(h,g,r,n,i)){p=!1;break}}return i.delete(t),i.delete(e),p}function tn(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function en(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var rn=1,nn=2,on="[object Boolean]",un="[object Date]",cn="[object Error]",an="[object Map]",fn="[object Number]",sn="[object RegExp]",ln="[object Set]",pn="[object String]",vn="[object Symbol]",hn="[object ArrayBuffer]",gn="[object DataView]",bn=a?a.prototype:void 0,yn=bn?bn.valueOf:void 0;var dn=1,jn=Object.prototype.hasOwnProperty;var _n=1,wn="[object Arguments]",mn="[object Array]",On="[object Object]",Cn=Object.prototype.hasOwnProperty;function An(t,e,r,n,o,i){var u=m(t),c=m(e),a=u?mn:ur(t),f=c?mn:ur(e),s=(a=a==wn?On:a)==On,l=(f=f==wn?On:f)==On,p=a==f;if(p&&zt(t)){if(!zt(e))return!1;u=!0,s=!1}if(p&&!s)return i||(i=new Me),u||Tt(t)?Zr(t,e,r,n,o,i):function(t,e,r,n,o,i,u){switch(r){case gn:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case hn:return!(t.byteLength!=e.byteLength||!i(new ar(t),new ar(e)));case on:case un:case fn:return st(+t,+e);case cn:return t.name==e.name&&t.message==e.message;case sn:case pn:return t==e+"";case an:var c=tn;case ln:var a=n&rn;if(c||(c=en),t.size!=e.size&&!a)return!1;var f=u.get(t);if(f)return f==e;n|=nn,u.set(t,e);var s=Zr(c(t),c(e),n,o,i,u);return u.delete(t),s;case vn:if(yn)return yn.call(t)==yn.call(e)}return!1}(t,e,a,r,n,o,i);if(!(r&_n)){var v=s&&Cn.call(t,"__wrapped__"),h=l&&Cn.call(e,"__wrapped__");if(v||h){var g=v?t.value():t,b=h?e.value():e;return i||(i=new Me),o(g,b,r,n,i)}}return!!p&&(i||(i=new Me),function(t,e,r,n,o,i){var u=r&dn,c=Re(t),a=c.length;if(a!=Re(e).length&&!u)return!1;for(var f=a;f--;){var s=c[f];if(!(u?s in e:jn.call(e,s)))return!1}var l=i.get(t),p=i.get(e);if(l&&p)return l==e&&p==t;var v=!0;i.set(t,e),i.set(e,t);for(var h=u;++f<a;){var g=t[s=c[f]],b=e[s];if(n)var y=u?n(b,g,s,e,t,i):n(g,b,s,t,e,i);if(!(void 0===y?g===b||o(g,b,r,n,i):y)){v=!1;break}h||(h="constructor"==s)}if(v&&!h){var d=t.constructor,j=e.constructor;d==j||!("constructor"in t)||!("constructor"in e)||"function"==typeof d&&d instanceof d&&"function"==typeof j&&j instanceof j||(v=!1)}return i.delete(t),i.delete(e),v}(t,e,r,n,o,i))}function Fn(t,e,r,n,o){return t===e||(null==t||null==e||!d(t)&&!d(e)?t!=t&&e!=e:An(t,e,r,n,Fn,o))}var xn=1,Sn=2;function Pn(t){return t==t&&!x(t)}function zn(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function Un(t){var e=function(t){for(var e=Wt(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,Pn(o)]}return e}(t);return 1==e.length&&e[0][2]?zn(e[0][0],e[0][1]):function(r){return r===t||function(t,e,r,n){var o=r.length,i=o,u=!n;if(null==t)return!i;for(t=Object(t);o--;){var c=r[o];if(u&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++o<i;){var a=(c=r[o])[0],f=t[a],s=c[1];if(u&&c[2]){if(void 0===f&&!(a in t))return!1}else{var l=new Me;if(n)var p=n(f,s,a,t,e,l);if(!(void 0===p?Fn(s,f,xn|Sn,n,l):p))return!1}}return!0}(r,t,e)}}function Mn(t,e){return null!=t&&e in Object(t)}function kn(t,e,r){for(var n=-1,o=(e=ve(e,t)).length,i=!1;++n<o;){var u=ge(e[n]);if(!(i=null!=t&&r(t,u)))break;t=t[u]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&dt(o)&&at(u,o)&&(m(t)||Ft(t))}function En(t,e){return null!=t&&kn(t,e,Mn)}var In=1,Bn=2;function Dn(t){return Xt(t)?(e=ge(t),function(t){return null==t?void 0:t[e]}):function(t){return function(e){return be(e,t)}}(t);var e}function Tn(t){return"function"==typeof t?t:null==t?S:"object"==typeof t?m(t)?function(t,e){return Xt(t)&&Pn(e)?zn(ge(t),e):function(r){var n=ye(r,t);return void 0===n&&n===e?En(r,t):Fn(e,n,In|Bn)}}(t[0],t[1]):Un(t):Dn(t)}function $n(t,e,r,n){for(var o=-1,i=null==t?0:t.length;++o<i;){var u=t[o];e(n,u,r(u),t)}return n}var qn,Ln=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),u=i.length;u--;){var c=i[qn?u:++n];if(!1===e(o[c],c,o))break}return t};function Vn(t,e){return t&&Ln(t,e,Wt)}var Nn=function(t,e){return function(r,n){if(null==r)return r;if(!jt(r))return t(r,n);for(var o=r.length,i=e?o:-1,u=Object(r);(e?i--:++i<o)&&!1!==n(u[i],i,u););return r}}(Vn);function Rn(t,e,r,n){return Nn(t,(function(t,o,i){e(n,t,r(t),i)})),n}function Wn(t,e,r){(void 0!==r&&!st(t[e],r)||void 0===r&&!(e in t))&&ft(t,e,r)}function Gn(t){return d(t)&&jt(t)}function Jn(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Hn(t,e,r,n,o,i,u){var c=Jn(t,r),a=Jn(e,r),f=u.get(a);if(f)Wn(t,r,f);else{var s,l=i?i(c,a,r+"",t,e,u):void 0,p=void 0===l;if(p){var v=m(a),h=!v&&zt(a),g=!v&&!h&&Tt(a);l=a,v||h||g?m(c)?l=c:Gn(c)?l=Q(c):h?(p=!1,l=De(a,!0)):g?(p=!1,l=vr(a,!0)):l=[]:Ue(a)||Ft(a)?(l=c,Ft(c)?l=vt(s=c,Ht(s)):x(c)&&!k(c)||(l=Er(a))):p=!1}p&&(u.set(a,l),o(l,a,n,i,u),u.delete(a)),Wn(t,r,l)}}function Kn(t,e,r,n,o){t!==e&&Ln(e,(function(i,u){if(o||(o=new Me),x(i))Hn(t,e,u,r,Kn,n,o);else{var c=n?n(Jn(t,u),i,u+"",t,e,o):void 0;void 0===c&&(c=i),Wn(t,u,c)}}),Ht)}var Qn,Xn=(Qn=function(t,e,r,n){Kn(t,e,r,n)},bt((function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Qn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!x(r))return!1;var n=typeof e;return!!("number"==n?jt(r)&&at(e,r.length):"string"==n&&e in r)&&st(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var u=e[r];u&&Qn(t,u,r,o)}return t})));function Yn(t,e,r){for(var n=-1,o=null==t?0:t.length;++n<o;)if(r(e,t[n]))return!0;return!1}var Zn=Object.prototype.hasOwnProperty;function to(t,e){return null!=t&&Zn.call(t,e)}function eo(t,e){return e.length<2?t:be(t,function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n<o;)i[n]=t[n+e];return i}(e,0,-1))}var ro=Object.prototype.hasOwnProperty;var no,oo,io=(no=function(t,e,r){ft(t,r,e)},function(t,e){var r=m(t)?$n:Rn,n=oo?oo():{};return r(t,no,Tn(e),n)});function uo(t,e){return null==(t=eo(t,e=ve(e,t)))||delete t[ge((r=e,n=null==r?0:r.length,n?r[n-1]:void 0))];var r,n}function co(t){return Ue(t)?void 0:t}var ao=Oe((function(t,e){var r={};if(null==t)return r;var n=!1;e=w(e,(function(e){return e=ve(e,t),n||(n=e.length>1),e})),vt(t,We(t),r),n&&(r=Jr(r,7,co));for(var o=e.length;o--;)uo(r,e[o]);return r}));function fo(t,e,r,n){if(!x(t))return t;for(var o=-1,i=(e=ve(e,t)).length,u=i-1,c=t;null!=c&&++o<i;){var a=ge(e[o]),f=r;if("__proto__"===a||"constructor"===a||"prototype"===a)return t;if(o!=u){var s=c[a];void 0===(f=n?n(s,a,c):void 0)&&(f=x(s)?s:at(e[o+1])?[]:{})}pt(c,a,f),c=c[a]}return t}function so(t,e){return function(t,e,r){for(var n=-1,o=e.length,i={};++n<o;){var u=e[n],c=be(t,u);r(c,u)&&fo(i,ve(u,t),c)}return i}(t,e,(function(e,r){return En(t,r)}))}var lo=Oe((function(t,e){return null==t?{}:so(t,e)})),po=He&&1/en(new He([,-0]))[1]==1/0?function(t){return new He(t)}:function(){};var vo=bt((function(t){return function(t,e,r){var n=-1,o=it,i=t.length,u=!0,c=[],a=c;if(r)u=!1,o=Yn;else if(i>=200){var f=e?null:po(t);if(f)return en(f);u=!1,o=Qr,a=new Hr}else a=e?[]:c;t:for(;++n<i;){var s=t[n],l=e?e(s):s;if(s=r||0!==s?s:0,u&&l==l){for(var p=a.length;p--;)if(a[p]===l)continue t;e&&a.push(l),c.push(s)}else o(a,l,r)||(a!==c&&a.push(l),c.push(s))}return c}(we(t,1,Gn,!0))}));const ho=["config/config.ts","config/config.js","config.ts","config.js"],go=["routes","microServiceMap","setting","define","optimization","provide","resolve"];class bo{opts;mainConfigFile;configFiles=[];constructor(t){const e=t.defaultConfigFiles?t.defaultConfigFiles:ho;this.mainConfigFile=bo.getMainConfigFile({cwd:t.cwd,defaultConfigFiles:e}),this.opts={...t,defaultConfigFiles:e}}getMsPagesUserConfig(t){let e={};return("string"==typeof t?[t]:t).map((t=>{const n=bo.getMainConfigFile({cwd:t,defaultConfigFiles:this.opts.defaultConfigFiles}),o=bo.getUserConfig({cwd:t,mainConfigFile:n});e=r.mergeConfig(e,lo(o,go))})),e}getMsUserConfig(){this.configFiles=[];let e=bo.getUserConfig({cwd:this.opts.cwd,mainConfigFile:this.mainConfigFile});this.mainConfigFile&&this.configFiles.push(this.mainConfigFile);const o=[this.opts.cwd],i=r.getSrcPath();ye(e,"mfa.pages",[]);const u=ye(e,"packages",{}),c={"@gant":t.resolve(this.opts.cwd,i,".gant"),"@@":t.resolve(this.opts.cwd)};let a={context:this.opts.cwd,publicPathDir:t.resolve(this.opts.cwd,i,".gant"),resolve:{alias:c}};return Ue(u)&&Object.keys(u).map((t=>{const e=u[t];if(o.includes(e))return;o.push(e);const n=bo.getMainConfigFile({cwd:e,defaultConfigFiles:this.opts.defaultConfigFiles});n&&this.configFiles.push(n);const i=bo.getUserConfig({cwd:e,mainConfigFile:n});a=r.mergeConfig(a,lo(i,go))})),{...r.mergeConfig(r.mergeConfig(n.defineConfig(),a),e)}}getUserConfig(){this.configFiles=[];let e=bo.getUserConfig({cwd:this.opts.cwd,mainConfigFile:this.mainConfigFile});this.mainConfigFile&&this.configFiles.push(this.mainConfigFile);const o=[this.opts.cwd],i=ye(e,"packages",{}),u=r.getSrcPath(),c={"@gant":t.resolve(this.opts.cwd,u,".gant"),[e.name||"@@"]:t.resolve(this.opts.cwd),...i};let a={context:this.opts.cwd,resolve:{alias:c}};return Ue(i)&&Object.keys(i).map((t=>{const e=i[t];if(o.includes(e))return;o.push(e);const n=bo.getMainConfigFile({cwd:e,defaultConfigFiles:this.opts.defaultConfigFiles});n&&this.configFiles.push(n);const u=bo.getUserConfig({cwd:e,mainConfigFile:n});a=r.mergeConfig(a,lo(u,go))})),{...r.mergeConfig(r.mergeConfig(n.defineConfig(),a),e)}}static getMainConfigFile(r){let n=null;for(const o of r.defaultConfigFiles||ho){const i=t.join(r.cwd,o);if(e.existsSync(i)){n=i;break}}return n}static getUserConfig(t){let e={};if(!t.mainConfigFile)return e;try{e=o.getJavascriptfile(r.getAbsFile(t.mainConfigFile,t.cwd))}catch(t){console.log("getUserConfig Error :",t)}return e}}exports.Config=bo,exports.cloneDeep=function(t){return Jr(t,5)},exports.get=ye,exports.has=function(t,e){return null!=t&&kn(t,e,to)},exports.isArray=m,exports.isEmpty=function(t){if(null==t)return!0;if(jt(t)&&(m(t)||"string"==typeof t||"function"==typeof t.splice||zt(t)||Tt(t)||Ft(t)))return!t.length;var e=ur(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(wt(t))return!Rt(t).length;for(var r in t)if(ro.call(t,r))return!1;return!0},exports.isNull=function(t){return null===t},exports.isObject=x,exports.isUndefined=function(t){return void 0===t},exports.keyBy=io,exports.keys=Wt,exports.mapValues=function(t,e){var r={};return e=Tn(e),Vn(t,(function(t,n,o){ft(r,n,e(t,n,o))})),r},exports.mergeWith=Xn,exports.omit=ao,exports.pick=lo,exports.union=vo,exports.values=function(t){return null==t?[]:function(t,e){return w(e,(function(e){return t[e]}))}(t,Wt(t))};
|
|
2
|
+
"use strict";var t=require("path"),e=require("fs"),r=require("../utils/index.js"),n=require("./defineConfig.js"),o=require("../utils/getJavascriptfile.js"),i="object"==typeof global&&global&&global.Object===Object&&global,u="object"==typeof self&&self&&self.Object===Object&&self,c=i||u||Function("return this")(),a=c.Symbol,f=Object.prototype,s=f.hasOwnProperty,l=f.toString,p=a?a.toStringTag:void 0;var v=Object.prototype.toString;var h="[object Null]",g="[object Undefined]",b=a?a.toStringTag:void 0;function y(t){return null==t?void 0===t?g:h:b&&b in Object(t)?function(t){var e=s.call(t,p),r=t[p];try{t[p]=void 0;var n=!0}catch(t){}var o=l.call(t);return n&&(e?t[p]=r:delete t[p]),o}(t):function(t){return v.call(t)}(t)}function d(t){return null!=t&&"object"==typeof t}var j="[object Symbol]";function _(t){return"symbol"==typeof t||d(t)&&y(t)==j}function w(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}var m=Array.isArray,O=1/0,C=a?a.prototype:void 0,A=C?C.toString:void 0;function F(t){if("string"==typeof t)return t;if(m(t))return w(t,F)+"";if(_(t))return A?A.call(t):"";var e=t+"";return"0"==e&&1/t==-O?"-0":e}function x(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function S(t){return t}var P="[object AsyncFunction]",z="[object Function]",U="[object GeneratorFunction]",M="[object Proxy]";function k(t){if(!x(t))return!1;var e=y(t);return e==z||e==U||e==P||e==M}var E,I=c["__core-js_shared__"],B=(E=/[^.]+$/.exec(I&&I.keys&&I.keys.IE_PROTO||""))?"Symbol(src)_1."+E:"";var D=Function.prototype.toString;function T(t){if(null!=t){try{return D.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var $=/^\[object .+?Constructor\]$/,q=Function.prototype,L=Object.prototype,V=q.toString,N=L.hasOwnProperty,R=RegExp("^"+V.call(N).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function W(t){return!(!x(t)||(e=t,B&&B in e))&&(k(t)?R:$).test(T(t));var e}function G(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return W(r)?r:void 0}var J=G(c,"WeakMap"),H=Object.create,K=function(){function t(){}return function(e){if(!x(e))return{};if(H)return H(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Q(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}var X=Date.now;var Y,Z,tt,et=function(){try{var t=G(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),rt=et?function(t,e){return et(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:S,nt=(Y=rt,Z=0,tt=0,function(){var t=X(),e=16-(t-tt);if(tt=t,e>0){if(++Z>=800)return arguments[0]}else Z=0;return Y.apply(void 0,arguments)});function ot(t){return t!=t}function it(t,e){return!!(null==t?0:t.length)&&function(t,e,r){return e==e?function(t,e,r){for(var n=r-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1}(t,e,r):function(t,e,r,n){for(var o=t.length,i=r+(n?1:-1);n?i--:++i<o;)if(e(t[i],i,t))return i;return-1}(t,ot,r)}(t,e,0)>-1}var ut=9007199254740991,ct=/^(?:0|[1-9]\d*)$/;function at(t,e){var r=typeof t;return!!(e=null==e?ut:e)&&("number"==r||"symbol"!=r&&ct.test(t))&&t>-1&&t%1==0&&t<e}function ft(t,e,r){"__proto__"==e&&et?et(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function st(t,e){return t===e||t!=t&&e!=e}var lt=Object.prototype.hasOwnProperty;function pt(t,e,r){var n=t[e];lt.call(t,e)&&st(n,r)&&(void 0!==r||e in t)||ft(t,e,r)}function vt(t,e,r,n){var o=!r;r||(r={});for(var i=-1,u=e.length;++i<u;){var c=e[i],a=n?n(r[c],t[c],c,r,t):void 0;void 0===a&&(a=t[c]),o?ft(r,c,a):pt(r,c,a)}return r}var ht=Math.max;function gt(t,e,r){return e=ht(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=ht(n.length-e,0),u=Array(i);++o<i;)u[o]=n[e+o];o=-1;for(var c=Array(e+1);++o<e;)c[o]=n[o];return c[e]=r(u),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,c)}}function bt(t,e){return nt(gt(t,e,S),t+"")}var yt=9007199254740991;function dt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=yt}function jt(t){return null!=t&&dt(t.length)&&!k(t)}var _t=Object.prototype;function wt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||_t)}function mt(t){return d(t)&&"[object Arguments]"==y(t)}var Ot=Object.prototype,Ct=Ot.hasOwnProperty,At=Ot.propertyIsEnumerable,Ft=mt(function(){return arguments}())?mt:function(t){return d(t)&&Ct.call(t,"callee")&&!At.call(t,"callee")};var xt="object"==typeof exports&&exports&&!exports.nodeType&&exports,St=xt&&"object"==typeof module&&module&&!module.nodeType&&module,Pt=St&&St.exports===xt?c.Buffer:void 0,zt=(Pt?Pt.isBuffer:void 0)||function(){return!1},Ut={};function Mt(t){return function(e){return t(e)}}Ut["[object Float32Array]"]=Ut["[object Float64Array]"]=Ut["[object Int8Array]"]=Ut["[object Int16Array]"]=Ut["[object Int32Array]"]=Ut["[object Uint8Array]"]=Ut["[object Uint8ClampedArray]"]=Ut["[object Uint16Array]"]=Ut["[object Uint32Array]"]=!0,Ut["[object Arguments]"]=Ut["[object Array]"]=Ut["[object ArrayBuffer]"]=Ut["[object Boolean]"]=Ut["[object DataView]"]=Ut["[object Date]"]=Ut["[object Error]"]=Ut["[object Function]"]=Ut["[object Map]"]=Ut["[object Number]"]=Ut["[object Object]"]=Ut["[object RegExp]"]=Ut["[object Set]"]=Ut["[object String]"]=Ut["[object WeakMap]"]=!1;var kt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Et=kt&&"object"==typeof module&&module&&!module.nodeType&&module,It=Et&&Et.exports===kt&&i.process,Bt=function(){try{var t=Et&&Et.require&&Et.require("util").types;return t||It&&It.binding&&It.binding("util")}catch(t){}}(),Dt=Bt&&Bt.isTypedArray,Tt=Dt?Mt(Dt):function(t){return d(t)&&dt(t.length)&&!!Ut[y(t)]},$t=Object.prototype.hasOwnProperty;function qt(t,e){var r=m(t),n=!r&&Ft(t),o=!r&&!n&&zt(t),i=!r&&!n&&!o&&Tt(t),u=r||n||o||i,c=u?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],a=c.length;for(var f in t)!e&&!$t.call(t,f)||u&&("length"==f||o&&("offset"==f||"parent"==f)||i&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||at(f,a))||c.push(f);return c}function Lt(t,e){return function(r){return t(e(r))}}var Vt=Lt(Object.keys,Object),Nt=Object.prototype.hasOwnProperty;function Rt(t){if(!wt(t))return Vt(t);var e=[];for(var r in Object(t))Nt.call(t,r)&&"constructor"!=r&&e.push(r);return e}function Wt(t){return jt(t)?qt(t):Rt(t)}var Gt=Object.prototype.hasOwnProperty;function Jt(t){if(!x(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=wt(t),r=[];for(var n in t)("constructor"!=n||!e&&Gt.call(t,n))&&r.push(n);return r}function Ht(t){return jt(t)?qt(t,!0):Jt(t)}var Kt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qt=/^\w*$/;function Xt(t,e){if(m(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!_(t))||(Qt.test(t)||!Kt.test(t)||null!=e&&t in Object(e))}var Yt=G(Object,"create");var Zt=Object.prototype.hasOwnProperty;var te=Object.prototype.hasOwnProperty;function ee(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function re(t,e){for(var r=t.length;r--;)if(st(t[r][0],e))return r;return-1}ee.prototype.clear=function(){this.__data__=Yt?Yt(null):{},this.size=0},ee.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},ee.prototype.get=function(t){var e=this.__data__;if(Yt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return Zt.call(e,t)?e[t]:void 0},ee.prototype.has=function(t){var e=this.__data__;return Yt?void 0!==e[t]:te.call(e,t)},ee.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Yt&&void 0===e?"__lodash_hash_undefined__":e,this};var ne=Array.prototype.splice;function oe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}oe.prototype.clear=function(){this.__data__=[],this.size=0},oe.prototype.delete=function(t){var e=this.__data__,r=re(e,t);return!(r<0)&&(r==e.length-1?e.pop():ne.call(e,r,1),--this.size,!0)},oe.prototype.get=function(t){var e=this.__data__,r=re(e,t);return r<0?void 0:e[r][1]},oe.prototype.has=function(t){return re(this.__data__,t)>-1},oe.prototype.set=function(t,e){var r=this.__data__,n=re(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ie=G(c,"Map");function ue(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function ce(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ce.prototype.clear=function(){this.size=0,this.__data__={hash:new ee,map:new(ie||oe),string:new ee}},ce.prototype.delete=function(t){var e=ue(this,t).delete(t);return this.size-=e?1:0,e},ce.prototype.get=function(t){return ue(this,t).get(t)},ce.prototype.has=function(t){return ue(this,t).has(t)},ce.prototype.set=function(t,e){var r=ue(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};var ae="Expected a function";function fe(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError(ae);var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var u=t.apply(this,n);return r.cache=i.set(o,u)||i,u};return r.cache=new(fe.Cache||ce),r}fe.Cache=ce;var se=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,le=/\\(\\)?/g,pe=function(t){var e=fe(t,(function(t){return 500===r.size&&r.clear(),t})),r=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(se,(function(t,r,n,o){e.push(n?o.replace(le,"$1"):r||t)})),e}));function ve(t,e){return m(t)?t:Xt(t,e)?[t]:pe(function(t){return null==t?"":F(t)}(t))}var he=1/0;function ge(t){if("string"==typeof t||_(t))return t;var e=t+"";return"0"==e&&1/t==-he?"-0":e}function be(t,e){for(var r=0,n=(e=ve(e,t)).length;null!=t&&r<n;)t=t[ge(e[r++])];return r&&r==n?t:void 0}function ye(t,e,r){var n=null==t?void 0:be(t,e);return void 0===n?r:n}function de(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}var je=a?a.isConcatSpreadable:void 0;function _e(t){return m(t)||Ft(t)||!!(je&&t&&t[je])}function we(t,e,r,n,o){var i=-1,u=t.length;for(r||(r=_e),o||(o=[]);++i<u;){var c=t[i];e>0&&r(c)?e>1?we(c,e-1,r,n,o):de(o,c):n||(o[o.length]=c)}return o}function me(t){return(null==t?0:t.length)?we(t,1):[]}function Oe(t){return nt(gt(t,void 0,me),t+"")}var Ce=Lt(Object.getPrototypeOf,Object),Ae="[object Object]",Fe=Function.prototype,xe=Object.prototype,Se=Fe.toString,Pe=xe.hasOwnProperty,ze=Se.call(Object);function Ue(t){if(!d(t)||y(t)!=Ae)return!1;var e=Ce(t);if(null===e)return!0;var r=Pe.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Se.call(r)==ze}function Me(t){var e=this.__data__=new oe(t);this.size=e.size}Me.prototype.clear=function(){this.__data__=new oe,this.size=0},Me.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Me.prototype.get=function(t){return this.__data__.get(t)},Me.prototype.has=function(t){return this.__data__.has(t)},Me.prototype.set=function(t,e){var r=this.__data__;if(r instanceof oe){var n=r.__data__;if(!ie||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new ce(n)}return r.set(t,e),this.size=r.size,this};var ke="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ee=ke&&"object"==typeof module&&module&&!module.nodeType&&module,Ie=Ee&&Ee.exports===ke?c.Buffer:void 0,Be=Ie?Ie.allocUnsafe:void 0;function De(t,e){if(e)return t.slice();var r=t.length,n=Be?Be(r):new t.constructor(r);return t.copy(n),n}function Te(){return[]}var $e=Object.prototype.propertyIsEnumerable,qe=Object.getOwnPropertySymbols,Le=qe?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var u=t[r];e(u,r,t)&&(i[o++]=u)}return i}(qe(t),(function(e){return $e.call(t,e)})))}:Te;var Ve=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)de(e,Le(t)),t=Ce(t);return e}:Te;function Ne(t,e,r){var n=e(t);return m(t)?n:de(n,r(t))}function Re(t){return Ne(t,Wt,Le)}function We(t){return Ne(t,Ht,Ve)}var Ge=G(c,"DataView"),Je=G(c,"Promise"),He=G(c,"Set"),Ke="[object Map]",Qe="[object Promise]",Xe="[object Set]",Ye="[object WeakMap]",Ze="[object DataView]",tr=T(Ge),er=T(ie),rr=T(Je),nr=T(He),or=T(J),ir=y;(Ge&&ir(new Ge(new ArrayBuffer(1)))!=Ze||ie&&ir(new ie)!=Ke||Je&&ir(Je.resolve())!=Qe||He&&ir(new He)!=Xe||J&&ir(new J)!=Ye)&&(ir=function(t){var e=y(t),r="[object Object]"==e?t.constructor:void 0,n=r?T(r):"";if(n)switch(n){case tr:return Ze;case er:return Ke;case rr:return Qe;case nr:return Xe;case or:return Ye}return e});var ur=ir,cr=Object.prototype.hasOwnProperty;var ar=c.Uint8Array;function fr(t){var e=new t.constructor(t.byteLength);return new ar(e).set(new ar(t)),e}var sr=/\w*$/;var lr=a?a.prototype:void 0,pr=lr?lr.valueOf:void 0;function vr(t,e){var r=e?fr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var hr="[object Boolean]",gr="[object Date]",br="[object Map]",yr="[object Number]",dr="[object RegExp]",jr="[object Set]",_r="[object String]",wr="[object Symbol]",mr="[object ArrayBuffer]",Or="[object DataView]",Cr="[object Float32Array]",Ar="[object Float64Array]",Fr="[object Int8Array]",xr="[object Int16Array]",Sr="[object Int32Array]",Pr="[object Uint8Array]",zr="[object Uint8ClampedArray]",Ur="[object Uint16Array]",Mr="[object Uint32Array]";function kr(t,e,r){var n,o,i,u=t.constructor;switch(e){case mr:return fr(t);case hr:case gr:return new u(+t);case Or:return function(t,e){var r=e?fr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case Cr:case Ar:case Fr:case xr:case Sr:case Pr:case zr:case Ur:case Mr:return vr(t,r);case br:return new u;case yr:case _r:return new u(t);case dr:return(i=new(o=t).constructor(o.source,sr.exec(o))).lastIndex=o.lastIndex,i;case jr:return new u;case wr:return n=t,pr?Object(pr.call(n)):{}}}function Er(t){return"function"!=typeof t.constructor||wt(t)?{}:K(Ce(t))}var Ir=Bt&&Bt.isMap,Br=Ir?Mt(Ir):function(t){return d(t)&&"[object Map]"==ur(t)};var Dr=Bt&&Bt.isSet,Tr=Dr?Mt(Dr):function(t){return d(t)&&"[object Set]"==ur(t)},$r=1,qr=2,Lr=4,Vr="[object Arguments]",Nr="[object Function]",Rr="[object GeneratorFunction]",Wr="[object Object]",Gr={};function Jr(t,e,r,n,o,i){var u,c=e&$r,a=e&qr,f=e&Lr;if(r&&(u=o?r(t,n,o,i):r(t)),void 0!==u)return u;if(!x(t))return t;var s=m(t);if(s){if(u=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&cr.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!c)return Q(t,u)}else{var l=ur(t),p=l==Nr||l==Rr;if(zt(t))return De(t,c);if(l==Wr||l==Vr||p&&!o){if(u=a||p?{}:Er(t),!c)return a?function(t,e){return vt(t,Ve(t),e)}(t,function(t,e){return t&&vt(e,Ht(e),t)}(u,t)):function(t,e){return vt(t,Le(t),e)}(t,function(t,e){return t&&vt(e,Wt(e),t)}(u,t))}else{if(!Gr[l])return o?t:{};u=kr(t,l,c)}}i||(i=new Me);var v=i.get(t);if(v)return v;i.set(t,u),Tr(t)?t.forEach((function(n){u.add(Jr(n,e,r,n,t,i))})):Br(t)&&t.forEach((function(n,o){u.set(o,Jr(n,e,r,o,t,i))}));var h=s?void 0:(f?a?We:Re:a?Ht:Wt)(t);return function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););}(h||t,(function(n,o){h&&(n=t[o=n]),pt(u,o,Jr(n,e,r,o,t,i))})),u}Gr[Vr]=Gr["[object Array]"]=Gr["[object ArrayBuffer]"]=Gr["[object DataView]"]=Gr["[object Boolean]"]=Gr["[object Date]"]=Gr["[object Float32Array]"]=Gr["[object Float64Array]"]=Gr["[object Int8Array]"]=Gr["[object Int16Array]"]=Gr["[object Int32Array]"]=Gr["[object Map]"]=Gr["[object Number]"]=Gr[Wr]=Gr["[object RegExp]"]=Gr["[object Set]"]=Gr["[object String]"]=Gr["[object Symbol]"]=Gr["[object Uint8Array]"]=Gr["[object Uint8ClampedArray]"]=Gr["[object Uint16Array]"]=Gr["[object Uint32Array]"]=!0,Gr["[object Error]"]=Gr[Nr]=Gr["[object WeakMap]"]=!1;function Hr(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new ce;++e<r;)this.add(t[e])}function Kr(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function Qr(t,e){return t.has(e)}Hr.prototype.add=Hr.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Hr.prototype.has=function(t){return this.__data__.has(t)};var Xr=1,Yr=2;function Zr(t,e,r,n,o,i){var u=r&Xr,c=t.length,a=e.length;if(c!=a&&!(u&&a>c))return!1;var f=i.get(t),s=i.get(e);if(f&&s)return f==e&&s==t;var l=-1,p=!0,v=r&Yr?new Hr:void 0;for(i.set(t,e),i.set(e,t);++l<c;){var h=t[l],g=e[l];if(n)var b=u?n(g,h,l,e,t,i):n(h,g,l,t,e,i);if(void 0!==b){if(b)continue;p=!1;break}if(v){if(!Kr(e,(function(t,e){if(!Qr(v,e)&&(h===t||o(h,t,r,n,i)))return v.push(e)}))){p=!1;break}}else if(h!==g&&!o(h,g,r,n,i)){p=!1;break}}return i.delete(t),i.delete(e),p}function tn(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function en(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var rn=1,nn=2,on="[object Boolean]",un="[object Date]",cn="[object Error]",an="[object Map]",fn="[object Number]",sn="[object RegExp]",ln="[object Set]",pn="[object String]",vn="[object Symbol]",hn="[object ArrayBuffer]",gn="[object DataView]",bn=a?a.prototype:void 0,yn=bn?bn.valueOf:void 0;var dn=1,jn=Object.prototype.hasOwnProperty;var _n=1,wn="[object Arguments]",mn="[object Array]",On="[object Object]",Cn=Object.prototype.hasOwnProperty;function An(t,e,r,n,o,i){var u=m(t),c=m(e),a=u?mn:ur(t),f=c?mn:ur(e),s=(a=a==wn?On:a)==On,l=(f=f==wn?On:f)==On,p=a==f;if(p&&zt(t)){if(!zt(e))return!1;u=!0,s=!1}if(p&&!s)return i||(i=new Me),u||Tt(t)?Zr(t,e,r,n,o,i):function(t,e,r,n,o,i,u){switch(r){case gn:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case hn:return!(t.byteLength!=e.byteLength||!i(new ar(t),new ar(e)));case on:case un:case fn:return st(+t,+e);case cn:return t.name==e.name&&t.message==e.message;case sn:case pn:return t==e+"";case an:var c=tn;case ln:var a=n&rn;if(c||(c=en),t.size!=e.size&&!a)return!1;var f=u.get(t);if(f)return f==e;n|=nn,u.set(t,e);var s=Zr(c(t),c(e),n,o,i,u);return u.delete(t),s;case vn:if(yn)return yn.call(t)==yn.call(e)}return!1}(t,e,a,r,n,o,i);if(!(r&_n)){var v=s&&Cn.call(t,"__wrapped__"),h=l&&Cn.call(e,"__wrapped__");if(v||h){var g=v?t.value():t,b=h?e.value():e;return i||(i=new Me),o(g,b,r,n,i)}}return!!p&&(i||(i=new Me),function(t,e,r,n,o,i){var u=r&dn,c=Re(t),a=c.length;if(a!=Re(e).length&&!u)return!1;for(var f=a;f--;){var s=c[f];if(!(u?s in e:jn.call(e,s)))return!1}var l=i.get(t),p=i.get(e);if(l&&p)return l==e&&p==t;var v=!0;i.set(t,e),i.set(e,t);for(var h=u;++f<a;){var g=t[s=c[f]],b=e[s];if(n)var y=u?n(b,g,s,e,t,i):n(g,b,s,t,e,i);if(!(void 0===y?g===b||o(g,b,r,n,i):y)){v=!1;break}h||(h="constructor"==s)}if(v&&!h){var d=t.constructor,j=e.constructor;d==j||!("constructor"in t)||!("constructor"in e)||"function"==typeof d&&d instanceof d&&"function"==typeof j&&j instanceof j||(v=!1)}return i.delete(t),i.delete(e),v}(t,e,r,n,o,i))}function Fn(t,e,r,n,o){return t===e||(null==t||null==e||!d(t)&&!d(e)?t!=t&&e!=e:An(t,e,r,n,Fn,o))}var xn=1,Sn=2;function Pn(t){return t==t&&!x(t)}function zn(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function Un(t){var e=function(t){for(var e=Wt(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,Pn(o)]}return e}(t);return 1==e.length&&e[0][2]?zn(e[0][0],e[0][1]):function(r){return r===t||function(t,e,r,n){var o=r.length,i=o,u=!n;if(null==t)return!i;for(t=Object(t);o--;){var c=r[o];if(u&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++o<i;){var a=(c=r[o])[0],f=t[a],s=c[1];if(u&&c[2]){if(void 0===f&&!(a in t))return!1}else{var l=new Me;if(n)var p=n(f,s,a,t,e,l);if(!(void 0===p?Fn(s,f,xn|Sn,n,l):p))return!1}}return!0}(r,t,e)}}function Mn(t,e){return null!=t&&e in Object(t)}function kn(t,e,r){for(var n=-1,o=(e=ve(e,t)).length,i=!1;++n<o;){var u=ge(e[n]);if(!(i=null!=t&&r(t,u)))break;t=t[u]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&dt(o)&&at(u,o)&&(m(t)||Ft(t))}function En(t,e){return null!=t&&kn(t,e,Mn)}var In=1,Bn=2;function Dn(t){return Xt(t)?(e=ge(t),function(t){return null==t?void 0:t[e]}):function(t){return function(e){return be(e,t)}}(t);var e}function Tn(t){return"function"==typeof t?t:null==t?S:"object"==typeof t?m(t)?function(t,e){return Xt(t)&&Pn(e)?zn(ge(t),e):function(r){var n=ye(r,t);return void 0===n&&n===e?En(r,t):Fn(e,n,In|Bn)}}(t[0],t[1]):Un(t):Dn(t)}function $n(t,e,r,n){for(var o=-1,i=null==t?0:t.length;++o<i;){var u=t[o];e(n,u,r(u),t)}return n}var qn,Ln=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),u=i.length;u--;){var c=i[qn?u:++n];if(!1===e(o[c],c,o))break}return t};function Vn(t,e){return t&&Ln(t,e,Wt)}var Nn=function(t,e){return function(r,n){if(null==r)return r;if(!jt(r))return t(r,n);for(var o=r.length,i=e?o:-1,u=Object(r);(e?i--:++i<o)&&!1!==n(u[i],i,u););return r}}(Vn);function Rn(t,e,r,n){return Nn(t,(function(t,o,i){e(n,t,r(t),i)})),n}function Wn(t,e,r){(void 0!==r&&!st(t[e],r)||void 0===r&&!(e in t))&&ft(t,e,r)}function Gn(t){return d(t)&&jt(t)}function Jn(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Hn(t,e,r,n,o,i,u){var c=Jn(t,r),a=Jn(e,r),f=u.get(a);if(f)Wn(t,r,f);else{var s,l=i?i(c,a,r+"",t,e,u):void 0,p=void 0===l;if(p){var v=m(a),h=!v&&zt(a),g=!v&&!h&&Tt(a);l=a,v||h||g?m(c)?l=c:Gn(c)?l=Q(c):h?(p=!1,l=De(a,!0)):g?(p=!1,l=vr(a,!0)):l=[]:Ue(a)||Ft(a)?(l=c,Ft(c)?l=vt(s=c,Ht(s)):x(c)&&!k(c)||(l=Er(a))):p=!1}p&&(u.set(a,l),o(l,a,n,i,u),u.delete(a)),Wn(t,r,l)}}function Kn(t,e,r,n,o){t!==e&&Ln(e,(function(i,u){if(o||(o=new Me),x(i))Hn(t,e,u,r,Kn,n,o);else{var c=n?n(Jn(t,u),i,u+"",t,e,o):void 0;void 0===c&&(c=i),Wn(t,u,c)}}),Ht)}var Qn,Xn=(Qn=function(t,e,r,n){Kn(t,e,r,n)},bt((function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Qn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!x(r))return!1;var n=typeof e;return!!("number"==n?jt(r)&&at(e,r.length):"string"==n&&e in r)&&st(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var u=e[r];u&&Qn(t,u,r,o)}return t})));function Yn(t,e,r){for(var n=-1,o=null==t?0:t.length;++n<o;)if(r(e,t[n]))return!0;return!1}var Zn=Object.prototype.hasOwnProperty;function to(t,e){return null!=t&&Zn.call(t,e)}function eo(t,e){return e.length<2?t:be(t,function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n<o;)i[n]=t[n+e];return i}(e,0,-1))}var ro=Object.prototype.hasOwnProperty;var no,oo,io=(no=function(t,e,r){ft(t,r,e)},function(t,e){var r=m(t)?$n:Rn,n=oo?oo():{};return r(t,no,Tn(e),n)});function uo(t,e){return null==(t=eo(t,e=ve(e,t)))||delete t[ge((r=e,n=null==r?0:r.length,n?r[n-1]:void 0))];var r,n}function co(t){return Ue(t)?void 0:t}var ao=Oe((function(t,e){var r={};if(null==t)return r;var n=!1;e=w(e,(function(e){return e=ve(e,t),n||(n=e.length>1),e})),vt(t,We(t),r),n&&(r=Jr(r,7,co));for(var o=e.length;o--;)uo(r,e[o]);return r}));function fo(t,e,r,n){if(!x(t))return t;for(var o=-1,i=(e=ve(e,t)).length,u=i-1,c=t;null!=c&&++o<i;){var a=ge(e[o]),f=r;if("__proto__"===a||"constructor"===a||"prototype"===a)return t;if(o!=u){var s=c[a];void 0===(f=n?n(s,a,c):void 0)&&(f=x(s)?s:at(e[o+1])?[]:{})}pt(c,a,f),c=c[a]}return t}function so(t,e){return function(t,e,r){for(var n=-1,o=e.length,i={};++n<o;){var u=e[n],c=be(t,u);r(c,u)&&fo(i,ve(u,t),c)}return i}(t,e,(function(e,r){return En(t,r)}))}var lo=Oe((function(t,e){return null==t?{}:so(t,e)})),po=He&&1/en(new He([,-0]))[1]==1/0?function(t){return new He(t)}:function(){};var vo=bt((function(t){return function(t,e,r){var n=-1,o=it,i=t.length,u=!0,c=[],a=c;if(r)u=!1,o=Yn;else if(i>=200){var f=e?null:po(t);if(f)return en(f);u=!1,o=Qr,a=new Hr}else a=e?[]:c;t:for(;++n<i;){var s=t[n],l=e?e(s):s;if(s=r||0!==s?s:0,u&&l==l){for(var p=a.length;p--;)if(a[p]===l)continue t;e&&a.push(l),c.push(s)}else o(a,l,r)||(a!==c&&a.push(l),c.push(s))}return c}(we(t,1,Gn,!0))}));const ho=["config/config.ts","config/config.js","config.ts","config.js"],go=["routes","microServiceMap","setting","define","optimization","provide"];class bo{opts;mainConfigFile;configFiles=[];constructor(t){const e=t.defaultConfigFiles?t.defaultConfigFiles:ho;this.mainConfigFile=bo.getMainConfigFile({cwd:t.cwd,defaultConfigFiles:e}),this.opts={...t,defaultConfigFiles:e}}getMsPagesUserConfig(t){let e={};return("string"==typeof t?[t]:t).map((t=>{const n=bo.getMainConfigFile({cwd:t,defaultConfigFiles:this.opts.defaultConfigFiles}),o=bo.getUserConfig({cwd:t,mainConfigFile:n});e=r.mergeConfig(e,lo(o,go))})),e}getMsUserConfig(){this.configFiles=[];let e=bo.getUserConfig({cwd:this.opts.cwd,mainConfigFile:this.mainConfigFile});this.mainConfigFile&&this.configFiles.push(this.mainConfigFile);const o=[this.opts.cwd],i=r.getSrcPath();ye(e,"mfa.pages",[]);const u=ye(e,"alias",{}),c=ye(e,"packages",{}),a={"@gant":t.resolve(this.opts.cwd,i,".gant"),"@@":t.resolve(this.opts.cwd),...u};let f={context:this.opts.cwd,publicPathDir:t.resolve(this.opts.cwd,i,".gant"),resolve:{alias:a}};return Ue(c)&&Object.keys(c).map((t=>{const e=c[t];if(o.includes(e))return;o.push(e);const n=bo.getMainConfigFile({cwd:e,defaultConfigFiles:this.opts.defaultConfigFiles});n&&this.configFiles.push(n);const i=bo.getUserConfig({cwd:e,mainConfigFile:n});f=r.mergeConfig(f,lo(i,go))})),{...r.mergeConfig(r.mergeConfig(n.defineConfig(),f),e)}}getUserConfig(){this.configFiles=[];let e=bo.getUserConfig({cwd:this.opts.cwd,mainConfigFile:this.mainConfigFile});this.mainConfigFile&&this.configFiles.push(this.mainConfigFile);const o=[this.opts.cwd],i=ye(e,"packages",{}),u=r.getSrcPath(),c={"@gant":t.resolve(this.opts.cwd,u,".gant"),[e.name||"@@"]:t.resolve(this.opts.cwd),...i};let a={context:this.opts.cwd,resolve:{alias:c}};return Ue(i)&&Object.keys(i).map((t=>{const e=i[t];if(o.includes(e))return;o.push(e);const n=bo.getMainConfigFile({cwd:e,defaultConfigFiles:this.opts.defaultConfigFiles});n&&this.configFiles.push(n);const u=bo.getUserConfig({cwd:e,mainConfigFile:n});a=r.mergeConfig(a,lo(u,go))})),{...r.mergeConfig(r.mergeConfig(n.defineConfig(),a),e)}}static getMainConfigFile(r){let n=null;for(const o of r.defaultConfigFiles||ho){const i=t.join(r.cwd,o);if(e.existsSync(i)){n=i;break}}return n}static getUserConfig(t){let e={};if(!t.mainConfigFile)return e;try{e=o.getJavascriptfile(r.getAbsFile(t.mainConfigFile,t.cwd))}catch(t){console.log("getUserConfig Error :",t)}return e}}exports.Config=bo,exports.cloneDeep=function(t){return Jr(t,5)},exports.get=ye,exports.has=function(t,e){return null!=t&&kn(t,e,to)},exports.isArray=m,exports.isEmpty=function(t){if(null==t)return!0;if(jt(t)&&(m(t)||"string"==typeof t||"function"==typeof t.splice||zt(t)||Tt(t)||Ft(t)))return!t.length;var e=ur(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(wt(t))return!Rt(t).length;for(var r in t)if(ro.call(t,r))return!1;return!0},exports.isNull=function(t){return null===t},exports.isObject=x,exports.isUndefined=function(t){return void 0===t},exports.keyBy=io,exports.keys=Wt,exports.mapValues=function(t,e){var r={};return e=Tn(e),Vn(t,(function(t,n,o){ft(r,n,e(t,n,o))})),r},exports.mergeWith=Xn,exports.omit=ao,exports.pick=lo,exports.union=vo,exports.values=function(t){return null==t?[]:function(t,e){return w(e,(function(e){return t[e]}))}(t,Wt(t))};
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
*
|
|
8
8
|
* MIT Licensed
|
|
9
9
|
*/
|
|
10
|
-
const CA=v,xA=y,FA=l,PA=function(){var e;return e=jA?process.env.TEMP||process.env.TMP||(process.env.SystemRoot||process.env.windir)+"\\temp":process.env.TMPDIR||process.env.TMP||process.env.TEMP||"/tmp",SA.test(e)&&(e=e.slice(0,-1)),e},AA=process.binding("constants"),BA=PA(),MA="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",TA=/XXXXXX/,kA=3,RA=(AA.O_CREAT||AA.fs.O_CREAT)|(AA.O_EXCL||AA.fs.O_EXCL)|(AA.O_RDWR||AA.fs.O_RDWR),IA=AA.EBADF||AA.os.errno.EBADF,LA=AA.ENOENT||AA.os.errno.ENOENT,NA=[];var UA=!1,GA=!1;function WA(e){var t=[],r=null;try{r=FA.randomBytes(e)}catch(t){r=FA.pseudoRandomBytes(e)}for(var n=0;n<e;n++)t.push(MA[r[n]%MA.length]);return t.join("")}function qA(e){return void 0===e}function VA(e,t){return"function"==typeof e?[t||{},e]:qA(e)?[{},t]:[e,t]}function zA(e){if(e.name)return xA.join(e.dir||BA,e.name);if(e.template)return e.template.replace(TA,WA(6));const t=[e.prefix||"tmp-",process.pid,WA(12),e.postfix||""].join("");return xA.join(e.dir||BA,t)}function $A(e,t){var r=VA(e,t),n=r[0],o=r[1],i=n.name?1:n.tries||kA;return isNaN(i)||i<0?o(new Error("Invalid tries")):n.template&&!n.template.match(TA)?o(new Error("Invalid template provided")):void function e(){const t=zA(n);CA.stat(t,(function(r){if(!r)return i-- >0?e():o(new Error("Could not get a unique tmp filename, max tries reached "+t));o(null,t)}))}()}function KA(e){var t=VA(e)[0],r=t.name?1:t.tries||kA;if(isNaN(r)||r<0)throw new Error("Invalid tries");if(t.template&&!t.template.match(TA))throw new Error("Invalid template provided");do{const e=zA(t);try{CA.statSync(e)}catch(t){return e}}while(r-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function YA(e){const t=[e];do{for(var r=t.pop(),n=!1,o=CA.readdirSync(r),i=0,a=o.length;i<a;i++){var u=xA.join(r,o[i]);CA.lstatSync(u).isDirectory()?(n||(n=!0,t.push(r)),t.push(u)):CA.unlinkSync(u)}n||CA.rmdirSync(r)}while(0!==t.length)}function HA(e,t,r){const n=QA((function(e){try{0<=e[0]&&CA.closeSync(e[0])}catch(e){if(!(t=e,eB(t,-IA,"EBADF")||ZA(e)))throw e}var t;try{CA.unlinkSync(e[1])}catch(e){if(!ZA(e))throw e}}),[t,e]);return r.keep||NA.unshift(n),n}function JA(e,t){const r=QA(t.unsafeCleanup?YA:CA.rmdirSync.bind(CA),e);return t.keep||NA.unshift(r),r}function QA(e,t){var r=!1;return function n(o){if(!r){const o=NA.indexOf(n);o>=0&&NA.splice(o,1),r=!0,e(t)}o&&o(null)}}function XA(){if(!GA||UA)for(;NA.length;)try{NA[0].call(null)}catch(e){}}function ZA(e){return eB(e,-LA,"ENOENT")}function eB(e,t,r){return e.code==t||e.code==r}const tB=process.versions.node.split(".").map((function(e){return parseInt(e,10)}));0===tB[0]&&(tB[1]<9||9===tB[1]&&tB[2]<5)&&process.addListener("uncaughtException",(function(e){throw GA=!0,XA(),e})),process.addListener("exit",(function(e){e&&(GA=!0),XA()})),EA.tmpdir=BA,EA.dir=function(e,t){var r=VA(e,t),n=r[0],o=r[1];$A(n,(function(e,t){if(e)return o(e);CA.mkdir(t,n.mode||448,(function(e){if(e)return o(e);o(null,t,JA(t,n))}))}))},EA.dirSync=function(e){var t=VA(e)[0];const r=KA(t);return CA.mkdirSync(r,t.mode||448),{name:r,removeCallback:JA(r,t)}},EA.file=function(e,t){var r=VA(e,t),n=r[0],o=r[1];n.postfix=qA(n.postfix)?".tmp":n.postfix,$A(n,(function(e,t){if(e)return o(e);CA.open(t,RA,n.mode||384,(function(e,r){return e?o(e):n.discardDescriptor?CA.close(r,(function(e){if(e){try{CA.unlinkSync(t)}catch(t){ZA(t)||(e=t)}return o(e)}o(null,t,void 0,HA(t,-1,n))})):n.detachDescriptor?o(null,t,r,HA(t,-1,n)):void o(null,t,r,HA(t,r,n))}))}))},EA.fileSync=function(e){var t=VA(e)[0];t.postfix=t.postfix||".tmp";const r=t.discardDescriptor||t.detachDescriptor,n=KA(t);var o=CA.openSync(n,RA,t.mode||384);return t.discardDescriptor&&(CA.closeSync(o),o=void 0),{name:n,fd:o,removeCallback:HA(n,r?-1:o,t)}},EA.tmpName=$A,EA.tmpNameSync=KA,EA.setGracefulCleanup=function(){UA=!0};var rB={},nB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(rB,"__esModule",{value:!0});var oB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed to create temporary file for editor")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return nB(t,e),t}(Error);rB.CreateFileError=oB;var iB={},aB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(iB,"__esModule",{value:!0});var uB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed launch editor")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return aB(t,e),t}(Error);iB.LaunchEditorError=uB;var sB={},cB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(sB,"__esModule",{value:!0});var lB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed to read temporary file")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return cB(t,e),t}(Error);sB.ReadFileError=lB;var fB={},pB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(fB,"__esModule",{value:!0});var dB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed to cleanup temporary file")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return pB(t,e),t}(Error);fB.RemoveFileError=dB,Object.defineProperty(dP,"__esModule",{value:!0});var hB=hP,bB=s,vB=v,yB=OA,mB=EA,gB=rB;dP.CreateFileError=gB.CreateFileError;var DB=iB;dP.LaunchEditorError=DB.LaunchEditorError;var _B=sB;dP.ReadFileError=_B.ReadFileError;var wB=fB;dP.RemoveFileError=wB.RemoveFileError,dP.edit=function(e,t){void 0===e&&(e="");var r=new EB(e,t);return r.run(),r.cleanup(),r.text};var OB=dP.editAsync=function(e,t,r){void 0===e&&(e="");var n=new EB(e,r);n.runAsync((function(e,r){if(e)setImmediate(t,e,null);else try{n.cleanup(),setImmediate(t,null,r)}catch(e){setImmediate(t,e,null)}}))},EB=function(){function e(e,t){void 0===e&&(e=""),this.text="",this.fileOptions={},this.text=e,t&&(this.fileOptions=t),this.determineEditor(),this.createTemporaryFile()}return e.splitStringBySpace=function(e){for(var t=[],r="",n=0;n<e.length;n++){var o=e[n];n>0&&" "===o&&"\\"!==e[n-1]&&r.length>0?(t.push(r),r=""):r+=o}return r.length>0&&t.push(r),t},Object.defineProperty(e.prototype,"temp_file",{get:function(){return console.log("DEPRECATED: temp_file. Use tempFile moving forward."),this.tempFile},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"last_exit_status",{get:function(){return console.log("DEPRECATED: last_exit_status. Use lastExitStatus moving forward."),this.lastExitStatus},enumerable:!0,configurable:!0}),e.prototype.run=function(){return this.launchEditor(),this.readTemporaryFile(),this.text},e.prototype.runAsync=function(e){var t=this;try{this.launchEditorAsync((function(){try{t.readTemporaryFile(),setImmediate(e,null,t.text)}catch(t){setImmediate(e,t,null)}}))}catch(t){setImmediate(e,t,null)}},e.prototype.cleanup=function(){this.removeTemporaryFile()},e.prototype.determineEditor=function(){var t=process.env.VISUAL?process.env.VISUAL:process.env.EDITOR?process.env.EDITOR:/^win/.test(process.platform)?"notepad":"vim",r=e.splitStringBySpace(t).map((function(e){return e.replace("\\ "," ")})),n=r.shift();this.editor={args:r,bin:n}},e.prototype.createTemporaryFile=function(){try{this.tempFile=mB.tmpNameSync(this.fileOptions);var e={encoding:"utf8"};this.fileOptions.hasOwnProperty("mode")&&(e.mode=this.fileOptions.mode),vB.writeFileSync(this.tempFile,this.text,e)}catch(e){throw new gB.CreateFileError(e)}},e.prototype.readTemporaryFile=function(){try{var e=vB.readFileSync(this.tempFile);if(0===e.length)this.text="";else{var t=hB.detect(e).toString();yB.encodingExists(t)||(t="utf8"),this.text=yB.decode(e,t)}}catch(e){throw new _B.ReadFileError(e)}},e.prototype.removeTemporaryFile=function(){try{vB.unlinkSync(this.tempFile)}catch(e){throw new wB.RemoveFileError(e)}},e.prototype.launchEditor=function(){try{var e=bB.spawnSync(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=e.status}catch(e){throw new DB.LaunchEditorError(e)}},e.prototype.launchEditorAsync=function(e){var t=this;try{bB.spawn(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",(function(r){t.lastExitStatus=r,setImmediate(e)}))}catch(e){throw new DB.LaunchEditorError(e)}},e}();dP.ExternalEditor=EB;class jB extends nP{_run(e){this.done=e,this.editorResult=new Te.Subject;const t=Jv(this.rl);this.lineSubscription=t.line.subscribe(this.startExternalEditor.bind(this));void 0===this.opt.waitUserInput||this.opt.waitUserInput||this.startExternalEditor();const r=this.handleSubmitEvents(this.editorResult);return r.success.forEach(this.onEnd.bind(this)),r.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,this.render(),this}render(e){let t="",r=this.getQuestion();"answered"===this.status?r+=K.dim("Received"):r+=K.dim("Press <enter> to launch your preferred editor."),e&&(t=K.red(">> ")+e),this.screen.render(r,t)}startExternalEditor(){this.rl.pause(),OB(this.currentText,this.endExternalEditor.bind(this),{postfix:this.opt.postfix??".txt"})}endExternalEditor(e,t){this.rl.resume(),e?this.editorResult.error(e):this.editorResult.next(t)}onEnd(e){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=e.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(e){this.render(e.isValid)}}var SB,CB={exports:{}},xB=Object.prototype.toString,FB=Math.max,PB=function(e,t){for(var r=[],n=0;n<e.length;n+=1)r[n]=e[n];for(var o=0;o<t.length;o+=1)r[o+e.length]=t[o];return r},AB=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==xB.apply(t))throw new TypeError("Function.prototype.bind called on incompatible "+t);for(var r,n=function(e,t){for(var r=[],n=t||0,o=0;n<e.length;n+=1,o+=1)r[o]=e[n];return r}(arguments,1),o=FB(0,t.length-n.length),i=[],a=0;a<o;a++)i[a]="$"+a;if(r=Function("binder","return function ("+function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r}(i,",")+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof r){var o=t.apply(this,PB(n,arguments));return Object(o)===o?o:this}return t.apply(e,PB(n,arguments))})),t.prototype){var u=function(){};u.prototype=t.prototype,r.prototype=new u,u.prototype=null}return r},BB=Function.prototype.bind||AB,MB=Error,TB=EvalError,kB=RangeError,RB=ReferenceError,IB=SyntaxError,LB=TypeError,NB=URIError,UB="undefined"!=typeof Symbol&&Symbol,GB=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||!0!==o.enumerable)return!1}return!0},WB={__proto__:null,foo:{}},qB=Object,VB=Function.prototype.call,zB=Object.prototype.hasOwnProperty,$B=BB.call(VB,zB),KB=MB,YB=TB,HB=kB,JB=RB,QB=IB,XB=LB,ZB=NB,eM=Function,tM=function(e){try{return eM('"use strict"; return ('+e+").constructor;")()}catch(e){}},rM=Object.getOwnPropertyDescriptor;if(rM)try{rM({},"")}catch(e){rM=null}var nM=function(){throw new XB},oM=rM?function(){try{return nM}catch(e){try{return rM(arguments,"callee").get}catch(e){return nM}}}():nM,iM="function"==typeof UB&&"function"==typeof Symbol&&"symbol"==typeof UB("foo")&&"symbol"==typeof Symbol("bar")&&GB(),aM={__proto__:WB}.foo===WB.foo&&!(WB instanceof qB),uM=Object.getPrototypeOf||(aM?function(e){return e.__proto__}:null),sM={},cM="undefined"!=typeof Uint8Array&&uM?uM(Uint8Array):SB,lM={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?SB:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?SB:ArrayBuffer,"%ArrayIteratorPrototype%":iM&&uM?uM([][Symbol.iterator]()):SB,"%AsyncFromSyncIteratorPrototype%":SB,"%AsyncFunction%":sM,"%AsyncGenerator%":sM,"%AsyncGeneratorFunction%":sM,"%AsyncIteratorPrototype%":sM,"%Atomics%":"undefined"==typeof Atomics?SB:Atomics,"%BigInt%":"undefined"==typeof BigInt?SB:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?SB:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?SB:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?SB:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":KB,"%eval%":eval,"%EvalError%":YB,"%Float32Array%":"undefined"==typeof Float32Array?SB:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?SB:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?SB:FinalizationRegistry,"%Function%":eM,"%GeneratorFunction%":sM,"%Int8Array%":"undefined"==typeof Int8Array?SB:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?SB:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?SB:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":iM&&uM?uM(uM([][Symbol.iterator]())):SB,"%JSON%":"object"==typeof JSON?JSON:SB,"%Map%":"undefined"==typeof Map?SB:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&iM&&uM?uM((new Map)[Symbol.iterator]()):SB,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?SB:Promise,"%Proxy%":"undefined"==typeof Proxy?SB:Proxy,"%RangeError%":HB,"%ReferenceError%":JB,"%Reflect%":"undefined"==typeof Reflect?SB:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?SB:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&iM&&uM?uM((new Set)[Symbol.iterator]()):SB,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?SB:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":iM&&uM?uM(""[Symbol.iterator]()):SB,"%Symbol%":iM?Symbol:SB,"%SyntaxError%":QB,"%ThrowTypeError%":oM,"%TypedArray%":cM,"%TypeError%":XB,"%Uint8Array%":"undefined"==typeof Uint8Array?SB:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?SB:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?SB:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?SB:Uint32Array,"%URIError%":ZB,"%WeakMap%":"undefined"==typeof WeakMap?SB:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?SB:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?SB:WeakSet};if(uM)try{null.error}catch(e){var fM=uM(uM(e));lM["%Error.prototype%"]=fM}var pM,dM,hM=function e(t){var r;if("%AsyncFunction%"===t)r=tM("async function () {}");else if("%GeneratorFunction%"===t)r=tM("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=tM("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var o=e("%AsyncGenerator%");o&&uM&&(r=uM(o.prototype))}return lM[t]=r,r},bM={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},vM=BB,yM=$B,mM=vM.call(Function.call,Array.prototype.concat),gM=vM.call(Function.apply,Array.prototype.splice),DM=vM.call(Function.call,String.prototype.replace),_M=vM.call(Function.call,String.prototype.slice),wM=vM.call(Function.call,RegExp.prototype.exec),OM=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,EM=/\\(\\)?/g,jM=function(e,t){var r,n=e;if(yM(bM,n)&&(n="%"+(r=bM[n])[0]+"%"),yM(lM,n)){var o=lM[n];if(o===sM&&(o=hM(n)),void 0===o&&!t)throw new XB("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:o}}throw new QB("intrinsic "+e+" does not exist!")},SM=function(e,t){if("string"!=typeof e||0===e.length)throw new XB("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new XB('"allowMissing" argument must be a boolean');if(null===wM(/^%?[^%]*%?$/,e))throw new QB("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(e){var t=_M(e,0,1),r=_M(e,-1);if("%"===t&&"%"!==r)throw new QB("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new QB("invalid intrinsic syntax, expected opening `%`");var n=[];return DM(e,OM,(function(e,t,r,o){n[n.length]=r?DM(o,EM,"$1"):t||e})),n}(e),n=r.length>0?r[0]:"",o=jM("%"+n+"%",t),i=o.name,a=o.value,u=!1,s=o.alias;s&&(n=s[0],gM(r,mM([0,1],s)));for(var c=1,l=!0;c<r.length;c+=1){var f=r[c],p=_M(f,0,1),d=_M(f,-1);if(('"'===p||"'"===p||"`"===p||'"'===d||"'"===d||"`"===d)&&p!==d)throw new QB("property names with quotes must have matching quotes");if("constructor"!==f&&l||(u=!0),yM(lM,i="%"+(n+="."+f)+"%"))a=lM[i];else if(null!=a){if(!(f in a)){if(!t)throw new XB("base intrinsic for "+e+" exists, but the property is not available.");return}if(rM&&c+1>=r.length){var h=rM(a,f);a=(l=!!h)&&"get"in h&&!("originalValue"in h.get)?h.get:a[f]}else l=yM(a,f),a=a[f];l&&!u&&(lM[i]=a)}}return a};function CM(){if(dM)return pM;dM=1;var e=SM("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch(t){e=!1}return pM=e}var xM=SM("%Object.getOwnPropertyDescriptor%",!0);if(xM)try{xM([],"length")}catch(e){xM=null}var FM=xM,PM=CM(),AM=IB,BM=LB,MM=FM,TM=CM(),kM=function(){return!!TM};kM.hasArrayLengthDefineBug=function(){if(!TM)return null;try{return 1!==TM([],"length",{value:1}).length}catch(e){return!0}};var RM=SM,IM=function(e,t,r){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new BM("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new BM("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new BM("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new BM("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new BM("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new BM("`loose`, if provided, must be a boolean");var n=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,i=arguments.length>5?arguments[5]:null,a=arguments.length>6&&arguments[6],u=!!MM&&MM(e,t);if(PM)PM(e,t,{configurable:null===i&&u?u.configurable:!i,enumerable:null===n&&u?u.enumerable:!n,value:r,writable:null===o&&u?u.writable:!o});else{if(!a&&(n||o||i))throw new AM("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=r}},LM=kM(),NM=FM,UM=LB,GM=RM("%Math.floor%"),WM=function(e,t){if("function"!=typeof e)throw new UM("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||GM(t)!==t)throw new UM("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],n=!0,o=!0;if("length"in e&&NM){var i=NM(e,"length");i&&!i.configurable&&(n=!1),i&&!i.writable&&(o=!1)}return(n||o||!r)&&(LM?IM(e,"length",t,!0,!0):IM(e,"length",t)),e};!function(e){var t=BB,r=SM,n=WM,o=LB,i=r("%Function.prototype.apply%"),a=r("%Function.prototype.call%"),u=r("%Reflect.apply%",!0)||t.call(a,i),s=CM(),c=r("%Math.max%");e.exports=function(e){if("function"!=typeof e)throw new o("a function is required");var r=u(t,a,arguments);return n(r,1+c(0,e.length-(arguments.length-1)),!0)};var l=function(){return u(t,i,arguments)};s?s(e.exports,"apply",{value:l}):e.exports.apply=l}(CB);var qM=CB.exports,VM=i.Stream,zM=qM;function $M(e,t,r){var n=zM(e||function(e){this.queue(e)}),o=zM(t||function(){this.queue(null)}),i=!1,a=!1,u=[],s=!1,c=new VM;function l(){for(;u.length&&!c.paused;){var e=u.shift();if(null===e)return c.emit("end");c.emit("data",e)}}return c.readable=!0,c.writable=!0,c.paused=!1,c.autoDestroy=!(r&&!1===r.autoDestroy),c.write=function(e){return n(this,e),!c.paused},c.queue=function(e){return s||(null===e&&(s=!0),u.push(e),l()),c},c.push=c.queue,c.on("end",(function(){c.readable=!1,!c.writable&&c.autoDestroy&&process.nextTick((function(){c.destroy()}))})),c.end=function(e){if(!i)return i=!0,arguments.length&&c.write(e),c.writable=!1,o(c),!c.readable&&c.autoDestroy&&c.destroy(),c},c.destroy=function(){if(!a)return a=!0,i=!0,u.length=0,c.writable=!1,c.readable=!1,c.emit("close"),c},c.pause=function(){if(!c.paused)return c.paused=!0,c},c.resume=function(){return c.paused&&(c.paused=!1,c.emit("resume")),l(),c.paused||c.emit("drain"),c},c}var KM=$M;$M.through=$M;var YM=h.getDefaultExportFromCjs(KM);const HM=i;var JM=class extends HM{#e=null;constructor(e={}){super(e),this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=e.replace,this._prompt=e.prompt||null,this._hadControl=!1}#t(e,t){return this._dest?this._dest[e]:this._src?this._src[e]:t}#r(e,...t){"function"==typeof this._dest?.[e]&&this._dest[e](...t),"function"==typeof this._src?.[e]&&this._src[e](...t)}get isTTY(){return null!==this.#e?this.#e:this.#t("isTTY",!1)}set isTTY(e){this.#e=e}get rows(){return this.#t("rows")}get columns(){return this.#t("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(e){this._src=e}pipe(e,t){return this._dest=e,super.pipe(e,t)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(e){if(this.muted){if(!this.replace)return!0;if(e.match(/^\u001b/))return 0===e.indexOf(this._prompt)&&(e=(e=e.slice(this._prompt.length)).replace(/./g,this.replace),e=this._prompt+e),this._hadControl=!0,this.emit("data",e);this._prompt&&this._hadControl&&0===e.indexOf(this._prompt)&&(this._hadControl=!1,this.emit("data",this._prompt),e=e.slice(this._prompt.length)),e=e.toString().replace(/./g,this.replace)}this.emit("data",e)}end(e){this.muted&&(e=e&&this.replace?e.toString().replace(/./g,this.replace):null),e&&this.emit("data",e),this.emit("end")}destroy(...e){return this.#r("destroy",...e)}destroySoon(...e){return this.#r("destroySoon",...e)}close(...e){return this.#r("close",...e)}},QM=h.getDefaultExportFromCjs(JM);class XM{constructor(e){this.rl||=m.createInterface(function(e={}){e.skipTTYChecks=void 0===e.skipTTYChecks||e.skipTTYChecks;const t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){const e=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw e.isTtyError=!0,e}const r=new QM;r.pipe(e.output||process.stdout);const n=r;return{terminal:!0,...e,input:t,output:n}}(e)),this.rl.resume(),this.onForceClose=this.onForceClose.bind(this),process.on("exit",this.onForceClose),this.rl.on("SIGINT",this.onForceClose)}onForceClose(){this.close(),process.kill(process.pid,"SIGINT"),console.log("")}close(){this.rl.removeListener("SIGINT",this.onForceClose),process.removeListener("exit",this.onForceClose),this.rl.output.unmute(),this.activePrompt&&"function"==typeof this.activePrompt.close&&this.activePrompt.close(),this.rl.output.end(),this.rl.pause(),this.rl.close()}}var ZM=Dy,eT=j_,tT=vm,rT=Function.prototype,nT=Object.prototype,oT=rT.toString,iT=nT.hasOwnProperty,aT=oT.call(Object);var uT=function(e){if(!tT(e)||"[object Object]"!=ZM(e))return!1;var t=eT(e);if(null===t)return!0;var r=iT.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&oT.call(r)==aT},sT=VD,cT=rj,lT=cm,fT=_y,pT=oj;var dT=function(e,t,r,n){if(!fT(e))return e;for(var o=-1,i=(t=cT(t,e)).length,a=i-1,u=e;null!=u&&++o<i;){var s=pT(t[o]),c=r;if("__proto__"===s||"constructor"===s||"prototype"===s)return e;if(o!=a){var l=u[s];void 0===(c=n?n(l,s,u):void 0)&&(c=fT(l)?l:lT(t[o+1])?[]:{})}sT(u,s,c),u=u[s]}return e},hT=dT;var bT=function(e,t,r){return null==e?e:hT(e,t,r)};const vT=function(e,t,r){return"function"!=typeof e[t]?Te.of(e):Te.from(Me(e[t])(r).then((r=>(e[t]=r,e))))},yT={isPlainObject:h.getDefaultExportFromCjs(uT),set:h.getDefaultExportFromCjs(bT),get:lj};class mT extends XM{constructor(e,t){super(t),this.prompts=e}run(e,t){yT.isPlainObject(t)?this.answers={...t}:this.answers={},yT.isPlainObject(e)&&(e=Object.values(e).every((e=>yT.isPlainObject(e)&&void 0===e.name))?Object.entries(e).map((([e,t])=>({name:e,...t}))):[e]);const r=Array.isArray(e)?Te.from(e):e;return this.process=r.pipe(Te.concatMap(this.processQuestion.bind(this)),Te.publish()),this.process.connect(),this.process.pipe(Te.reduce(((e,t)=>(yT.set(e,t.name,t.answer),e)),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(e){return this.close(),Promise.reject(e)}processQuestion(e){return e={...e},Te.defer((()=>Te.of(e).pipe(Te.concatMap(this.setDefaultType.bind(this)),Te.concatMap(this.filterIfRunnable.bind(this)),Te.concatMap((()=>vT(e,"message",this.answers))),Te.concatMap((()=>vT(e,"default",this.answers))),Te.concatMap((()=>vT(e,"choices",this.answers))),Te.concatMap(this.fetchAnswer.bind(this)))))}fetchAnswer(e){const t=this.prompts[e.type];return this.activePrompt=new t(e,this.rl,this.answers),Te.defer((()=>Te.from(this.activePrompt.run().then((t=>({name:e.name,answer:t}))))))}setDefaultType(e){return this.prompts[e.type]||(e.type="input"),Te.defer((()=>Te.of(e)))}filterIfRunnable(e){if(!0!==e.askAnswered&&void 0!==yT.get(this.answers,e.name))return Te.empty();if(!1===e.when)return Te.empty();if("function"!=typeof e.when)return Te.of(e);const{answers:t}=this;return Te.defer((()=>Te.from(Me(e.when)(t).then((t=>{if(t)return e}))).pipe(Te.filter((e=>null!=e)))))}}function gT(e){const t=function(r,n){let o;try{o=new mT(t.prompts,e)}catch(e){return Promise.reject(e)}const i=o.run(r,n);return i.ui=o,i};return t.prompts={},t.registerPrompt=function(e,r){return t.prompts[e]=r,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",oP),this.registerPrompt("input",iP),this.registerPrompt("number",aP),this.registerPrompt("confirm",uP),this.registerPrompt("rawlist",sP),this.registerPrompt("expand",cP),this.registerPrompt("checkbox",lP),this.registerPrompt("password",pP),this.registerPrompt("editor",jB)},t.restoreDefaultPrompts(),t}const DT=gT();const _T={prompt:DT,ui:{BottomBar:class extends XM{constructor(e={}){super(e),this.log=YM(this.writeLog.bind(this)),this.bottomBar=e.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return XF(this.rl,this.bottomBar.split("\n").length),this}updateBottomBar(e){return XF(this.rl,1),this.rl.output.unmute(),this.clean(),this.bottomBar=e,this.render(),this.rl.output.mute(),this}writeLog(e){return this.rl.output.unmute(),this.clean(),this.rl.output.write(this.enforceLF(e.toString())),this.render(),this.rl.output.mute(),this}enforceLF(e){return e.match(/[\r\n]$/)?e:e+"\n"}write(e){const t=e.split(/\n/);this.height=t.length,this.rl.setPrompt(t[t.length-1]),0===this.rl.output.rows&&0===this.rl.output.columns&&JF(this.rl,e.length+this.rl.line.length),this.rl.output.write(e)}},Prompt:mT},createPromptModule:gT,registerPrompt:function(e,t){DT.registerPrompt(e,t)},restoreDefaultPrompts:function(){DT.restoreDefaultPrompts()},Separator:iS};var wT="0.2.17";const OT=process.cwd();exports.createModule=async()=>{const e=await g.loadJSON(y.resolve(OT,"package.json")),t=await _T.prompt([{type:"list",name:"type",message:"请选择一个选项:",default:"react",choices:["vue","react"]},{type:"input",message:"workspaces name",name:"workspaces",validate:function(e){return!(e&&!v.existsSync(y.resolve(OT,e)))||"工作空间不存在"}},{type:"input",message:"package name",name:"name",validate:function(e){return!!e.replace(/\s/g,"")||"姓名不能为空,请重新输入"}},{type:"input",message:"version",name:"version",default:e.version}]),r="vue"===t.type,n=v.readFileSync(y.resolve(__dirname,r?"../../template/template.vue.package.json":"../../template/template.package.json"),"utf-8"),o=h.ejs.compile(n),i=y.resolve(OT,t.workspaces,t.name);v.existsSync(y.resolve(i))||v.mkdirSync(i),s.exec(`cd ${i}`,((e,n,a)=>{e?console.error(`错误: ${e.message}`):a?console.error(`错误: ${a}`):(h.createCwdConfig(i,t.name,r),v.mkdirSync(y.resolve(i,"public")),v.mkdirSync(y.resolve(i,"src")),v.writeFileSync(y.resolve(i,"package.json"),o({...t,coreVersion:`^${wT}`})),v.writeFileSync(y.resolve(i,"tsconfig.json"),'{\n "extends": ["./src/.gant/tsconfig.json"]\n }'),v.writeFileSync(y.resolve(i,"tsconfig.json"),'{\n "extends": ["./src/.gant/tsconfig.json"]\n }'))}))},exports.stringWidthExports=FS;
|
|
10
|
+
const CA=v,xA=y,FA=l,PA=function(){var e;return e=jA?process.env.TEMP||process.env.TMP||(process.env.SystemRoot||process.env.windir)+"\\temp":process.env.TMPDIR||process.env.TMP||process.env.TEMP||"/tmp",SA.test(e)&&(e=e.slice(0,-1)),e},AA=process.binding("constants"),BA=PA(),MA="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",TA=/XXXXXX/,kA=3,RA=(AA.O_CREAT||AA.fs.O_CREAT)|(AA.O_EXCL||AA.fs.O_EXCL)|(AA.O_RDWR||AA.fs.O_RDWR),IA=AA.EBADF||AA.os.errno.EBADF,LA=AA.ENOENT||AA.os.errno.ENOENT,NA=[];var UA=!1,GA=!1;function WA(e){var t=[],r=null;try{r=FA.randomBytes(e)}catch(t){r=FA.pseudoRandomBytes(e)}for(var n=0;n<e;n++)t.push(MA[r[n]%MA.length]);return t.join("")}function qA(e){return void 0===e}function VA(e,t){return"function"==typeof e?[t||{},e]:qA(e)?[{},t]:[e,t]}function zA(e){if(e.name)return xA.join(e.dir||BA,e.name);if(e.template)return e.template.replace(TA,WA(6));const t=[e.prefix||"tmp-",process.pid,WA(12),e.postfix||""].join("");return xA.join(e.dir||BA,t)}function $A(e,t){var r=VA(e,t),n=r[0],o=r[1],i=n.name?1:n.tries||kA;return isNaN(i)||i<0?o(new Error("Invalid tries")):n.template&&!n.template.match(TA)?o(new Error("Invalid template provided")):void function e(){const t=zA(n);CA.stat(t,(function(r){if(!r)return i-- >0?e():o(new Error("Could not get a unique tmp filename, max tries reached "+t));o(null,t)}))}()}function KA(e){var t=VA(e)[0],r=t.name?1:t.tries||kA;if(isNaN(r)||r<0)throw new Error("Invalid tries");if(t.template&&!t.template.match(TA))throw new Error("Invalid template provided");do{const e=zA(t);try{CA.statSync(e)}catch(t){return e}}while(r-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function YA(e){const t=[e];do{for(var r=t.pop(),n=!1,o=CA.readdirSync(r),i=0,a=o.length;i<a;i++){var u=xA.join(r,o[i]);CA.lstatSync(u).isDirectory()?(n||(n=!0,t.push(r)),t.push(u)):CA.unlinkSync(u)}n||CA.rmdirSync(r)}while(0!==t.length)}function HA(e,t,r){const n=QA((function(e){try{0<=e[0]&&CA.closeSync(e[0])}catch(e){if(!(t=e,eB(t,-IA,"EBADF")||ZA(e)))throw e}var t;try{CA.unlinkSync(e[1])}catch(e){if(!ZA(e))throw e}}),[t,e]);return r.keep||NA.unshift(n),n}function JA(e,t){const r=QA(t.unsafeCleanup?YA:CA.rmdirSync.bind(CA),e);return t.keep||NA.unshift(r),r}function QA(e,t){var r=!1;return function n(o){if(!r){const o=NA.indexOf(n);o>=0&&NA.splice(o,1),r=!0,e(t)}o&&o(null)}}function XA(){if(!GA||UA)for(;NA.length;)try{NA[0].call(null)}catch(e){}}function ZA(e){return eB(e,-LA,"ENOENT")}function eB(e,t,r){return e.code==t||e.code==r}const tB=process.versions.node.split(".").map((function(e){return parseInt(e,10)}));0===tB[0]&&(tB[1]<9||9===tB[1]&&tB[2]<5)&&process.addListener("uncaughtException",(function(e){throw GA=!0,XA(),e})),process.addListener("exit",(function(e){e&&(GA=!0),XA()})),EA.tmpdir=BA,EA.dir=function(e,t){var r=VA(e,t),n=r[0],o=r[1];$A(n,(function(e,t){if(e)return o(e);CA.mkdir(t,n.mode||448,(function(e){if(e)return o(e);o(null,t,JA(t,n))}))}))},EA.dirSync=function(e){var t=VA(e)[0];const r=KA(t);return CA.mkdirSync(r,t.mode||448),{name:r,removeCallback:JA(r,t)}},EA.file=function(e,t){var r=VA(e,t),n=r[0],o=r[1];n.postfix=qA(n.postfix)?".tmp":n.postfix,$A(n,(function(e,t){if(e)return o(e);CA.open(t,RA,n.mode||384,(function(e,r){return e?o(e):n.discardDescriptor?CA.close(r,(function(e){if(e){try{CA.unlinkSync(t)}catch(t){ZA(t)||(e=t)}return o(e)}o(null,t,void 0,HA(t,-1,n))})):n.detachDescriptor?o(null,t,r,HA(t,-1,n)):void o(null,t,r,HA(t,r,n))}))}))},EA.fileSync=function(e){var t=VA(e)[0];t.postfix=t.postfix||".tmp";const r=t.discardDescriptor||t.detachDescriptor,n=KA(t);var o=CA.openSync(n,RA,t.mode||384);return t.discardDescriptor&&(CA.closeSync(o),o=void 0),{name:n,fd:o,removeCallback:HA(n,r?-1:o,t)}},EA.tmpName=$A,EA.tmpNameSync=KA,EA.setGracefulCleanup=function(){UA=!0};var rB={},nB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(rB,"__esModule",{value:!0});var oB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed to create temporary file for editor")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return nB(t,e),t}(Error);rB.CreateFileError=oB;var iB={},aB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(iB,"__esModule",{value:!0});var uB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed launch editor")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return aB(t,e),t}(Error);iB.LaunchEditorError=uB;var sB={},cB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(sB,"__esModule",{value:!0});var lB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed to read temporary file")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return cB(t,e),t}(Error);sB.ReadFileError=lB;var fB={},pB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(fB,"__esModule",{value:!0});var dB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed to cleanup temporary file")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return pB(t,e),t}(Error);fB.RemoveFileError=dB,Object.defineProperty(dP,"__esModule",{value:!0});var hB=hP,bB=s,vB=v,yB=OA,mB=EA,gB=rB;dP.CreateFileError=gB.CreateFileError;var DB=iB;dP.LaunchEditorError=DB.LaunchEditorError;var _B=sB;dP.ReadFileError=_B.ReadFileError;var wB=fB;dP.RemoveFileError=wB.RemoveFileError,dP.edit=function(e,t){void 0===e&&(e="");var r=new EB(e,t);return r.run(),r.cleanup(),r.text};var OB=dP.editAsync=function(e,t,r){void 0===e&&(e="");var n=new EB(e,r);n.runAsync((function(e,r){if(e)setImmediate(t,e,null);else try{n.cleanup(),setImmediate(t,null,r)}catch(e){setImmediate(t,e,null)}}))},EB=function(){function e(e,t){void 0===e&&(e=""),this.text="",this.fileOptions={},this.text=e,t&&(this.fileOptions=t),this.determineEditor(),this.createTemporaryFile()}return e.splitStringBySpace=function(e){for(var t=[],r="",n=0;n<e.length;n++){var o=e[n];n>0&&" "===o&&"\\"!==e[n-1]&&r.length>0?(t.push(r),r=""):r+=o}return r.length>0&&t.push(r),t},Object.defineProperty(e.prototype,"temp_file",{get:function(){return console.log("DEPRECATED: temp_file. Use tempFile moving forward."),this.tempFile},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"last_exit_status",{get:function(){return console.log("DEPRECATED: last_exit_status. Use lastExitStatus moving forward."),this.lastExitStatus},enumerable:!0,configurable:!0}),e.prototype.run=function(){return this.launchEditor(),this.readTemporaryFile(),this.text},e.prototype.runAsync=function(e){var t=this;try{this.launchEditorAsync((function(){try{t.readTemporaryFile(),setImmediate(e,null,t.text)}catch(t){setImmediate(e,t,null)}}))}catch(t){setImmediate(e,t,null)}},e.prototype.cleanup=function(){this.removeTemporaryFile()},e.prototype.determineEditor=function(){var t=process.env.VISUAL?process.env.VISUAL:process.env.EDITOR?process.env.EDITOR:/^win/.test(process.platform)?"notepad":"vim",r=e.splitStringBySpace(t).map((function(e){return e.replace("\\ "," ")})),n=r.shift();this.editor={args:r,bin:n}},e.prototype.createTemporaryFile=function(){try{this.tempFile=mB.tmpNameSync(this.fileOptions);var e={encoding:"utf8"};this.fileOptions.hasOwnProperty("mode")&&(e.mode=this.fileOptions.mode),vB.writeFileSync(this.tempFile,this.text,e)}catch(e){throw new gB.CreateFileError(e)}},e.prototype.readTemporaryFile=function(){try{var e=vB.readFileSync(this.tempFile);if(0===e.length)this.text="";else{var t=hB.detect(e).toString();yB.encodingExists(t)||(t="utf8"),this.text=yB.decode(e,t)}}catch(e){throw new _B.ReadFileError(e)}},e.prototype.removeTemporaryFile=function(){try{vB.unlinkSync(this.tempFile)}catch(e){throw new wB.RemoveFileError(e)}},e.prototype.launchEditor=function(){try{var e=bB.spawnSync(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=e.status}catch(e){throw new DB.LaunchEditorError(e)}},e.prototype.launchEditorAsync=function(e){var t=this;try{bB.spawn(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",(function(r){t.lastExitStatus=r,setImmediate(e)}))}catch(e){throw new DB.LaunchEditorError(e)}},e}();dP.ExternalEditor=EB;class jB extends nP{_run(e){this.done=e,this.editorResult=new Te.Subject;const t=Jv(this.rl);this.lineSubscription=t.line.subscribe(this.startExternalEditor.bind(this));void 0===this.opt.waitUserInput||this.opt.waitUserInput||this.startExternalEditor();const r=this.handleSubmitEvents(this.editorResult);return r.success.forEach(this.onEnd.bind(this)),r.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,this.render(),this}render(e){let t="",r=this.getQuestion();"answered"===this.status?r+=K.dim("Received"):r+=K.dim("Press <enter> to launch your preferred editor."),e&&(t=K.red(">> ")+e),this.screen.render(r,t)}startExternalEditor(){this.rl.pause(),OB(this.currentText,this.endExternalEditor.bind(this),{postfix:this.opt.postfix??".txt"})}endExternalEditor(e,t){this.rl.resume(),e?this.editorResult.error(e):this.editorResult.next(t)}onEnd(e){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=e.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(e){this.render(e.isValid)}}var SB,CB={exports:{}},xB=Object.prototype.toString,FB=Math.max,PB=function(e,t){for(var r=[],n=0;n<e.length;n+=1)r[n]=e[n];for(var o=0;o<t.length;o+=1)r[o+e.length]=t[o];return r},AB=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==xB.apply(t))throw new TypeError("Function.prototype.bind called on incompatible "+t);for(var r,n=function(e,t){for(var r=[],n=t||0,o=0;n<e.length;n+=1,o+=1)r[o]=e[n];return r}(arguments,1),o=FB(0,t.length-n.length),i=[],a=0;a<o;a++)i[a]="$"+a;if(r=Function("binder","return function ("+function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r}(i,",")+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof r){var o=t.apply(this,PB(n,arguments));return Object(o)===o?o:this}return t.apply(e,PB(n,arguments))})),t.prototype){var u=function(){};u.prototype=t.prototype,r.prototype=new u,u.prototype=null}return r},BB=Function.prototype.bind||AB,MB=Error,TB=EvalError,kB=RangeError,RB=ReferenceError,IB=SyntaxError,LB=TypeError,NB=URIError,UB="undefined"!=typeof Symbol&&Symbol,GB=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||!0!==o.enumerable)return!1}return!0},WB={__proto__:null,foo:{}},qB=Object,VB=Function.prototype.call,zB=Object.prototype.hasOwnProperty,$B=BB.call(VB,zB),KB=MB,YB=TB,HB=kB,JB=RB,QB=IB,XB=LB,ZB=NB,eM=Function,tM=function(e){try{return eM('"use strict"; return ('+e+").constructor;")()}catch(e){}},rM=Object.getOwnPropertyDescriptor;if(rM)try{rM({},"")}catch(e){rM=null}var nM=function(){throw new XB},oM=rM?function(){try{return nM}catch(e){try{return rM(arguments,"callee").get}catch(e){return nM}}}():nM,iM="function"==typeof UB&&"function"==typeof Symbol&&"symbol"==typeof UB("foo")&&"symbol"==typeof Symbol("bar")&&GB(),aM={__proto__:WB}.foo===WB.foo&&!(WB instanceof qB),uM=Object.getPrototypeOf||(aM?function(e){return e.__proto__}:null),sM={},cM="undefined"!=typeof Uint8Array&&uM?uM(Uint8Array):SB,lM={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?SB:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?SB:ArrayBuffer,"%ArrayIteratorPrototype%":iM&&uM?uM([][Symbol.iterator]()):SB,"%AsyncFromSyncIteratorPrototype%":SB,"%AsyncFunction%":sM,"%AsyncGenerator%":sM,"%AsyncGeneratorFunction%":sM,"%AsyncIteratorPrototype%":sM,"%Atomics%":"undefined"==typeof Atomics?SB:Atomics,"%BigInt%":"undefined"==typeof BigInt?SB:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?SB:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?SB:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?SB:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":KB,"%eval%":eval,"%EvalError%":YB,"%Float32Array%":"undefined"==typeof Float32Array?SB:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?SB:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?SB:FinalizationRegistry,"%Function%":eM,"%GeneratorFunction%":sM,"%Int8Array%":"undefined"==typeof Int8Array?SB:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?SB:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?SB:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":iM&&uM?uM(uM([][Symbol.iterator]())):SB,"%JSON%":"object"==typeof JSON?JSON:SB,"%Map%":"undefined"==typeof Map?SB:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&iM&&uM?uM((new Map)[Symbol.iterator]()):SB,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?SB:Promise,"%Proxy%":"undefined"==typeof Proxy?SB:Proxy,"%RangeError%":HB,"%ReferenceError%":JB,"%Reflect%":"undefined"==typeof Reflect?SB:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?SB:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&iM&&uM?uM((new Set)[Symbol.iterator]()):SB,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?SB:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":iM&&uM?uM(""[Symbol.iterator]()):SB,"%Symbol%":iM?Symbol:SB,"%SyntaxError%":QB,"%ThrowTypeError%":oM,"%TypedArray%":cM,"%TypeError%":XB,"%Uint8Array%":"undefined"==typeof Uint8Array?SB:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?SB:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?SB:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?SB:Uint32Array,"%URIError%":ZB,"%WeakMap%":"undefined"==typeof WeakMap?SB:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?SB:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?SB:WeakSet};if(uM)try{null.error}catch(e){var fM=uM(uM(e));lM["%Error.prototype%"]=fM}var pM,dM,hM=function e(t){var r;if("%AsyncFunction%"===t)r=tM("async function () {}");else if("%GeneratorFunction%"===t)r=tM("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=tM("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var o=e("%AsyncGenerator%");o&&uM&&(r=uM(o.prototype))}return lM[t]=r,r},bM={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},vM=BB,yM=$B,mM=vM.call(Function.call,Array.prototype.concat),gM=vM.call(Function.apply,Array.prototype.splice),DM=vM.call(Function.call,String.prototype.replace),_M=vM.call(Function.call,String.prototype.slice),wM=vM.call(Function.call,RegExp.prototype.exec),OM=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,EM=/\\(\\)?/g,jM=function(e,t){var r,n=e;if(yM(bM,n)&&(n="%"+(r=bM[n])[0]+"%"),yM(lM,n)){var o=lM[n];if(o===sM&&(o=hM(n)),void 0===o&&!t)throw new XB("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:o}}throw new QB("intrinsic "+e+" does not exist!")},SM=function(e,t){if("string"!=typeof e||0===e.length)throw new XB("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new XB('"allowMissing" argument must be a boolean');if(null===wM(/^%?[^%]*%?$/,e))throw new QB("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(e){var t=_M(e,0,1),r=_M(e,-1);if("%"===t&&"%"!==r)throw new QB("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new QB("invalid intrinsic syntax, expected opening `%`");var n=[];return DM(e,OM,(function(e,t,r,o){n[n.length]=r?DM(o,EM,"$1"):t||e})),n}(e),n=r.length>0?r[0]:"",o=jM("%"+n+"%",t),i=o.name,a=o.value,u=!1,s=o.alias;s&&(n=s[0],gM(r,mM([0,1],s)));for(var c=1,l=!0;c<r.length;c+=1){var f=r[c],p=_M(f,0,1),d=_M(f,-1);if(('"'===p||"'"===p||"`"===p||'"'===d||"'"===d||"`"===d)&&p!==d)throw new QB("property names with quotes must have matching quotes");if("constructor"!==f&&l||(u=!0),yM(lM,i="%"+(n+="."+f)+"%"))a=lM[i];else if(null!=a){if(!(f in a)){if(!t)throw new XB("base intrinsic for "+e+" exists, but the property is not available.");return}if(rM&&c+1>=r.length){var h=rM(a,f);a=(l=!!h)&&"get"in h&&!("originalValue"in h.get)?h.get:a[f]}else l=yM(a,f),a=a[f];l&&!u&&(lM[i]=a)}}return a};function CM(){if(dM)return pM;dM=1;var e=SM("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch(t){e=!1}return pM=e}var xM=SM("%Object.getOwnPropertyDescriptor%",!0);if(xM)try{xM([],"length")}catch(e){xM=null}var FM=xM,PM=CM(),AM=IB,BM=LB,MM=FM,TM=CM(),kM=function(){return!!TM};kM.hasArrayLengthDefineBug=function(){if(!TM)return null;try{return 1!==TM([],"length",{value:1}).length}catch(e){return!0}};var RM=SM,IM=function(e,t,r){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new BM("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new BM("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new BM("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new BM("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new BM("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new BM("`loose`, if provided, must be a boolean");var n=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,i=arguments.length>5?arguments[5]:null,a=arguments.length>6&&arguments[6],u=!!MM&&MM(e,t);if(PM)PM(e,t,{configurable:null===i&&u?u.configurable:!i,enumerable:null===n&&u?u.enumerable:!n,value:r,writable:null===o&&u?u.writable:!o});else{if(!a&&(n||o||i))throw new AM("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=r}},LM=kM(),NM=FM,UM=LB,GM=RM("%Math.floor%"),WM=function(e,t){if("function"!=typeof e)throw new UM("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||GM(t)!==t)throw new UM("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],n=!0,o=!0;if("length"in e&&NM){var i=NM(e,"length");i&&!i.configurable&&(n=!1),i&&!i.writable&&(o=!1)}return(n||o||!r)&&(LM?IM(e,"length",t,!0,!0):IM(e,"length",t)),e};!function(e){var t=BB,r=SM,n=WM,o=LB,i=r("%Function.prototype.apply%"),a=r("%Function.prototype.call%"),u=r("%Reflect.apply%",!0)||t.call(a,i),s=CM(),c=r("%Math.max%");e.exports=function(e){if("function"!=typeof e)throw new o("a function is required");var r=u(t,a,arguments);return n(r,1+c(0,e.length-(arguments.length-1)),!0)};var l=function(){return u(t,i,arguments)};s?s(e.exports,"apply",{value:l}):e.exports.apply=l}(CB);var qM=CB.exports,VM=i.Stream,zM=qM;function $M(e,t,r){var n=zM(e||function(e){this.queue(e)}),o=zM(t||function(){this.queue(null)}),i=!1,a=!1,u=[],s=!1,c=new VM;function l(){for(;u.length&&!c.paused;){var e=u.shift();if(null===e)return c.emit("end");c.emit("data",e)}}return c.readable=!0,c.writable=!0,c.paused=!1,c.autoDestroy=!(r&&!1===r.autoDestroy),c.write=function(e){return n(this,e),!c.paused},c.queue=function(e){return s||(null===e&&(s=!0),u.push(e),l()),c},c.push=c.queue,c.on("end",(function(){c.readable=!1,!c.writable&&c.autoDestroy&&process.nextTick((function(){c.destroy()}))})),c.end=function(e){if(!i)return i=!0,arguments.length&&c.write(e),c.writable=!1,o(c),!c.readable&&c.autoDestroy&&c.destroy(),c},c.destroy=function(){if(!a)return a=!0,i=!0,u.length=0,c.writable=!1,c.readable=!1,c.emit("close"),c},c.pause=function(){if(!c.paused)return c.paused=!0,c},c.resume=function(){return c.paused&&(c.paused=!1,c.emit("resume")),l(),c.paused||c.emit("drain"),c},c}var KM=$M;$M.through=$M;var YM=h.getDefaultExportFromCjs(KM);const HM=i;var JM=class extends HM{#e=null;constructor(e={}){super(e),this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=e.replace,this._prompt=e.prompt||null,this._hadControl=!1}#t(e,t){return this._dest?this._dest[e]:this._src?this._src[e]:t}#r(e,...t){"function"==typeof this._dest?.[e]&&this._dest[e](...t),"function"==typeof this._src?.[e]&&this._src[e](...t)}get isTTY(){return null!==this.#e?this.#e:this.#t("isTTY",!1)}set isTTY(e){this.#e=e}get rows(){return this.#t("rows")}get columns(){return this.#t("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(e){this._src=e}pipe(e,t){return this._dest=e,super.pipe(e,t)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(e){if(this.muted){if(!this.replace)return!0;if(e.match(/^\u001b/))return 0===e.indexOf(this._prompt)&&(e=(e=e.slice(this._prompt.length)).replace(/./g,this.replace),e=this._prompt+e),this._hadControl=!0,this.emit("data",e);this._prompt&&this._hadControl&&0===e.indexOf(this._prompt)&&(this._hadControl=!1,this.emit("data",this._prompt),e=e.slice(this._prompt.length)),e=e.toString().replace(/./g,this.replace)}this.emit("data",e)}end(e){this.muted&&(e=e&&this.replace?e.toString().replace(/./g,this.replace):null),e&&this.emit("data",e),this.emit("end")}destroy(...e){return this.#r("destroy",...e)}destroySoon(...e){return this.#r("destroySoon",...e)}close(...e){return this.#r("close",...e)}},QM=h.getDefaultExportFromCjs(JM);class XM{constructor(e){this.rl||=m.createInterface(function(e={}){e.skipTTYChecks=void 0===e.skipTTYChecks||e.skipTTYChecks;const t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){const e=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw e.isTtyError=!0,e}const r=new QM;r.pipe(e.output||process.stdout);const n=r;return{terminal:!0,...e,input:t,output:n}}(e)),this.rl.resume(),this.onForceClose=this.onForceClose.bind(this),process.on("exit",this.onForceClose),this.rl.on("SIGINT",this.onForceClose)}onForceClose(){this.close(),process.kill(process.pid,"SIGINT"),console.log("")}close(){this.rl.removeListener("SIGINT",this.onForceClose),process.removeListener("exit",this.onForceClose),this.rl.output.unmute(),this.activePrompt&&"function"==typeof this.activePrompt.close&&this.activePrompt.close(),this.rl.output.end(),this.rl.pause(),this.rl.close()}}var ZM=Dy,eT=j_,tT=vm,rT=Function.prototype,nT=Object.prototype,oT=rT.toString,iT=nT.hasOwnProperty,aT=oT.call(Object);var uT=function(e){if(!tT(e)||"[object Object]"!=ZM(e))return!1;var t=eT(e);if(null===t)return!0;var r=iT.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&oT.call(r)==aT},sT=VD,cT=rj,lT=cm,fT=_y,pT=oj;var dT=function(e,t,r,n){if(!fT(e))return e;for(var o=-1,i=(t=cT(t,e)).length,a=i-1,u=e;null!=u&&++o<i;){var s=pT(t[o]),c=r;if("__proto__"===s||"constructor"===s||"prototype"===s)return e;if(o!=a){var l=u[s];void 0===(c=n?n(l,s,u):void 0)&&(c=fT(l)?l:lT(t[o+1])?[]:{})}sT(u,s,c),u=u[s]}return e},hT=dT;var bT=function(e,t,r){return null==e?e:hT(e,t,r)};const vT=function(e,t,r){return"function"!=typeof e[t]?Te.of(e):Te.from(Me(e[t])(r).then((r=>(e[t]=r,e))))},yT={isPlainObject:h.getDefaultExportFromCjs(uT),set:h.getDefaultExportFromCjs(bT),get:lj};class mT extends XM{constructor(e,t){super(t),this.prompts=e}run(e,t){yT.isPlainObject(t)?this.answers={...t}:this.answers={},yT.isPlainObject(e)&&(e=Object.values(e).every((e=>yT.isPlainObject(e)&&void 0===e.name))?Object.entries(e).map((([e,t])=>({name:e,...t}))):[e]);const r=Array.isArray(e)?Te.from(e):e;return this.process=r.pipe(Te.concatMap(this.processQuestion.bind(this)),Te.publish()),this.process.connect(),this.process.pipe(Te.reduce(((e,t)=>(yT.set(e,t.name,t.answer),e)),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(e){return this.close(),Promise.reject(e)}processQuestion(e){return e={...e},Te.defer((()=>Te.of(e).pipe(Te.concatMap(this.setDefaultType.bind(this)),Te.concatMap(this.filterIfRunnable.bind(this)),Te.concatMap((()=>vT(e,"message",this.answers))),Te.concatMap((()=>vT(e,"default",this.answers))),Te.concatMap((()=>vT(e,"choices",this.answers))),Te.concatMap(this.fetchAnswer.bind(this)))))}fetchAnswer(e){const t=this.prompts[e.type];return this.activePrompt=new t(e,this.rl,this.answers),Te.defer((()=>Te.from(this.activePrompt.run().then((t=>({name:e.name,answer:t}))))))}setDefaultType(e){return this.prompts[e.type]||(e.type="input"),Te.defer((()=>Te.of(e)))}filterIfRunnable(e){if(!0!==e.askAnswered&&void 0!==yT.get(this.answers,e.name))return Te.empty();if(!1===e.when)return Te.empty();if("function"!=typeof e.when)return Te.of(e);const{answers:t}=this;return Te.defer((()=>Te.from(Me(e.when)(t).then((t=>{if(t)return e}))).pipe(Te.filter((e=>null!=e)))))}}function gT(e){const t=function(r,n){let o;try{o=new mT(t.prompts,e)}catch(e){return Promise.reject(e)}const i=o.run(r,n);return i.ui=o,i};return t.prompts={},t.registerPrompt=function(e,r){return t.prompts[e]=r,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",oP),this.registerPrompt("input",iP),this.registerPrompt("number",aP),this.registerPrompt("confirm",uP),this.registerPrompt("rawlist",sP),this.registerPrompt("expand",cP),this.registerPrompt("checkbox",lP),this.registerPrompt("password",pP),this.registerPrompt("editor",jB)},t.restoreDefaultPrompts(),t}const DT=gT();const _T={prompt:DT,ui:{BottomBar:class extends XM{constructor(e={}){super(e),this.log=YM(this.writeLog.bind(this)),this.bottomBar=e.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return XF(this.rl,this.bottomBar.split("\n").length),this}updateBottomBar(e){return XF(this.rl,1),this.rl.output.unmute(),this.clean(),this.bottomBar=e,this.render(),this.rl.output.mute(),this}writeLog(e){return this.rl.output.unmute(),this.clean(),this.rl.output.write(this.enforceLF(e.toString())),this.render(),this.rl.output.mute(),this}enforceLF(e){return e.match(/[\r\n]$/)?e:e+"\n"}write(e){const t=e.split(/\n/);this.height=t.length,this.rl.setPrompt(t[t.length-1]),0===this.rl.output.rows&&0===this.rl.output.columns&&JF(this.rl,e.length+this.rl.line.length),this.rl.output.write(e)}},Prompt:mT},createPromptModule:gT,registerPrompt:function(e,t){DT.registerPrompt(e,t)},restoreDefaultPrompts:function(){DT.restoreDefaultPrompts()},Separator:iS};var wT="0.2.19";const OT=process.cwd();exports.createModule=async()=>{const e=await g.loadJSON(y.resolve(OT,"package.json")),t=await _T.prompt([{type:"list",name:"type",message:"请选择一个选项:",default:"react",choices:["vue","react"]},{type:"input",message:"workspaces name",name:"workspaces",validate:function(e){return!(e&&!v.existsSync(y.resolve(OT,e)))||"工作空间不存在"}},{type:"input",message:"package name",name:"name",validate:function(e){return!!e.replace(/\s/g,"")||"姓名不能为空,请重新输入"}},{type:"input",message:"version",name:"version",default:e.version}]),r="vue"===t.type,n=v.readFileSync(y.resolve(__dirname,r?"../../template/template.vue.package.json":"../../template/template.package.json"),"utf-8"),o=h.ejs.compile(n),i=y.resolve(OT,t.workspaces,t.name);v.existsSync(y.resolve(i))||v.mkdirSync(i),s.exec(`cd ${i}`,((e,n,a)=>{e?console.error(`错误: ${e.message}`):a?console.error(`错误: ${a}`):(h.createCwdConfig(i,t.name,r),v.mkdirSync(y.resolve(i,"public")),v.mkdirSync(y.resolve(i,"src")),v.writeFileSync(y.resolve(i,"package.json"),o({...t,coreVersion:`^${wT}`})),v.writeFileSync(y.resolve(i,"tsconfig.json"),'{\n "extends": ["./src/.gant/tsconfig.json"]\n }'),v.writeFileSync(y.resolve(i,"tsconfig.json"),'{\n "extends": ["./src/.gant/tsconfig.json"]\n }'))}))},exports.stringWidthExports=FS;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare function getJavascriptfile(filePath: string): any;
|
|
2
|
+
|
|
3
|
+
declare function loadJSON(filePath: string): any;
|
|
4
|
+
declare function getAbsFile(file: string, cwd: string): string;
|
|
5
|
+
declare function getAbsFiles(opts: {
|
|
6
|
+
files: string[];
|
|
7
|
+
cwd: string;
|
|
8
|
+
}): string[];
|
|
9
|
+
declare function generateDir(tempPath: string): void;
|
|
10
|
+
declare const mergeConfig: (object1: any, object2: any) => any;
|
|
11
|
+
declare function copyFolder(sourceFolder: string, destinationFolder: string): void;
|
|
12
|
+
declare function getMpasPageHtml(templatePath?: string): string;
|
|
13
|
+
declare const writeFileToJS: (filepath: string, content: string) => Promise<void>;
|
|
14
|
+
declare const writeFileToJSON: (filepath: string, content: string) => Promise<void>;
|
|
15
|
+
declare const getSrcPath: () => "src/" | "./";
|
|
16
|
+
|
|
17
|
+
export { copyFolder, generateDir, getAbsFile, getAbsFiles, getJavascriptfile, getMpasPageHtml, getSrcPath, loadJSON, mergeConfig, writeFileToJS, writeFileToJSON };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare function getJavascriptfile(filePath: string): any;
|
|
2
|
+
|
|
3
|
+
declare function loadJSON(filePath: string): any;
|
|
4
|
+
declare function getAbsFile(file: string, cwd: string): string;
|
|
5
|
+
declare function getAbsFiles(opts: {
|
|
6
|
+
files: string[];
|
|
7
|
+
cwd: string;
|
|
8
|
+
}): string[];
|
|
9
|
+
declare function generateDir(tempPath: string): void;
|
|
10
|
+
declare const mergeConfig: (object1: any, object2: any) => any;
|
|
11
|
+
declare function copyFolder(sourceFolder: string, destinationFolder: string): void;
|
|
12
|
+
declare function getMpasPageHtml(templatePath?: string): string;
|
|
13
|
+
declare const writeFileToJS: (filepath: string, content: string) => Promise<void>;
|
|
14
|
+
declare const writeFileToJSON: (filepath: string, content: string) => Promise<void>;
|
|
15
|
+
declare const getSrcPath: () => "src/" | "./";
|
|
16
|
+
declare function getTargetConfigFiles(directory: string, fileName: string): any[];
|
|
17
|
+
|
|
18
|
+
export { copyFolder, generateDir, getAbsFile, getAbsFiles, getJavascriptfile, getMpasPageHtml, getSrcPath, getTargetConfigFiles, loadJSON, mergeConfig, writeFileToJS, writeFileToJSON };
|
package/lib/core/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as S}from"./request/index.js";export{r as request}from"./request/index.js";export{e as expireCache}from"./cache/index.js";export{default as mitt}from"mitt";import{g as R,u as O}from"./store/index.js";export{a as MENU_BREADCRUMBS_UPDATE,M as MENU_HISTORY_UPDATE,b as PROGRESS_UPDEDATE,W as WS_CONTENT_CLOSE,d as WS_CONTENT_ERROR,e as WS_CONTENT_SUCCESS,c as codeListStore,i as companydataStore,l as loginStore,m as menuStore,p as parameterStore,P as progress,s as storageStore,w as websocket}from"./store/index.js";import{i as _}from"./i18n/index.js";export{t as tr}from"./i18n/index.js";export{P as PresetColors,T as TinyColor,
|
|
1
|
+
import{a as S}from"./request/index.js";export{r as request}from"./request/index.js";export{e as expireCache}from"./cache/index.js";export{default as mitt}from"mitt";import{g as R,u as O}from"./store/index.js";export{a as MENU_BREADCRUMBS_UPDATE,M as MENU_HISTORY_UPDATE,b as PROGRESS_UPDEDATE,W as WS_CONTENT_CLOSE,d as WS_CONTENT_ERROR,e as WS_CONTENT_SUCCESS,c as codeListStore,i as companydataStore,l as loginStore,m as menuStore,p as parameterStore,P as progress,s as storageStore,w as websocket}from"./store/index.js";import{i as _}from"./i18n/index.js";export{t as tr}from"./i18n/index.js";export{P as PresetColors,T as TinyColor,A as bounds,b as compactAlgorithm,J as convertDecimalToHex,K as convertHexToDecimal,a as darkAlgorithm,d as defaultAlgorithm,f as formatAliasToken,u as fromRatio,g as getAliasToken,h as getAlphaColor,k as getBackgroundColor,i as getDarkenSolidColor,j as getLightenSolidColor,e as getTokenCssVar,D as hslToRgb,F as hsvToRgb,w as inputToRGB,o as isReadable,y as isValidCSSUnit,v as legacyRandom,l as lighten,c as meetingDerivative,p as mostReadable,n as names,M as numberInputToObject,L as parseIntFromHex,z as random,r as readability,G as rgbToHex,C as rgbToHsl,E as rgbToHsv,B as rgbToRgb,I as rgbaToArgbHex,H as rgbaToHex,s as seed,x as stringInputToObject,m as tinycolor,q as toMsFilter,t as token}from"./theme/index.js";export{g as getTraceId}from"./microservices/index.js";import{g as N}from"./utils/index.js";export{a as getAntdLocaleKey,b as getRoutes,s as setLocaleKey}from"./utils/index.js";import{uniqueId as U}from"lodash-es";export*from"axios";const $="X-G-TRACE-ID",V=e=>s=>{const{url:a="",serviceId:r}=s,o={};Object.keys(e).forEach((s=>{e[s].forEach((e=>{o[e]=s}))}));const t={};Object.keys(e).forEach((e=>{t[e]=e}));let i=`${a}.api`;const[,n]=i.split("/");return i=o[n]?`/${o[n]}${i}`:r?`/${t[r]}${i}`:i,delete s.serviceId,s.url=i,s},X=e=>s=>{const a=U($);return s.headers={...s.headers,[$]:a,needHtmlEscape:"false",userLanguage:e,...O.userIdentity},s};var Y=async({microServiceMap:e,dynamicLangCallback:s,...a})=>{S.interceptors.request.use(V(e)),await R.findPlantform();const r=N();S.interceptors.request.use(X(r)),await _(r),await(s?.());return await R.init(a)};export{N as getLocaleKey,R as globalStore,Y as init,_ as initDynamicLang,S as requestInstance,X as useRequestHeader,V as useRequestMicroSevices,O as userStore};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/main.ts"],"sourcesContent":["import { requestInstance, InternalAxiosRequestConfig, userStore, globalStore, initDynamicLang } from './core';\nimport type { GlobalOptions } from './core/store/type';\nimport { getLocaleKey } from './core/utils';\nimport { uniqueId, get, isEmpty } from 'lodash-es';\n\nconst TraceIdKey = 'X-G-TRACE-ID';\n\nexport const useRequestMicroSevices = (microServiceMap?: any) => {\n return (config: InternalAxiosRequestConfig) => {\n const { url = '', serviceId } = config;\n const serviceIdMap: any = {};\n Object.keys(microServiceMap).forEach(key => {\n microServiceMap[key as keyof typeof microServiceMap].forEach((module: any) => {\n serviceIdMap[module] = key;\n });\n });\n const urlMap: any = {};\n Object.keys(microServiceMap).forEach(key => {\n urlMap[key] = key;\n });\n const suffix = '.api';\n //传入拼接的url\n let newUrl = suffix ? `${url}${suffix}` : url;\n const [, urlPrefix] = newUrl.split('/');\n newUrl = serviceIdMap[urlPrefix]\n ? `/${serviceIdMap[urlPrefix]}${newUrl}`\n : serviceId\n ? `/${urlMap[serviceId]}${newUrl}`\n : newUrl;\n\n delete config.serviceId;\n config.url = newUrl;\n return config;\n };\n};\nexport const useRequestHeader = (userLanguage: string) => (config: InternalAxiosRequestConfig) => {\n const TRACE_ID = uniqueId(TraceIdKey);\n config.headers = {\n ...config.headers,\n [TraceIdKey]: TRACE_ID,\n needHtmlEscape: 'false',\n userLanguage,\n ...userStore.userIdentity,\n } as any;\n return config;\n};\nexport interface MainOptions extends GlobalOptions {\n microServiceMap?: any;\n locale?: string;\n dynamicLangCallback?: () => void;\n}\n\nexport default async ({ microServiceMap, dynamicLangCallback, ...globalOptions }: MainOptions) => {\n requestInstance.interceptors.request.use(useRequestMicroSevices(microServiceMap));\n await globalStore.findPlantform();\n const locale = getLocaleKey();\n requestInstance.interceptors.request.use(useRequestHeader(locale));\n\n await initDynamicLang(locale);\n await dynamicLangCallback?.();\n const res = await globalStore.init(globalOptions);\n return res;\n};\n"],"names":["TraceIdKey","useRequestMicroSevices","microServiceMap","config","url","serviceId","serviceIdMap","Object","keys","forEach","key","module","urlMap","newUrl","urlPrefix","split","useRequestHeader","userLanguage","TRACE_ID","uniqueId","headers","needHtmlEscape","userStore","userIdentity","main","async","dynamicLangCallback","globalOptions","requestInstance","interceptors","request","use","globalStore","findPlantform","locale","getLocaleKey","initDynamicLang","init"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/main.ts"],"sourcesContent":["import { requestInstance, InternalAxiosRequestConfig, userStore, globalStore, initDynamicLang } from './core';\nimport type { GlobalOptions } from './core/store/type';\nimport { getLocaleKey } from './core/utils';\nimport { uniqueId, get, isEmpty } from 'lodash-es';\n\nconst TraceIdKey = 'X-G-TRACE-ID';\n\nexport const useRequestMicroSevices = (microServiceMap?: any) => {\n return (config: InternalAxiosRequestConfig) => {\n const { url = '', serviceId } = config;\n const serviceIdMap: any = {};\n Object.keys(microServiceMap).forEach(key => {\n microServiceMap[key as keyof typeof microServiceMap].forEach((module: any) => {\n serviceIdMap[module] = key;\n });\n });\n const urlMap: any = {};\n Object.keys(microServiceMap).forEach(key => {\n urlMap[key] = key;\n });\n const suffix = '.api';\n //传入拼接的url\n let newUrl = suffix ? `${url}${suffix}` : url;\n const [, urlPrefix] = newUrl.split('/');\n newUrl = serviceIdMap[urlPrefix]\n ? `/${serviceIdMap[urlPrefix]}${newUrl}`\n : serviceId\n ? `/${urlMap[serviceId]}${newUrl}`\n : newUrl;\n\n delete config.serviceId;\n config.url = newUrl;\n return config;\n };\n};\nexport const useRequestHeader = (userLanguage: string) => (config: InternalAxiosRequestConfig) => {\n const TRACE_ID = uniqueId(TraceIdKey);\n config.headers = {\n ...config.headers,\n [TraceIdKey]: TRACE_ID,\n needHtmlEscape: 'false',\n userLanguage,\n ...userStore.userIdentity,\n } as any;\n return config;\n};\nexport interface MainOptions extends GlobalOptions {\n microServiceMap?: any;\n locale?: string;\n dynamicLangCallback?: () => void;\n}\n\nexport default async ({ microServiceMap, dynamicLangCallback, ...globalOptions }: MainOptions) => {\n requestInstance.interceptors.request.use(useRequestMicroSevices(microServiceMap));\n await globalStore.findPlantform();\n const locale = getLocaleKey();\n requestInstance.interceptors.request.use(useRequestHeader(locale));\n\n await initDynamicLang(locale);\n await dynamicLangCallback?.();\n const res = await globalStore.init(globalOptions);\n return res;\n};\n"],"names":["TraceIdKey","useRequestMicroSevices","microServiceMap","config","url","serviceId","serviceIdMap","Object","keys","forEach","key","module","urlMap","newUrl","urlPrefix","split","useRequestHeader","userLanguage","TRACE_ID","uniqueId","headers","needHtmlEscape","userStore","userIdentity","main","async","dynamicLangCallback","globalOptions","requestInstance","interceptors","request","use","globalStore","findPlantform","locale","getLocaleKey","initDynamicLang","init"],"mappings":"ujDAKA,MAAMA,EAAa,eAENC,EAA0BC,GAC7BC,IACN,MAAMC,IAAEA,EAAM,GAAEC,UAAEA,GAAcF,EAC1BG,EAAoB,CAAA,EAC1BC,OAAOC,KAAKN,GAAiBO,SAAQC,IACnCR,EAAgBQ,GAAqCD,SAASE,IAC5DL,EAAaK,GAAUD,CAAG,GAC1B,IAEJ,MAAME,EAAc,CAAA,EACpBL,OAAOC,KAAKN,GAAiBO,SAAQC,IACnCE,EAAOF,GAAOA,CAAG,IAInB,IAAIG,EAAkB,GAAGT,QACzB,MAAS,CAAAU,GAAaD,EAAOE,MAAM,KASnC,OARAF,EAASP,EAAaQ,GAClB,IAAIR,EAAaQ,KAAaD,IAC9BR,EACE,IAAIO,EAAOP,KAAaQ,IACxBA,SAECV,EAAOE,UACdF,EAAOC,IAAMS,EACNV,CAAM,EAGJa,EAAoBC,GAA0Bd,IACzD,MAAMe,EAAWC,EAASnB,GAQ1B,OAPAG,EAAOiB,QAAU,IACZjB,EAAOiB,QACVpB,CAACA,GAAakB,EACdG,eAAgB,QAChBJ,kBACGK,EAAUC,cAERpB,CAAM,EAQf,IAAeqB,EAAAC,OAASvB,kBAAiBwB,yBAAwBC,MAC/DC,EAAgBC,aAAaC,QAAQC,IAAI9B,EAAuBC,UAC1D8B,EAAYC,gBAClB,MAAMC,EAASC,IACfP,EAAgBC,aAAaC,QAAQC,IAAIf,EAAiBkB,UAEpDE,EAAgBF,SAChBR,OAEN,aADkBM,EAAYK,KAAKV,EACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/core/request/index.ts","../../../src/core/request/InterceptorManager.ts"],"sourcesContent":["import axios from 'axios';\nimport type { AxiosResponse, AxiosInterceptorManager } from 'axios';\nimport {\n GantAxiosRequestConfig,\n GantServerOptions,\n InternalAxiosRequestConfig,\n} from './interface';\nimport InterceptorManager from './InterceptorManager';\nexport * from './interface';\n\nconst instance = axios.create({});\nconst responseInterceptor = new InterceptorManager<AxiosResponse>();\n\ntype RequestMethodType = <T = any>(\n url: string,\n config?: GantAxiosRequestConfig,\n options?: GantServerOptions,\n) => Promise<T>;\n\ntype Request = {\n <T = any>(\n url: string,\n config: GantAxiosRequestConfig,\n options?: GantServerOptions,\n ): Promise<T>;\n} & {\n post: RequestMethodType;\n get: RequestMethodType;\n put: RequestMethodType;\n delete: RequestMethodType;\n};\nconst defaultOptions = {\n showSuccess: false,\n successMessage: '',\n showWarning: false,\n showError: true,\n getParams: false,\n isStream: false,\n dangerParse: false,\n};\nconst requestInterceptor: RequestMethodType = function (\n url,\n config,\n optionsProp,\n) {\n const options = { ...defaultOptions, ...optionsProp };\n const { getParams, isStream } = options;\n const responseInterceptorChain: any[] = [];\n\n responseInterceptor.forEach(function pushResponseInterceptors(\n interceptor: any,\n ) {\n responseInterceptorChain.push(interceptor);\n });\n\n let promise = instance.request<any, AxiosResponse>({\n method: 'post',\n ...config,\n url,\n });\n let i = 0;\n while (i < responseInterceptorChain.length) {\n const fulfilled = responseInterceptorChain[i]?.fulfilled;\n const rejected = responseInterceptorChain[i]?.rejected;\n promise = promise\n .then((res: any) => {\n if (typeof fulfilled == 'function') return fulfilled(res, options);\n return res;\n })\n .catch((reject: any) => {\n if (typeof rejected == 'function') return rejected(reject, options);\n return Promise.reject(reject);\n });\n i++;\n }\n return promise.then((res: AxiosResponse) => {\n const { data: serveData } = res;\n return getParams ? res : isStream ? serveData : serveData.data;\n });\n};\n\nconst request = requestInterceptor as Request;\n\n//兼容写法\n(\n ['post', 'get', 'put', 'delete'] as ('post' | 'get' | 'put' | 'delete')[]\n).forEach((method) => {\n request[method] = function namedRequest(url, config, ...options) {\n return request(url, { ...config, method }, ...options);\n } as RequestMethodType;\n});\n\nexport default request;\nexport const requestInstance = {\n ...instance,\n interceptors: {\n request: instance.interceptors\n .request as AxiosInterceptorManager<InternalAxiosRequestConfig>,\n response: responseInterceptor,\n },\n};\n","import { GantServerOptions } from './interface';\nimport { forEach } from 'lodash-es';\nclass InterceptorManager<V> {\n handlers: any[];\n constructor() {\n this.handlers = [];\n }\n\n /**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\n use(\n fulfilled?:\n | ((value: V, options?: GantServerOptions) => V | Promise<V>)\n | null,\n rejected?: ((error: any, options?: GantServerOptions) => any) | null,\n ) {\n this.handlers.push({\n fulfilled,\n rejected,\n });\n return this.handlers.length - 1;\n }\n\n /**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n *\n * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise\n */\n eject(id: number) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n }\n\n /**\n * Clear all interceptors from the stack\n *\n * @returns {void}\n */\n clear() {\n if (this.handlers) {\n this.handlers = [];\n }\n }\n\n /**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n *\n * @returns {void}\n */\n forEach(fn: any) {\n forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n }\n}\n\nexport default InterceptorManager;\n"],"names":["instance","axios","create","responseInterceptor","handlers","constructor","this","use","fulfilled","rejected","push","length","eject","id","clear","forEach","fn","h","defaultOptions","showSuccess","successMessage","showWarning","showError","getParams","isStream","dangerParse","request","url","config","optionsProp","options","responseInterceptorChain","interceptor","promise","method","i","then","res","catch","reject","Promise","data","serveData","requestInstance","interceptors","response"],"mappings":"yDAUA,MAAMA,EAAWC,EAAMC,OAAO,CAAA,GACxBC,EAAsB,ICT5B,MACEC,SACA,WAAAC,GACEC,KAAKF,SAAW,EACjB,CAUD,GAAAG,CACEC,EAGAC,GAMA,OAJAH,KAAKF,SAASM,KAAK,CACjBF,YACAC,aAEKH,KAAKF,SAASO,OAAS,CAC/B,CASD,KAAAC,CAAMC,GACAP,KAAKF,SAASS,KAChBP,KAAKF,SAASS,GAAM,KAEvB,CAOD,KAAAC,GACMR,KAAKF,WACPE,KAAKF,SAAW,GAEnB,CAYD,OAAAW,CAAQC,GACND,EAAQT,KAAKF,UAAU,SAAwBa,GACnC,OAANA,GACFD,EAAGC,EAEP,GACD,GDtCGC,EAAiB,CACrBC,aAAa,EACbC,eAAgB,GAChBC,aAAa,EACbC,WAAW,EACXC,WAAW,EACXC,UAAU,EACVC,aAAa,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/core/request/index.ts","../../../src/core/request/InterceptorManager.ts"],"sourcesContent":["import axios from 'axios';\nimport type { AxiosResponse, AxiosInterceptorManager } from 'axios';\nimport {\n GantAxiosRequestConfig,\n GantServerOptions,\n InternalAxiosRequestConfig,\n} from './interface';\nimport InterceptorManager from './InterceptorManager';\nexport * from './interface';\n\nconst instance = axios.create({});\nconst responseInterceptor = new InterceptorManager<AxiosResponse>();\n\ntype RequestMethodType = <T = any>(\n url: string,\n config?: GantAxiosRequestConfig,\n options?: GantServerOptions,\n) => Promise<T>;\n\ntype Request = {\n <T = any>(\n url: string,\n config: GantAxiosRequestConfig,\n options?: GantServerOptions,\n ): Promise<T>;\n} & {\n post: RequestMethodType;\n get: RequestMethodType;\n put: RequestMethodType;\n delete: RequestMethodType;\n};\nconst defaultOptions = {\n showSuccess: false,\n successMessage: '',\n showWarning: false,\n showError: true,\n getParams: false,\n isStream: false,\n dangerParse: false,\n \n};\nconst requestInterceptor: RequestMethodType = function (\n url,\n config,\n optionsProp,\n) {\n const options = { ...defaultOptions, ...optionsProp };\n const { getParams, isStream } = options;\n const responseInterceptorChain: any[] = [];\n\n responseInterceptor.forEach(function pushResponseInterceptors(\n interceptor: any,\n ) {\n responseInterceptorChain.push(interceptor);\n });\n\n let promise = instance.request<any, AxiosResponse>({\n method: 'post',\n ...config,\n url,\n });\n let i = 0;\n while (i < responseInterceptorChain.length) {\n const fulfilled = responseInterceptorChain[i]?.fulfilled;\n const rejected = responseInterceptorChain[i]?.rejected;\n promise = promise\n .then((res: any) => {\n if (typeof fulfilled == 'function') return fulfilled(res, options);\n return res;\n })\n .catch((reject: any) => {\n if (typeof rejected == 'function') return rejected(reject, options);\n return Promise.reject(reject);\n });\n i++;\n }\n return promise.then((res: AxiosResponse) => {\n const { data: serveData } = res;\n return getParams ? res : isStream ? serveData : serveData.data;\n });\n};\n\nconst request = requestInterceptor as Request;\n\n//兼容写法\n(\n ['post', 'get', 'put', 'delete'] as ('post' | 'get' | 'put' | 'delete')[]\n).forEach((method) => {\n request[method] = function namedRequest(url, config, ...options) {\n return request(url, { ...config, method }, ...options);\n } as RequestMethodType;\n});\n\nexport default request;\nexport const requestInstance = {\n ...instance,\n interceptors: {\n request: instance.interceptors\n .request as AxiosInterceptorManager<InternalAxiosRequestConfig>,\n response: responseInterceptor,\n },\n};\n","import { GantServerOptions } from './interface';\nimport { forEach } from 'lodash-es';\nclass InterceptorManager<V> {\n handlers: any[];\n constructor() {\n this.handlers = [];\n }\n\n /**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\n use(\n fulfilled?:\n | ((value: V, options?: GantServerOptions) => V | Promise<V>)\n | null,\n rejected?: ((error: any, options?: GantServerOptions) => any) | null,\n ) {\n this.handlers.push({\n fulfilled,\n rejected,\n });\n return this.handlers.length - 1;\n }\n\n /**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n *\n * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise\n */\n eject(id: number) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n }\n\n /**\n * Clear all interceptors from the stack\n *\n * @returns {void}\n */\n clear() {\n if (this.handlers) {\n this.handlers = [];\n }\n }\n\n /**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n *\n * @returns {void}\n */\n forEach(fn: any) {\n forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n }\n}\n\nexport default InterceptorManager;\n"],"names":["instance","axios","create","responseInterceptor","handlers","constructor","this","use","fulfilled","rejected","push","length","eject","id","clear","forEach","fn","h","defaultOptions","showSuccess","successMessage","showWarning","showError","getParams","isStream","dangerParse","request","url","config","optionsProp","options","responseInterceptorChain","interceptor","promise","method","i","then","res","catch","reject","Promise","data","serveData","requestInstance","interceptors","response"],"mappings":"yDAUA,MAAMA,EAAWC,EAAMC,OAAO,CAAA,GACxBC,EAAsB,ICT5B,MACEC,SACA,WAAAC,GACEC,KAAKF,SAAW,EACjB,CAUD,GAAAG,CACEC,EAGAC,GAMA,OAJAH,KAAKF,SAASM,KAAK,CACjBF,YACAC,aAEKH,KAAKF,SAASO,OAAS,CAC/B,CASD,KAAAC,CAAMC,GACAP,KAAKF,SAASS,KAChBP,KAAKF,SAASS,GAAM,KAEvB,CAOD,KAAAC,GACMR,KAAKF,WACPE,KAAKF,SAAW,GAEnB,CAYD,OAAAW,CAAQC,GACND,EAAQT,KAAKF,UAAU,SAAwBa,GACnC,OAANA,GACFD,EAAGC,EAEP,GACD,GDtCGC,EAAiB,CACrBC,aAAa,EACbC,eAAgB,GAChBC,aAAa,EACbC,WAAW,EACXC,WAAW,EACXC,UAAU,EACVC,aAAa,GA4CTC,EAzCwC,SAC5CC,EACAC,EACAC,GAEA,MAAMC,EAAU,IAAKZ,KAAmBW,IAClCN,UAAEA,EAASC,SAAEA,GAAaM,EAC1BC,EAAkC,GAExC5B,EAAoBY,SAAQ,SAC1BiB,GAEAD,EAAyBrB,KAAKsB,EAChC,IAEA,IAAIC,EAAUjC,EAAS0B,QAA4B,CACjDQ,OAAQ,UACLN,EACHD,QAEEQ,EAAI,EACR,KAAOA,EAAIJ,EAAyBpB,QAAQ,CAC1C,MAAMH,EAAYuB,EAAyBI,IAAI3B,UACzCC,EAAWsB,EAAyBI,IAAI1B,SAC9CwB,EAAUA,EACPG,MAAMC,GACmB,mBAAb7B,EAAgCA,EAAU6B,EAAKP,GACnDO,IAERC,OAAOC,GACiB,mBAAZ9B,EAA+BA,EAAS8B,EAAQT,GACpDU,QAAQD,OAAOA,KAE1BJ,GACD,CACD,OAAOF,EAAQG,MAAMC,IACnB,MAAQI,KAAMC,GAAcL,EAC5B,OAAOd,EAAYc,EAAMb,EAAWkB,EAAYA,EAAUD,IAAI,GAElE,EAME,CAAC,OAAQ,MAAO,MAAO,UACvB1B,SAASmB,IACTR,EAAQQ,GAAU,SAAsBP,EAAKC,KAAWE,GACtD,OAAOJ,EAAQC,EAAK,IAAKC,EAAQM,aAAaJ,EAChD,CAAsB,IAIX,MAAAa,EAAkB,IAC1B3C,EACH4C,aAAc,CACZlB,QAAS1B,EAAS4C,aACflB,QACHmB,SAAU1C"}
|
package/lib/core/store/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as t}from"../request/index.js";import{groupBy as e,reduce as s,find as i,keyBy as n,pick as a,get as r,uniqueId as o,omit as c,isEmpty as h,findIndex as u,isPlainObject as d,cloneDeep as m,mapValues as g,uniqBy as p}from"lodash-es";import l from"mitt";const y=new class{codeLists=[];codeMaps={};async findAllCodeList(){const s=await t("/codeList/findAll",{data:{},serviceId:"fwPlatform"})||[],i=e(s,"type");this.codeLists=s,this.codeMaps=i}getCodeLocaleList=t=>[...this.codeMaps?.[t]]||[];getCodeLocaleName=(t,e)=>{const n=this.getCodeLocaleList(t);function a(t){const e=i(n,(e=>e.value===String(t)));return e?.name||""}if(Array.isArray(e)){const t=s(e,((t="",e="")=>t+","+a(e)),"");return t.slice(1,t.length)}if(String(e).indexOf(",")>=0){const t=e.replace("[","").replace("]","").split(","),i=s(t,((t="",e="")=>t+","+a(e)),"");return i.slice(1,i.length)}return a(e)}};y.getCodeLocaleList,y.getCodeLocaleName;const w=new class{parameterList=[];parameterMap={};findAllParameters=async()=>{const e=await t("/parameter/findAll",{serviceId:"fwPlatform",data:{}},{showError:!1})||[],s=n(e,"name");this.parameterList=e,this.parameterMap=s};getSystemParameterByName=t=>"string"==typeof t?this.parameterMap[t]:a(this.parameterMap,t)},S="ping",f="pong",I="WS_CONTENT_SUCCESS",L="WS_CONTENT_ERROR",P="WS_CONTENT_CLOSE";const T=new class{RECIPIENT_TYPE_ALL="all";RECIPIENT_TYPE_USER="user";RECIPIENT_TYPE_OBSERVER="obsvr";RECIPIENT_TYPE_CONNECTION="conn";webSocketUrl="";ws=null;repeat=0;connectLoading=!1;disReconnect=!1;pingTimeoutFn=null;pongTimeoutFn=null;reconnectFn=null;repeatLimit=2;connectionId="";userLoginName="";eventStack={};emitter;constructor(){this.emitter=l()}init=(t,e)=>{this.userLoginName=t,this.webSocketUrl=(t=>{const e=`userLoginName=${t}`,{host:s,protocol:i,port:n,hostname:a}=window.location,r=i.includes("https");let o=r?"wss":"ws",c=s;!r&&n&&(c=`${a}:${parseInt(n)}`);return`${o}://${c}/notification-ws?${e}`})(t),this.disReconnect=r(e,"disReconnect",!1),this.repeatLimit=r(e,"repeatLimit",20),this.createWebSocket()};createWebSocket=()=>{this.connectLoading=!0;try{this.ws=new WebSocket(this.webSocketUrl),this.registerEvent()}catch(t){this.ws=null,this.reconnect()}finally{this.connectLoading=!1}};reconnect=()=>{this.reconnectFn&&clearTimeout(this.reconnectFn),this.repeatLimit&&this.repeatLimit<=this.repeat||this.connectLoading||this.disReconnect||this.ws||(this.repeat++,this.reconnectFn=setTimeout((()=>{this.createWebSocket()}),1e4))};heartCheck=()=>{this.repeat=0,this.disReconnect||(this.pingTimeoutFn=setTimeout((()=>{const t=`{"userLoginName":"${this.userLoginName}","connectionId":"${this.connectionId}","content":"${S}"}`;this.ws?.send(t),this.pongTimeoutFn=setTimeout((()=>{this.ws?.close()}),1e4)}),1e4))};heartReset=()=>{this.pingTimeoutFn&&(clearTimeout(this.pingTimeoutFn),this.pingTimeoutFn=null),this.pongTimeoutFn&&(clearTimeout(this.pongTimeoutFn),this.pongTimeoutFn=null)};disconnect=()=>{this.heartReset(),1==this.ws?.readyState&&this.ws?.close(),this.ws=null};registerEvent=()=>{this.ws&&(this.ws.onopen=()=>{this.heartCheck()},this.ws.onmessage=t=>{this.heartReset(),this.heartCheck();const e=t.data;try{if(e==f||JSON.parse(e).content==S||JSON.parse(e).content==f)return;const t=JSON.parse(e),s={...t,senderTime:t.senderTime};if(this.emitter.emit(I,s),Object.keys(this.eventStack).map((t=>{const e=this.eventStack[t],i=e.recipientType?.includes(s.recipientType);i&&e?.event?.(s)})),s.recipientType==this.RECIPIENT_TYPE_CONNECTION)return void(this.connectionId=s.recipientCode)}catch(t){console.warn("received error!!!",t)}},this.ws.onerror=()=>{this.heartReset(),this.reconnect(),this.emitter.emit(L)},this.ws.onclose=()=>{console.warn("webSocket close"),this.ws=null,this.heartReset(),this.reconnect(),this.emitter.emit(P)})};addTypeListener=(t,e)=>{const s=Array.isArray(t)?t:[t],i=o();return this.eventStack[i]={recipientType:s,type:"recipientType",event:e},i};removeListener=t=>{this.eventStack=c(this.eventStack,t)}},{RECIPIENT_TYPE_OBSERVER:C}=T,v="PROGRESS_UPDEDATE";const k=new class{websocketId;progressObserver={};emitter;constructor(){this.websocketId=T.addTypeListener(C,this.progressEvent)}progressEvent(t){Object.keys(this.progressObserver).map((e=>{const s=this.progressObserver[e];t?.recipientCode===s.type&&(this.progressObserver[e]={...s,data:t})})),this.updedataProgress()}updedataProgress(){const t=[];Object.keys(this.progressObserver).map((e=>{const s=this.progressObserver[e];h(s?.data)||t.push({...s})})),this.emitter.emit(v,t)}addProgressListener(t,e){const s=o();return this.progressObserver[s]={type:t,options:e},s}removeProgressListener(t){this.progressObserver=c(this.progressObserver,t)}async requestProgress(e,s){if(!T.connectionId&&!s?.headers?.connectionId)return console.error("WebSocket no link established");const i=(new Date).getDate()+"",n=this.addProgressListener(i),a=t=>{const e=t.find((t=>t.type===i));e&&s?.onProgress?.(e.data?.progress)};this.emitter.on(v,a);try{const n=await t.post(e,{headers:{observerId:i,connectionId:T.connectionId,...s?.headers},data:s?.params},{getParams:s?.getParams});s?.success?.(n)}catch(t){console.error("---\x3e",t),s?.error?.(t)}this.emitter.off(v,a),this.removeProgressListener(n)}};const U=(({prefixKey:t="",storage:e=localStorage}={})=>new class{storage=e;prefixKey=t;getKey(t){return`${this.prefixKey}${t}`.toUpperCase()}set(t,e,s=604800){const i=JSON.stringify({value:e,expire:null!==s?(new Date).getTime()+1e3*s:null});this.storage.setItem(this.getKey(t),i)}get(t,e=null){const s=this.storage.getItem(this.getKey(t));if(s)try{const e=JSON.parse(s),{value:i,expire:n}=e;if(null===n||n>=Date.now())return i;this.remove(t)}catch(t){return console.error(t),e}return e}remove(t){this.storage.removeItem(this.getKey(t))}clear(){this.storage.clear()}setCookie(t,e,s=604800){document.cookie=`${this.getKey(t)}=${e}; Max-Age=${s}`}getCookie(t){const e=document.cookie.split("; ");for(let s=0,i=e.length;s<i;s++){const i=e[s].split("=");if(i[0]===this.getKey(t))return i[1]}return""}removeCookie(t){this.setCookie(t,1,-1)}clearCookie(){const t=document.cookie.match(/[^ =;]+(?==)/g);if(t)for(let e=t.length;e--;)document.cookie=t[e]+"=0;expire="+new Date(0).toUTCString()}})();class b{userIdentity={};currentUser={};isSuperAdmin=!1;roles=[];functions=[];delegations=[];userSetting={};users=[];getUserIdentity(){if(!h(this.userIdentity))return this.userIdentity;const t=U?.get("userIdentity");return t||{}}setUserIdentity(t){return this.userIdentity={...this.userIdentity,...t},U.set("userIdentity",this.userIdentity),this.userIdentity}clearUserIdentity(){U.remove("userIdentity"),this.userIdentity={}}setUserAggregateInfo=({delegations:t,roles:e,functions:s,isSuperAdmin:i,currentUser:n})=>{this.delegations=t,this.roles=e,this.functions=s,this.isSuperAdmin=i,this.currentUser=n};getUserSettingType=t=>`${this.currentUser.id}-${t}`;getUserSetting=async e=>{const s=this.getUserSettingType(e),i=this.currentUser.id;if(this.userSetting[s])return this.userSetting[s];const n=await async function(e){return t("/accountUserSelf/getUserData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:i+e}),a=n?.bigData?JSON.parse(n.bigData):void 0;return this.userSetting[s]=a,a};updateUserSetting=async(e,s)=>{const i=this.getUserSettingType(e),n=this.currentUser.id;return await async function(e,s){return t("/accountUserSelf/setUserData",{data:e,serviceId:"fwSecurity"},s)}({dataType:e,dataId:n+e,bigData:JSON.stringify(s)}),this.userSetting[i]=s,s};removeUserSetting=async e=>{const s=this.getUserSettingType(e),i=this.currentUser.id;await async function(e,s){return t("/accountUserSelf/delUserData",{data:e,serviceId:"fwSecurity"},s)}({dataType:e,dataId:i}),delete this.userSetting[s]};getUserInfo=async(e,s)=>{const i=u(this.users,(t=>s?t.userLoginName===e:t.id===e));if(i>-1)return r(this.users,`[${i}]`);const n=s?await async function(e){return t("/security/getUserByUserLoginName",{method:"POST",data:{userLoginName:e},serviceId:"fwSecurity"})}(e):await async function(e){return t("/security/getUserById",{method:"POST",data:{id:e},serviceId:"fwSecurity"})}(e);return d(n)&&this.users.push(n),n}}const E=/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i,O=/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i,N=t=>E.test(t)||O.test(t)||0===t?.indexOf("/")?t:"/"+t,D="MENU_HISTORY_UPDATE",R="MENU_BREADCRUMBS_UPDATE";l();class A{menuDataMaps={};menuData=[];menuPathMaps={};breadcrumbs=[];menuHistorys=[];userId;emitter;constructor(){this.emitter=l()}addListenerMenuHistorys=t=>{this.emitter.on(D,t)};removeListenerMenuHistorys=t=>this.emitter.off(D,t);addListenerBreadcrumbs=t=>this.emitter.on(R,t);removeListenerBreadcrumbs=t=>this.emitter.off(R,t);getTreeMenuData=(t,e,s)=>t.map((t=>{const{id:i,path:n,leaf:a}=t,r=e[i],o={...t,key:i,path:s?s+N(n):N(n)};if(r&&!a){const t=this.getTreeMenuData(r,e,o.path);o.children=t}return this.menuDataMaps[o.path]=o,o})).sort(((t,e)=>t.seqNum-e.seqNum));init=(t,s)=>{const i=m(t);if(h(i))return;const n=e(i,"parentResourceId"),{ROOT:a,...r}=n;this.menuData=this.getTreeMenuData(a,r),this.menuData=[...this.menuData];const o=g(this.menuDataMaps,"name");this.updateMenuMaps(o),this.initMenuHistorys(s)};updateMenuMaps=t=>{this.menuPathMaps={...this.menuPathMaps,...t};const e=this.menuHistorys.map((t=>{const e=this.menuPathMaps[t.pathname];return{pathname:t.pathname,name:e||t.name}})),s=this.breadcrumbs.map((t=>{const e=this.menuPathMaps[t.pathname];return{...t,name:e||t.name}}));this.updatehistorys(e),this.updateBreadcrumbs(s)};liseterHistorys=t=>{let e=this.menuHistorys;this.menuDataMaps[t]?.leaf&&!e.some((e=>e.pathname===t))&&(e=[{pathname:t,name:this.menuPathMaps[t]},...e],this.updatehistorys(e))};updatehistorys=t=>{if(!this.userId)return;const e=t.map((t=>({...t,name:t.name?t.name:this.menuPathMaps[t.pathname]})));this.menuHistorys=e,this.menuHistorys=p(this.menuHistorys,"pathname"),this.emitter.emit(D,this.menuHistorys),U.set(`${this.userId}-menu-history`,this.menuHistorys)};initMenuHistorys=t=>{this.userId=t;const e=U.get(`${t}-menu-history`,this.menuHistorys);this.updatehistorys(e)};liseterBreadcrumbs=t=>{const e=t.split("/");let s=1;const i=[],n={pathname:t,name:this.menuPathMaps[t]};for(;s<e.length;){const t=e.slice(0,s).join("/");this.menuPathMaps[t]&&i.push({name:this.menuPathMaps[t],pathname:t}),s++}i.push(n),this.updateBreadcrumbs(i)};updateBreadcrumbs=t=>{this.breadcrumbs=t,this.breadcrumbs=p(this.breadcrumbs,"pathname"),this.emitter.emit(R,t)}}class M{loginPathname;BASE="/";get baseLoginPathname(){return`${this.BASE}${this.loginPathname?.replace("/","")}`}tokenValue="";get isLoginPathname(){const t=window.location.pathname;return this.baseLoginPathname==t}getRealPath=t=>`${this.BASE}${t.replace("/","")}`;chekToken=async()=>{const e=await t("/authentication/checkToken",{serviceId:"fwSecurity"},{showError:!1});return e&&this.isLoginPathname&&window.location.replace(this.BASE),e};getLoginMethod=async()=>t("/authentication/getLoginMethod",{serviceId:"fwSecurity"});redirectBaseLogin=async()=>{const t=window.location.pathname,e=window.location.href;if(this.isLoginPathname)return!0;const s=new URLSearchParams;t!==this.BASE&&"/"!==t&&s.append("redirectUrl",e);const i=decodeURIComponent(s.toString());return window.location.replace(`${this.baseLoginPathname}${i?"?"+decodeURIComponent(s.toString()):""}`),!1};checkPassword=async()=>"noPass"!==await t("/security/checkPasswordUpdateTime",{data:{}},{showError:!1})||(this.tokenValue=await t("/authentication/extractToken",{data:{}}),!1);refactorToken=async()=>{var e;await(e=this.tokenValue,t("/authentication/refactorToken",{data:{value:e}}))};login=async t=>{const e=await this.baseLogin(t);return e.error,e};baseLogin=async e=>{const s={error:void 0,data:void 0};try{const i=await function(e){return t("/authentication/login",{data:e,serviceId:"fwSecurity"})}(e),{userToken:n,traceId:a}=i;if(n){s.data=i;return await this.checkPassword()||(s.error="passwordExpiration"),s}return a?(s.data=i,s.error="SLIDER_VERIFICATION_LOGIN",s):(s.error="passwordError",s)}catch(t){return s.error="validateError",s}};loginSuccess=()=>{let t=new URLSearchParams(window.location.search).get("redirectUrl");t?window.location.href=t:window.location.replace(this.BASE)};baseLoginOut=async()=>{const e=new URLSearchParams,s=window.location.href;window.location.pathname!==this.BASE&&e.append("redirectUrl",s),await t("/authentication/logout",{data:{},serviceId:"fwSecurity"}),window.location.replace(`${this.baseLoginPathname}?${e.toString()}`)}}const $={sso:!1,ssoUrlSearchParams:["ticket"],ssoCheckTokenUrl:"",ssoSuccessUrlkey:"successUrl",ssoLoginUrl:window.location.origin+"/fwSecurity/ssoAuth/login.api",ssologinOutUrl:window.location.origin+"fwSecurity/ssoAuth/logout.api"};class _{init(t){this.ssoConfig={...this.ssoConfig,...t}}ssoConfig=$;isSso=async e=>{if(!this.ssoConfig.sso)return!1;let s=!1;try{s=await t("/ssoAuthConfig/checkOnlyRedirect",{},{showError:!1})}catch(t){console.error("sso",t)}return e&&(s=await e()),!!s};ssoLogin=()=>{const{ssoSuccessUrlkey:t,ssoUrlSearchParams:e,ssoLoginUrl:s}=this.ssoConfig,i=new URLSearchParams(window.location.search.slice(1)),n=new URLSearchParams,a=window.location.href;return n.append(t,encodeURIComponent(a)),e.map((t=>{const e=i.get(t);e&&n.append(t,e)})),window.location.href=`${s}?${n.toString()}`,!1};ssoLoginOut=()=>{window.location.href=this.ssoConfig.ssologinOutUrl}}class B{getValidateCodeImage=e=>function(e={}){return t("/authentication/getValidateCode",{data:e,serviceId:"fwSecurity"})}(e);sliderVerificationCodeImage=()=>t("/authentication/sliderVerificationCode",{method:"POST",serviceId:"fwSecurity"});checkCaptcha=e=>{return s=e,t("/authentication/checkCaptcha",{method:"POST",data:{...s},serviceId:"fwSecurity"});var s}}class x extends M{ssoLogin;validate;noCheckPermissionsPath=[];ssoCallback;constructor(){super(),this.ssoLogin=new _,this.validate=new B}init=(t,e="/",s)=>{this.BASE=e,this.ssoCallback=s,this.noCheckPermissionsPath=t?.noCheckPermissionsPath,this.ssoLogin.init(t),this.loginPathname=t?.loginPathname||"/login"};isNoLoginRequiredPage=()=>{const t=window.location.pathname,e=this.noCheckPermissionsPath?.some((e=>this.getRealPath(e)==t));return e};loginOut=async()=>{await this.ssoLogin.isSso(this.ssoCallback)&&this.ssoLogin.ssoLoginOut(),await this.baseLoginOut()};loginAuthentication=async e=>{var s;await(s=e,t("/authentication/beforeLoginCheckCode",{method:"POST",data:{...s},serviceId:"fwSecurity"})),this.loginSuccess()};redirectLogin=async()=>{if(this.isNoLoginRequiredPage())return!0;return await this.ssoLogin.isSso(this.ssoCallback)?(this.ssoLogin.ssoLogin(),!1):!!this.isLoginPathname||await this.redirectBaseLogin()}}const F=new class{userStore;menuStore;loginStore;isSuperAdmin=!1;loginCallback;constructor(){this.userStore=new b,this.menuStore=new A,this.loginStore=new x}platformLanguages=[];productInfo={isProdEnv:!1,productName:""};get isPrd(){return this.productInfo?.isProdEnv}get userInfo(){return this.userStore.currentUser}get menuData(){return this.menuStore.menuData}findPlantform=async()=>{const e=await t("/platformManage/getPlatformAggregateInfo",{method:"POST"},{showError:!1});this.platformLanguages=e.platformLanguages,this.productInfo=e.productInfo};getAggregateInfo=async e=>{const s=await async function(){return t("/security/findUserAggregateInfo",{method:"POST"})}(),{user:i,startMenus:n,isSuperAdmin:a,...r}=s;this.userStore.setUserAggregateInfo({...r,currentUser:i}),this.isSuperAdmin=a;const o="function"==typeof e?await e(s):e;this.menuStore.init(h(o)?n:o,i.id)};init=async t=>{const{base:e="/",menuData:s,loginSuccessCallback:i,ssoCallback:n,websocket:a=!0}=t;this.loginStore.init(t?.loginConfig,e,n);try{const t=await this.loginStore.chekToken();return t?(this.userStore.setUserIdentity(t),await this.getAggregateInfo(s),await y.findAllCodeList(),await w.findAllParameters(),a&&T.init(this.userStore.currentUser.userLoginName),await(i?.()),!0):await this.loginStore.redirectLogin()}catch(t){console.error(t)}return!1}};const H="company-v1";var V=new class{data={};getCompanyDataType=t=>`${H}-${t}`;getCompanyData=async e=>{const s=this.getCompanyDataType(e);if(this.data[s])return this.data[s];const i=await async function(e){return t("/companyData/getCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:H}),n=i?.bigData?JSON.parse(i.bigData):void 0;this.data[s]=n};updateCompanyData=async(e,s)=>{const i=this.getCompanyDataType(e);return await async function(e){return t("/companyData/setCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:H,bigData:JSON.stringify(s)}),this.data[i]=s,s};removeCompanyData=async e=>{const s=this.getCompanyDataType(e);await async function(e){return t("/companyData/delCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:H}),delete this.data[s]}};const J=y,K=w,W=F.userStore,Y=F.loginStore,q=F.menuStore;export{D as M,k as P,P as W,R as a,v as b,J as c,L as d,I as e,F as g,V as i,Y as l,q as m,K as p,U as s,W as u,T as w};
|
|
1
|
+
import{r as t}from"../request/index.js";import{groupBy as e,reduce as s,find as i,keyBy as n,pick as r,get as a,uniqueId as o,omit as c,isEmpty as h,findIndex as u,isPlainObject as d,cloneDeep as m,mapValues as g,uniqBy as p}from"lodash-es";import l from"mitt";const y=new class{codeLists=[];codeMaps={};async findAllCodeList(){const s=await t("/codeList/findAll",{data:{},serviceId:"fwPlatform"})||[],i=e(s,"type");this.codeLists=s,this.codeMaps=i}getCodeLocaleList=t=>[...this.codeMaps?.[t]]||[];getCodeLocaleName=(t,e)=>{const n=this.getCodeLocaleList(t);function r(t){const e=i(n,(e=>e.value===String(t)));return e?.name||""}if(Array.isArray(e)){const t=s(e,((t="",e="")=>t+","+r(e)),"");return t.slice(1,t.length)}if(String(e).indexOf(",")>=0){const t=e.replace("[","").replace("]","").split(","),i=s(t,((t="",e="")=>t+","+r(e)),"");return i.slice(1,i.length)}return r(e)}};y.getCodeLocaleList,y.getCodeLocaleName;const w=new class{parameterList=[];parameterMap={};findAllParameters=async()=>{const e=await t("/parameter/findAll",{serviceId:"fwPlatform",data:{}},{showError:!1})||[],s=n(e,"name");this.parameterList=e,this.parameterMap=s};getSystemParameterByName=t=>"string"==typeof t?this.parameterMap[t]:r(this.parameterMap,t)},S="ping",f="pong",I="WS_CONTENT_SUCCESS",L="WS_CONTENT_ERROR",P="WS_CONTENT_CLOSE";const T=new class{RECIPIENT_TYPE_ALL="all";RECIPIENT_TYPE_USER="user";RECIPIENT_TYPE_OBSERVER="obsvr";RECIPIENT_TYPE_CONNECTION="conn";webSocketUrl="";ws=null;repeat=0;connectLoading=!1;disReconnect=!1;pingTimeoutFn=null;pongTimeoutFn=null;reconnectFn=null;repeatLimit=2;connectionId="";userLoginName="";eventStack={};emitter;constructor(){this.emitter=l()}init=(t,e)=>{this.userLoginName=t,this.webSocketUrl=(t=>{const e=`userLoginName=${t}`,{host:s,protocol:i,port:n,hostname:r}=window.location,a=i.includes("https");let o=a?"wss":"ws",c=s;!a&&n&&(c=`${r}:${parseInt(n)}`);return`${o}://${c}/notification-ws?${e}`})(t),this.disReconnect=a(e,"disReconnect",!1),this.repeatLimit=a(e,"repeatLimit",20),this.createWebSocket()};createWebSocket=()=>{this.connectLoading=!0;try{this.ws=new WebSocket(this.webSocketUrl),this.registerEvent()}catch(t){this.ws=null,this.reconnect()}finally{this.connectLoading=!1}};reconnect=()=>{this.reconnectFn&&clearTimeout(this.reconnectFn),this.repeatLimit&&this.repeatLimit<=this.repeat||this.connectLoading||this.disReconnect||this.ws||(this.repeat++,this.reconnectFn=setTimeout((()=>{this.createWebSocket()}),1e4))};heartCheck=()=>{this.repeat=0,this.disReconnect||(this.pingTimeoutFn=setTimeout((()=>{const t=`{"userLoginName":"${this.userLoginName}","connectionId":"${this.connectionId}","content":"${S}"}`;this.ws?.send(t),this.pongTimeoutFn=setTimeout((()=>{this.ws?.close()}),1e4)}),1e4))};heartReset=()=>{this.pingTimeoutFn&&(clearTimeout(this.pingTimeoutFn),this.pingTimeoutFn=null),this.pongTimeoutFn&&(clearTimeout(this.pongTimeoutFn),this.pongTimeoutFn=null)};disconnect=()=>{this.heartReset(),1==this.ws?.readyState&&this.ws?.close(),this.ws=null};registerEvent=()=>{this.ws&&(this.ws.onopen=()=>{this.heartCheck()},this.ws.onmessage=t=>{this.heartReset(),this.heartCheck();const e=t.data;try{if(e==f||JSON.parse(e).content==S||JSON.parse(e).content==f)return;const t=JSON.parse(e),s={...t,senderTime:t.senderTime};if(this.emitter.emit(I,s),Object.keys(this.eventStack).map((t=>{const e=this.eventStack[t],i=e.recipientType?.includes(s.recipientType);i&&e?.event?.(s)})),s.recipientType==this.RECIPIENT_TYPE_CONNECTION)return void(this.connectionId=s.recipientCode)}catch(t){console.warn("received error!!!",t)}},this.ws.onerror=()=>{this.heartReset(),this.reconnect(),this.emitter.emit(L)},this.ws.onclose=()=>{console.warn("webSocket close"),this.ws=null,this.heartReset(),this.reconnect(),this.emitter.emit(P)})};addTypeListener=(t,e)=>{const s=Array.isArray(t)?t:[t],i=o();return this.eventStack[i]={recipientType:s,type:"recipientType",event:e},i};removeListener=t=>{this.eventStack=c(this.eventStack,t)}},{RECIPIENT_TYPE_OBSERVER:C}=T,v="PROGRESS_UPDEDATE";const k=new class{websocketId;progressObserver={};emitter;constructor(){this.emitter=l(),this.progressEvent=this.progressEvent.bind(this),this.websocketId=T.addTypeListener(C,this.progressEvent)}progressEvent(t){Object.keys(this.progressObserver).map((e=>{const s=this.progressObserver[e];t?.recipientCode===s.type&&(this.progressObserver[e]={...s,data:t})})),this.updedataProgress()}updedataProgress(){const t=[];Object.keys(this.progressObserver).map((e=>{const s=this.progressObserver[e];h(s?.data)||t.push({...s})})),this.emitter.emit(v,t)}addProgressListener(t,e){const s=o();return this.progressObserver[s]={type:t,options:e},s}removeProgressListener(t){this.progressObserver=c(this.progressObserver,t)}async requestProgress(e,s){if(!T.connectionId&&!s?.headers?.connectionId)return console.error("WebSocket no link established");const i=(new Date).getDate()+"",n=this.addProgressListener(i),r=t=>{const e=t.find((t=>t.type===i));e&&s?.onProgress?.(e.data?.progress)};this.emitter.on(v,r);try{const n=await t.post(e,{headers:{observerId:i,connectionId:T.connectionId,...s?.headers},data:s?.params},{getParams:s?.getParams});s?.success?.(n)}catch(t){console.error("---\x3e",t),s?.error?.(t)}this.emitter.off(v,r),this.removeProgressListener(n)}};const U=(({prefixKey:t="",storage:e=localStorage}={})=>new class{storage=e;prefixKey=t;getKey(t){return`${this.prefixKey}${t}`.toUpperCase()}set(t,e,s=604800){const i=JSON.stringify({value:e,expire:null!==s?(new Date).getTime()+1e3*s:null});this.storage.setItem(this.getKey(t),i)}get(t,e=null){const s=this.storage.getItem(this.getKey(t));if(s)try{const e=JSON.parse(s),{value:i,expire:n}=e;if(null===n||n>=Date.now())return i;this.remove(t)}catch(t){return console.error(t),e}return e}remove(t){this.storage.removeItem(this.getKey(t))}clear(){this.storage.clear()}setCookie(t,e,s=604800){document.cookie=`${this.getKey(t)}=${e}; Max-Age=${s}`}getCookie(t){const e=document.cookie.split("; ");for(let s=0,i=e.length;s<i;s++){const i=e[s].split("=");if(i[0]===this.getKey(t))return i[1]}return""}removeCookie(t){this.setCookie(t,1,-1)}clearCookie(){const t=document.cookie.match(/[^ =;]+(?==)/g);if(t)for(let e=t.length;e--;)document.cookie=t[e]+"=0;expire="+new Date(0).toUTCString()}})();class b{userIdentity={};currentUser={};isSuperAdmin=!1;roles=[];functions=[];delegations=[];userSetting={};users=[];getUserIdentity(){if(!h(this.userIdentity))return this.userIdentity;const t=U?.get("userIdentity");return t||{}}setUserIdentity(t){return this.userIdentity={...this.userIdentity,...t},U.set("userIdentity",this.userIdentity),this.userIdentity}clearUserIdentity(){U.remove("userIdentity"),this.userIdentity={}}setUserAggregateInfo=({delegations:t,roles:e,functions:s,isSuperAdmin:i,currentUser:n})=>{this.delegations=t,this.roles=e,this.functions=s,this.isSuperAdmin=i,this.currentUser=n};getUserSettingType=t=>`${this.currentUser.id}-${t}`;getUserSetting=async e=>{const s=this.getUserSettingType(e),i=this.currentUser.id;if(this.userSetting[s])return this.userSetting[s];const n=await async function(e){return t("/accountUserSelf/getUserData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:i+e}),r=n?.bigData?JSON.parse(n.bigData):void 0;return this.userSetting[s]=r,r};updateUserSetting=async(e,s)=>{const i=this.getUserSettingType(e),n=this.currentUser.id;return await async function(e,s){return t("/accountUserSelf/setUserData",{data:e,serviceId:"fwSecurity"},s)}({dataType:e,dataId:n+e,bigData:JSON.stringify(s)}),this.userSetting[i]=s,s};removeUserSetting=async e=>{const s=this.getUserSettingType(e),i=this.currentUser.id;await async function(e,s){return t("/accountUserSelf/delUserData",{data:e,serviceId:"fwSecurity"},s)}({dataType:e,dataId:i}),delete this.userSetting[s]};getUserInfo=async(e,s)=>{const i=u(this.users,(t=>s?t.userLoginName===e:t.id===e));if(i>-1)return a(this.users,`[${i}]`);const n=s?await async function(e){return t("/security/getUserByUserLoginName",{method:"POST",data:{userLoginName:e},serviceId:"fwSecurity"})}(e):await async function(e){return t("/security/getUserById",{method:"POST",data:{id:e},serviceId:"fwSecurity"})}(e);return d(n)&&this.users.push(n),n}}const E=/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i,O=/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i,N=t=>E.test(t)||O.test(t)||0===t?.indexOf("/")?t:"/"+t,D="MENU_HISTORY_UPDATE",R="MENU_BREADCRUMBS_UPDATE";l();class A{menuDataMaps={};menuData=[];menuPathMaps={};breadcrumbs=[];menuHistorys=[];userId;emitter;constructor(){this.emitter=l()}addListenerMenuHistorys=t=>{this.emitter.on(D,t)};removeListenerMenuHistorys=t=>this.emitter.off(D,t);addListenerBreadcrumbs=t=>this.emitter.on(R,t);removeListenerBreadcrumbs=t=>this.emitter.off(R,t);getTreeMenuData=(t,e,s)=>t.map((t=>{const{id:i,path:n,leaf:r}=t,a=e[i],o={...t,key:i,path:s?s+N(n):N(n)};if(a&&!r){const t=this.getTreeMenuData(a,e,o.path);o.children=t}return this.menuDataMaps[o.path]=o,o})).sort(((t,e)=>t.seqNum-e.seqNum));init=(t,s)=>{const i=m(t);if(h(i))return;const n=e(i,"parentResourceId"),{ROOT:r,...a}=n;this.menuData=this.getTreeMenuData(r,a),this.menuData=[...this.menuData];const o=g(this.menuDataMaps,"name");this.updateMenuMaps(o),this.initMenuHistorys(s)};updateMenuMaps=t=>{this.menuPathMaps={...this.menuPathMaps,...t};const e=this.menuHistorys.map((t=>{const e=this.menuPathMaps[t.pathname];return{pathname:t.pathname,name:e||t.name}})),s=this.breadcrumbs.map((t=>{const e=this.menuPathMaps[t.pathname];return{...t,name:e||t.name}}));this.updatehistorys(e),this.updateBreadcrumbs(s)};liseterHistorys=t=>{let e=this.menuHistorys;this.menuDataMaps[t]?.leaf&&!e.some((e=>e.pathname===t))&&(e=[{pathname:t,name:this.menuPathMaps[t]},...e],this.updatehistorys(e))};updatehistorys=t=>{if(!this.userId)return;const e=t.map((t=>({...t,name:t.name?t.name:this.menuPathMaps[t.pathname]})));this.menuHistorys=e,this.menuHistorys=p(this.menuHistorys,"pathname"),this.emitter.emit(D,this.menuHistorys),U.set(`${this.userId}-menu-history`,this.menuHistorys)};initMenuHistorys=t=>{this.userId=t;const e=U.get(`${t}-menu-history`,this.menuHistorys);this.updatehistorys(e)};liseterBreadcrumbs=t=>{const e=t.split("/");let s=1;const i=[],n={pathname:t,name:this.menuPathMaps[t]};for(;s<e.length;){const t=e.slice(0,s).join("/");this.menuPathMaps[t]&&i.push({name:this.menuPathMaps[t],pathname:t}),s++}i.push(n),this.updateBreadcrumbs(i)};updateBreadcrumbs=t=>{this.breadcrumbs=t,this.breadcrumbs=p(this.breadcrumbs,"pathname"),this.emitter.emit(R,t)}}class M{loginPathname;BASE="/";get baseLoginPathname(){return`${this.BASE}${this.loginPathname?.replace("/","")}`}tokenValue="";get isLoginPathname(){const t=window.location.pathname;return this.baseLoginPathname==t}getRealPath=t=>`${this.BASE}${t.replace("/","")}`;chekToken=async()=>{const e=await t("/authentication/checkToken",{serviceId:"fwSecurity"},{showError:!1});return e&&this.isLoginPathname&&window.location.replace(this.BASE),e};getLoginMethod=async()=>t("/authentication/getLoginMethod",{serviceId:"fwSecurity"});redirectBaseLogin=async()=>{const t=window.location.pathname,e=window.location.href;if(this.isLoginPathname)return!0;const s=new URLSearchParams;t!==this.BASE&&"/"!==t&&s.append("redirectUrl",e);const i=decodeURIComponent(s.toString());return window.location.replace(`${this.baseLoginPathname}${i?"?"+decodeURIComponent(s.toString()):""}`),!1};checkPassword=async()=>"noPass"!==await t("/security/checkPasswordUpdateTime",{data:{}},{showError:!1})||(this.tokenValue=await t("/authentication/extractToken",{data:{}}),!1);refactorToken=async()=>{var e;await(e=this.tokenValue,t("/authentication/refactorToken",{data:{value:e}}))};login=async t=>{const e=await this.baseLogin(t);return e.error,e};baseLogin=async e=>{const s={error:void 0,data:void 0};try{const i=await function(e){return t("/authentication/login",{data:e,serviceId:"fwSecurity"})}(e),{userToken:n,traceId:r}=i;if(n){s.data=i;return await this.checkPassword()||(s.error="passwordExpiration"),s}return r?(s.data=i,s.error="SLIDER_VERIFICATION_LOGIN",s):(s.error="passwordError",s)}catch(t){return s.error="validateError",s}};loginSuccess=()=>{let t=new URLSearchParams(window.location.search).get("redirectUrl");t?window.location.href=t:window.location.replace(this.BASE)};baseLoginOut=async()=>{const e=new URLSearchParams,s=window.location.href;window.location.pathname!==this.BASE&&e.append("redirectUrl",s),await t("/authentication/logout",{data:{},serviceId:"fwSecurity"}),window.location.replace(`${this.baseLoginPathname}?${e.toString()}`)}}const $={sso:!1,ssoUrlSearchParams:["ticket"],ssoCheckTokenUrl:"",ssoSuccessUrlkey:"successUrl",ssoLoginUrl:window.location.origin+"/fwSecurity/ssoAuth/login.api",ssologinOutUrl:window.location.origin+"fwSecurity/ssoAuth/logout.api"};class _{init(t){this.ssoConfig={...this.ssoConfig,...t}}ssoConfig=$;isSso=async e=>{if(!this.ssoConfig.sso)return!1;let s=!1;try{s=await t("/ssoAuthConfig/checkOnlyRedirect",{},{showError:!1})}catch(t){console.error("sso",t)}return e&&(s=await e()),!!s};ssoLogin=()=>{const{ssoSuccessUrlkey:t,ssoUrlSearchParams:e,ssoLoginUrl:s}=this.ssoConfig,i=new URLSearchParams(window.location.search.slice(1)),n=new URLSearchParams,r=window.location.href;return n.append(t,encodeURIComponent(r)),e.map((t=>{const e=i.get(t);e&&n.append(t,e)})),window.location.href=`${s}?${n.toString()}`,!1};ssoLoginOut=()=>{window.location.href=this.ssoConfig.ssologinOutUrl}}class B{getValidateCodeImage=e=>function(e={}){return t("/authentication/getValidateCode",{data:e,serviceId:"fwSecurity"})}(e);sliderVerificationCodeImage=()=>t("/authentication/sliderVerificationCode",{method:"POST",serviceId:"fwSecurity"});checkCaptcha=e=>{return s=e,t("/authentication/checkCaptcha",{method:"POST",data:{...s},serviceId:"fwSecurity"});var s}}class x extends M{ssoLogin;validate;noCheckPermissionsPath=[];ssoCallback;constructor(){super(),this.ssoLogin=new _,this.validate=new B}init=(t,e="/",s)=>{this.BASE=e,this.ssoCallback=s,this.noCheckPermissionsPath=t?.noCheckPermissionsPath,this.ssoLogin.init(t),this.loginPathname=t?.loginPathname||"/login"};isNoLoginRequiredPage=()=>{const t=window.location.pathname,e=this.noCheckPermissionsPath?.some((e=>this.getRealPath(e)==t));return e};loginOut=async()=>{await this.ssoLogin.isSso(this.ssoCallback)&&this.ssoLogin.ssoLoginOut(),await this.baseLoginOut()};loginAuthentication=async e=>{var s;await(s=e,t("/authentication/beforeLoginCheckCode",{method:"POST",data:{...s},serviceId:"fwSecurity"})),this.loginSuccess()};redirectLogin=async()=>{if(this.isNoLoginRequiredPage())return!0;return await this.ssoLogin.isSso(this.ssoCallback)?(this.ssoLogin.ssoLogin(),!1):!!this.isLoginPathname||await this.redirectBaseLogin()}}const F=new class{userStore;menuStore;loginStore;isSuperAdmin=!1;loginCallback;constructor(){this.userStore=new b,this.menuStore=new A,this.loginStore=new x}platformLanguages=[];productInfo={isProdEnv:!1,productName:""};get isPrd(){return this.productInfo?.isProdEnv}get userInfo(){return this.userStore.currentUser}get menuData(){return this.menuStore.menuData}findPlantform=async()=>{const e=await t("/platformManage/getPlatformAggregateInfo",{method:"POST"},{showError:!1});this.platformLanguages=e.platformLanguages,this.productInfo=e.productInfo};getAggregateInfo=async e=>{const s=await async function(){return t("/security/findUserAggregateInfo",{method:"POST"})}(),{user:i,startMenus:n,isSuperAdmin:r,...a}=s;this.userStore.setUserAggregateInfo({...a,currentUser:i}),this.isSuperAdmin=r;const o="function"==typeof e?await e(s):e;this.menuStore.init(h(o)?n:o,i.id)};init=async t=>{const{base:e="/",menuData:s,loginSuccessCallback:i,ssoCallback:n,websocket:r=!0}=t;this.loginStore.init(t?.loginConfig,e,n);try{const t=await this.loginStore.chekToken();return t?(this.userStore.setUserIdentity(t),await this.getAggregateInfo(s),await y.findAllCodeList(),await w.findAllParameters(),r&&T.init(this.userStore.currentUser.userLoginName),await(i?.()),!0):await this.loginStore.redirectLogin()}catch(t){console.error(t)}return!1}};const H="company-v1";var V=new class{data={};getCompanyDataType=t=>`${H}-${t}`;getCompanyData=async e=>{const s=this.getCompanyDataType(e);if(this.data[s])return this.data[s];const i=await async function(e){return t("/companyData/getCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:H}),n=i?.bigData?JSON.parse(i.bigData):void 0;this.data[s]=n};updateCompanyData=async(e,s)=>{const i=this.getCompanyDataType(e);return await async function(e){return t("/companyData/setCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:H,bigData:JSON.stringify(s)}),this.data[i]=s,s};removeCompanyData=async e=>{const s=this.getCompanyDataType(e);await async function(e){return t("/companyData/delCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:H}),delete this.data[s]}};const J=y,K=w,W=F.userStore,Y=F.loginStore,q=F.menuStore;export{D as M,k as P,P as W,R as a,v as b,J as c,L as d,I as e,F as g,V as i,Y as l,q as m,K as p,U as s,W as u,T as w};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|