@gsc-basic/utils 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1381 -1
- package/dist/index.js +1275 -1
- package/package.json +10 -5
package/dist/index.js
CHANGED
|
@@ -1 +1,1275 @@
|
|
|
1
|
-
function t(t,e){if(e==null||e>t.length)e=t.length;for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function e(t){if(Array.isArray(t))return t}function n(e){if(Array.isArray(e))return t(e)}function r(t,e){if(!(t instanceof e)){throw new TypeError("Cannot call a class as a function")}}function i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||false;r.configurable=true;if("value"in r)r.writable=true;Object.defineProperty(t,r.key,r)}}function a(t,e,n){if(e)i(t.prototype,e);if(n)i(t,n);return t}function o(t,e,n){if(e in t){Object.defineProperty(t,e,{value:n,enumerable:true,configurable:true,writable:true})}else{t[e]=n}return t}function s(t,e){if(e!=null&&typeof Symbol!=="undefined"&&e[Symbol.hasInstance]){return!!e[Symbol.hasInstance](t)}else{return t instanceof e}}function u(t){if(typeof Symbol!=="undefined"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function c(t,e){var n=t==null?null:typeof Symbol!=="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(n==null)return;var r=[];var i=true;var a=false;var o,s;try{for(n=n.call(t);!(i=(o=n.next()).done);i=true){r.push(o.value);if(e&&r.length===e)break}}catch(t){a=true;s=t}finally{try{if(!i&&n["return"]!=null)n["return"]()}finally{if(a)throw s}}return r}function d(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};var r=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))}r.forEach(function(e){o(t,e,n[e])})}return t}function h(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);if(e){r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})}n.push.apply(n,r)}return n}function v(t,e){e=e!=null?e:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(t,Object.getOwnPropertyDescriptors(e))}else{h(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}return t}function p(t,e){if(t==null)return{};var n=m(t,e);var r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++){r=a[i];if(e.indexOf(r)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(t,r))continue;n[r]=t[r]}}return n}function m(t,e){if(t==null)return{};var n={};var r=Object.keys(t);var i,a;for(a=0;a<r.length;a++){i=r[a];if(e.indexOf(i)>=0)continue;n[i]=t[i]}return n}function y(t,n){return e(t)||c(t,n)||b(t,n)||d()}function g(t){return n(t)||u(t)||b(t)||l()}function w(t){"@swc/helpers - typeof";return t&&typeof Symbol!=="undefined"&&t.constructor===Symbol?"symbol":typeof t}function b(e,n){if(!e)return;if(typeof e==="string")return t(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor)r=e.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return t(e,n)}import{isPlainObject as S,mergeWith as E,isArray as k,isEqual as _,intersectionWith as O,unionWith as A}from"lodash-es";var L={mobile:/^(?:(?:\+|00)86)?1[3-9]\d{9}$/,tel:/^(?:(?:\d{3}-)?\d{8}|(?:\d{4}-)?\d{7,8})(?:-\d+)?$/,numAndLetter:/^[A-Z0-9]+$/i,password:/^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])(?=\S*[!@#$%^&*? ])\S+$/,email:/^[A-Z0-9\u4E00-\u9FA5]+@[\w-]+(?:\.[\w-]+)+$/i,postalCode:/^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/,identityCard:/^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[12]\d|30|31)\d{3}[\dX]$/i,ip:/^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?::(?:\d|[1-9]\d{1,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5]))?$/,url:/^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-][^!@#$%^&*?.\s]{0,64}\.)+[a-z]{2,6}\/?/,httpsUrl:/^https:\/\//,domain:/^([0-9a-z-]+\.)+([a-z]{2,})$/i,plateNumber:/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$/,md5:/^[a-f0-9]{32}$/i,base64:/^\s*data:(?:[a-z]+\/[a-z0-9-+.]+(?:;[a-z-]+=[a-z0-9-]+)?)?(?:;base64)?,([\w!$&',()*+;=\-.~:@/?%\s]*?)\s*$/i,uuid:/^[a-f\d]{4}(?:[a-f\d]{4}-){4}[a-f\d]{12}$/i,version:/^\d+(?:\.\d+){2}$/,videoUrl:/^https?:\/\/(.+\/)+.+(\.(swf|avi|flv|mpg|rm|mov|wav|asf|3gp|mkv|rmvb|mp4))$/i,imageUrl:/^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i,chinese:/^(?:[\u3400-\u4DB5\u4E00-\u9FEA\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0])+$/,itcode:/^[a-z]+\d*$/i};var D=Object.prototype.toString;function j(t,e){return D.call(t)==="[object ".concat(e,"]")}function C(t){return t!==null&&j(t,"Object")}function F(t){return L.url.test(t)}function I(t){return Array.isArray(t)&&t.length>0}function T(t){return Number.isInteger(t)&&t>=0}var P=(typeof window==="undefined"?"undefined":w(window))>"u",x=!P,B=x&&window.navigator.userAgent.toLowerCase().includes("chrome"),$=x&&window.navigator.userAgent.toLowerCase().includes("safari"),z=(typeof window==="undefined"?"undefined":w(window))<"u"&&(typeof document==="undefined"?"undefined":w(document))<"u",R=z&&w(document.body.style.lineClamp)<"u",U=z&&(typeof ResizeObserver==="undefined"?"undefined":w(ResizeObserver))<"u",M=function(t){return L.chinese.test(t)};var N=function(t,e){var n=t;return n.install=function(r){r.component(n.name||n.displayName,t),e&&(r.config.globalProperties[e]=t)},t};function H(t){if(!t)return t;var e=t.matched,n=p(t,["matched"]);return v(f({},n),{matched:e?e.map(function(t){return{meta:t.meta,name:t.name,path:t.path}}):void 0})}function Z(t,e){var n=e||{},r=n.target,i=r===void 0?"__blank":r,a=n.noopener,o=a===void 0?!0:a,s=n.noreferrer,u=s===void 0?!0:s,c=[];o&&c.push("noopener=yes"),u&&c.push("noreferrer=yes"),window.open(t,i,c.join(","))}function W(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"replace";return e?t?E(t,e,function(t,e){if(k(e)&&k(t))switch(n){case"union":return A(t,e,_);case"intersection":return O(t,e,_);case"concat":return t.concat(e);case"replace":return e;default:throw new Error("Unknown merge array strategy: ".concat(n))}if(C(e)&&C(t))return W(t,e,n)}):e:t}function J(t){var e;return(e=t===null||t===void 0?void 0:t.parentNode)!==null&&e!==void 0?e:document.body}function V(t,e){if(!I(Object.keys(e)))return t;var n="";for(var r in e)n+="".concat(r,"=").concat(encodeURIComponent(e[r]),"&");return n=n.replace(/&$/,""),/\?$/.test(t)?t+n:t.replace(/\/?$/,"?")+n}function q(t){S(t)&&Object.keys(t).forEach(function(e){Reflect.deleteProperty(t,e)})}function X(t){return["$","(",")","*","+",".","[","]","?","\\","^","{","}","|"].includes(t)?"\\".concat(t):t}function Y(t){var e=[""].concat(g(g(t).map(function(t){return X(t)})),[""]).join(".*");return new RegExp(e,"i")}function G(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var n=e.size,r=n===void 0?14:n,i=e.family,a=i===void 0?getComputedStyle(document.documentElement).getPropertyValue("--vxe-font-family")||"sans-serif":i,o=document.createElement("canvas").getContext("2d");o.font="".concat(r,"px ").concat(a);var s=o.measureText(t),u=Math.abs(s.actualBoundingBoxLeft)+Math.abs(s.actualBoundingBoxRight);return Math.ceil(Math.max(s.width,u))}function K(t,e){return e?typeof e=="string"?" ".concat(t,"--").concat(e):Array.isArray(e)?e.reduce(function(e,n){return e+K(t,n)},""):Object.keys(e).reduce(function(n,r){return n+(e[r]?K(t,r):"")},""):""}function Q(t){return function(e,n){return e&&typeof e!="string"&&(n=e,e=""),e=e?"".concat(t,"__").concat(e):t,"".concat(e).concat(K(e,n))}}function tt(t,e){return[Q("".concat(e,"-").concat(t))]}function te(t,e){var n="".concat(e,"-").concat(t);return[n,Q(n)]}import{encrypt as tn,decrypt as tr}from"crypto-js/aes";import ti,{parse as ta}from"crypto-js/enc-utf8";import to from"crypto-js/pad-pkcs7";import ts from"crypto-js/mode-ecb";import tu from"crypto-js/md5";import tc from"crypto-js/enc-base64";var td=/*#__PURE__*/function(){"use strict";function t(e){r(this,t);var n=e.key,i=e.iv;n&&(this.key=ta(n)),i&&(this.iv=ta(i))}a(t,[{key:"getOptions",get:function t(){return{mode:ts,padding:to,iv:this.iv}}},{key:"encryptByAES",value:function t(t){return tn(t,this.key,this.getOptions).toString()}},{key:"decryptByAES",value:function t(t){return tr(t,this.key,this.getOptions).toString(ti)}}]);return t}();function tl(t){return ti.parse(t).toString(tc)}function tf(t){return tc.parse(t).toString(ti)}function th(t){return tu(t).toString()}import{upperFirst as tv}from"lodash-es";var tp=document.documentElement,tm=function(){return"startViewTransition"in document&&window.matchMedia("(prefers-reduced-motion: no-preference)").matches};function ty(t){return!t||!t.getBoundingClientRect?0:t.getBoundingClientRect()}function tg(t){return(t||"").replace(/^\s+|\s+$/g,"")}function tw(t,e){if(!t||!e)return!1;if(e.includes(" "))throw new Error("className should not contain space.");return t.classList?t.classList.contains(e):" ".concat(t.className," ").includes(" ".concat(e," "))}function tb(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:tp;n.style.setProperty(t,e)}function tS(t,e){if(!t)return;var n=t.className,r=(e||"").split(" ");for(var i=0,a=r.length;i<a;i++){var o=r[i];o&&(t.classList?t.classList.add(o):tw(t,o)||(n+=" ".concat(o)))}t.classList||(t.className=n)}function tE(t,e){if(!t||!e)return;var n=e.split(" "),r=" ".concat(t.className," ");for(var i=0,a=n.length;i<a;i++){var o=n[i];o&&(t.classList?t.classList.remove(o):tw(t,o)&&(r=r.replace(" ".concat(o," ")," ")))}t.classList||(t.className=tg(r))}function tk(t){var e=document.documentElement,n=e.scrollLeft,r=e.scrollTop,i=e.clientLeft,a=e.clientTop,o=window.scrollX,s=window.scrollY,u=ty(t),c=u.left,d=u.top,l=u.width,f=u.height,h=(o||n)-(i||0),v=(s||r)-(a||0),p=c+o,m=d+s,y=p-h,g=m-v,w=window.document.documentElement.clientWidth,b=window.document.documentElement.clientHeight;return{left:y,top:g,right:w-l-y,bottom:b-f-g,rightIncludeBody:w-y,bottomIncludeBody:b-g}}function t_(t,e){var n=["webkit","Moz","ms","OT"],r={};return n.forEach(function(n){r["".concat(n).concat(tv(t))]=e}),v(f({},r),o({},t,e))}function tO(t,e,n){t&&e&&n&&t.addEventListener(e,n,!1)}function tA(t,e,n){t&&e&&n&&t.removeEventListener(e,n,!1)}function tL(t){var e=!1;return function(){var n=this;for(var r=arguments.length,i=new Array(r),a=0;a<r;a++){i[a]=arguments[a]}e||(e=!0,window.requestAnimationFrame(function(){t.apply(n,i),e=!1}))}}import tD from"resize-observer-polyfill";function tj(t){var e=true,n=false,r=undefined;try{for(var i=t[Symbol.iterator](),a;!(e=(a=i.next()).done);e=true){var o=a.value;var s=o.target.__resizeListeners__||[];s.length&&s.forEach(function(t){t()})}}catch(t){n=true;r=t}finally{try{if(!e&&i.return!=null){i.return()}}finally{if(n){throw r}}}}function tC(t,e){P||(t.__resizeListeners__||(t.__resizeListeners__=[],t.__ro__=new tD(tj),t.__ro__.observe(t)),t.__resizeListeners__.push(e))}function tF(t,e){!t||!t.__resizeListeners__||(t.__resizeListeners__.splice(t.__resizeListeners__.indexOf(e),1),t.__resizeListeners__.length||(t.__ro__.disconnect(),t.__ro__=null,t.__resizeListeners__=null))}function tI(){var t=new Event("resize",{bubbles:!0,cancelable:!0});window.dispatchEvent(t)}function tT(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};function n(t){var e=window.history[t];return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++){r[i]=arguments[i]}var a=new Event(t);return a.arguments=r,window.dispatchEvent(a),e.apply(this,r)}}return window.history.pushState=n("pushState"),window.history.replaceState=n("replaceState"),window.addEventListener("popstate",t,e),window.addEventListener("hashchange",t,e),window.addEventListener("replaceState",t,e),window.addEventListener("pushState",t,e),{removeListener:function(){window.removeEventListener("popstate",t,e),window.removeEventListener("hashchange",t,e),window.removeEventListener("replaceState",t,e),window.removeEventListener("pushState",t,e)}}}import{round as tP,isNil as tx}from"lodash-es";function tB(t){var e=t.split(","),n=e[0].match(/:(.*?);/)[1],r=window.atob(e[1]),i=r.length,a=new Uint8Array(i);for(;i--;)a[i]=r.charCodeAt(i);return new Blob([a],{type:n})}function t$(t,e){return new Promise(function(n,r){var i=document.createElement("CANVAS"),a=i.getContext("2d"),o=new Image;o.crossOrigin="",o.onload=function(){if(!i||!a)return r();i.height=o.height,i.width=o.width,a.drawImage(o,0,0);var t=i.toDataURL(e||"image/png");i=null,n(t)},o.src=t})}function tz(t){var e=t.loaded,n=t.total;if(n<=0||tx(n))return 0;var r=e/n;return tP((r>1?1:r)*100)}function tR(t,e,n,r){t$(t).then(function(t){tU(t,e,n,r)})}function tU(t,e,n,r){var i=tB(t);tM(i,e,n,r)}function tM(t,e,n,r){var i=(typeof r==="undefined"?"undefined":w(r))<"u"?[r,t]:[t],a=new Blob(i,{type:n||"application/octet-stream"});if(w(window.navigator.msSaveBlob)<"u")window.navigator.msSaveBlob(a,e);else{var o=window.URL.createObjectURL(a),s=document.createElement("a");s.style.display="none",s.href=o,s.setAttribute("download",e),w(s.download)>"u"&&s.setAttribute("target","_blank"),document.body.appendChild(s),s.click(),document.body.removeChild(s),window.URL.revokeObjectURL(o)}}function tN(t){var e=t.url,n=t.target,r=n===void 0?"_blank":n,i=t.fileName;if(/iP/.test(window.navigator.userAgent))return!1;if(B||$){var a=document.createElement("a");return a.href=e,a.download=i||e.substring(e.lastIndexOf("/")+1,e.length),a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a),!0}return e.includes("?")||(e+="?download"),Z(e,{target:r}),!0}var tH=function(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"ig";var r=new RegExp(e,n);return g(t.matchAll(r)).map(function(t){return{index:t.index,subString:t[0]}})};function tZ(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}var tW=function(t,e){var n=t;if(!e)return n;var r=e.tagName,i=r===void 0?"mark":r,a=e.bgColor,o=e.color,s=e.style,u=s===void 0?{}:s,c=e.renderHighlightKeyword;if(typeof c=="function")return c(t);u.backgroundColor=a,u.color=o;var d='style="'.concat(Object.keys(u).map(function(t){return"".concat(tZ(t),":").concat(u[t])}).join(";"),'"');return"<".concat(i," ").concat(d,">").concat(n,"</").concat(i,">")},tJ=function(t,e){var n="";return e.forEach(function(e){var r=e.start,i=e.end,a=e.option,o=t.slice(r,i),s=tW(o,a);n+=s,e.subString=s}),n},tV=function(t,e){var n=[];return e.forEach(function(e){var r={keyword:""};typeof e=="string"?r={keyword:e}:r=e;var i=r.keyword,a=r.caseSensitive,o=a===void 0?!0:a,s=tH(t,i,o?"g":"gi"),u={keyword:i,indexList:s,option:r};n.push(u)}),n},tq=function(t,e){var n=tV(t,e),r=[],i=function(t,e){for(var n=0;n<r.length;n++){var i=r[n];if(t>i.start&&t<i.end||t+e>i.start&&t+e<i.end||i.start>t&&i.start<t+e||i.end>t&&i.end<t+e||t===i.start&&t+e===i.end)return-1;if(t+e<=i.start)return n}return r.length};n.forEach(function(t){var e=t.indexList,n=t.option;e.forEach(function(t){var e=t.index,a=t.subString,o={start:e,end:e+a.length,option:n},s=i(e,a.length);s!==-1&&r.splice(s,0,o)})});var a=[];return r.forEach(function(e,n){var i=e.start,o=e.end,s=r[n+1];n===0&&i>0&&a.push({start:0,end:i,subString:t.slice(0,i)}),a.push(v(f({},e),{subString:t.slice(i,o)})),(s===null||s===void 0?void 0:s.start)>o&&a.push({start:o,end:s.start,subString:t.slice(o,s.start)}),n===r.length-1&&o<t.length-1&&a.push({start:o,end:t.length-1,subString:t.slice(o,t.length)})}),a},tX=function(t,e){var n=tq(t,e);return{highText:tJ(t,n),highList:n}};import{clearInterval as tY,clearTimeout as tG,setInterval as tK,setTimeout as tQ}from"worker-timers";var t0="active",t1="idle",t2="hidden",t4,t6,t3,t8={},t9={attach:function t(t,e){t8[t]||(t8[t]=[]),t8[t].push(e)},fire:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];t8[t]&&t8[t].forEach(function(t){t.apply(void 0,g(e))})},remove:function t(t,e){e||Reflect.deleteProperty(t8,t),t8[t]&&(t8[t]=t8[t].filter(function(t){return e!==t}))},dom:function t(t,e,n){return t3||(t.addEventListener?t3=function(t,e,n){return t.addEventListener(e,n,!1)}:typeof t.attachEvent=="function"?t3=function(t,e,n){return t.attachEvent("on".concat(e),n,!1)}:t3=function(t,e,n){return t["on".concat(e)]=n}),t3(t,e,n)}},t5=/*#__PURE__*/function(){"use strict";function t(e,n,i){var a=this;r(this,t);this.activity=e,this.seconds=n,this.callback=i,this.stopped=!1,this.start(),this.activity.on("statusChanged",function(t){a.stopped===!1&&(t.status===t0?a.start():a.pause())})}a(t,[{key:"start",value:function t(){this.stopped=!1,tY(this.token),this.token=tK(this.callback,this.seconds*1e3)}},{key:"stop",value:function t(){this.stopped=!0,tY(this.token)}},{key:"resume",value:function t(){this.start()}},{key:"pause",value:function t(){this.stop()}}]);return t}(),t7=/*#__PURE__*/function(){"use strict";function t(){var e=this;r(this,t);if(this.status=t0,this.timers=[],this.idleTime=3e4,this.isLegacyModeOn=!1,document.hidden!==void 0?(t4="hidden",t6="visibilitychange"):document.mozHidden!==void 0?(t4="mozHidden",t6="mozvisibilitychange"):document.msHidden!==void 0?(t4="msHidden",t6="msvisibilitychange"):document.webkitHidden!==void 0&&(t4="webkitHidden",t6="webkitvisibilitychange"),t4===void 0)this.legacyMode();else{var n=function(){document[t4]?e.blur():e.focus()};n(),t9.dom(document,t6,n)}this.startIdleTimer(),this.trackIdleStatus()}a(t,[{key:"legacyMode",value:function t(){var t=this;this.isLegacyModeOn||(t9.dom(window,"blur",function(){return t.blur()}),t9.dom(window,"focus",function(){return t.focus()}),this.isLegacyModeOn=!0)}},{key:"startIdleTimer",value:function t(t){var e=this;s(t,MouseEvent)&&t.movementX===0&&t.movementY===0||(this.timers.map(tG),this.timers.length=0,this.status===t1&&this.wakeUp(),this.idleStartedTime=+new Date,this.timers.push(tQ(function(){if(e.status===t0||e.status===t2)return e.idle()},this.idleTime)))}},{key:"trackIdleStatus",value:function t(){t9.dom(document,"mousemove",this.startIdleTimer.bind(this)),t9.dom(document,"mousedown",this.startIdleTimer.bind(this)),t9.dom(document,"keyup",this.startIdleTimer.bind(this)),t9.dom(document,"touchstart",this.startIdleTimer.bind(this)),t9.dom(window,"scroll",this.startIdleTimer.bind(this)),this.focus(this.startIdleTimer.bind(this))}},{key:"on",value:function t(t,e){return t9.attach(t,e),this}},{key:"off",value:function t(t,e){return t9.remove(t,e),this}},{key:"setIdleDuration",value:function t(t){return this.idleTime=t*1e3,this.startIdleTimer(),this}},{key:"getIdleDuration",value:function t(){return this.idleTime}},{key:"getIdleInfo",value:function t(){var t=+new Date,e;if(this.status===t1)e={isIdle:!0,idleFor:t-this.idleStartedTime,timeLeft:0,timeLeftPer:100};else{var n=this.idleStartedTime+this.idleTime-t;e={isIdle:!1,idleFor:t-this.idleStartedTime,timeLeft:n,timeLeftPer:Number.parseFloat((100-n*100/this.idleTime).toFixed(2))}}return e}},{key:"idle",value:function t(t){return t?this.on("idle",t):(this.status=t1,t9.fire("idle"),t9.fire("statusChanged",[{status:this.status}])),this}},{key:"blur",value:function t(t){return t?this.on("blur",t):(this.status=t2,t9.fire("blur"),t9.fire("statusChanged",[{status:this.status}])),this}},{key:"focus",value:function t(t){return t?this.on("focus",t):this.status!==t0&&(this.status=t0,t9.fire("focus"),t9.fire("wakeUp"),t9.fire("statusChanged",[{status:this.status}])),this}},{key:"wakeUp",value:function t(t){return t?this.on("wakeUp",t):this.status!==t0&&(this.status=t0,t9.fire("wakeUp"),t9.fire("statusChanged",[{status:this.status}])),this}},{key:"onEvery",value:function t(t,e){return new t5(this,t,e)}},{key:"now",value:function t(t){return t!==void 0?this.status===t:this.status===t0}}]);return t}();import{isFunction as et}from"lodash-es";function ee(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"default",n=arguments.length>2?arguments[2]:void 0;if(!t||!Reflect.has(t,e)||!et(t[e]))return null;var r=t[e];return r?r(n):null}function en(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];var n=Object.keys(t),r={};return n.forEach(function(n){if(e.includes(n))return null;r[n]=function(e){return ee(t,n,e)}}),r}function er(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=e.type,r=n===void 0?"text/javascript":n;return new Promise(function(e,n){var i=!1,a=document.querySelector('script[src="'.concat(t,'"]'));if(!a)a=document.createElement("script"),a.type=r,a.async=!0,a.src=t,i=!0;else if(a.hasAttribute("data-loaded")){e({el:a});return}a.addEventListener("error",n),a.addEventListener("abort",n),a.addEventListener("load",function(){a.setAttribute("data-loaded",!0),e({el:a})}),i&&document.head.appendChild(a)})}function ei(t){return new Promise(function(e,n){var r=document.querySelector('script[src="'.concat(t,'"]'));if(!r){n();return}document.head.removeChild(r),e()})}function ea(t,e,n){return el(t,e,n,!1)}function eo(t,e,n){return el(t,e,n,!0).length>0}function es(t){return typeof t!="string"?t:t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var eu=new Map;function ec(t,e){if(!Array.isArray(t))switch(typeof t==="undefined"?"undefined":w(t)){case"string":t=[t];break;case"undefined":t=[];break;default:throw new TypeError("Expected '".concat(e,"' to be a string or an array, but got a type of '").concat(typeof t==="undefined"?"undefined":w(t),"'"))}return t.filter(function(t){if(typeof t!="string"){if((typeof t==="undefined"?"undefined":w(t))>"u")return!1;throw new TypeError("Expected '".concat(e,"' to be an array of strings, but found a type of '").concat(typeof t==="undefined"?"undefined":w(t),"' in the array"))}return!0})}function ed(t,e){e=f({caseSensitive:!1},e);var n=t+JSON.stringify(e);if(eu.has(n))return eu.get(n);var r=t[0]==="!";r&&(t=t.slice(1)),t=es(t).replace(/\\\*/g,"[\\s\\S]*");var i=new RegExp("^".concat(t,"$"),e.caseSensitive?"":"i");return i.negated=r,eu.set(n,i),i}function el(t,e,n,r){if(t=ec(t,"inputs"),e=ec(e,"patterns"),e.length===0)return[];e=e.map(function(t){return ed(t,n)});var i=n||{},a=i.allPatterns,o=[];var s=true,u=false,c=undefined;try{for(var d=t[Symbol.iterator](),l;!(s=(l=d.next()).done);s=true){var f=l.value;var h=void 0,v=g(e).fill(!1);var p=true,m=false,w=undefined;try{for(var b=e.entries()[Symbol.iterator](),S;!(p=(S=b.next()).done);p=true){var E=y(S.value,2),k=E[0],_=E[1];if(_.test(f)&&(v[k]=!0,h=!_.negated,!h))break}}catch(t){m=true;w=t}finally{try{if(!p&&b.return!=null){b.return()}}finally{if(m){throw w}}}if(!(h===!1||h===void 0&&e.some(function(t){return!t.negated})||a&&v.some(function(t,n){return!t&&!e[n].negated}))&&(o.push(f),r))break}}catch(t){u=true;c=t}finally{try{if(!s&&d.return!=null){d.return()}}finally{if(u){throw c}}}return o}var ef={id:"id",children:"children",pid:"pid"},eh=function(t){return Object.assign({},ef,t)};function ev(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n=eh(n);var r=n.children,i=g(t);var a=true,o=false,s=undefined;try{for(var u=i[Symbol.iterator](),c;!(a=(c=u.next()).done);a=true){var d=c.value;var l;if(e(d))return d;d[r]&&(l=i).push.apply(l,g(d[r]))}}catch(t){o=true;s=t}finally{try{if(!a&&u.return!=null){u.return()}}finally{if(o){throw s}}}return null}function ep(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var r;n=eh(n);var i=n.children,a=g(t),o=[];var s=true,u=false,c=undefined;try{for(var d=a[Symbol.iterator](),l;!(s=(l=d.next()).done);s=true){var f=l.value;e(f)&&o.push(f),f[i]&&(r=a).push.apply(r,g(f[i]))}}catch(t){u=true;c=t}finally{try{if(!s&&d.return!=null){d.return()}}finally{if(u){throw c}}}return o}function em(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n=eh(n);var r=[],i=g(t),a=new Set,o=n.children;for(;i.length;){var s;var u=i[0];if(a.has(u))r.pop(),i.shift();else if(a.add(u),u[o]&&(s=i).unshift.apply(s,g(u[o])),r.push(u),e(u))return r}return null}function ey(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n=eh(n);var r=[],i=g(t),a=[],o=new Set,s=n.children;for(;i.length;){var u;var c=i[0];o.has(c)?(r.pop(),i.shift()):(o.add(c),c[s]&&(u=i).unshift.apply(u,g(c[s])),r.push(c),e(c)&&a.push(g(r)))}return a}function eg(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n=eh(n);var r=n.children;function i(t){return t.map(function(t){return f({},t)}).filter(function(t){return t[r]=t[r]&&i(t[r]),e(t)||t[r]&&t[r].length})}return i(t)}function ew(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n=eh(n);var r=g(t),i=n.children;for(var a=0;a<r.length;a++){var o;if(e(r[a]))return;i&&r[a][i]&&(o=r).splice.apply(o,[a+1,0].concat(g(r[a][i])))}}function eb(t,e){return t.map(function(t){return eS(t,e)})}function eS(t,e){var n=e.children,r=n===void 0?"children":n,i=e.conversion;var a=Array.isArray(t[r])&&t[r].length>0,s=i(t)||{};return a?v(f({},s),o({},r,t[r].map(function(t){return eS(t,{children:r,conversion:i})}))):f({},s)}import{v4 as eE}from"uuid";function ek(){var t,e;var n;return(n=(e=window.crypto)===null||e===void 0?void 0:(t=e.randomUUID)===null||t===void 0?void 0:t.call(e))!==null&&n!==void 0?n:eE()}var e_=0;function eO(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";var e=Date.now(),n=Math.floor(Math.random()*1e9);return e_++,"".concat(t,"_").concat(n).concat(e_).concat(String(e))}export{td as AesEncryption,tS as addClass,tT as addLocationListener,tC as addResizeListener,Q as buildBEM,eO as buildShortUUID,ek as buildUUID,tt as createBEM,te as createNamespace,Y as createSearchReg,tB as dataURLtoBlob,tf as decodeByBase64,W as deepMerge,tA as domOffEvent,tO as domOnEvent,tU as downloadByBase64,tM as downloadByData,tR as downloadByOnlineUrl,tN as downloadByUrl,tz as downloadPercent,tm as enableTransitions,tl as encryptByBase64,th as encryptByMd5,es as escapeStringRegexp,en as extendSlots,eg as filterTree,ev as findNode,ep as findNodeAll,em as findPath,ey as findPathAll,ew as forEachTree,G as getActualWidthOfChars,ty as getBoundingClientRect,J as getPopupContainer,H as getRawRoute,ee as getSlot,tk as getViewportOffset,t_ as hackCss,tw as hasClass,tX as highlightHtml,t7 as ifActivity,j as is,z as isBrowser,M as isChineseText,B as isChrome,x as isClient,I as isIterableArray,eo as isMatch,C as isObject,T as isPositiveInteger,$ as isSafari,P as isServer,R as isSupportNativeEllipsis,U as isSupportResizeObserver,F as isUrl,er as loadScript,ea as matcher,Z as openWindow,L as regexpMap,tE as removeClass,tF as removeResizeListener,tb as setCssVar,V as setObjToUrlParams,eb as treeMap,eS as treeMapEach,tI as triggerWindowResize,ei as unloadScript,q as unsetAllProperty,t$ as urlToBase64,tL as useRafThrottle,N as withInstall};
|
|
1
|
+
// src/common.js
|
|
2
|
+
import { isPlainObject, mergeWith, isArray, isEqual, intersectionWith, unionWith } from "lodash-es";
|
|
3
|
+
|
|
4
|
+
// src/regexp.js
|
|
5
|
+
var regexpMap = {
|
|
6
|
+
// 手机号(mobile phone)中国(宽松), 只要是13,14,15,16,17,18,19开头即可
|
|
7
|
+
mobile: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/,
|
|
8
|
+
// 座机(tel phone)电话(国内),如: 0341-86091234
|
|
9
|
+
tel: /^(?:(?:\d{3}-)?\d{8}|(?:\d{4}-)?\d{7,8})(?:-\d+)?$/,
|
|
10
|
+
// 数字和字母组成
|
|
11
|
+
numAndLetter: /^[A-Z0-9]+$/i,
|
|
12
|
+
// 密码强度校验,最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符
|
|
13
|
+
password: /^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])(?=\S*[!@#$%^&*? ])\S+$/,
|
|
14
|
+
// email(支持中文邮箱)
|
|
15
|
+
email: /^[A-Z0-9\u4E00-\u9FA5]+@[\w-]+(?:\.[\w-]+)+$/i,
|
|
16
|
+
// 邮政编码(中国)
|
|
17
|
+
postalCode: /^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/,
|
|
18
|
+
// 身份证号(2代,18位数字),最后一位是校验位,可能为数字或字符X
|
|
19
|
+
identityCard: /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[12]\d|30|31)\d{3}[\dX]$/i,
|
|
20
|
+
// IP地址--ip-v4[:端口]
|
|
21
|
+
ip: /^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?::(?:\d|[1-9]\d{1,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5]))?$/,
|
|
22
|
+
// URL
|
|
23
|
+
url: /^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-][^!@#$%^&*?.\s]{0,64}\.)+[a-z]{2,6}\/?/,
|
|
24
|
+
// 是否为https url
|
|
25
|
+
httpsUrl: /^https:\/\//,
|
|
26
|
+
// 域名(非网址, 不包含协议)
|
|
27
|
+
domain: /^([0-9a-z-]+\.)+([a-z]{2,})$/i,
|
|
28
|
+
// 车牌号(新能源+非新能源)
|
|
29
|
+
plateNumber: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$/,
|
|
30
|
+
// md5格式(32位)
|
|
31
|
+
md5: /^[a-f0-9]{32}$/i,
|
|
32
|
+
// base64格式
|
|
33
|
+
base64: /^\s*data:(?:[a-z]+\/[a-z0-9-+.]+(?:;[a-z-]+=[a-z0-9-]+)?)?(?:;base64)?,([\w!$&',()*+;=\-.~:@/?%\s]*?)\s*$/i,
|
|
34
|
+
// GUID/UUID
|
|
35
|
+
uuid: /^[a-f\d]{4}(?:[a-f\d]{4}-){4}[a-f\d]{12}$/i,
|
|
36
|
+
// 版本号(version)格式必须为X.Y.Z
|
|
37
|
+
version: /^\d+(?:\.\d+){2}$/,
|
|
38
|
+
// 视频(video)链接地址(视频格式可按需增删)
|
|
39
|
+
videoUrl: /^https?:\/\/(.+\/)+.+(\.(swf|avi|flv|mpg|rm|mov|wav|asf|3gp|mkv|rmvb|mp4))$/i,
|
|
40
|
+
// 图片(image)链接地址(图片格式可按需增删)
|
|
41
|
+
imageUrl: /^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i,
|
|
42
|
+
// 中文
|
|
43
|
+
chinese: /^(?:[\u3400-\u4DB5\u4E00-\u9FEA\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0])+$/,
|
|
44
|
+
itcode: /^[a-z]+\d*$/i
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/is.js
|
|
48
|
+
var toString = Object.prototype.toString;
|
|
49
|
+
function is(val, type) {
|
|
50
|
+
return toString.call(val) === `[object ${type}]`;
|
|
51
|
+
}
|
|
52
|
+
function isObject(val) {
|
|
53
|
+
return val !== null && is(val, "Object");
|
|
54
|
+
}
|
|
55
|
+
function isUrl(path) {
|
|
56
|
+
return regexpMap.url.test(path);
|
|
57
|
+
}
|
|
58
|
+
function isIterableArray(val) {
|
|
59
|
+
return Array.isArray(val) && val.length > 0;
|
|
60
|
+
}
|
|
61
|
+
function isPositiveInteger(num) {
|
|
62
|
+
return Number.isInteger(num) && num >= 0;
|
|
63
|
+
}
|
|
64
|
+
var isServer = typeof window === "undefined";
|
|
65
|
+
var isClient = !isServer;
|
|
66
|
+
var isChrome = isClient && window.navigator.userAgent.toLowerCase().includes("chrome");
|
|
67
|
+
var isSafari = isClient && window.navigator.userAgent.toLowerCase().includes("safari");
|
|
68
|
+
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
69
|
+
var isSupportNativeEllipsis = isBrowser && typeof document.body.style.lineClamp !== "undefined";
|
|
70
|
+
var isSupportResizeObserver = isBrowser && typeof ResizeObserver !== "undefined";
|
|
71
|
+
var isChineseText = (text) => {
|
|
72
|
+
return regexpMap.chinese.test(text);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// src/common.js
|
|
76
|
+
var withInstall = (component, alias) => {
|
|
77
|
+
const comp = component;
|
|
78
|
+
comp.install = (app) => {
|
|
79
|
+
app.component(comp.name || comp.displayName, component);
|
|
80
|
+
if (alias) {
|
|
81
|
+
app.config.globalProperties[alias] = component;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
return component;
|
|
85
|
+
};
|
|
86
|
+
function getRawRoute(route) {
|
|
87
|
+
if (!route) {
|
|
88
|
+
return route;
|
|
89
|
+
}
|
|
90
|
+
const { matched, ...opt } = route;
|
|
91
|
+
return {
|
|
92
|
+
...opt,
|
|
93
|
+
matched: matched ? matched.map((item) => ({
|
|
94
|
+
meta: item.meta,
|
|
95
|
+
name: item.name,
|
|
96
|
+
path: item.path
|
|
97
|
+
})) : void 0
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function openWindow(url, opt) {
|
|
101
|
+
const { target = "__blank", noopener = true, noreferrer = true } = opt || {};
|
|
102
|
+
const feature = [];
|
|
103
|
+
noopener && feature.push("noopener=yes");
|
|
104
|
+
noreferrer && feature.push("noreferrer=yes");
|
|
105
|
+
window.open(url, target, feature.join(","));
|
|
106
|
+
}
|
|
107
|
+
function deepMerge(source, target, mergeArrays = "replace") {
|
|
108
|
+
if (!target) {
|
|
109
|
+
return source;
|
|
110
|
+
}
|
|
111
|
+
if (!source) {
|
|
112
|
+
return target;
|
|
113
|
+
}
|
|
114
|
+
return mergeWith(source, target, (sourceValue, targetValue) => {
|
|
115
|
+
if (isArray(targetValue) && isArray(sourceValue)) {
|
|
116
|
+
switch (mergeArrays) {
|
|
117
|
+
case "union":
|
|
118
|
+
return unionWith(sourceValue, targetValue, isEqual);
|
|
119
|
+
case "intersection":
|
|
120
|
+
return intersectionWith(sourceValue, targetValue, isEqual);
|
|
121
|
+
case "concat":
|
|
122
|
+
return sourceValue.concat(targetValue);
|
|
123
|
+
case "replace":
|
|
124
|
+
return targetValue;
|
|
125
|
+
default:
|
|
126
|
+
throw new Error(`Unknown merge array strategy: ${mergeArrays}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (isObject(targetValue) && isObject(sourceValue)) {
|
|
130
|
+
return deepMerge(sourceValue, targetValue, mergeArrays);
|
|
131
|
+
}
|
|
132
|
+
return void 0;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function getPopupContainer(node) {
|
|
136
|
+
return (node == null ? void 0 : node.parentNode) ?? document.body;
|
|
137
|
+
}
|
|
138
|
+
function setObjToUrlParams(baseUrl, obj) {
|
|
139
|
+
if (!isIterableArray(Object.keys(obj))) {
|
|
140
|
+
return baseUrl;
|
|
141
|
+
}
|
|
142
|
+
let parameters = "";
|
|
143
|
+
for (const key in obj) {
|
|
144
|
+
parameters += `${key}=${encodeURIComponent(obj[key])}&`;
|
|
145
|
+
}
|
|
146
|
+
parameters = parameters.replace(/&$/, "");
|
|
147
|
+
return /\?$/.test(baseUrl) ? baseUrl + parameters : baseUrl.replace(/\/?$/, "?") + parameters;
|
|
148
|
+
}
|
|
149
|
+
function unsetAllProperty(params) {
|
|
150
|
+
if (isPlainObject(params)) {
|
|
151
|
+
Object.keys(params).forEach((key) => {
|
|
152
|
+
Reflect.deleteProperty(params, key);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function transform(c) {
|
|
157
|
+
const code = ["$", "(", ")", "*", "+", ".", "[", "]", "?", "\\", "^", "{", "}", "|"];
|
|
158
|
+
return code.includes(c) ? `\\${c}` : c;
|
|
159
|
+
}
|
|
160
|
+
function createSearchReg(key) {
|
|
161
|
+
const keys = [...key].map((item) => transform(item));
|
|
162
|
+
const str = ["", ...keys, ""].join(".*");
|
|
163
|
+
return new RegExp(str, "i");
|
|
164
|
+
}
|
|
165
|
+
function getActualWidthOfChars(text = "", options = {}) {
|
|
166
|
+
const {
|
|
167
|
+
size = 14,
|
|
168
|
+
family = getComputedStyle(document.documentElement).getPropertyValue("--vxe-font-family") || "sans-serif"
|
|
169
|
+
} = options;
|
|
170
|
+
const canvas = document.createElement("canvas");
|
|
171
|
+
const ctx = canvas.getContext("2d");
|
|
172
|
+
ctx.font = `${size}px ${family}`;
|
|
173
|
+
const metrics = ctx.measureText(text);
|
|
174
|
+
const actual = Math.abs(metrics.actualBoundingBoxLeft) + Math.abs(metrics.actualBoundingBoxRight);
|
|
175
|
+
return Math.ceil(Math.max(metrics.width, actual));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// src/bem.js
|
|
179
|
+
function genBem(name, mods) {
|
|
180
|
+
if (!mods) {
|
|
181
|
+
return "";
|
|
182
|
+
}
|
|
183
|
+
if (typeof mods === "string") {
|
|
184
|
+
return ` ${name}--${mods}`;
|
|
185
|
+
}
|
|
186
|
+
if (Array.isArray(mods)) {
|
|
187
|
+
return mods.reduce((ret, item) => ret + genBem(name, item), "");
|
|
188
|
+
}
|
|
189
|
+
return Object.keys(mods).reduce((ret, key) => ret + (mods[key] ? genBem(name, key) : ""), "");
|
|
190
|
+
}
|
|
191
|
+
function buildBEM(name) {
|
|
192
|
+
return (el, mods) => {
|
|
193
|
+
if (el && typeof el !== "string") {
|
|
194
|
+
mods = el;
|
|
195
|
+
el = "";
|
|
196
|
+
}
|
|
197
|
+
el = el ? `${name}__${el}` : name;
|
|
198
|
+
return `${el}${genBem(el, mods)}`;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function createBEM(name, prefixCls = "gsc") {
|
|
202
|
+
return [buildBEM(`${prefixCls}-${name}`)];
|
|
203
|
+
}
|
|
204
|
+
function createNamespace(name, prefixCls = "gsc") {
|
|
205
|
+
const prefixedName = `${prefixCls}-${name}`;
|
|
206
|
+
return [prefixedName, buildBEM(prefixedName)];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/cipher.js
|
|
210
|
+
import { encrypt, decrypt } from "crypto-js/aes";
|
|
211
|
+
import UTF8, { parse } from "crypto-js/enc-utf8";
|
|
212
|
+
import pkcs7 from "crypto-js/pad-pkcs7";
|
|
213
|
+
import ECB from "crypto-js/mode-ecb";
|
|
214
|
+
import md5 from "crypto-js/md5";
|
|
215
|
+
import Base64 from "crypto-js/enc-base64";
|
|
216
|
+
var AesEncryption = class {
|
|
217
|
+
constructor(opt) {
|
|
218
|
+
const { key, iv } = opt;
|
|
219
|
+
if (key) {
|
|
220
|
+
this.key = parse(key);
|
|
221
|
+
}
|
|
222
|
+
if (iv) {
|
|
223
|
+
this.iv = parse(iv);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
get getOptions() {
|
|
227
|
+
return {
|
|
228
|
+
mode: ECB,
|
|
229
|
+
padding: pkcs7,
|
|
230
|
+
iv: this.iv
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
encryptByAES(cipherText) {
|
|
234
|
+
return encrypt(cipherText, this.key, this.getOptions).toString();
|
|
235
|
+
}
|
|
236
|
+
decryptByAES(cipherText) {
|
|
237
|
+
return decrypt(cipherText, this.key, this.getOptions).toString(UTF8);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
function encryptByBase64(cipherText) {
|
|
241
|
+
return UTF8.parse(cipherText).toString(Base64);
|
|
242
|
+
}
|
|
243
|
+
function decodeByBase64(cipherText) {
|
|
244
|
+
return Base64.parse(cipherText).toString(UTF8);
|
|
245
|
+
}
|
|
246
|
+
function encryptByMd5(password) {
|
|
247
|
+
return md5(password).toString();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// src/domUtils.js
|
|
251
|
+
import { upperFirst } from "lodash-es";
|
|
252
|
+
var docEle = document.documentElement;
|
|
253
|
+
var enableTransitions = () => {
|
|
254
|
+
return "startViewTransition" in document && window.matchMedia("(prefers-reduced-motion: no-preference)").matches;
|
|
255
|
+
};
|
|
256
|
+
function getBoundingClientRect(element) {
|
|
257
|
+
if (!element || !element.getBoundingClientRect) {
|
|
258
|
+
return 0;
|
|
259
|
+
}
|
|
260
|
+
return element.getBoundingClientRect();
|
|
261
|
+
}
|
|
262
|
+
function trim(string) {
|
|
263
|
+
return (string || "").replace(/^\s+|\s+$/g, "");
|
|
264
|
+
}
|
|
265
|
+
function hasClass(el, cls) {
|
|
266
|
+
if (!el || !cls) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
if (cls.includes(" ")) {
|
|
270
|
+
throw new Error("className should not contain space.");
|
|
271
|
+
}
|
|
272
|
+
if (el.classList) {
|
|
273
|
+
return el.classList.contains(cls);
|
|
274
|
+
} else {
|
|
275
|
+
return ` ${el.className} `.includes(` ${cls} `);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function setCssVar(prop, val, dom = docEle) {
|
|
279
|
+
dom.style.setProperty(prop, val);
|
|
280
|
+
}
|
|
281
|
+
function addClass(el, cls) {
|
|
282
|
+
if (!el) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
let curClass = el.className;
|
|
286
|
+
const classes = (cls || "").split(" ");
|
|
287
|
+
for (let i = 0, j = classes.length; i < j; i++) {
|
|
288
|
+
const clsName = classes[i];
|
|
289
|
+
if (!clsName) {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
if (el.classList) {
|
|
293
|
+
el.classList.add(clsName);
|
|
294
|
+
} else if (!hasClass(el, clsName)) {
|
|
295
|
+
curClass += ` ${clsName}`;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (!el.classList) {
|
|
299
|
+
el.className = curClass;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function removeClass(el, cls) {
|
|
303
|
+
if (!el || !cls) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const classes = cls.split(" ");
|
|
307
|
+
let curClass = ` ${el.className} `;
|
|
308
|
+
for (let i = 0, j = classes.length; i < j; i++) {
|
|
309
|
+
const clsName = classes[i];
|
|
310
|
+
if (!clsName) {
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
if (el.classList) {
|
|
314
|
+
el.classList.remove(clsName);
|
|
315
|
+
} else if (hasClass(el, clsName)) {
|
|
316
|
+
curClass = curClass.replace(` ${clsName} `, " ");
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (!el.classList) {
|
|
320
|
+
el.className = trim(curClass);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function getViewportOffset(element) {
|
|
324
|
+
const doc = document.documentElement;
|
|
325
|
+
const docScrollLeft = doc.scrollLeft;
|
|
326
|
+
const docScrollTop = doc.scrollTop;
|
|
327
|
+
const docClientLeft = doc.clientLeft;
|
|
328
|
+
const docClientTop = doc.clientTop;
|
|
329
|
+
const pageXOffset = window.scrollX;
|
|
330
|
+
const pageYOffset = window.scrollY;
|
|
331
|
+
const box = getBoundingClientRect(element);
|
|
332
|
+
const { left: retLeft, top: rectTop, width: rectWidth, height: rectHeight } = box;
|
|
333
|
+
const scrollLeft = (pageXOffset || docScrollLeft) - (docClientLeft || 0);
|
|
334
|
+
const scrollTop = (pageYOffset || docScrollTop) - (docClientTop || 0);
|
|
335
|
+
const offsetLeft = retLeft + pageXOffset;
|
|
336
|
+
const offsetTop = rectTop + pageYOffset;
|
|
337
|
+
const left = offsetLeft - scrollLeft;
|
|
338
|
+
const top = offsetTop - scrollTop;
|
|
339
|
+
const clientWidth = window.document.documentElement.clientWidth;
|
|
340
|
+
const clientHeight = window.document.documentElement.clientHeight;
|
|
341
|
+
return {
|
|
342
|
+
left,
|
|
343
|
+
top,
|
|
344
|
+
right: clientWidth - rectWidth - left,
|
|
345
|
+
bottom: clientHeight - rectHeight - top,
|
|
346
|
+
rightIncludeBody: clientWidth - left,
|
|
347
|
+
bottomIncludeBody: clientHeight - top
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function hackCss(attr, value) {
|
|
351
|
+
const prefix = ["webkit", "Moz", "ms", "OT"];
|
|
352
|
+
const styleObj = {};
|
|
353
|
+
prefix.forEach((item) => {
|
|
354
|
+
styleObj[`${item}${upperFirst(attr)}`] = value;
|
|
355
|
+
});
|
|
356
|
+
return {
|
|
357
|
+
...styleObj,
|
|
358
|
+
[attr]: value
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function on(element, event, handler) {
|
|
362
|
+
if (element && event && handler) {
|
|
363
|
+
element.addEventListener(event, handler, false);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
function off(element, event, handler) {
|
|
367
|
+
if (element && event && handler) {
|
|
368
|
+
element.removeEventListener(event, handler, false);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
function useRafThrottle(fn) {
|
|
372
|
+
let locked = false;
|
|
373
|
+
return function(...args) {
|
|
374
|
+
if (locked) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
locked = true;
|
|
378
|
+
window.requestAnimationFrame(() => {
|
|
379
|
+
fn.apply(this, args);
|
|
380
|
+
locked = false;
|
|
381
|
+
});
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// src/event.js
|
|
386
|
+
import ResizeObserver2 from "resize-observer-polyfill";
|
|
387
|
+
function resizeHandler(entries) {
|
|
388
|
+
for (const entry of entries) {
|
|
389
|
+
const listeners = entry.target.__resizeListeners__ || [];
|
|
390
|
+
if (listeners.length) {
|
|
391
|
+
listeners.forEach((fn) => {
|
|
392
|
+
fn();
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
function addResizeListener(element, fn) {
|
|
398
|
+
if (isServer) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
if (!element.__resizeListeners__) {
|
|
402
|
+
element.__resizeListeners__ = [];
|
|
403
|
+
element.__ro__ = new ResizeObserver2(resizeHandler);
|
|
404
|
+
element.__ro__.observe(element);
|
|
405
|
+
}
|
|
406
|
+
element.__resizeListeners__.push(fn);
|
|
407
|
+
}
|
|
408
|
+
function removeResizeListener(element, fn) {
|
|
409
|
+
if (!element || !element.__resizeListeners__) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
|
|
413
|
+
if (!element.__resizeListeners__.length) {
|
|
414
|
+
element.__ro__.disconnect();
|
|
415
|
+
element.__ro__ = null;
|
|
416
|
+
element.__resizeListeners__ = null;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
function triggerWindowResize() {
|
|
420
|
+
const event = new Event("resize", { bubbles: true, cancelable: true });
|
|
421
|
+
window.dispatchEvent(event);
|
|
422
|
+
}
|
|
423
|
+
function addLocationListener(fn, options = {}) {
|
|
424
|
+
function addEvent(type) {
|
|
425
|
+
const original = window.history[type];
|
|
426
|
+
return function(...args) {
|
|
427
|
+
const e = new Event(type);
|
|
428
|
+
e.arguments = args;
|
|
429
|
+
window.dispatchEvent(e);
|
|
430
|
+
return original.apply(this, args);
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
;
|
|
434
|
+
window.history.pushState = addEvent("pushState");
|
|
435
|
+
window.history.replaceState = addEvent("replaceState");
|
|
436
|
+
window.addEventListener("popstate", fn, options);
|
|
437
|
+
window.addEventListener("hashchange", fn, options);
|
|
438
|
+
window.addEventListener("replaceState", fn, options);
|
|
439
|
+
window.addEventListener("pushState", fn, options);
|
|
440
|
+
return {
|
|
441
|
+
removeListener: () => {
|
|
442
|
+
window.removeEventListener("popstate", fn, options);
|
|
443
|
+
window.removeEventListener("hashchange", fn, options);
|
|
444
|
+
window.removeEventListener("replaceState", fn, options);
|
|
445
|
+
window.removeEventListener("pushState", fn, options);
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// src/file.js
|
|
451
|
+
import { round, isNil } from "lodash-es";
|
|
452
|
+
function dataURLtoBlob(base64Buf) {
|
|
453
|
+
const arr = base64Buf.split(",");
|
|
454
|
+
const typeItem = arr[0];
|
|
455
|
+
const mime = typeItem.match(/:(.*?);/)[1];
|
|
456
|
+
const bstr = window.atob(arr[1]);
|
|
457
|
+
let n = bstr.length;
|
|
458
|
+
const u8arr = new Uint8Array(n);
|
|
459
|
+
while (n--) {
|
|
460
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
461
|
+
}
|
|
462
|
+
return new Blob([u8arr], { type: mime });
|
|
463
|
+
}
|
|
464
|
+
function urlToBase64(url, mineType) {
|
|
465
|
+
return new Promise((resolve, reject) => {
|
|
466
|
+
let canvas = document.createElement("CANVAS");
|
|
467
|
+
const ctx = canvas.getContext("2d");
|
|
468
|
+
const img = new Image();
|
|
469
|
+
img.crossOrigin = "";
|
|
470
|
+
img.onload = function() {
|
|
471
|
+
if (!canvas || !ctx) {
|
|
472
|
+
return reject();
|
|
473
|
+
}
|
|
474
|
+
canvas.height = img.height;
|
|
475
|
+
canvas.width = img.width;
|
|
476
|
+
ctx.drawImage(img, 0, 0);
|
|
477
|
+
const dataURL = canvas.toDataURL(mineType || "image/png");
|
|
478
|
+
canvas = null;
|
|
479
|
+
resolve(dataURL);
|
|
480
|
+
};
|
|
481
|
+
img.src = url;
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
function downloadPercent(event) {
|
|
485
|
+
const { loaded, total } = event;
|
|
486
|
+
if (total <= 0 || isNil(total)) {
|
|
487
|
+
return 0;
|
|
488
|
+
}
|
|
489
|
+
const percent = loaded / total;
|
|
490
|
+
return round((percent > 1 ? 1 : percent) * 100);
|
|
491
|
+
}
|
|
492
|
+
function downloadByOnlineUrl(url, filename, mime, bom) {
|
|
493
|
+
urlToBase64(url).then((base64) => {
|
|
494
|
+
downloadByBase64(base64, filename, mime, bom);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
function downloadByBase64(buf, filename, mime, bom) {
|
|
498
|
+
const base64Buf = dataURLtoBlob(buf);
|
|
499
|
+
downloadByData(base64Buf, filename, mime, bom);
|
|
500
|
+
}
|
|
501
|
+
function downloadByData(data, filename, mime, bom) {
|
|
502
|
+
const blobData = typeof bom !== "undefined" ? [bom, data] : [data];
|
|
503
|
+
const blob = new Blob(blobData, { type: mime || "application/octet-stream" });
|
|
504
|
+
if (typeof window.navigator.msSaveBlob !== "undefined") {
|
|
505
|
+
window.navigator.msSaveBlob(blob, filename);
|
|
506
|
+
} else {
|
|
507
|
+
const blobURL = window.URL.createObjectURL(blob);
|
|
508
|
+
const tempLink = document.createElement("a");
|
|
509
|
+
tempLink.style.display = "none";
|
|
510
|
+
tempLink.href = blobURL;
|
|
511
|
+
tempLink.setAttribute("download", filename);
|
|
512
|
+
if (typeof tempLink.download === "undefined") {
|
|
513
|
+
tempLink.setAttribute("target", "_blank");
|
|
514
|
+
}
|
|
515
|
+
document.body.appendChild(tempLink);
|
|
516
|
+
tempLink.click();
|
|
517
|
+
document.body.removeChild(tempLink);
|
|
518
|
+
window.URL.revokeObjectURL(blobURL);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
function downloadByUrl({ url, target = "_blank", fileName }) {
|
|
522
|
+
if (/iP/.test(window.navigator.userAgent)) {
|
|
523
|
+
return false;
|
|
524
|
+
}
|
|
525
|
+
if (isChrome || isSafari) {
|
|
526
|
+
const link = document.createElement("a");
|
|
527
|
+
link.href = url;
|
|
528
|
+
link.download = fileName || url.substring(url.lastIndexOf("/") + 1, url.length);
|
|
529
|
+
link.style.display = "none";
|
|
530
|
+
document.body.appendChild(link);
|
|
531
|
+
link.click();
|
|
532
|
+
document.body.removeChild(link);
|
|
533
|
+
return true;
|
|
534
|
+
}
|
|
535
|
+
if (!url.includes("?")) {
|
|
536
|
+
url += "?download";
|
|
537
|
+
}
|
|
538
|
+
openWindow(url, { target });
|
|
539
|
+
return true;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// src/highlightHtml.js
|
|
543
|
+
var getKeywordIndexList = (content, keyword, flags = "ig") => {
|
|
544
|
+
const reg = new RegExp(keyword, flags);
|
|
545
|
+
const res = content.matchAll(reg);
|
|
546
|
+
const arr = [...res];
|
|
547
|
+
const allIndexArr = arr.map((e) => ({
|
|
548
|
+
index: e.index,
|
|
549
|
+
subString: e["0"]
|
|
550
|
+
}));
|
|
551
|
+
return allIndexArr;
|
|
552
|
+
};
|
|
553
|
+
function humpToLine(name) {
|
|
554
|
+
return name.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
555
|
+
}
|
|
556
|
+
var renderNodeTag = (subStr, option) => {
|
|
557
|
+
const s = subStr;
|
|
558
|
+
if (!option) {
|
|
559
|
+
return s;
|
|
560
|
+
}
|
|
561
|
+
const { tagName = "mark", bgColor, color, style = {}, renderHighlightKeyword } = option;
|
|
562
|
+
if (typeof renderHighlightKeyword === "function") {
|
|
563
|
+
return renderHighlightKeyword(subStr);
|
|
564
|
+
}
|
|
565
|
+
style.backgroundColor = bgColor;
|
|
566
|
+
style.color = color;
|
|
567
|
+
const styleContent = Object.keys(style).map((k) => `${humpToLine(k)}:${style[k]}`).join(";");
|
|
568
|
+
const styleStr = `style="${styleContent}"`;
|
|
569
|
+
return `<${tagName} ${styleStr}>${s}</${tagName}>`;
|
|
570
|
+
};
|
|
571
|
+
var renderHighlightHtml = (content, list) => {
|
|
572
|
+
let str = "";
|
|
573
|
+
list.forEach((item) => {
|
|
574
|
+
const { start, end, option } = item;
|
|
575
|
+
const s = content.slice(start, end);
|
|
576
|
+
const subStr = renderNodeTag(s, option);
|
|
577
|
+
str += subStr;
|
|
578
|
+
item.subString = subStr;
|
|
579
|
+
});
|
|
580
|
+
return str;
|
|
581
|
+
};
|
|
582
|
+
var parseHighlightIndex = (content, keywords) => {
|
|
583
|
+
const result = [];
|
|
584
|
+
keywords.forEach((keywordOption) => {
|
|
585
|
+
let option = { keyword: "" };
|
|
586
|
+
if (typeof keywordOption === "string") {
|
|
587
|
+
option = { keyword: keywordOption };
|
|
588
|
+
} else {
|
|
589
|
+
option = keywordOption;
|
|
590
|
+
}
|
|
591
|
+
const { keyword, caseSensitive = true } = option;
|
|
592
|
+
const indexList = getKeywordIndexList(content, keyword, caseSensitive ? "g" : "gi");
|
|
593
|
+
const res = {
|
|
594
|
+
keyword,
|
|
595
|
+
indexList,
|
|
596
|
+
option
|
|
597
|
+
};
|
|
598
|
+
result.push(res);
|
|
599
|
+
});
|
|
600
|
+
return result;
|
|
601
|
+
};
|
|
602
|
+
var parseHighlightString = (content, keywords) => {
|
|
603
|
+
const result = parseHighlightIndex(content, keywords);
|
|
604
|
+
const splitList = [];
|
|
605
|
+
const findSplitIndex = (index, len) => {
|
|
606
|
+
for (let i = 0; i < splitList.length; i++) {
|
|
607
|
+
const cur = splitList[i];
|
|
608
|
+
if (index > cur.start && index < cur.end || index + len > cur.start && index + len < cur.end || cur.start > index && cur.start < index + len || cur.end > index && cur.end < index + len || index === cur.start && index + len === cur.end) {
|
|
609
|
+
return -1;
|
|
610
|
+
}
|
|
611
|
+
if (index + len <= cur.start) {
|
|
612
|
+
return i;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return splitList.length;
|
|
616
|
+
};
|
|
617
|
+
result.forEach(({ indexList, option }) => {
|
|
618
|
+
indexList.forEach((e) => {
|
|
619
|
+
const { index, subString } = e;
|
|
620
|
+
const item = {
|
|
621
|
+
start: index,
|
|
622
|
+
end: index + subString.length,
|
|
623
|
+
option
|
|
624
|
+
};
|
|
625
|
+
const splitIndex = findSplitIndex(index, subString.length);
|
|
626
|
+
if (splitIndex !== -1) {
|
|
627
|
+
splitList.splice(splitIndex, 0, item);
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
const list = [];
|
|
632
|
+
splitList.forEach((cur, i) => {
|
|
633
|
+
const { start, end } = cur;
|
|
634
|
+
const next = splitList[i + 1];
|
|
635
|
+
if (i === 0 && start > 0) {
|
|
636
|
+
list.push({ start: 0, end: start, subString: content.slice(0, start) });
|
|
637
|
+
}
|
|
638
|
+
list.push({ ...cur, subString: content.slice(start, end) });
|
|
639
|
+
if ((next == null ? void 0 : next.start) > end) {
|
|
640
|
+
list.push({
|
|
641
|
+
start: end,
|
|
642
|
+
end: next.start,
|
|
643
|
+
subString: content.slice(end, next.start)
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
if (i === splitList.length - 1 && end < content.length - 1) {
|
|
647
|
+
list.push({
|
|
648
|
+
start: end,
|
|
649
|
+
end: content.length - 1,
|
|
650
|
+
subString: content.slice(end, content.length)
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
return list;
|
|
655
|
+
};
|
|
656
|
+
var highlightHtml = (content, keywords) => {
|
|
657
|
+
const splitList = parseHighlightString(content, keywords);
|
|
658
|
+
return {
|
|
659
|
+
highText: renderHighlightHtml(content, splitList),
|
|
660
|
+
highList: splitList
|
|
661
|
+
};
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
// src/ifActivity.js
|
|
665
|
+
import { clearInterval, clearTimeout, setInterval, setTimeout } from "worker-timers";
|
|
666
|
+
var STATUS_ACTIVE = "active";
|
|
667
|
+
var STATUS_IDLE = "idle";
|
|
668
|
+
var STATUS_HIDDEN = "hidden";
|
|
669
|
+
var DOC_HIDDEN;
|
|
670
|
+
var VISIBILITY_CHANGE_EVENT;
|
|
671
|
+
var setListener;
|
|
672
|
+
var store = {};
|
|
673
|
+
var Events = {
|
|
674
|
+
attach(event, callback) {
|
|
675
|
+
if (!store[event]) {
|
|
676
|
+
store[event] = [];
|
|
677
|
+
}
|
|
678
|
+
store[event].push(callback);
|
|
679
|
+
},
|
|
680
|
+
fire(event, args = []) {
|
|
681
|
+
if (store[event]) {
|
|
682
|
+
store[event].forEach((callback) => {
|
|
683
|
+
callback(...args);
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
remove(event, callback) {
|
|
688
|
+
if (!callback) {
|
|
689
|
+
Reflect.deleteProperty(store, event);
|
|
690
|
+
}
|
|
691
|
+
if (store[event]) {
|
|
692
|
+
store[event] = store[event].filter((savedCallback) => {
|
|
693
|
+
return callback !== savedCallback;
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
},
|
|
697
|
+
dom(element, event, callback) {
|
|
698
|
+
if (!setListener) {
|
|
699
|
+
if (element.addEventListener) {
|
|
700
|
+
setListener = (el, ev, fn) => {
|
|
701
|
+
return el.addEventListener(ev, fn, false);
|
|
702
|
+
};
|
|
703
|
+
} else if (typeof element.attachEvent === "function") {
|
|
704
|
+
setListener = (el, ev, fn) => {
|
|
705
|
+
return el.attachEvent(`on${ev}`, fn, false);
|
|
706
|
+
};
|
|
707
|
+
} else {
|
|
708
|
+
setListener = (el, ev, fn) => {
|
|
709
|
+
return el[`on${ev}`] = fn;
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return setListener(element, event, callback);
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
var Timer = class {
|
|
717
|
+
constructor(activity, seconds, callback) {
|
|
718
|
+
this.activity = activity;
|
|
719
|
+
this.seconds = seconds;
|
|
720
|
+
this.callback = callback;
|
|
721
|
+
this.stopped = false;
|
|
722
|
+
this.start();
|
|
723
|
+
this.activity.on("statusChanged", (data) => {
|
|
724
|
+
if (this.stopped === false) {
|
|
725
|
+
if (data.status === STATUS_ACTIVE) {
|
|
726
|
+
this.start();
|
|
727
|
+
} else {
|
|
728
|
+
this.pause();
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
start() {
|
|
734
|
+
this.stopped = false;
|
|
735
|
+
clearInterval(this.token);
|
|
736
|
+
this.token = setInterval(this.callback, this.seconds * 1e3);
|
|
737
|
+
}
|
|
738
|
+
stop() {
|
|
739
|
+
this.stopped = true;
|
|
740
|
+
clearInterval(this.token);
|
|
741
|
+
}
|
|
742
|
+
resume() {
|
|
743
|
+
this.start();
|
|
744
|
+
}
|
|
745
|
+
pause() {
|
|
746
|
+
this.stop();
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
var IfActivity = class {
|
|
750
|
+
constructor() {
|
|
751
|
+
this.status = STATUS_ACTIVE;
|
|
752
|
+
this.timers = [];
|
|
753
|
+
this.idleTime = 3e4;
|
|
754
|
+
this.isLegacyModeOn = false;
|
|
755
|
+
if (document.hidden !== void 0) {
|
|
756
|
+
DOC_HIDDEN = "hidden";
|
|
757
|
+
VISIBILITY_CHANGE_EVENT = "visibilitychange";
|
|
758
|
+
} else if (document.mozHidden !== void 0) {
|
|
759
|
+
DOC_HIDDEN = "mozHidden";
|
|
760
|
+
VISIBILITY_CHANGE_EVENT = "mozvisibilitychange";
|
|
761
|
+
} else if (document.msHidden !== void 0) {
|
|
762
|
+
DOC_HIDDEN = "msHidden";
|
|
763
|
+
VISIBILITY_CHANGE_EVENT = "msvisibilitychange";
|
|
764
|
+
} else if (document.webkitHidden !== void 0) {
|
|
765
|
+
DOC_HIDDEN = "webkitHidden";
|
|
766
|
+
VISIBILITY_CHANGE_EVENT = "webkitvisibilitychange";
|
|
767
|
+
}
|
|
768
|
+
if (DOC_HIDDEN === void 0) {
|
|
769
|
+
this.legacyMode();
|
|
770
|
+
} else {
|
|
771
|
+
const trackChange = () => {
|
|
772
|
+
if (document[DOC_HIDDEN]) {
|
|
773
|
+
this.blur();
|
|
774
|
+
} else {
|
|
775
|
+
this.focus();
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
trackChange();
|
|
779
|
+
Events.dom(document, VISIBILITY_CHANGE_EVENT, trackChange);
|
|
780
|
+
}
|
|
781
|
+
this.startIdleTimer();
|
|
782
|
+
this.trackIdleStatus();
|
|
783
|
+
}
|
|
784
|
+
legacyMode() {
|
|
785
|
+
if (this.isLegacyModeOn) {
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
Events.dom(window, "blur", () => {
|
|
789
|
+
return this.blur();
|
|
790
|
+
});
|
|
791
|
+
Events.dom(window, "focus", () => {
|
|
792
|
+
return this.focus();
|
|
793
|
+
});
|
|
794
|
+
this.isLegacyModeOn = true;
|
|
795
|
+
}
|
|
796
|
+
startIdleTimer(event) {
|
|
797
|
+
if (event instanceof MouseEvent && event.movementX === 0 && event.movementY === 0) {
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
this.timers.map(clearTimeout);
|
|
801
|
+
this.timers.length = 0;
|
|
802
|
+
if (this.status === STATUS_IDLE) {
|
|
803
|
+
this.wakeUp();
|
|
804
|
+
}
|
|
805
|
+
this.idleStartedTime = +/* @__PURE__ */ new Date();
|
|
806
|
+
this.timers.push(
|
|
807
|
+
setTimeout(() => {
|
|
808
|
+
if (this.status === STATUS_ACTIVE || this.status === STATUS_HIDDEN) {
|
|
809
|
+
return this.idle();
|
|
810
|
+
}
|
|
811
|
+
}, this.idleTime)
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
trackIdleStatus() {
|
|
815
|
+
Events.dom(document, "mousemove", this.startIdleTimer.bind(this));
|
|
816
|
+
Events.dom(document, "mousedown", this.startIdleTimer.bind(this));
|
|
817
|
+
Events.dom(document, "keyup", this.startIdleTimer.bind(this));
|
|
818
|
+
Events.dom(document, "touchstart", this.startIdleTimer.bind(this));
|
|
819
|
+
Events.dom(window, "scroll", this.startIdleTimer.bind(this));
|
|
820
|
+
this.focus(this.startIdleTimer.bind(this));
|
|
821
|
+
}
|
|
822
|
+
on(event, callback) {
|
|
823
|
+
Events.attach(event, callback);
|
|
824
|
+
return this;
|
|
825
|
+
}
|
|
826
|
+
// will remove events
|
|
827
|
+
off(event, callback) {
|
|
828
|
+
Events.remove(event, callback);
|
|
829
|
+
return this;
|
|
830
|
+
}
|
|
831
|
+
setIdleDuration(seconds) {
|
|
832
|
+
this.idleTime = seconds * 1e3;
|
|
833
|
+
this.startIdleTimer();
|
|
834
|
+
return this;
|
|
835
|
+
}
|
|
836
|
+
getIdleDuration() {
|
|
837
|
+
return this.idleTime;
|
|
838
|
+
}
|
|
839
|
+
getIdleInfo() {
|
|
840
|
+
const now = +/* @__PURE__ */ new Date();
|
|
841
|
+
let res;
|
|
842
|
+
if (this.status === STATUS_IDLE) {
|
|
843
|
+
res = {
|
|
844
|
+
isIdle: true,
|
|
845
|
+
idleFor: now - this.idleStartedTime,
|
|
846
|
+
timeLeft: 0,
|
|
847
|
+
timeLeftPer: 100
|
|
848
|
+
};
|
|
849
|
+
} else {
|
|
850
|
+
const timeLeft = this.idleStartedTime + this.idleTime - now;
|
|
851
|
+
res = {
|
|
852
|
+
isIdle: false,
|
|
853
|
+
idleFor: now - this.idleStartedTime,
|
|
854
|
+
timeLeft,
|
|
855
|
+
timeLeftPer: Number.parseFloat((100 - timeLeft * 100 / this.idleTime).toFixed(2))
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
return res;
|
|
859
|
+
}
|
|
860
|
+
idle(callback) {
|
|
861
|
+
if (callback) {
|
|
862
|
+
this.on("idle", callback);
|
|
863
|
+
} else {
|
|
864
|
+
this.status = STATUS_IDLE;
|
|
865
|
+
Events.fire("idle");
|
|
866
|
+
Events.fire("statusChanged", [{ status: this.status }]);
|
|
867
|
+
}
|
|
868
|
+
return this;
|
|
869
|
+
}
|
|
870
|
+
blur(callback) {
|
|
871
|
+
if (callback) {
|
|
872
|
+
this.on("blur", callback);
|
|
873
|
+
} else {
|
|
874
|
+
this.status = STATUS_HIDDEN;
|
|
875
|
+
Events.fire("blur");
|
|
876
|
+
Events.fire("statusChanged", [{ status: this.status }]);
|
|
877
|
+
}
|
|
878
|
+
return this;
|
|
879
|
+
}
|
|
880
|
+
focus(callback) {
|
|
881
|
+
if (callback) {
|
|
882
|
+
this.on("focus", callback);
|
|
883
|
+
} else if (this.status !== STATUS_ACTIVE) {
|
|
884
|
+
this.status = STATUS_ACTIVE;
|
|
885
|
+
Events.fire("focus");
|
|
886
|
+
Events.fire("wakeUp");
|
|
887
|
+
Events.fire("statusChanged", [{ status: this.status }]);
|
|
888
|
+
}
|
|
889
|
+
return this;
|
|
890
|
+
}
|
|
891
|
+
wakeUp(callback) {
|
|
892
|
+
if (callback) {
|
|
893
|
+
this.on("wakeUp", callback);
|
|
894
|
+
} else if (this.status !== STATUS_ACTIVE) {
|
|
895
|
+
this.status = STATUS_ACTIVE;
|
|
896
|
+
Events.fire("wakeUp");
|
|
897
|
+
Events.fire("statusChanged", [{ status: this.status }]);
|
|
898
|
+
}
|
|
899
|
+
return this;
|
|
900
|
+
}
|
|
901
|
+
// 页面活跃时执行定时器
|
|
902
|
+
onEvery(seconds, callback) {
|
|
903
|
+
return new Timer(this, seconds, callback);
|
|
904
|
+
}
|
|
905
|
+
now(check) {
|
|
906
|
+
if (check !== void 0) {
|
|
907
|
+
return this.status === check;
|
|
908
|
+
}
|
|
909
|
+
return this.status === STATUS_ACTIVE;
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
// src/jsxHelper.js
|
|
914
|
+
import { isFunction } from "lodash-es";
|
|
915
|
+
function getSlot(slots, slot = "default", data) {
|
|
916
|
+
if (!slots || !Reflect.has(slots, slot)) {
|
|
917
|
+
return null;
|
|
918
|
+
}
|
|
919
|
+
if (!isFunction(slots[slot])) {
|
|
920
|
+
return null;
|
|
921
|
+
}
|
|
922
|
+
const slotFn = slots[slot];
|
|
923
|
+
if (!slotFn) {
|
|
924
|
+
return null;
|
|
925
|
+
}
|
|
926
|
+
return slotFn(data);
|
|
927
|
+
}
|
|
928
|
+
function extendSlots(slots, excludeKeys = []) {
|
|
929
|
+
const slotKeys = Object.keys(slots);
|
|
930
|
+
const ret = {};
|
|
931
|
+
slotKeys.forEach((key) => {
|
|
932
|
+
if (excludeKeys.includes(key)) {
|
|
933
|
+
return null;
|
|
934
|
+
}
|
|
935
|
+
ret[key] = (data) => getSlot(slots, key, data);
|
|
936
|
+
});
|
|
937
|
+
return ret;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
// src/loadScript.js
|
|
941
|
+
function loadScript(src, { type = "text/javascript" } = {}) {
|
|
942
|
+
return new Promise((resolve, reject) => {
|
|
943
|
+
let shouldAppend = false;
|
|
944
|
+
let el = document.querySelector(`script[src="${src}"]`);
|
|
945
|
+
if (!el) {
|
|
946
|
+
el = document.createElement("script");
|
|
947
|
+
el.type = type;
|
|
948
|
+
el.async = true;
|
|
949
|
+
el.src = src;
|
|
950
|
+
shouldAppend = true;
|
|
951
|
+
} else if (el.hasAttribute("data-loaded")) {
|
|
952
|
+
resolve({ el });
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
el.addEventListener("error", reject);
|
|
956
|
+
el.addEventListener("abort", reject);
|
|
957
|
+
el.addEventListener("load", () => {
|
|
958
|
+
el.setAttribute("data-loaded", true);
|
|
959
|
+
resolve({ el });
|
|
960
|
+
});
|
|
961
|
+
if (shouldAppend) {
|
|
962
|
+
document.head.appendChild(el);
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
function unloadScript(src) {
|
|
967
|
+
return new Promise((resolve, reject) => {
|
|
968
|
+
const el = document.querySelector(`script[src="${src}"]`);
|
|
969
|
+
if (!el) {
|
|
970
|
+
reject();
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
document.head.removeChild(el);
|
|
974
|
+
resolve();
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
// src/matcher.js
|
|
979
|
+
function matcher(inputs, patterns, options) {
|
|
980
|
+
return baseMatcher(inputs, patterns, options, false);
|
|
981
|
+
}
|
|
982
|
+
function isMatch(inputs, patterns, options) {
|
|
983
|
+
return baseMatcher(inputs, patterns, options, true).length > 0;
|
|
984
|
+
}
|
|
985
|
+
function escapeStringRegexp(value) {
|
|
986
|
+
if (typeof value !== "string") {
|
|
987
|
+
return value;
|
|
988
|
+
}
|
|
989
|
+
return value.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
990
|
+
}
|
|
991
|
+
var regexpCache = /* @__PURE__ */ new Map();
|
|
992
|
+
function sanitizeArray(input, inputName) {
|
|
993
|
+
if (!Array.isArray(input)) {
|
|
994
|
+
switch (typeof input) {
|
|
995
|
+
case "string":
|
|
996
|
+
input = [input];
|
|
997
|
+
break;
|
|
998
|
+
case "undefined":
|
|
999
|
+
input = [];
|
|
1000
|
+
break;
|
|
1001
|
+
default:
|
|
1002
|
+
throw new TypeError(
|
|
1003
|
+
`Expected '${inputName}' to be a string or an array, but got a type of '${typeof input}'`
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
return input.filter((string) => {
|
|
1008
|
+
if (typeof string !== "string") {
|
|
1009
|
+
if (typeof string === "undefined") {
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
throw new TypeError(
|
|
1013
|
+
`Expected '${inputName}' to be an array of strings, but found a type of '${typeof string}' in the array`
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
return true;
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
function makeRegexp(pattern, options) {
|
|
1020
|
+
options = {
|
|
1021
|
+
caseSensitive: false,
|
|
1022
|
+
...options
|
|
1023
|
+
};
|
|
1024
|
+
const cacheKey = pattern + JSON.stringify(options);
|
|
1025
|
+
if (regexpCache.has(cacheKey)) {
|
|
1026
|
+
return regexpCache.get(cacheKey);
|
|
1027
|
+
}
|
|
1028
|
+
const negated = pattern[0] === "!";
|
|
1029
|
+
if (negated) {
|
|
1030
|
+
pattern = pattern.slice(1);
|
|
1031
|
+
}
|
|
1032
|
+
pattern = escapeStringRegexp(pattern).replace(/\\\*/g, "[\\s\\S]*");
|
|
1033
|
+
const regexp = new RegExp(`^${pattern}$`, options.caseSensitive ? "" : "i");
|
|
1034
|
+
regexp.negated = negated;
|
|
1035
|
+
regexpCache.set(cacheKey, regexp);
|
|
1036
|
+
return regexp;
|
|
1037
|
+
}
|
|
1038
|
+
function baseMatcher(inputs, patterns, options, firstMatchOnly) {
|
|
1039
|
+
inputs = sanitizeArray(inputs, "inputs");
|
|
1040
|
+
patterns = sanitizeArray(patterns, "patterns");
|
|
1041
|
+
if (patterns.length === 0) {
|
|
1042
|
+
return [];
|
|
1043
|
+
}
|
|
1044
|
+
patterns = patterns.map((pattern) => makeRegexp(pattern, options));
|
|
1045
|
+
const { allPatterns } = options || {};
|
|
1046
|
+
const result = [];
|
|
1047
|
+
for (const input of inputs) {
|
|
1048
|
+
let matches;
|
|
1049
|
+
const didFit = [...patterns].fill(false);
|
|
1050
|
+
for (const [index, pattern] of patterns.entries()) {
|
|
1051
|
+
if (pattern.test(input)) {
|
|
1052
|
+
didFit[index] = true;
|
|
1053
|
+
matches = !pattern.negated;
|
|
1054
|
+
if (!matches) {
|
|
1055
|
+
break;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
if (!(matches === false || matches === void 0 && patterns.some((pattern) => !pattern.negated) || allPatterns && didFit.some((yes, index) => !yes && !patterns[index].negated))) {
|
|
1060
|
+
result.push(input);
|
|
1061
|
+
if (firstMatchOnly) {
|
|
1062
|
+
break;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
return result;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
// src/treeHelper.js
|
|
1070
|
+
var DEFAULT_CONFIG = {
|
|
1071
|
+
id: "id",
|
|
1072
|
+
children: "children",
|
|
1073
|
+
pid: "pid"
|
|
1074
|
+
};
|
|
1075
|
+
var getConfig = (config) => Object.assign({}, DEFAULT_CONFIG, config);
|
|
1076
|
+
function findNode(tree, func, config = {}) {
|
|
1077
|
+
config = getConfig(config);
|
|
1078
|
+
const { children } = config;
|
|
1079
|
+
const list = [...tree];
|
|
1080
|
+
for (const node of list) {
|
|
1081
|
+
if (func(node)) {
|
|
1082
|
+
return node;
|
|
1083
|
+
}
|
|
1084
|
+
node[children] && list.push(...node[children]);
|
|
1085
|
+
}
|
|
1086
|
+
return null;
|
|
1087
|
+
}
|
|
1088
|
+
function findNodeAll(tree, func, config = {}) {
|
|
1089
|
+
config = getConfig(config);
|
|
1090
|
+
const { children } = config;
|
|
1091
|
+
const list = [...tree];
|
|
1092
|
+
const result = [];
|
|
1093
|
+
for (const node of list) {
|
|
1094
|
+
func(node) && result.push(node);
|
|
1095
|
+
node[children] && list.push(...node[children]);
|
|
1096
|
+
}
|
|
1097
|
+
return result;
|
|
1098
|
+
}
|
|
1099
|
+
function findPath(tree, func, config = {}) {
|
|
1100
|
+
config = getConfig(config);
|
|
1101
|
+
const path = [];
|
|
1102
|
+
const list = [...tree];
|
|
1103
|
+
const visitedSet = /* @__PURE__ */ new Set();
|
|
1104
|
+
const { children } = config;
|
|
1105
|
+
while (list.length) {
|
|
1106
|
+
const node = list[0];
|
|
1107
|
+
if (visitedSet.has(node)) {
|
|
1108
|
+
path.pop();
|
|
1109
|
+
list.shift();
|
|
1110
|
+
} else {
|
|
1111
|
+
visitedSet.add(node);
|
|
1112
|
+
node[children] && list.unshift(...node[children]);
|
|
1113
|
+
path.push(node);
|
|
1114
|
+
if (func(node)) {
|
|
1115
|
+
return path;
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
return null;
|
|
1120
|
+
}
|
|
1121
|
+
function findPathAll(tree, func, config = {}) {
|
|
1122
|
+
config = getConfig(config);
|
|
1123
|
+
const path = [];
|
|
1124
|
+
const list = [...tree];
|
|
1125
|
+
const result = [];
|
|
1126
|
+
const visitedSet = /* @__PURE__ */ new Set();
|
|
1127
|
+
const { children } = config;
|
|
1128
|
+
while (list.length) {
|
|
1129
|
+
const node = list[0];
|
|
1130
|
+
if (visitedSet.has(node)) {
|
|
1131
|
+
path.pop();
|
|
1132
|
+
list.shift();
|
|
1133
|
+
} else {
|
|
1134
|
+
visitedSet.add(node);
|
|
1135
|
+
node[children] && list.unshift(...node[children]);
|
|
1136
|
+
path.push(node);
|
|
1137
|
+
func(node) && result.push([...path]);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
return result;
|
|
1141
|
+
}
|
|
1142
|
+
function filter(tree, func, config = {}) {
|
|
1143
|
+
config = getConfig(config);
|
|
1144
|
+
const children = config.children;
|
|
1145
|
+
function listFilter(list) {
|
|
1146
|
+
return list.map((node) => ({ ...node })).filter((node) => {
|
|
1147
|
+
node[children] = node[children] && listFilter(node[children]);
|
|
1148
|
+
return func(node) || node[children] && node[children].length;
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
return listFilter(tree);
|
|
1152
|
+
}
|
|
1153
|
+
function forEach(tree, func, config = {}) {
|
|
1154
|
+
config = getConfig(config);
|
|
1155
|
+
const list = [...tree];
|
|
1156
|
+
const { children } = config;
|
|
1157
|
+
for (let i = 0; i < list.length; i++) {
|
|
1158
|
+
if (func(list[i])) {
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
children && list[i][children] && list.splice(i + 1, 0, ...list[i][children]);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
function treeMap(treeData, opt) {
|
|
1165
|
+
return treeData.map((item) => treeMapEach(item, opt));
|
|
1166
|
+
}
|
|
1167
|
+
function treeMapEach(data, { children = "children", conversion }) {
|
|
1168
|
+
const haveChildren = Array.isArray(data[children]) && data[children].length > 0;
|
|
1169
|
+
const conversionData = conversion(data) || {};
|
|
1170
|
+
if (haveChildren) {
|
|
1171
|
+
return {
|
|
1172
|
+
...conversionData,
|
|
1173
|
+
[children]: data[children].map(
|
|
1174
|
+
(i) => treeMapEach(i, {
|
|
1175
|
+
children,
|
|
1176
|
+
conversion
|
|
1177
|
+
})
|
|
1178
|
+
)
|
|
1179
|
+
};
|
|
1180
|
+
} else {
|
|
1181
|
+
return {
|
|
1182
|
+
...conversionData
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
// src/uuid.js
|
|
1188
|
+
import { v4 as uuidV4 } from "uuid";
|
|
1189
|
+
function buildUUID({ native = true } = {}) {
|
|
1190
|
+
var _a, _b;
|
|
1191
|
+
if (!native) {
|
|
1192
|
+
return uuidV4();
|
|
1193
|
+
}
|
|
1194
|
+
return ((_b = (_a = window.crypto) == null ? void 0 : _a.randomUUID) == null ? void 0 : _b.call(_a)) ?? uuidV4();
|
|
1195
|
+
}
|
|
1196
|
+
var unique = 0;
|
|
1197
|
+
function buildShortUUID(prefix = "") {
|
|
1198
|
+
const time = Date.now();
|
|
1199
|
+
const random = Math.floor(Math.random() * 1e9);
|
|
1200
|
+
unique++;
|
|
1201
|
+
return `${prefix}_${random}${unique}${String(time)}`;
|
|
1202
|
+
}
|
|
1203
|
+
export {
|
|
1204
|
+
AesEncryption,
|
|
1205
|
+
IfActivity,
|
|
1206
|
+
addClass,
|
|
1207
|
+
addLocationListener,
|
|
1208
|
+
addResizeListener,
|
|
1209
|
+
buildBEM,
|
|
1210
|
+
buildShortUUID,
|
|
1211
|
+
buildUUID,
|
|
1212
|
+
createBEM,
|
|
1213
|
+
createNamespace,
|
|
1214
|
+
createSearchReg,
|
|
1215
|
+
dataURLtoBlob,
|
|
1216
|
+
decodeByBase64,
|
|
1217
|
+
deepMerge,
|
|
1218
|
+
off as domOffEvent,
|
|
1219
|
+
on as domOnEvent,
|
|
1220
|
+
downloadByBase64,
|
|
1221
|
+
downloadByData,
|
|
1222
|
+
downloadByOnlineUrl,
|
|
1223
|
+
downloadByUrl,
|
|
1224
|
+
downloadPercent,
|
|
1225
|
+
enableTransitions,
|
|
1226
|
+
encryptByBase64,
|
|
1227
|
+
encryptByMd5,
|
|
1228
|
+
escapeStringRegexp,
|
|
1229
|
+
extendSlots,
|
|
1230
|
+
filter as filterTree,
|
|
1231
|
+
findNode,
|
|
1232
|
+
findNodeAll,
|
|
1233
|
+
findPath,
|
|
1234
|
+
findPathAll,
|
|
1235
|
+
forEach as forEachTree,
|
|
1236
|
+
getActualWidthOfChars,
|
|
1237
|
+
getBoundingClientRect,
|
|
1238
|
+
getPopupContainer,
|
|
1239
|
+
getRawRoute,
|
|
1240
|
+
getSlot,
|
|
1241
|
+
getViewportOffset,
|
|
1242
|
+
hackCss,
|
|
1243
|
+
hasClass,
|
|
1244
|
+
highlightHtml,
|
|
1245
|
+
is,
|
|
1246
|
+
isBrowser,
|
|
1247
|
+
isChineseText,
|
|
1248
|
+
isChrome,
|
|
1249
|
+
isClient,
|
|
1250
|
+
isIterableArray,
|
|
1251
|
+
isMatch,
|
|
1252
|
+
isObject,
|
|
1253
|
+
isPositiveInteger,
|
|
1254
|
+
isSafari,
|
|
1255
|
+
isServer,
|
|
1256
|
+
isSupportNativeEllipsis,
|
|
1257
|
+
isSupportResizeObserver,
|
|
1258
|
+
isUrl,
|
|
1259
|
+
loadScript,
|
|
1260
|
+
matcher,
|
|
1261
|
+
openWindow,
|
|
1262
|
+
regexpMap,
|
|
1263
|
+
removeClass,
|
|
1264
|
+
removeResizeListener,
|
|
1265
|
+
setCssVar,
|
|
1266
|
+
setObjToUrlParams,
|
|
1267
|
+
treeMap,
|
|
1268
|
+
treeMapEach,
|
|
1269
|
+
triggerWindowResize,
|
|
1270
|
+
unloadScript,
|
|
1271
|
+
unsetAllProperty,
|
|
1272
|
+
urlToBase64,
|
|
1273
|
+
useRafThrottle,
|
|
1274
|
+
withInstall
|
|
1275
|
+
};
|