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