UNPKG

wjw-react-lib

Version:

wjw react component

2 lines 18 kB
(()=>{"use strict";var e={407:(e,r,t)=>{t.d(r,{Z:()=>o});var n=t(537),i=t.n(n),s=t(765),u=t.n(s);const a=require("buffer");var o=function(){function e(){i()(this,e)}return u()(e,null,[{key:"b64_to_str",value:function(e){var r=e.replace(/\s/g,"+");return a.Buffer.from(r,"base64").toString()}},{key:"str_to_b64",value:function(e){return a.Buffer.from(e).toString("base64")}},{key:"wjw_encode",value:function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";""===t&&(t="wjw0303");for(var n=(new TextEncoder).encode(r),i=(new TextEncoder).encode(t),s=i.length,u=n.length,a=0;a<u;a++)n[a]=i[(u-a)%s]>>>a%4^~n[a];return e.str_to_b64(n)}},{key:"wjw_decode",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";""===r&&(r="wjw0303");for(var t=a.Buffer.from(e,"base64"),n=(new TextEncoder).encode(r),i=n.length,s=t.length,u=0;u<s;u++)t[u]=n[(s-u)%i]>>u%4^~t[u];return a.Buffer.from(t).toString()}}]),e}()},933:(e,r,t)=>{t.d(r,{Z:()=>f});var n=t(537),i=t.n(n),s=t(765),u=t.n(s);const a=require("xmldom");var o=t(101),l=t(464),h=t.n(l),c=t(10),f=function(){function e(r){i()(this,e),(r=r.trim()).startsWith("<")&&r.endsWith(">")||(r=c.Z.get_page(r)),r=r.trim(),this._doc=(new a.DOMParser).parseFromString(r,"text/xml"),this._doc&&(this._CURSOR=this._doc.documentElement,this.CursorArray=[],this.CursorArray[0]=this.CURSOR)}return u()(e,[{key:"type",get:function(){return"WjwE4x"}},{key:"DOC",get:function(){return this._doc},set:function(e){this._doc=e}},{key:"CURSOR",get:function(){return this._CURSOR},set:function(e){this._CURSOR=e}},{key:"CursorArray",get:function(){return this._CursorArray},set:function(e){this._CursorArray=e}},{key:"outFarmt",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.CURSOR=this._doc.documentElement;var r=this.eachNode();return e&&(r='<?xml version="1.0" encoding="utf-8" ?>\n'+r),r}},{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(e||(e=this.DOC),r){var t=(new a.XMLSerializer).serializeToString(e);return t}return this.outFarmt()}},{key:"parse_path",value:function(e){e=e.trim(),"."!==o.Z.substr(e,0,1)&&(e="."+e);var r=[],t="";for(var n in e){var i=e[n];if("."!==i&&"."===t&&(r.push("."),t=""),"."!==i||"."!==t)if("."!==i||""!==t){t.indexOf("\\.");var s=t.indexOf("=");"."!==i||")"!==o.Z.substr(t,-1)?"."===i&&s<0&&"\\"!==o.Z.substr(t,-1)?(t.indexOf("\\.")>=0&&(t=t.replace("\\.",".")),r.push(t),t="."):("="===i&&(t=t.replace("\\.",".")),t+=i):(t.indexOf("\\.")>=0&&(t=t.replace("\\.",".")),r.push(t),t=".")}else t+=".";else r.push(".."),t=""}return""!==t&&r.push(t),r}},{key:"itemType",value:function(e){return"."===(e=e.trim())||".."===e?0:o.Z.preg_match("/^[_a-zA-Z][_a-zA-Z0-9.:\\-]*$/",e)?1:o.Z.preg_match("/^@[_a-zA-Z][_a-zA-Z0-9.:\\-]*$/",e)?2:o.Z.preg_match("/^[_a-zA-Z][_a-zA-Z0-9\\.:\\-]*\\[\\d+\\]$/",e)?3:o.Z.preg_match("/^\\(.+\\)$/",e)?4:o.Z.preg_match("/^[_a-zA-Z][_a-zA-Z0-9]*\\(.*\\)$/",e)?5:-1}},{key:"fnc_isEndNode",value:function(e){var r=0;if(!e.childNodes)return!0;for(var t in e.childNodes)1===e.childNodes[t].nodeType&&r++;var n=!0;return r>0&&(n=!1),n}},{key:"findChildNode",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(r||(r=this.CURSOR),!r)return null;if(this.CursorArray=[],this.fnc_isEndNode(r))return null;var t=0;for(var n in r.childNodes){var i=r.childNodes[n];i.nodeName===e&&(this.CursorArray[t]=i,t++)}return this.CURSOR=this.CursorArray[0],0===t?(this.CURSOR=null,this.CursorArray=null,null):(this.CURSOR=this.CursorArray[0],this.CURSOR)}},{key:"findAnyNode",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;r||(r=this.CURSOR),this.CursorArray=[];var t=r.getElementsByTagName(e);if(!t)return this.CURSOR=null,this.CursorArray=null,null;for(var n in t){var i=t[n];this.CursorArray[n]=i}return this.CURSOR=this.CursorArray[0],this.CURSOR}},{key:"trimYH",value:function(e){return""===(e=e.trim())?"":(r=o.Z.preg_match("/^['\"](.+)['\"]$/",e))?r[1]:e;var r}},{key:"expression4",value:function(e){var r=o.Z.preg_match("/^\\((.+?)=(.+)\\)$/",e.trim()),t=r[1],n=this.trimYH(r[2]);if("@"===o.Z.substr(t,0,1)){var i=o.Z.substr(t,1),s=this.CursorArray;if(!s)return null;for(var u in this.CursorArray=[],s){var a=s[u];a.getAttribute(i)===n&&(this.CursorArray[u]=a)}}else{var l=this.CursorArray;if(!l)return null;for(var h in this.CursorArray=[],l){var c=l[h];this.get_xml(c)===n&&(this.CursorArray[h]=c)}}return this.CURSOR=this.CursorArray[0],this.CURSOR}},{key:"fnc_nodes",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",t=r;if(!t)return this.CursorArray||(this.CursorArray[0]=e),this.CursorArray;this.CursorArray=[];var n=e.getElementsByTagName(t);if(!n)return this.CursorArray=null,null;for(var i in n){var s=n[i];this.CursorArray[i]=s}return this.CursorArray}},{key:"fnc_kvChilds",value:function(e){var r=[],t=e.childNodes;for(var n in t){var i=t[n];1===i.nodeType&&this.fnc_isEndNode(i)&&(r[i.nodeName]=this.get_nodeTxet(i))}return r}},{key:"fnc_kvs",value:function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=[];if(this.fnc_isEndNode(e)){var n=e.nodeName;t[n]=this.get_nodeTxet(e)}var i="";r&&(i="@");var s=e.attributes;if(!s)return t;for(var u in s){var a=s[u],o=a.nodeName,l=a.nodeValue;t[i+o]=l}return t}},{key:"toObj",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e)return null;var t=Object(),n=this.fnc_isEndNode(e),i=e.attributes;if(i)for(var s in i){var u=i[s];if(2===u.nodeType){var a=u.nodeName,l=u.nodeValue,c=this.get_nodeTxet(e);r||!n||c?t["@"+a]=l:t[a]=l}}var f=e.nodeName;if(n){var v=this.get_nodeTxet(e);v.trim()>""?o.Z.count(t)>0?t[f]=v:t=v:null==t&&(t="")}else{var d=[],g=0;for(var y in e.childNodes){var p=e.childNodes[y];if(1===p.nodeType){var _=p.nodeName;h().isUndefined(d[_])&&(d[_]=[],g=0);var m=this.toObj(p,r);d[_][g]=m,g++}}var R=Object();for(var C in d){var b=d[C];b.length>1||"row"===C?R[C]=b:R[C]=b[0]}o.Z.count(t)>0?t[f]=R:t=R}return t}},{key:"toJson",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e||(e=this.DOC);var t=this.toObj(e,r);return o.Z.json_encode(t,!1)}},{key:"computFuc",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;r||(r=this.CURSOR);var t=o.Z.preg_match("/(^[_a-zA-Z][_a-zA-Z0-9]*)\\((.*)\\)$/",e),n=t[1],i=this.trimYH(t[2]);switch(n){case"toString":var s=r.toString();return s.replace(/<.+?>/g," ").replace(/\s+/g," ");case"toXmlString":return r.toString();case"node":return this.CURSOR;case"array":return this.toObj(r);case"nodes":return this.fnc_nodes(r,i);case"arrays":var u=this.fnc_nodes(r,i);if(!u)return null;var a=[];for(var l in u){var h=u[l];a[l]=this.toObj(h)}return a;case"kvs":if(r=this.CURSOR,!i)return this.fnc_kvs(r);for(var c in a=[],u=r.getElementsByTagName(i)){var f=u[c];a.push(this.toArray(f))}return a;case"kvChilds":if(r=this.CURSOR,!i)return this.fnc_kvChilds(r);for(var v in a=[],u=r.getElementsByTagName(i)){var d=u[v];a.push(this.toArray(d))}return a;case"toJson":return this.toJson(this.CURSOR);default:o.Z.print("err!无此函数"+n)}return null}},{key:"get_xml",value:function(e){this.CURSOR=this._doc.documentElement,this.CursorArray=[],this.CursorArray[0]=this.CURSOR;for(var r=this.parse_path(e),t="",n=".";t=r.shift();){var i=this.itemType(t),s=r.length,u="";switch(i){case 0:n=t;continue;case 1:if(u="."===n?this.findChildNode(t):this.findAnyNode(t),0===s)return this.CURSOR?this.get_nodeTxet(this.CURSOR):null;if(null==u)return null;break;case 2:var a=o.Z.substr(t,1);return this.CURSOR.getAttribute(a);case 3:var l=o.Z.preg_match("/(^[_a-zA-Z][_a-zA-Z0-9]*)\\[(\\d+)\\]$/",t),h=l[1],c=l[2],f=this.CURSOR.getElementsByTagName(h);if(c>f.length-1)return null;if(this.CURSOR=f.item(c),0===s)return this.CURSOR?this.get_nodeTxet(this.CURSOR):null;break;case 4:if(null==(u=this.expression4(t)))return null;if(0===s)return this.CURSOR?this.get_nodeTxet(this.CURSOR):null;break;case 5:if(u=this.computFuc(t),0===s)return u;break;default:o.Z.print("表达式出错"+t)}if(!this.CURSOR)return o.Z.print("指针为空,出错"),null}return""}},{key:"save",value:function(e){var r=this.toString();o.Z.file_put_contents(e,r)}},{key:"set_xml",value:function(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=this.CURSOR,i="";if(o.Z.is_string(e)){var s=o.Z.preg_match("/(.+?)(?:$|\\.(?:@([^@\\.]+)$))/",e),u=s[1].trim();i=s[2],e=u+".node()",n=this.get_xml(e)}else n=e;if(!n)return null;if(i)if(i.indexOf(":")>0){var a=i.split(":")[0],l=n.lookupNamespaceURI(a);n.setAttributeNS(l,i,r)}else n.setAttribute(i,r);else{if(!this.fnc_isEndNode(n))return"不能对有子结点的结点斌值";n.firstChild.nodeValue=r}return t&&this.save(t),""}},{key:"eachNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;r||(r=this.DOC.documentElement);var n=o.Z.substr(" ",0,4*t),i="";null!==e&&e(r,t);var s=r.nodeName;for(var u in i=n+"<"+s,t++,r.attributes){var a=r.attributes[u];2===a.nodeType&&(i+=" "+a.nodeName+'="'+a.nodeValue+'"')}if(this.fnc_isEndNode(r)){var l=this.get_nodeTxet(r,!0);i+=l?">"+l+"</"+s+">\n":" />\n"}else{for(var h in i+=">\n",r.childNodes){var c=r.childNodes[h];8===c.nodeType&&(i+=n+"\x3c!--\n",i+=n+" "+c.nodeValue.trim(),i+=n+"\n--\x3e\n"),1===c.nodeType&&(i+=this.eachNode(e,c,t))}i+=n+"</"+s+">\n"}return i}},{key:"get_nodeTxet",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e)return"";var t=e.firstChild;return t?3===t.nodeType?e.firstChild.nodeValue:4===t.nodeType?r?"<![CDATA["+e.firstChild.nodeValue+"]]>":e.firstChild.nodeValue:"":""}}]),e}()},101:(e,r,t)=>{t.d(r,{Z:()=>l});var n=t(537),i=t.n(n),s=t(765),u=t.n(s),a=t(464),o=t.n(a);Date.prototype.Format=function(e){var r={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};for(var t in/(y+)/.test(e)&&(e=e.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length))),r)new RegExp("("+t+")").test(e)&&(e=e.replace(RegExp.$1,1==RegExp.$1.length?r[t]:("00"+r[t]).substr((""+r[t]).length)));return e};var l=function(){function e(){i()(this,e)}return u()(e,null,[{key:"print",value:function(e){console.log(e)}},{key:"is_array",value:function(e){return o().isArray(e)}},{key:"is_string",value:function(e){return o().isString(e)}},{key:"is_numeric",value:function(e){var r=1*e;return!isNaN(r)&&o().isNumber(r)}},{key:"date",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=new Date;return r>0&&new Date(r),o().isDate(r)&&(t=r),e=(e=(e=(e=(e=(e=e.replace("Y","yyyy")).replace("m","MM")).replace("d","dd")).replace("H","hh")).replace("i","mm")).replace("s","ss"),t.Format(e)}},{key:"json_encode",value:function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=4;return r&&(t=0),JSON.stringify(e,null,t)}},{key:"json_decode",value:function(e){return JSON.parse(e)}},{key:"is_float",value:function(r){return e.is_numeric(r)&&r.indexOf(".")>=0}},{key:"count",value:function(e){if(o().isNullOrUndefined(e))return-1;var r=0;for(var t in e)r++;return r}},{key:"substr",value:function(r,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(o().isString(r)||(r=r.toString()),0===n||e.count(r)<1)return"";var i=r.length;if(t>i)return r;var s=0,u=0;return null===n&&(n=i),t>=0&&n>0?(s=t,(u=n)>i-t&&(u=i-t),r.substr(s,u)):t>=0&&n<0?(s=t,(u=n+i-t)<0&&(u=0),r.substr(s,u)):t<0&&n>0?(s=i+t,(u=Math.abs(t))>n&&(u=n),r.substr(s,u)):t<0&&n<0?((s=i+t)<0&&(s=0),(u=Math.abs(t)+n)<0&&(u=0),r.substr(s,u)):""}},{key:"var_dump",value:function(e){var r=o().inspect(e);return console.log(r),r}},{key:"_pnstr_flag",value:function(e){var r=e.trim(),t="";if(0===r.indexOf("/")){var n=r.lastIndexOf("/");n>0&&(t=r.substr(n+1).trim(),r=r.substr(1,n-1))}return{_pnstr:r,_flag:t}}},{key:"preg_match",value:function(r,t){var n=e._pnstr_flag(r);return new RegExp(n._pnstr,n._flag.replace("g","")).exec(t)}},{key:"str_match",value:function(r,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=e.preg_match(r,t);return i?-1===n?1===i.length?i[0]:i[i.length-1]:n>=0&&n<i.length?i[n]:"":null}},{key:"preg_match_all",value:function(r,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=e._pnstr_flag(r);i._flag.indexOf("g")<0&&(i._flag=i._flag+"g");for(var s=new RegExp(i._pnstr,i._flag),u=[],a=[];a=s.exec(t);)u.push(a);if(!u)return null;if(!n)return u;for(var o=[],l=0;l<u[0].length;l++){o[l]=[];for(var h=0;h<u.length;h++)o[l][h]=u[h][l]}return o}},{key:"is_json",value:function(r){if(!e.is_string(r))return!1;var t=r.trim();return"{"===e.substr(t,0,1)&&"}"===e.substr(t,-1)||"["===e.substr(t,0,1)&&"]"===e.substr(t,-1)}},{key:"is_xml",value:function(r){if(!e.is_string(r))return!1;var t=r.trim();return"<"===e.substr(t,0,1)&&">"===e.substr(t,-1)}}]),e}()},819:(e,r,t)=>{t.d(r,{Z:()=>h});var n=t(537),i=t.n(n),s=t(765),u=t.n(s),a=t(779),o=t.n(a),l=t(101),h=function(){function e(){i()(this,e)}return u()(e,null,[{key:"style_to_String",value:function(e){return e?"string"==typeof e?e:Object.keys(e).reduce((function(r,t){return r+t.split(/(?=[A-Z])/).join("-").toLowerCase()+":"+e[t]+";"}),""):""}},{key:"get_webdb",value:function(e){var r=localStorage.getItem(e);if(!r)return null;r=r.trim();var t=l.Z.substr(r,0,1),n=l.Z.substr(r,-1);return"["===t||"]"===n||"{"===t||"}"===n?JSON.parse(r):r}},{key:"put_webdb",value:function(e,r){return l.Z.is_string(r)||l.Z.is_numeric(r)?(localStorage.setItem(e,r),r):(r=JSON.stringify(r),localStorage.setItem(e,r),r)}}]),e}();o()(h,"string_to_Style",(function(e){if(!e)return{};var r={};return e.split(";").forEach((function(e){var t=e.split(":",2);t.length>1&&(r[t[0].trim().replace(/-([a-z])/gi,(function(e,r){return r.toUpperCase()}))]=t[1].trim())})),r}))},10:(e,r,t)=>{t.d(r,{Z:()=>m});const n=require("@babel/runtime/helpers/asyncToGenerator");var i=t.n(n),s=t(537),u=t.n(s),a=t(765),o=t.n(a),l=t(779),h=t.n(l);const c=require("@babel/runtime/regenerator");var f=t.n(c);const v=require("axios");var d=t.n(v),g=t(407);const y=require("querystring");var p=t.n(y),_=t(101),m=function(){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;u()(this,e),r&&(e.BASE_URL=r),this._axios=d().create({baseURL:e.BASE_URL})}var r,t;return o()(e,[{key:"getPageAsync",value:(t=i()(f().mark((function e(r){var t=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.length>1&&void 0!==t[1]&&t[1];case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}],[{key:"get_page_yield",value:function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e.get_page(r,t);case 2:case"end":return n.stop()}}),n)}));return n().next().value}},{key:"get_page",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3,n=new XMLHttpRequest,i=window.setTimeout((function(){console.log("请求超过".concat(t,"秒失败!")),n.abort()}),t),s=null;return null===r?n.open("GET",e,!1):(n.open("POST",e,!1),s=_.Z.is_string(r)?r:p().stringify(r)),n.send(s),window.clearTimeout(i),200===n.status?n.responseText:e+"请求失败! "+n.status}},{key:"get_token_key",value:function(e){var r=Math.floor(1e9*Math.random())+1e10;return{rnd:r,enstr:g.Z.wjw_encode(e,r)}}},{key:"php_router_async",value:(r=i()(f().mark((function r(t){var n,i,s,u,a,o,l,h,c,v,g=arguments;return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=g.length>1&&void 0!==g[1]?g[1]:null,i=g.length>2&&void 0!==g[2]?g[2]:null,s=g.length>3&&void 0!==g[3]?g[3]:null,u=g.length>4&&void 0!==g[4]?g[4]:null,a={call:t,arg:[],token:"",refrm:"xml"},n&&(a.arg=n),s&&(a.refrm=s),i||(i=e.DEFAUT_ROUTER_URL,console.log(i)),null!==u&&(a.token="wjw13966163128"),o=JSON.stringify(a),!0===u&&(l=e.get_token_key(o),h=l.rnd,c=l.enstr,i=i+"?encodeCall="+h,o=c),r.next=13,d().post(i,o);case 13:return v=r.sent,r.abrupt("return",v.data);case 15:case"end":return r.stop()}}),r)}))),function(e){return r.apply(this,arguments)})}]),e}();h()(m,"BASE_URL",""),h()(m,"DEFAUT_ROUTER_URL","/PHP/Router.php")},537:e=>{e.exports=require("@babel/runtime/helpers/classCallCheck")},765:e=>{e.exports=require("@babel/runtime/helpers/createClass")},779:e=>{e.exports=require("@babel/runtime/helpers/defineProperty")},464:e=>{e.exports=require("util")}},r={};function t(n){var i=r[n];if(void 0!==i)return i.exports;var s=r[n]={exports:{}};return e[n](s,s.exports,t),s.exports}t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{t.r(n),t.d(n,{WjwCrypt:()=>s.Z,WjwE4x:()=>r.Z,WjwPhp:()=>e.Z,WjwSys:()=>c,WjwWebTools:()=>u.Z,WjwWget:()=>i.Z});var e=t(101),r=t(933),i=t(10),s=t(407),u=t(819),a=t(537),o=t.n(a),l=t(765),h=t.n(l),c=function(){function e(){o()(this,e)}return h()(e,null,[{key:"WjwBool",value:function(e){if(!e)return!1;if("string"==typeof e){var r=e;if("0"==r||"0000-00-00"==r||"0000-00-00 00:00:00"==r||"none"==r.toLowerCase()||"err!"==r.toLowerCase())return!1}else if(Object.keys(e).length<1)return!1;return!0}}]),e}()})(),module.exports=n})(); //# sourceMappingURL=WjwJsLib.js.map