@bestime/utils_browser 1.0.5 → 1.0.7

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.
@@ -97,6 +97,7 @@ interface LibraryFileConfig {
97
97
  dependencies?: LibraryFileConfig[];
98
98
  with?: LibraryFileConfig[];
99
99
  attribute?: Record<string, string>;
100
+ interceptor?: (libInstence: any) => void;
100
101
  }
101
102
  type SuccessCallback = (...args: any[]) => void;
102
103
  /**
@@ -173,18 +174,172 @@ declare const _default: {
173
174
  isIPhone: boolean;
174
175
  };
175
176
 
177
+ /**
178
+ * 获取浏览器缩放比
179
+ */
180
+ declare function getRatio(): number;
181
+
182
+ type Direction = 1 | -1;
183
+ /**
184
+ *
185
+ * @param el DOM元素
186
+ * @param callback 滚动回调
187
+ * @param isPrevent 是否阻止原生滚动,仅用来获取滚动方向
188
+ * @returns
189
+ */
190
+ declare function export_default$1(
191
+ el: HTMLElement,
192
+ callback: (direction: Direction) => void,
193
+ isPrevent: boolean
194
+ ): {
195
+ dispose: () => void;
196
+ };
197
+
198
+ type TCallbackHandler = (next: () => void) => void;
199
+ interface IOptions$1 {
200
+ onBottom?: TCallbackHandler;
201
+ onTop?: TCallbackHandler;
202
+ /** Y轴触底、触顶的差值 */
203
+ offetY?: number;
204
+ }
205
+ /**
206
+ * 监听dom滚动到顶部或头部
207
+ * @param el
208
+ * @param config
209
+ */
210
+ declare function export_default(
211
+ el: HTMLElement,
212
+ config?: IOptions$1
213
+ ): {
214
+ /**
215
+ * 销毁
216
+ */
217
+ dispose: () => void;
218
+ };
219
+
220
+ type TElementFullCallback = () => void;
221
+ type TFullScreenActionCallback = (isSuccess: boolean) => void;
222
+ type TElement = HTMLElement & {
223
+ webkitRequestFullScreen?: TElementFullCallback;
224
+ mozRequestFullScreen?: TElementFullCallback;
225
+ msRequestFullscreen?: TElementFullCallback;
226
+ };
227
+ declare function fullScreen(
228
+ element: TElement,
229
+ value: boolean,
230
+ callabck?: TFullScreenActionCallback
231
+ ): void;
232
+
233
+ declare function createXLSX(options: {
234
+ pluginUrl: string;
235
+ header: any[];
236
+ body: any[];
237
+ }): Promise<HTMLTableElement>;
238
+
239
+ interface IPluginSrc {
240
+ index: string;
241
+ worker: string;
242
+ }
243
+ declare function pdfToImage(
244
+ url: string,
245
+ canvas: HTMLCanvasElement,
246
+ src?: IPluginSrc
247
+ ): Promise<unknown>;
248
+
249
+ /**
250
+ * 动态计算弹出框位置,使之保持在可是范围内。多用于跟随鼠标移动的菜单或信息框
251
+ * @param options - 配置项
252
+ * @returns - 计算后的位置
253
+ */
254
+ declare function infoContainerPosition(options: {
255
+ /** 需要将容器设置到:坐标X */
256
+ x: number;
257
+ /** 需要将容器设置到:坐标Y */
258
+ y: number;
259
+ /** 容器宽度 */
260
+ width: number;
261
+ /** 容器高度 */
262
+ height: number;
263
+ /** 与目标位置X偏移量。默认 10 */
264
+ offsetX?: number;
265
+ /** 与目标位置Y偏移量。默认 10 */
266
+ offsetY?: number;
267
+ /** 距离视口多少时表示超出可视范围。默认 10*/
268
+ padding?: number;
269
+ mode?: 'top-right';
270
+ }): {
271
+ x: number;
272
+ y: number;
273
+ };
274
+
275
+ interface IOptions {
276
+ text?: string;
277
+ fontSize?: number;
278
+ color?: string;
279
+ reverse?: boolean;
280
+ interval?: number;
281
+ }
282
+ interface IPointItem {
283
+ text: string;
284
+ x: number;
285
+ y: number;
286
+ speed: number;
287
+ }
288
+ declare class TextRainCanvas {
289
+ text: string;
290
+ fontSize: number;
291
+ color: number[];
292
+ reverse: boolean;
293
+ isStop: boolean;
294
+ interval: number;
295
+ width: number;
296
+ height: number;
297
+ textLineHeight: number;
298
+ count: number;
299
+ oCanvas: HTMLCanvasElement;
300
+ ctx: CanvasRenderingContext2D;
301
+ timer: any;
302
+ pointList: {
303
+ currentIndex: number;
304
+ list: IPointItem[];
305
+ }[];
306
+ constructor(oCanvas: HTMLCanvasElement, option?: IOptions);
307
+ draw(): void;
308
+ createColumn(
309
+ x: number,
310
+ y: number
311
+ ): {
312
+ currentIndex: number;
313
+ list: IPointItem[];
314
+ };
315
+ dispose(): void;
316
+ start(): void;
317
+ getPointList(): {
318
+ currentIndex: number;
319
+ list: IPointItem[];
320
+ }[];
321
+ }
322
+
176
323
  export {
324
+ TextRainCanvas,
177
325
  addClass,
178
326
  _default as browser,
327
+ createXLSX,
179
328
  downloadFileByArrayBuffer,
180
329
  downloadFileByUrl,
330
+ fullScreen,
181
331
  getCookie,
182
332
  getJsFileBaseUrl,
333
+ getRatio,
183
334
  getRelativePos,
184
335
  getStorage,
185
336
  getWindowSize,
337
+ infoContainerPosition,
186
338
  libraryFile,
187
339
  observeDomResize,
340
+ export_default as observeDomScroll,
341
+ export_default$1 as observeMouseWheel,
342
+ pdfToImage,
188
343
  prevent,
189
344
  removeClass,
190
345
  removeCookie,
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 浏览器工具库 => jUtilsBrowser
3
+ * @update 2024-08-27 10:02:10
4
+ */
5
+ import{defualtFormatter,isString,variableHasValue,isArray,forEach,_KvPair,_Number,parseTreeToTableHeader,isNull,getRandom}from"@bestime/utils_base";function getWindowSize(){return{width:document.documentElement.clientWidth||document.body.clientWidth||window.innerWidth||0,height:document.documentElement.clientHeight||document.body.clientHeight||window.innerHeight||0}}let htivId=0,idName="",isStart=!1;const records={};let timer;function stop(){isStart=!1,clearInterval(timer),timer=undefined}function startRun(){clearInterval(timer),isStart=!0,timer=setInterval(function(){for(var e in records){const t=records[e];t.current=+new Date,t.current-t.start>=t.interval&&(t.start=t.current,records[e].handler())}},17)}function add(e,t){return idName="HI-"+ ++htivId,records[idName]={start:+new Date,current:0,handler:e,interval:t},isStart||startRun(),idName}function remove(e){delete records[e],0===Object.keys(records).length&&stop()}var hpInterval={add:add,remove:remove};function observeDomResize(n,o,i,e){let r=[0,0,!1],l=[0,0,!1],s=[0,0,!1],a=[0,0,!1];const t=hpInterval.add(c,e=e||500);function c(){if(document.body.contains(n)){let e=!1;var t;i?.includes("position")&&(t=n.getBoundingClientRect(),s[0]=t.left,s[2]=s[0]!==s[1],a[0]=t.top,a[2]=a[0]!==a[1]),r[0]=n.offsetWidth,r[2]=r[0]!==r[1],l[0]=n.offsetHeight,l[2]=l[0]!==l[1],r[2]&&(r[1]=r[0],i?.includes("width")&&(e=!0)),l[2]&&(l[1]=l[0],i?.includes("height")&&(e=!0)),(a[2]||s[2])&&(a[1]=a[0],s[1]=s[0],i?.includes("position")&&(e=!0)),i&&0!==i.length||(r[2]||l[2]||a[2]||s[2])&&(e=!0),e&&o(n)}else u()}function u(){hpInterval.remove(t),r=undefined,l=undefined}return c(),u}function downloadFileByUrl(e,t){const n=document.createElement("a");n.style.display="none",n.download=t,n.setAttribute("href",e),n.setAttribute("target","_blank"),n.setAttribute("download",t),document.body.appendChild(n),n.click(),n.remove()}const $undefinedValue=void 0,$decodeURIComponent=decodeURIComponent,$browserGlobal=window,$headElement=document.getElementsByTagName("head")[0];function downloadFileByArrayBuffer(e,t){const n=$browserGlobal.URL;e=n.createObjectURL(new Blob([e]));downloadFileByUrl(e,t),n.revokeObjectURL(e),undefined}function removeElement(e){e.parentNode&&e.parentNode.removeChild(e)}function prevent(e,t,n){e=e||$browserGlobal.event,n=!1!==n,(t=!1!==t)&&$browserGlobal.event?$browserGlobal.event.cancelBubble=!0:e.stopPropagation(),n&&$browserGlobal.event?$browserGlobal.event.returnValue=!1:e.preventDefault()}function getStorage(e){e=localStorage.getItem(e);return defualtFormatter("",e)}function removeStorage(e){localStorage.removeItem(e)}function hpSetStringValue(e){return e=isString(e)?e:JSON.stringify(e)}function setStorage(e,t){localStorage.setItem(e,hpSetStringValue(t))}function getRelativePos(e){var t=e.getBoundingClientRect();return{x:t.left,y:t.top,height:e.offsetHeight,width:e.offsetWidth,clientWidth:e.clientWidth,clientHeight:e.clientHeight}}function getJsFileBaseUrl(e){e=e||0;for(var t="/[^/]*",n=document.scripts,o=0;o<e;o++)t+=t;return n[n.length-1].src.replace(new RegExp(t+"$"),"")}function hpCreateFileLoaderElement(t,n,o,i){if($headElement){let e;if("js"===t?(e=document.createElement("script")).src=n:((e=document.createElement("link")).setAttribute("rel","stylesheet"),e.href=n),i)for(var r in i)e.setAttribute(r,i[r]);e.onload=e.onerror=o,$headElement.appendChild(e)}}const cache={};function loadMultiple(n,o){const i=[];let r=0;for(let t=0;t<n.length;t++)loadSingle(n[t],function(e){i[t]=e,++r===n.length&&o.apply($undefinedValue,i)})}function loadSingle(e,t){var n=e.dependencies&&e.dependencies.length,o=e["with"]&&e["with"].length;cache[e.url]||(cache[e.url]={count:0,dependencies:!n,"with":!o,complete:!1,create:!1,url:e.url});const i=cache[e.url];function r(){return $browserGlobal[e.module]}function l(){i.complete&&i.dependencies&&i["with"]&&(e.module?t(r()):t())}i.count++,!i.dependencies&&n?(i.dependencies=!0,loadMultiple(e.dependencies,function(){loadSingle(e,t)})):!i["with"]&&o?(i["with"]=!0,loadMultiple(e["with"].concat(e),l)):i.create?variableHasValue(function(){return i.complete},l,300):(i.create=!0,hpCreateFileLoaderElement(e.type,e.url,function(){i.complete=!0,e.interceptor&&e.interceptor(r()),l()},e.attribute))}function libraryFile(e,t){(e instanceof Array?loadMultiple:loadSingle)(e,t)}function setObjectToString(e){return e=isString(e)?e:JSON.stringify(e)}function setCookie(e,t,n){t=setObjectToString(t);let o=e+"="+encodeURI(t)+";path=/;";"number"==typeof n&&((e=new Date).setTime(e.getTime()+n),o+="expires="+e.toUTCString()),document.cookie=o}function getCookie(e,t){t=t||document.cookie;let o="";return t.replace(new RegExp("(^|;\\s?)"+e+"=(.*?)($|(;\\s?))"),function(e,t,n){o=$decodeURIComponent(n)}),o}function removeCookie(e){setCookie(e,"",-1)}function removeClass(t,e){isArray(e)?forEach(e,function(e){t.classList.remove(e)}):t.classList.remove(e)}function addClass(t,e){isArray(e)?forEach(e,function(e){t.classList.add(e)}):t.classList.add(e)}function replaceClass(e,t,n){removeClass(e,t),addClass(e,n)}function toggleClass(t,e){isArray(e)?forEach(e,function(e){t.classList.toggle(e)}):t.classList.toggle(e)}const agent=$browserGlobal.navigator.userAgent;var browser={isChrome:/Chrome/.test(agent),isIPhone:/iPhone/.test(agent)};function getRatio(){return window.devicePixelRatio||1}function observeMouseWheel(e,n,o){function t(e){let t;if(t=e.wheelDelta?0<e.wheelDelta?1:-1:e.detail<0?1:-1,n(t),o)return e.preventDefault&&e.preventDefault(),!1}return e.addEventListener("mousewheel",t),e.addEventListener("DOMMouseScroll",t),{dispose:function(){e.removeEventListener("mousewheel",t),e.removeEventListener("DOMMouseScroll",t)}}}function observeDomScroll(n,e){const o=_KvPair(e),i=_Number(o.offetY);let r=!1,l=0;function t(){var e,t;r||(t=(e=n.scrollTop)-l,l=e,0!=t?t<0&&o.onTop&&e<=0+i?(r=!0,o.onTop(function(){r=!1})):0<t&&o.onBottom&&e>=n.scrollHeight-n.offsetHeight-i?(r=!0,o.onBottom(function(){r=!1})):r=!1:(r=!1,console.log("未处理")))}return n.addEventListener("scroll",t),{dispose:function(){n.removeEventListener("scroll",t)}}}const defaultCallback=e=>{};function open(e,t){const n=t||defaultCallback;e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullScreen?e.webkitRequestFullScreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen(),n(!0)}function close(e){const t=e||defaultCallback,n=document;document.exitFullscreen?document.exitFullscreen().then(function(){t(!0)})["catch"](function(){t(!1)}):n.webkitCancelFullScreen?(n.webkitCancelFullScreen(),t(!0)):n.mozCancelFullScreen?(n.mozCancelFullScreen(),t(!0)):n.msExitFullscreen&&(n.msExitFullscreen(),t(!0))}function fullScreen(e,t,n){t?open(e,n):close(n)}async function createXLSX(e){const t=document.createElement("table"),n=parseTreeToTableHeader(e.header);var o=n.data.map(function(e){return`<tr>${e.map(function(e){if(e&&0!==e.colSpan)return`<td align="center" rowSpan="${e.rowSpan}" colSpan="${e.colSpan}">${e?.title}</td>`}).join("")}</tr>`}).join(""),e=e.body.map(function(o){return`<tr>${n.columns.map(function(e){var t=o.$colField?.[e]??1,n=o.$rowSpan?.[e]??1;if(0!==t&&0!==n)return`<td align="center" colSpan="${t}" rowSpan="${n}">${o[e]??""}</td>`}).filter(function(e){return!isNull(e)}).join("")}</tr>`}).join("");return t.innerHTML=`<thead>${o}</thead><tbody>${e}</tbody>`,t.setAttribute("border","1"),t}async function loadPdfPlugin(e){const t=e||{index:"//mozilla.github.io/pdf.js/build/pdf.mjs",worker:"//mozilla.github.io/pdf.js/build/pdf.worker.mjs"};return new Promise(function(e){libraryFile({type:"js",module:"pdfjsLib",attribute:{type:"module"},url:t.index,interceptor:function(e){e.GlobalWorkerOptions.workerSrc=t.worker}},e)})}async function pdfToImage(e,i,t){const n=await loadPdfPlugin(t);return new Promise(function(o){n.getDocument(e).promise.then(function(e){e.getPage(1).then(function(e){var t=e.getViewport({scale:1}),n=i.getContext("2d");i.height=t.height,i.width=t.width,e.render({canvasContext:n,viewport:t}).promise.then(function(){o({width:t.width,height:t.height})})})},function(e){console.error(e),o({width:0,height:0})})})}function infoContainerPosition(e){var t=e.mode||"top-right",n=e.width,o=e.height,i=defualtFormatter(10,e.offsetY),r=defualtFormatter(10,e.offsetX),l=defualtFormatter(10,e.padding);let s=e.x,a=e.y;var e=getWindowSize(),c=[l,e.width-n-l],e=[l,e.height-o-l];return"top-right"===t?(s+=r,a=a-o-i,s<c[0]?s=c[0]:s>c[1]&&(l=s-n-2*r,s=c[0]<l?l:c[1]),a<e[0]?(l=a+o+2*i,a=l<e[1]?l:e[0]):a>e[1]&&(a=a-o-2*i)):"bottom-right"===t?(s+=r,a+=i):"top-left"===t&&(s=s-n-r,a=a-o-i),{x:s,y:a}}function hexToRgb(e){for(var t=[],n=1;n<7;n+=2)t.push(parseInt("0x"+e.slice(n,n+2)));return t}class TextRainCanvas{text="abcdefghijklmnopqrstuvwxyz";fontSize=14;color=[0,255,0];reverse=!1;isStop=!1;interval=100;width;height;textLineHeight;count;oCanvas;ctx;timer;pointList=[];constructor(e,t){this.draw=this.draw.bind(this);var n=e.offsetWidth,o=e.offsetHeight;e.width=n,e.height=o,this.width=n,this.height=o,t&&(this.text=t.text||this.text,this.fontSize=t.fontSize||this.fontSize,this.color=t.color?hexToRgb(t.color):this.color,this.reverse=(null!=t.reverse?t:this).reverse,this.interval=t.interval||this.interval),this.oCanvas=e,this.ctx=e.getContext("2d"),this.textLineHeight=1.2*this.fontSize,this.count=Math.ceil(this.height/this.textLineHeight),this.getPointList(),this.draw()}draw(){if(this.isStop)return clearTimeout(this.timer);this.ctx.font=this.fontSize+'px "Microsoft YaHei"',this.ctx.textBaseline="top",this.ctx.clearRect(0,0,this.width,this.height),this.pointList.forEach(o=>{o.list.forEach((e,t)=>{let n;this.reverse?(n=(t-o.currentIndex)/10,n=1-e.speed*n,t<o.currentIndex&&(n=0)):(n=(o.currentIndex-t)/10,n=1-e.speed*n,t>o.currentIndex&&(n=0)),0<n&&(this.ctx.fillStyle=`rgba(${this.color.join(",")}, ${n})`,this.ctx.fillText(e.text,e.x,e.y))}),this.reverse?(o.currentIndex--,o.currentIndex+10<0&&(o.currentIndex=this.count+getRandom(0,this.count))):(o.currentIndex++,o.currentIndex-10>o.list.length-1&&(o.currentIndex=-getRandom(0,this.count)))}),clearTimeout(this.timer),this.timer=setTimeout(this.draw,this.interval)}createColumn(t,e){const n=[];for(let e=0;e<this.count;e++){var o=getRandom(0,this.text.length-1);n.push({text:this.text[o],x:t,y:Math.floor(e*this.textLineHeight),speed:1})}return{currentIndex:e,list:n}}dispose(){this.isStop=!0,clearTimeout(this.timer)}start(){this.isStop=!1,this.draw()}getPointList(){const o=[];var i=this.fontSize,e=Math.floor(this.width/i);for(let n=0;n<e;n++){let t=0;for(let e=0;e<this.count&&(e?t+=getRandom(t+10,this.count):t+=getRandom(t,10),!(t>this.count));e++)this.reverse?o.push(this.createColumn(n*i,this.count+t)):o.push(this.createColumn(n*i,-t))}return this.pointList=o}}export{TextRainCanvas,addClass,browser,createXLSX,downloadFileByArrayBuffer,downloadFileByUrl,fullScreen,getCookie,getJsFileBaseUrl,getRatio,getRelativePos,getStorage,getWindowSize,infoContainerPosition,libraryFile,observeDomResize,observeDomScroll,observeMouseWheel,pdfToImage,prevent,removeClass,removeCookie,removeElement,removeStorage,replaceClass,setCookie,setStorage,toggleClass};
@@ -97,6 +97,7 @@ interface LibraryFileConfig {
97
97
  dependencies?: LibraryFileConfig[];
98
98
  with?: LibraryFileConfig[];
99
99
  attribute?: Record<string, string>;
100
+ interceptor?: (libInstence: any) => void;
100
101
  }
101
102
  type SuccessCallback = (...args: any[]) => void;
102
103
  /**
@@ -173,23 +174,177 @@ declare const _default: {
173
174
  isIPhone: boolean;
174
175
  };
175
176
 
177
+ /**
178
+ * 获取浏览器缩放比
179
+ */
180
+ declare function getRatio(): number;
181
+
182
+ type Direction = 1 | -1;
183
+ /**
184
+ *
185
+ * @param el DOM元素
186
+ * @param callback 滚动回调
187
+ * @param isPrevent 是否阻止原生滚动,仅用来获取滚动方向
188
+ * @returns
189
+ */
190
+ declare function export_default$1(
191
+ el: HTMLElement,
192
+ callback: (direction: Direction) => void,
193
+ isPrevent: boolean
194
+ ): {
195
+ dispose: () => void;
196
+ };
197
+
198
+ type TCallbackHandler = (next: () => void) => void;
199
+ interface IOptions$1 {
200
+ onBottom?: TCallbackHandler;
201
+ onTop?: TCallbackHandler;
202
+ /** Y轴触底、触顶的差值 */
203
+ offetY?: number;
204
+ }
205
+ /**
206
+ * 监听dom滚动到顶部或头部
207
+ * @param el
208
+ * @param config
209
+ */
210
+ declare function export_default(
211
+ el: HTMLElement,
212
+ config?: IOptions$1
213
+ ): {
214
+ /**
215
+ * 销毁
216
+ */
217
+ dispose: () => void;
218
+ };
219
+
220
+ type TElementFullCallback = () => void;
221
+ type TFullScreenActionCallback = (isSuccess: boolean) => void;
222
+ type TElement = HTMLElement & {
223
+ webkitRequestFullScreen?: TElementFullCallback;
224
+ mozRequestFullScreen?: TElementFullCallback;
225
+ msRequestFullscreen?: TElementFullCallback;
226
+ };
227
+ declare function fullScreen(
228
+ element: TElement,
229
+ value: boolean,
230
+ callabck?: TFullScreenActionCallback
231
+ ): void;
232
+
233
+ declare function createXLSX(options: {
234
+ pluginUrl: string;
235
+ header: any[];
236
+ body: any[];
237
+ }): Promise<HTMLTableElement>;
238
+
239
+ interface IPluginSrc {
240
+ index: string;
241
+ worker: string;
242
+ }
243
+ declare function pdfToImage(
244
+ url: string,
245
+ canvas: HTMLCanvasElement,
246
+ src?: IPluginSrc
247
+ ): Promise<unknown>;
248
+
249
+ /**
250
+ * 动态计算弹出框位置,使之保持在可是范围内。多用于跟随鼠标移动的菜单或信息框
251
+ * @param options - 配置项
252
+ * @returns - 计算后的位置
253
+ */
254
+ declare function infoContainerPosition(options: {
255
+ /** 需要将容器设置到:坐标X */
256
+ x: number;
257
+ /** 需要将容器设置到:坐标Y */
258
+ y: number;
259
+ /** 容器宽度 */
260
+ width: number;
261
+ /** 容器高度 */
262
+ height: number;
263
+ /** 与目标位置X偏移量。默认 10 */
264
+ offsetX?: number;
265
+ /** 与目标位置Y偏移量。默认 10 */
266
+ offsetY?: number;
267
+ /** 距离视口多少时表示超出可视范围。默认 10*/
268
+ padding?: number;
269
+ mode?: 'top-right';
270
+ }): {
271
+ x: number;
272
+ y: number;
273
+ };
274
+
275
+ interface IOptions {
276
+ text?: string;
277
+ fontSize?: number;
278
+ color?: string;
279
+ reverse?: boolean;
280
+ interval?: number;
281
+ }
282
+ interface IPointItem {
283
+ text: string;
284
+ x: number;
285
+ y: number;
286
+ speed: number;
287
+ }
288
+ declare class TextRainCanvas {
289
+ text: string;
290
+ fontSize: number;
291
+ color: number[];
292
+ reverse: boolean;
293
+ isStop: boolean;
294
+ interval: number;
295
+ width: number;
296
+ height: number;
297
+ textLineHeight: number;
298
+ count: number;
299
+ oCanvas: HTMLCanvasElement;
300
+ ctx: CanvasRenderingContext2D;
301
+ timer: any;
302
+ pointList: {
303
+ currentIndex: number;
304
+ list: IPointItem[];
305
+ }[];
306
+ constructor(oCanvas: HTMLCanvasElement, option?: IOptions);
307
+ draw(): void;
308
+ createColumn(
309
+ x: number,
310
+ y: number
311
+ ): {
312
+ currentIndex: number;
313
+ list: IPointItem[];
314
+ };
315
+ dispose(): void;
316
+ start(): void;
317
+ getPointList(): {
318
+ currentIndex: number;
319
+ list: IPointItem[];
320
+ }[];
321
+ }
322
+
176
323
  declare global {
177
324
  /**
178
325
  * 该声明文件用于全局声明(不用npm安装时拷贝到项目中直接使用)
179
326
  */
180
327
  namespace jUtilsBrowser {
181
328
  export {
329
+ TextRainCanvas,
182
330
  addClass,
183
331
  _default as browser,
332
+ createXLSX,
184
333
  downloadFileByArrayBuffer,
185
334
  downloadFileByUrl,
335
+ fullScreen,
186
336
  getCookie,
187
337
  getJsFileBaseUrl,
338
+ getRatio,
188
339
  getRelativePos,
189
340
  getStorage,
190
341
  getWindowSize,
342
+ infoContainerPosition,
191
343
  libraryFile,
192
344
  observeDomResize,
345
+ export_default as observeDomScroll,
346
+ export_default$1 as observeMouseWheel,
347
+ pdfToImage,
193
348
  prevent,
194
349
  removeClass,
195
350
  removeCookie,
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 浏览器工具库 => jUtilsBrowser
3
+ * @update 2024-08-27 10:02:10
4
+ */
5
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@bestime/utils_base")):"function"==typeof define&&define.amd?define(["exports","@bestime/utils_base"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jUtilsBrowser={},e.jUtilsBase)}(this,function(e,a){"use strict";function d(){return{width:document.documentElement.clientWidth||document.body.clientWidth||window.innerWidth||0,height:document.documentElement.clientHeight||document.body.clientHeight||window.innerHeight||0}}let n=0,i,o=!1;const r={};let s;var h={add:function(e,t){return i="HI-"+ ++n,r[i]={start:+new Date,current:0,handler:e,interval:t},o||(clearInterval(s),o=!0,s=setInterval(function(){for(var e in r){const t=r[e];t.current=+new Date,t.current-t.start>=t.interval&&(t.start=t.current,r[e].handler())}},17)),i},remove:function(e){delete r[e],0===Object.keys(r).length&&(o=!1,clearInterval(s),s=undefined)}};function c(e,t){const n=document.createElement("a");n.style.display="none",n.download=t,n.setAttribute("href",e),n.setAttribute("target","_blank"),n.setAttribute("download",t),document.body.appendChild(n),n.click(),n.remove()}const l=void 0,u=decodeURIComponent,f=window,m=document.getElementsByTagName("head")[0];const p={};function g(n,i){const o=[];let r=0;for(let t=0;t<n.length;t++)v(n[t],function(e){o[t]=e,++r===n.length&&i.apply(l,o)})}function v(e,t){var n=e.dependencies&&e.dependencies.length,i=e["with"]&&e["with"].length;p[e.url]||(p[e.url]={count:0,dependencies:!n,"with":!i,complete:!1,create:!1,url:e.url});const o=p[e.url];function r(){return f[e.module]}function s(){o.complete&&o.dependencies&&o["with"]&&(e.module?t(r()):t())}if(o.count++,!o.dependencies&&n)o.dependencies=!0,g(e.dependencies,function(){v(e,t)});else if(!o["with"]&&i)o["with"]=!0,g(e["with"].concat(e),s);else if(o.create)a.variableHasValue(function(){return o.complete},s,300);else{o.create=!0;var n=e.type,i=e.url,c=function(){o.complete=!0,e.interceptor&&e.interceptor(r()),s()},l=e.attribute;if(m){let e;if("js"===n?(e=document.createElement("script")).src=i:((e=document.createElement("link")).setAttribute("rel","stylesheet"),e.href=i),l)for(var u in l)e.setAttribute(u,l[u]);e.onload=e.onerror=c,m.appendChild(e)}}}function w(e,t){(e instanceof Array?g:v)(e,t)}function t(e,t,n){var i;i=t,t=i=a.isString(i)?i:JSON.stringify(i);let o=e+"="+encodeURI(t)+";path=/;";"number"==typeof n&&((i=new Date).setTime(i.getTime()+n),o+="expires="+i.toUTCString()),document.cookie=o}function x(t,e){a.isArray(e)?a.forEach(e,function(e){t.classList.remove(e)}):t.classList.remove(e)}function b(t,e){a.isArray(e)?a.forEach(e,function(e){t.classList.add(e)}):t.classList.add(e)}var S=f.navigator.userAgent,S={isChrome:/Chrome/.test(S),isIPhone:/iPhone/.test(S)};const y=e=>{};class C{text="abcdefghijklmnopqrstuvwxyz";fontSize=14;color=[0,255,0];reverse=!1;isStop=!1;interval=100;width;height;textLineHeight;count;oCanvas;ctx;timer;pointList=[];constructor(e,t){this.draw=this.draw.bind(this);var n=e.offsetWidth,i=e.offsetHeight;e.width=n,e.height=i,this.width=n,this.height=i,t&&(this.text=t.text||this.text,this.fontSize=t.fontSize||this.fontSize,this.color=t.color?function(e){for(var t=[],n=1;n<7;n+=2)t.push(parseInt("0x"+e.slice(n,n+2)));return t}(t.color):this.color,this.reverse=(null!=t.reverse?t:this).reverse,this.interval=t.interval||this.interval),this.oCanvas=e,this.ctx=e.getContext("2d"),this.textLineHeight=1.2*this.fontSize,this.count=Math.ceil(this.height/this.textLineHeight),this.getPointList(),this.draw()}draw(){if(this.isStop)return clearTimeout(this.timer);this.ctx.font=this.fontSize+'px "Microsoft YaHei"',this.ctx.textBaseline="top",this.ctx.clearRect(0,0,this.width,this.height),this.pointList.forEach(i=>{i.list.forEach((e,t)=>{let n;this.reverse?(n=(t-i.currentIndex)/10,n=1-e.speed*n,t<i.currentIndex&&(n=0)):(n=(i.currentIndex-t)/10,n=1-e.speed*n,t>i.currentIndex&&(n=0)),0<n&&(this.ctx.fillStyle=`rgba(${this.color.join(",")}, ${n})`,this.ctx.fillText(e.text,e.x,e.y))}),this.reverse?(i.currentIndex--,i.currentIndex+10<0&&(i.currentIndex=this.count+a.getRandom(0,this.count))):(i.currentIndex++,i.currentIndex-10>i.list.length-1&&(i.currentIndex=-a.getRandom(0,this.count)))}),clearTimeout(this.timer),this.timer=setTimeout(this.draw,this.interval)}createColumn(t,e){const n=[];for(let e=0;e<this.count;e++){var i=a.getRandom(0,this.text.length-1);n.push({text:this.text[i],x:t,y:Math.floor(e*this.textLineHeight),speed:1})}return{currentIndex:e,list:n}}dispose(){this.isStop=!0,clearTimeout(this.timer)}start(){this.isStop=!1,this.draw()}getPointList(){const i=[];var o=this.fontSize,e=Math.floor(this.width/o);for(let n=0;n<e;n++){let t=0;for(let e=0;e<this.count&&(e?t+=a.getRandom(t+10,this.count):t+=a.getRandom(t,10),!(t>this.count));e++)this.reverse?i.push(this.createColumn(n*o,this.count+t)):i.push(this.createColumn(n*o,-t))}return this.pointList=i}}e.TextRainCanvas=C,e.addClass=b,e.browser=S,e.createXLSX=async function(e){const t=document.createElement("table"),n=a.parseTreeToTableHeader(e.header);var i=n.data.map(function(e){return`<tr>${e.map(function(e){if(e&&0!==e.colSpan)return`<td align="center" rowSpan="${e.rowSpan}" colSpan="${e.colSpan}">${e?.title}</td>`}).join("")}</tr>`}).join(""),e=e.body.map(function(i){return`<tr>${n.columns.map(function(e){var t=i.$colField?.[e]??1,n=i.$rowSpan?.[e]??1;if(0!==t&&0!==n)return`<td align="center" colSpan="${t}" rowSpan="${n}">${i[e]??""}</td>`}).filter(function(e){return!a.isNull(e)}).join("")}</tr>`}).join("");return t.innerHTML=`<thead>${i}</thead><tbody>${e}</tbody>`,t.setAttribute("border","1"),t},e.downloadFileByArrayBuffer=function(e,t){const n=f.URL;c(e=n.createObjectURL(new Blob([e])),t),n.revokeObjectURL(e),undefined},e.downloadFileByUrl=c,e.fullScreen=function(e,t,n){if(t){t=e;e=n;const i=e||y;t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullScreen?t.webkitRequestFullScreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen&&t.msRequestFullscreen(),i(!0)}else{e=n;const o=e||y,r=document;document.exitFullscreen?document.exitFullscreen().then(function(){o(!0)})["catch"](function(){o(!1)}):r.webkitCancelFullScreen?(r.webkitCancelFullScreen(),o(!0)):r.mozCancelFullScreen?(r.mozCancelFullScreen(),o(!0)):r.msExitFullscreen&&(r.msExitFullscreen(),o(!0))}},e.getCookie=function(e,t){t=t||document.cookie;let i="";return t.replace(new RegExp("(^|;\\s?)"+e+"=(.*?)($|(;\\s?))"),function(e,t,n){i=u(n)}),i},e.getJsFileBaseUrl=function(e){e=e||0;for(var t="/[^/]*",n=document.scripts,i=0;i<e;i++)t+=t;return n[n.length-1].src.replace(new RegExp(t+"$"),"")},e.getRatio=function(){return window.devicePixelRatio||1},e.getRelativePos=function(e){var t=e.getBoundingClientRect();return{x:t.left,y:t.top,height:e.offsetHeight,width:e.offsetWidth,clientWidth:e.clientWidth,clientHeight:e.clientHeight}},e.getStorage=function(e){return e=localStorage.getItem(e),a.defualtFormatter("",e)},e.getWindowSize=d,e.infoContainerPosition=function(e){var t=e.mode||"top-right",n=e.width,i=e.height,o=a.defualtFormatter(10,e.offsetY),r=a.defualtFormatter(10,e.offsetX),s=a.defualtFormatter(10,e.padding);let c=e.x,l=e.y;var e=d(),u=[s,e.width-n-s],e=[s,e.height-i-s];return"top-right"===t?(c+=r,l=l-i-o,c<u[0]?c=u[0]:c>u[1]&&(s=c-n-2*r,c=u[0]<s?s:u[1]),l<e[0]?(s=l+i+2*o,l=s<e[1]?s:e[0]):l>e[1]&&(l=l-i-2*o)):"bottom-right"===t?(c+=r,l+=o):"top-left"===t&&(c=c-n-r,l=l-i-o),{x:c,y:l}},e.libraryFile=w,e.observeDomResize=function(n,i,o,e){let r=[0,0,!1],s=[0,0,!1],c=[0,0,!1],l=[0,0,!1];const t=h.add(u,e=e||500);function u(){if(document.body.contains(n)){let e=!1;var t;o?.includes("position")&&(t=n.getBoundingClientRect(),c[0]=t.left,c[2]=c[0]!==c[1],l[0]=t.top,l[2]=l[0]!==l[1]),r[0]=n.offsetWidth,r[2]=r[0]!==r[1],s[0]=n.offsetHeight,s[2]=s[0]!==s[1],r[2]&&(r[1]=r[0],o?.includes("width")&&(e=!0)),s[2]&&(s[1]=s[0],o?.includes("height")&&(e=!0)),(l[2]||c[2])&&(l[1]=l[0],c[1]=c[0],o?.includes("position")&&(e=!0)),o&&0!==o.length||(r[2]||s[2]||l[2]||c[2])&&(e=!0),e&&i(n)}else a()}function a(){h.remove(t),r=undefined,s=undefined}return u(),a},e.observeDomScroll=function(n,e){const i=a._KvPair(e),o=a._Number(i.offetY);let r=!1,s=0;function t(){var e,t;r||(t=(e=n.scrollTop)-s,s=e,0!=t?t<0&&i.onTop&&e<=0+o?(r=!0,i.onTop(function(){r=!1})):0<t&&i.onBottom&&e>=n.scrollHeight-n.offsetHeight-o?(r=!0,i.onBottom(function(){r=!1})):r=!1:(r=!1,console.log("未处理")))}return n.addEventListener("scroll",t),{dispose:function(){n.removeEventListener("scroll",t)}}},e.observeMouseWheel=function(e,n,i){function t(e){let t;if(t=e.wheelDelta?0<e.wheelDelta?1:-1:e.detail<0?1:-1,n(t),i)return e.preventDefault&&e.preventDefault(),!1}return e.addEventListener("mousewheel",t),e.addEventListener("DOMMouseScroll",t),{dispose:function(){e.removeEventListener("mousewheel",t),e.removeEventListener("DOMMouseScroll",t)}}},e.pdfToImage=async function(e,o,t){const n=await async function(e){const t=e||{index:"//mozilla.github.io/pdf.js/build/pdf.mjs",worker:"//mozilla.github.io/pdf.js/build/pdf.worker.mjs"};return new Promise(function(e){w({type:"js",module:"pdfjsLib",attribute:{type:"module"},url:t.index,interceptor:function(e){e.GlobalWorkerOptions.workerSrc=t.worker}},e)})}(t);return new Promise(function(i){n.getDocument(e).promise.then(function(e){e.getPage(1).then(function(e){var t=e.getViewport({scale:1}),n=o.getContext("2d");o.height=t.height,o.width=t.width,e.render({canvasContext:n,viewport:t}).promise.then(function(){i({width:t.width,height:t.height})})})},function(e){console.error(e),i({width:0,height:0})})})},e.prevent=function(e,t,n){e=e||f.event,n=!1!==n,(t=!1!==t)&&f.event?f.event.cancelBubble=!0:e.stopPropagation(),n&&f.event?f.event.returnValue=!1:e.preventDefault()},e.removeClass=x,e.removeCookie=function(e){t(e,"",-1)},e.removeElement=function(e){e.parentNode&&e.parentNode.removeChild(e)},e.removeStorage=function(e){localStorage.removeItem(e)},e.replaceClass=function(e,t,n){x(e,t),b(e,n)},e.setCookie=t,e.setStorage=function(e,t){localStorage.setItem(e,(e=t,e=a.isString(e)?e:JSON.stringify(e)))},e.toggleClass=function(t,e){a.isArray(e)?a.forEach(e,function(e){t.classList.toggle(e)}):t.classList.toggle(e)}});
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@bestime/utils_browser",
3
- "version": "1.0.5",
4
- "main": "./dist/jUtilsBrowser.esm.min.mjs",
5
- "module": "./dist/jUtilsBrowser.esm.min.mjs",
6
- "types": "./dist/jUtilsBrowser.esm.d.ts",
3
+ "version": "1.0.7",
4
+ "main": "./dist/esm/index.min.mjs",
5
+ "module": "./dist/esm/index.min.mjs",
6
+ "types": "./dist/esm/index.d.ts",
7
7
  "description": "个人常用工具库,浏览器使用",
8
8
  "type": "module",
9
9
  "files": [
@@ -15,7 +15,7 @@
15
15
  },
16
16
 
17
17
  "dependencies": {
18
- "@bestime/utils_base": "^1.0.3"
18
+ "@bestime/utils_base": "1.0.7"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@babel/core": "7.18.6",
package/README.md DELETED
@@ -1,15 +0,0 @@
1
- ### 不同git项目,使用不同用户名和邮箱
2
-
3
- 修改配置文件 ~/.gitconfig
4
-
5
- ```cmd
6
- [core]
7
- autocrlf = false
8
- [includeIf "gitdir:D:/bestime/git/"]
9
- path = D:/bestime/config/.gitconfig
10
- [includeIf "gitdir:D:/work-qssoft/git/qs-t/"]
11
- path = D:/bestime/config/qssoft.gitconfig
12
- [includeIf "gitdir:D:/work-qssoft/git/rdc-cq/"]
13
- path = D:/bestime/config/sitian.gitconfig
14
-
15
- ```
@@ -1,8 +0,0 @@
1
- /**
2
- * 浏览器工具库 => jUtilsBrowser
3
- * @QQ 1174295440
4
- * @author Bestime
5
- * @see https://github.com/bestime/tool
6
- * @update 2023-11-15 20:51:11
7
- */
8
- import{defaultValue,isString,variableHasValue,isArray,forEach}from"@bestime/utils_base";function getWindowSize(){return{width:document.documentElement.clientWidth||document.body.clientWidth||window.innerWidth||0,height:document.documentElement.clientHeight||document.body.clientHeight||window.innerHeight||0}}var timer,htivId=0,idName="",isStart=!1,records={};function stop(){isStart=!1,clearInterval(timer),timer=undefined}function startRun(){clearInterval(timer),isStart=!0,timer=setInterval(function(){for(var e in records){var t=records[e];t.current=+new Date,t.current-t.start>=t.interval&&(t.start=t.current,records[e].handler())}},17)}function add(e,t){return idName="HI-"+ ++htivId,records[idName]={start:+new Date,current:0,handler:e,interval:t},isStart||startRun(),idName}function remove(e){delete records[e],0===Object.keys(records).length&&stop()}var hpInterval={add:add,remove:remove};function observeDomResize(n,o,r,e){var i=[0,0,!1],l=[0,0,!1],a=[0,0,!1],c=[0,0,!1],t=hpInterval.add(d,e=e||500);function d(){var e,t;document.body.contains(n)?(e=!1,null!=r&&r.includes("position")&&(t=n.getBoundingClientRect(),a[0]=t.left,a[2]=a[0]!==a[1],c[0]=t.top,c[2]=c[0]!==c[1]),i[0]=n.offsetWidth,i[2]=i[0]!==i[1],l[0]=n.offsetHeight,l[2]=l[0]!==l[1],i[2]&&(i[1]=i[0],null!=r&&r.includes("width")&&(e=!0)),l[2]&&(l[1]=l[0],null!=r&&r.includes("height")&&(e=!0)),(c[2]||a[2])&&(c[1]=c[0],a[1]=a[0],null!=r&&r.includes("position")&&(e=!0)),r&&0!==r.length||(i[2]||l[2]||c[2]||a[2])&&(e=!0),e&&o(n)):s()}function s(){hpInterval.remove(t),i=undefined,l=undefined}return d(),s}function downloadFileByUrl(e,t){var n=document.createElement("a");n.style.display="none",n.download=t,n.setAttribute("href",e),n.setAttribute("target","_blank"),n.setAttribute("download",t),document.body.appendChild(n),n.click(),n.remove()}var $undefinedValue=void 0,$decodeURIComponent=decodeURIComponent,$browserGlobal=window,$headElement=document.getElementsByTagName("head")[0];function downloadFileByArrayBuffer(e,t){var n=$browserGlobal.URL,e=n.createObjectURL(new Blob([e]));downloadFileByUrl(e,t),n.revokeObjectURL(e),undefined}function removeElement(e){e.parentNode&&e.parentNode.removeChild(e)}function prevent(e,t,n){e=e||$browserGlobal.event,n=!1!==n,(t=!1!==t)&&$browserGlobal.event?$browserGlobal.event.cancelBubble=!0:e.stopPropagation(),n&&$browserGlobal.event?$browserGlobal.event.returnValue=!1:e.preventDefault()}function getStorage(e){e=localStorage.getItem(e);return defaultValue(e,"")}function removeStorage(e){localStorage.removeItem(e)}function hpSetStringValue(e){return e=isString(e)?e:JSON.stringify(e)}function setStorage(e,t){localStorage.setItem(e,hpSetStringValue(t))}function getRelativePos(e){var t=e.getBoundingClientRect();return{x:t.left,y:t.top,height:e.offsetHeight,width:e.offsetWidth,clientWidth:e.clientWidth,clientHeight:e.clientHeight}}function getJsFileBaseUrl(e){e=e||0;for(var t="/[^/]*",n=document.scripts,o=0;o<e;o++)t+=t;return n[n.length-1].src.replace(new RegExp(t+"$"),"")}function hpCreateFileLoaderElement(e,t,n,o){if($headElement){var r;if("js"===e?(r=document.createElement("script")).src=t:((r=document.createElement("link")).setAttribute("rel","stylesheet"),r.href=t),o)for(var i in o)r.setAttribute(i,o[i]);r.onload=r.onerror=n,$headElement.appendChild(r)}}var cache={};function loadMultiple(n,o){for(var r=[],i=0,e=0;e<n.length;e++)!function(t){loadSingle(n[t],function(e){r[t]=e,++i===n.length&&o.apply($undefinedValue,r)})}(e)}function loadSingle(e,t){var n=e.dependencies&&e.dependencies.length,o=e["with"]&&e["with"].length,r=(cache[e.url]||(cache[e.url]={count:0,dependencies:!n,"with":!o,complete:!1,create:!1,url:e.url}),cache[e.url]);function i(){r.complete&&r.dependencies&&r["with"]&&(e.module?t($browserGlobal[e.module]):t())}r.count++,!r.dependencies&&n?(r.dependencies=!0,loadMultiple(e.dependencies,function(){loadSingle(e,t)})):!r["with"]&&o?(r["with"]=!0,loadMultiple(e["with"].concat(e),i)):r.create?variableHasValue(function(){return r.complete},i,300):(r.create=!0,hpCreateFileLoaderElement(e.type,e.url,function(){r.complete=!0,i()},e.attribute))}function libraryFile(e,t){(e instanceof Array?loadMultiple:loadSingle)(e,t)}function setObjectToString(e){return e=isString(e)?e:JSON.stringify(e)}function setCookie(e,t,n){t=setObjectToString(t);e=e+"="+encodeURI(t)+";path=/;";"number"==typeof n&&((t=new Date).setTime(t.getTime()+n),e+="expires="+t.toUTCString()),document.cookie=e}function getCookie(e,t){t=t||document.cookie;var o="";return t.replace(new RegExp("(^|;\\s)"+e+"=(.*?)($|(;\\s))"),function(e,t,n){o=$decodeURIComponent(n)}),o}function removeCookie(e){setCookie(e,"",-1)}function removeClass(t,e){isArray(e)?forEach(e,function(e){t.classList.remove(e)}):t.classList.remove(e)}function addClass(t,e){isArray(e)?forEach(e,function(e){t.classList.add(e)}):t.classList.add(e)}function replaceClass(e,t,n){removeClass(e,t),addClass(e,n)}function toggleClass(t,e){isArray(e)?forEach(e,function(e){t.classList.toggle(e)}):t.classList.toggle(e)}var agent=$browserGlobal.navigator.userAgent,browser={isChrome:/Chrome/.test(agent),isIPhone:/iPhone/.test(agent)};export{addClass,browser,downloadFileByArrayBuffer,downloadFileByUrl,getCookie,getJsFileBaseUrl,getRelativePos,getStorage,getWindowSize,libraryFile,observeDomResize,prevent,removeClass,removeCookie,removeElement,removeStorage,replaceClass,setCookie,setStorage,toggleClass};
@@ -1,8 +0,0 @@
1
- /**
2
- * 浏览器工具库 => jUtilsBrowser
3
- * @QQ 1174295440
4
- * @author Bestime
5
- * @see https://github.com/bestime/tool
6
- * @update 2023-11-15 20:51:11
7
- */
8
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@bestime/utils_base")):"function"==typeof define&&define.amd?define(["exports","@bestime/utils_base"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jUtilsBrowser={},e.jUtilsBase)}(this,function(e,u){"use strict";var n,i,o=0,r=!1,c={};var d={add:function(e,t){return n="HI-"+ ++o,c[n]={start:+new Date,current:0,handler:e,interval:t},r||(clearInterval(i),r=!0,i=setInterval(function(){for(var e in c){var t=c[e];t.current=+new Date,t.current-t.start>=t.interval&&(t.start=t.current,c[e].handler())}},17)),n},remove:function(e){delete c[e],0===Object.keys(c).length&&(r=!1,clearInterval(i),i=undefined)}};function l(e,t){var n=document.createElement("a");n.style.display="none",n.download=t,n.setAttribute("href",e),n.setAttribute("target","_blank"),n.setAttribute("download",t),document.body.appendChild(n),n.click(),n.remove()}var a=void 0,s=decodeURIComponent,f=window,h=document.getElementsByTagName("head")[0];var g={};function m(n,i){for(var o=[],r=0,e=0;e<n.length;e++)!function(t){v(n[t],function(e){o[t]=e,++r===n.length&&i.apply(a,o)})}(e)}function v(e,t){var n=e.dependencies&&e.dependencies.length,i=e["with"]&&e["with"].length,o=(g[e.url]||(g[e.url]={count:0,dependencies:!n,"with":!i,complete:!1,create:!1,url:e.url}),g[e.url]);function r(){o.complete&&o.dependencies&&o["with"]&&(e.module?t(f[e.module]):t())}if(o.count++,!o.dependencies&&n)o.dependencies=!0,m(e.dependencies,function(){v(e,t)});else if(!o["with"]&&i)o["with"]=!0,m(e["with"].concat(e),r);else if(o.create)u.variableHasValue(function(){return o.complete},r,300);else{o.create=!0;var c,n=e.type,i=e.url,l=function(){o.complete=!0,r()},a=e.attribute;if(h){if("js"===n?(c=document.createElement("script")).src=i:((c=document.createElement("link")).setAttribute("rel","stylesheet"),c.href=i),a)for(var s in a)c.setAttribute(s,a[s]);c.onload=c.onerror=l,h.appendChild(c)}}}function t(e,t,n){i=t,t=i=u.isString(i)?i:JSON.stringify(i);var i=e+"="+encodeURI(t)+";path=/;";"number"==typeof n&&((e=new Date).setTime(e.getTime()+n),i+="expires="+e.toUTCString()),document.cookie=i}function p(t,e){u.isArray(e)?u.forEach(e,function(e){t.classList.remove(e)}):t.classList.remove(e)}function b(t,e){u.isArray(e)?u.forEach(e,function(e){t.classList.add(e)}):t.classList.add(e)}var w=f.navigator.userAgent,w={isChrome:/Chrome/.test(w),isIPhone:/iPhone/.test(w)};e.addClass=b,e.browser=w,e.downloadFileByArrayBuffer=function(e,t){var n=f.URL;l(e=n.createObjectURL(new Blob([e])),t),n.revokeObjectURL(e),undefined},e.downloadFileByUrl=l,e.getCookie=function(e,t){t=t||document.cookie;var i="";return t.replace(new RegExp("(^|;\\s)"+e+"=(.*?)($|(;\\s))"),function(e,t,n){i=s(n)}),i},e.getJsFileBaseUrl=function(e){e=e||0;for(var t="/[^/]*",n=document.scripts,i=0;i<e;i++)t+=t;return n[n.length-1].src.replace(new RegExp(t+"$"),"")},e.getRelativePos=function(e){var t=e.getBoundingClientRect();return{x:t.left,y:t.top,height:e.offsetHeight,width:e.offsetWidth,clientWidth:e.clientWidth,clientHeight:e.clientHeight}},e.getStorage=function(e){return e=localStorage.getItem(e),u.defaultValue(e,"")},e.getWindowSize=function(){return{width:document.documentElement.clientWidth||document.body.clientWidth||window.innerWidth||0,height:document.documentElement.clientHeight||document.body.clientHeight||window.innerHeight||0}},e.libraryFile=function(e,t){(e instanceof Array?m:v)(e,t)},e.observeDomResize=function(n,i,o,e){var r=[0,0,!1],c=[0,0,!1],l=[0,0,!1],a=[0,0,!1],t=d.add(s,e=e||500);function s(){var e,t;document.body.contains(n)?(e=!1,null!=o&&o.includes("position")&&(t=n.getBoundingClientRect(),l[0]=t.left,l[2]=l[0]!==l[1],a[0]=t.top,a[2]=a[0]!==a[1]),r[0]=n.offsetWidth,r[2]=r[0]!==r[1],c[0]=n.offsetHeight,c[2]=c[0]!==c[1],r[2]&&(r[1]=r[0],null!=o&&o.includes("width")&&(e=!0)),c[2]&&(c[1]=c[0],null!=o&&o.includes("height")&&(e=!0)),(a[2]||l[2])&&(a[1]=a[0],l[1]=l[0],null!=o&&o.includes("position")&&(e=!0)),o&&0!==o.length||(r[2]||c[2]||a[2]||l[2])&&(e=!0),e&&i(n)):u()}function u(){d.remove(t),r=undefined,c=undefined}return s(),u},e.prevent=function(e,t,n){e=e||f.event,n=!1!==n,(t=!1!==t)&&f.event?f.event.cancelBubble=!0:e.stopPropagation(),n&&f.event?f.event.returnValue=!1:e.preventDefault()},e.removeClass=p,e.removeCookie=function(e){t(e,"",-1)},e.removeElement=function(e){e.parentNode&&e.parentNode.removeChild(e)},e.removeStorage=function(e){localStorage.removeItem(e)},e.replaceClass=function(e,t,n){p(e,t),b(e,n)},e.setCookie=t,e.setStorage=function(e,t){localStorage.setItem(e,(e=t,e=u.isString(e)?e:JSON.stringify(e)))},e.toggleClass=function(t,e){u.isArray(e)?u.forEach(e,function(e){t.classList.toggle(e)}):t.classList.toggle(e)}});