@bestime/utils_browser 1.0.13 → 1.0.15

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.
@@ -19,7 +19,8 @@ declare function observeDomResize(
19
19
  element: HTMLElement,
20
20
  handler: (element: HTMLElement) => void,
21
21
  type?: ('width' | 'height' | 'position')[],
22
- interval?: number
22
+ interval?: number,
23
+ immediate?: boolean
23
24
  ): () => void;
24
25
 
25
26
  /**
@@ -194,7 +195,7 @@ type Direction = 1 | -1;
194
195
  * @param isPrevent 是否阻止原生滚动,仅用来获取滚动方向
195
196
  * @returns
196
197
  */
197
- declare function export_default$1(
198
+ declare function observeMouseWheel(
198
199
  el: HTMLElement,
199
200
  callback: (direction: Direction) => void,
200
201
  isPrevent: boolean
@@ -336,28 +337,13 @@ declare class TextRainCanvas {
336
337
 
337
338
  declare class SeamlessRolling {
338
339
  _wrapper: HTMLDivElement;
339
- _timer: number;
340
+ _timer: any;
340
341
  constructor(wraper: HTMLDivElement);
341
342
  _updateContent(): void;
342
343
  _doScroll(): void;
343
344
  dispose(): void;
344
345
  }
345
346
 
346
- type Tlanguage =
347
- | 'Microsoft Huihui - Chinese (Simplified, PRC)'
348
- | 'Microsoft Kangkang - Chinese (Simplified, PRC)'
349
- | 'Microsoft Kangkang - Chinese (Simplified, PRC)'
350
- | 'Microsoft Yaoyao - Chinese (Simplified, PRC)'
351
- | 'Google 한국의'
352
- | 'Google 日本語'
353
- | 'Google 粤語(香港)';
354
- declare function speakText(
355
- message: string,
356
- options: {
357
- language?: Tlanguage;
358
- }
359
- ): Promise<void>;
360
-
361
347
  declare function func01(text: string): Promise<void>;
362
348
  /**
363
349
  * 复制文本
@@ -376,6 +362,7 @@ interface IOptions$1 {
376
362
  fontColor: string;
377
363
  paddingTop: number;
378
364
  paddingBottom: number;
365
+ labelFormatter?: (data: number) => string;
379
366
  colors: IColorItem[];
380
367
  }
381
368
  interface IUseColorItem {
@@ -441,6 +428,29 @@ declare class WaterMark {
441
428
  _draw(): void;
442
429
  }
443
430
 
431
+ /**
432
+ * 将部分属性变为可选
433
+ */
434
+ type TPartialOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
435
+
436
+ interface IWaterfallFlowConfig {
437
+ el: HTMLElement;
438
+ gap: number;
439
+ /**
440
+ * 自动播放在第一次主动执行 resize 后生效(避免首次渲染过渡动画卡顿)
441
+ */
442
+ autoResize?: number;
443
+ }
444
+ declare class WaterfallFlow {
445
+ private _cfg;
446
+ private _timer;
447
+ constructor(config: TPartialOptional<IWaterfallFlowConfig, 'gap'>);
448
+ _autoPlay(): void;
449
+ resize(): void;
450
+ pause(): this;
451
+ dispose(): void;
452
+ }
453
+
444
454
  declare const style: (str: string) => void;
445
455
 
446
456
  export {
@@ -448,6 +458,7 @@ export {
448
458
  SeamlessRolling,
449
459
  TextRainCanvas,
450
460
  WaterMark,
461
+ WaterfallFlow,
451
462
  addClass,
452
463
  _default as browser,
453
464
  copyText,
@@ -466,7 +477,7 @@ export {
466
477
  libraryFile,
467
478
  observeDomResize,
468
479
  export_default as observeDomScroll,
469
- export_default$1 as observeMouseWheel,
480
+ observeMouseWheel,
470
481
  pdfToImage,
471
482
  prevent,
472
483
  removeClass,
@@ -476,7 +487,6 @@ export {
476
487
  replaceClass,
477
488
  setCookie,
478
489
  setStorage,
479
- speakText,
480
490
  style,
481
491
  toggleClass
482
492
  };
@@ -1,5 +1,9 @@
1
1
  /**
2
2
  * 浏览器工具库 => jUtilsBrowser
3
- * @update 2025-04-22 10:03:23
3
+ * @update 2026-01-17 22:11:46
4
4
  */
5
- import{defualtFormatter,isString,variableHasValue,isArray,forEach,_KvPair,_Number,parseTreeToTableHeader,isNull,getRandom,trim,roundFixed,getType,hexToRgba,rgbaToHex,min,max,split,_String}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],a=[0,0,!1],s=[0,0,!1],l=[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],l[0]=t.top,l[2]=l[0]!==l[1]),r[0]=n.offsetWidth,r[2]=r[0]!==r[1],a[0]=n.offsetHeight,a[2]=a[0]!==a[1],r[2]&&(r[1]=r[0],i?.includes("width")&&(e=!0)),a[2]&&(a[1]=a[0],i?.includes("height")&&(e=!0)),(l[2]||s[2])&&(l[1]=l[0],s[1]=s[0],i?.includes("position")&&(e=!0)),i&&0!==i.length||(r[2]||a[2]||l[2]||s[2])&&(e=!0),e&&o(n)}else d()}function d(){hpInterval.remove(t),r=undefined,a=undefined}return c(),d}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],iUrl=$browserGlobal.URL;function downloadFileByBolb(e,t){e=iUrl.createObjectURL(e);downloadFileByUrl(e,t),iUrl.revokeObjectURL(e),undefined}function downloadFileByArrayBuffer(e,t){downloadFileByBolb(new Blob([e]),t)}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 a(){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),a)):i.create?variableHasValue(function(){return i.complete},a,300):(i.create=!0,hpCreateFileLoaderElement(e.type,e.url,function(){i.complete=!0,e.interceptor&&e.interceptor(r()),a()},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,a=0;function t(){var e,t;r||(t=(e=n.scrollTop)-a,a=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(t){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){console.log("pdf",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),a=defualtFormatter(10,e.padding);let s=e.x,l=e.y;var e=e.targetSize||getWindowSize(),c=[a,e.width-n-a],e=[a,e.height-o-a];return"top-right"===t?(s+=r,l=l-o-i,s<c[0]?s=c[0]:s>c[1]&&(a=s-n-2*r,s=c[0]<a?a:c[1]),l<e[0]?(a=l+o+2*i,l=a<e[1]?a:e[0]):l>e[1]&&(l=l-o-2*i)):"bottom-right"===t?(s+=r,(l+=i)>e[1]&&(a=l-o-2*i,l=a<e[0]?e[1]:a),s>c[1]&&(e=s-n-2*r,s=e<c[0]?c[1]:e)):"top-left"===t&&(s=s-n-r,l=l-o-i),{x:s,y:l}}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;fontLineHeight;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.fontLineHeight=1.2*this.fontSize,this.count=Math.ceil(this.height/this.fontLineHeight),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.fontLineHeight),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}}class SeamlessRolling{_wrapper;_timer=-1;constructor(e){this._wrapper=e,this._updateContent()}_updateContent(){const e=this._wrapper.children[0];var t=e.cloneNode(!0);this._wrapper.appendChild(t),console.log("firstNode",e,t)}_doScroll(){clearTimeout(this._timer),this._timer=setTimeout(()=>{},60)}dispose(){clearTimeout(this._timer)}}var synth=window.speechSynthesis,utterance=new SpeechSynthesisUtterance;let voidList=[];function oVoidListChange(e){voidList=synth.getVoices()}async function readyLanguage(o){function i(e){console.log("朗读错误",e)}utterance.addEventListener("error",i);let r;return new Promise(function(e){function t(){clearTimeout(r),synth.cancel(),utterance.removeEventListener("error",i),utterance.removeEventListener("start",t),e()}!function n(){utterance.voice=o,utterance.text=1..toString(),synth.speak(utterance),clearTimeout(r),utterance.removeEventListener("start",t),utterance.addEventListener("start",t),r=setTimeout(n,1e3)}()})}async function speakText(e,t){synth.cancel(),utterance.rate=1,utterance.pitch=1,await variableHasValue["async"](function(){return 0<voidList.length});var n=voidList.find(e=>trim(e.name,"*")===trim(t.language,"*"))||voidList[0];utterance.lang=n.lang,await readyLanguage(n),utterance.text=e,synth.speak(utterance)}function func01(e){return navigator.clipboard.writeText(e)}async function func02(e){const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}synth.addEventListener("voiceschanged",oVoidListChange),window.addEventListener("beforeunload",function(e){return synth.cancel(),synth.removeEventListener("voiceschanged",oVoidListChange),!1});const copyText=$browserGlobal.navigator?.clipboard?.writeText?func01:func02;function rgbStringToList(e){e=e.replace(/^rgba\((.*)\)$/,"$1");const t=split(e,",");return t.map(function(e){return _Number(e)})}function getColorByRadio(e,t,n){n=Math.min(n,1);var[e,o,i]=rgbStringToList(hexToRgba(e)),[t,r,a]=rgbStringToList(hexToRgba(t)),t=Math.round(e+(t-e)*n),e=Math.round(o+(r-o)*n),r=Math.round(i+(a-i)*n);return rgbaToHex(`rgba(${t},${e},${r},1)`)}function convertColors(t){t.sort(function(e,t){return e.data-t.data});const n=[];var e=min(t,function(e){return e.data}),o=max(t,function(e){return e.data}),i=o-e;let r=0;for(let e=1;e<t.length;e++){var a=t[e-1],s=t[e],l=(s.data-a.data)/i,c=r+l;n.push({from:{value:a.data,color:a.color,ratio:r},to:{value:s.data,color:s.color,ratio:c},ratio:l,label:a.data+"至"+s.data}),r=c}return console.log("转换",n),{data:n,max:o,min:e}}class LinearGradientColorLegend{_cfg;_canvas;_colorList=[];_ctx;_minValue=0;_maxValue=0;constructor(e){this._cfg=Object.assign({fontSize:14,fontFamily:"Microsoft YaHei",tickWidth:5,paddingTop:10,paddingBottom:10,tickColor:"#92949b",fontColor:"#444",colors:[]},e),this.setColors(this._cfg.colors)}mount(e){this._canvas=e,this._ctx=e.getContext("2d"),this._draw()}_drawAxias(n,e){const o=this._ctx;var{fontFamily:t,fontSize:i,tickWidth:r,paddingTop:a,paddingBottom:s}=this._cfg,l=(o.font=i+"px "+t,3*i),c=e-s-a,d=Math.ceil(c/l),l=c/d;o.textBaseline="middle";let u=0;const h=[];for(let e=0;e<=d;e++){var f=1-e/d,f=roundFixed(f*(this._maxValue-this._minValue)+this._minValue,2),g=o.measureText(f);u=Math.max(g.width,u),h.push({label:f,width:g.width})}for(let t=0;t<h.length;t++){var m=h[t];let e=0;e=0===t?0:t===h.length-1?c-1:Math.floor(t*l),e+=a;var p=n-u-4-r;o.fillStyle=this._cfg.tickColor,o.fillRect(p,e,r,1),o.fillStyle=this._cfg.fontColor,o.fillText(m.label,p+r+4,e)}return{maxLabelWidth:4+u+r}}_draw(){if(!this._canvas||!this._ctx)return this;var{paddingTop:t,paddingBottom:e}=this._cfg,n=this._canvas.offsetWidth,o=this._canvas.offsetHeight,i=(this._canvas.width=n,this._canvas.height=o,this._ctx.clearRect(0,0,n,o),this._drawAxias(n,o))["maxLabelWidth"],r=o-t-e;for(let e=0;e<this._colorList.length;e++){var a=this._colorList[e],s=r*(1-a.to.ratio),l=r*(1-a.from.ratio),s=Math.ceil(s+t),l=Math.ceil(l+t);const c=this._ctx.createLinearGradient(0,s,0,l);c.addColorStop(1,a.from.color),c.addColorStop(0,a.to.color),this._ctx.fillStyle=c,this._ctx.fillRect(0,s,n-i,l-s)}}setColors(e){return e.length<2||(e=convertColors(e),this._colorList=e.data,this._minValue=e.min,this._maxValue=e.max,this._draw()),this}getColor(t){if(!this._colorList.length)return"#0000";!isNaN(t)&&"Number"===getType(t)||(t=this._colorList[0].from.value);var e=this._colorList.find(function(e){return t>=e.from.value&&t<e.to.value})??this._colorList[this._colorList.length-1],n=Math.min(t/(e.to.value-e.from.value),1);return getColorByRadio(e.from.color,e.to.color,n)}}const textCanvas=document.createElement("canvas");function createRotatedRectCanvas(e){var t=e.angle*Math.PI/180;const o=textCanvas.getContext("2d");o.font=e.fontSize+"px "+e.fontFamily;let i=0;const r=[],a=(e.text.forEach(function(e){e=o.measureText(e);r.push(e.width),i=Math.max(e.width,i)}),e.fontSize*e.fontLineHeight),s=a*e.text.length;var n=Math.abs(i*Math.cos(t))+Math.abs(s*Math.sin(t)),l=Math.abs(i*Math.sin(t))+Math.abs(s*Math.cos(t));textCanvas.width=n,textCanvas.height=l,o.translate(n/2,l/2),o.rotate(t),o.fillStyle=e.fontBackgroundColor,o.fillRect(-i/2,-s/2,i,s),o.fillStyle=e.fontColor,o.font=e.fontSize+"px "+e.fontFamily,o.textBaseline="top",o.textAlign="left";const c=(a-e.fontSize)/2;return e.text.forEach(function(e,t){var n=i/2-r[t]/2;o.fillText(e,-i/2+n,-s/2+t*a+c)}),{img:textCanvas,width:n,height:l}}class WaterMark{_cfg;_oWrapper;_canvas;constructor(e,t){this._oWrapper=e,this._cfg=Object.assign({fontFamily:"Microsoft YaHei",fontLineHeight:1.4,gapX:20,gapY:0,fontBackgroundColor:"rgba(0,0,0,0)",angle:-45,text:["作者 bestime","2025-04-09"],fontSize:16,fontColor:"red"},t),this._canvas=this._reload(),this._draw()}_reload(){let e=this._canvas;return e||(e=document.createElement("canvas"),this._oWrapper.appendChild(e)),e}setConfig(e){Object.assign(this._cfg,e),this._draw()}_draw(){const e=this._reload();var n=this._oWrapper.offsetWidth*window.devicePixelRatio,o=this._oWrapper.offsetHeight*window.devicePixelRatio;e.width=n,e.height=o,e.style.cssText="position:absolute;left:0;top:0;right:0;bottom:0;z-index: 1;user-select: none;pointer-events: none;",e.style.width=this._oWrapper.offsetWidth+"px",e.style.height=this._oWrapper.offsetHeight+"px";const i=e.getContext("2d");if(i&&(i.clearRect(0,0,n,o),!this._cfg.disabled)){var r=createRotatedRectCanvas(this._cfg);for(let t=0;t<n;t+=r.width+this._cfg.gapX)for(let e=0;e<o;e+=r.height+this._cfg.gapY)i.drawImage(r.img,t,e)}}}function fillHtml(e,t){e.styleSheet?e.styleSheet.cssText=t:e.innerHTML=t}let id=0;function createStyle(e){id++,(e=trim(e))&&!/^[0-9]/.test(e)||(e="bt-style-"+id);var t,i="",n=document.createElement("style");return n.className=e,document.getElementsByTagName("head")[0].appendChild(n),function(e){var o;t=i,_String(e).replace(/(.*?)({.*?})/g,function(e,t,n){return t=trim(t),i=i.replace(new RegExp("("+t+"\\s*?)({.*?})","g"),function(){return o=!0,t+trim(n)}),""}),o?t!==i&&fillHtml(n,i):(i+=_String(e),fillHtml(n,i))}}const style=createStyle("bt-browser-core");export{LinearGradientColorLegend,SeamlessRolling,TextRainCanvas,WaterMark,addClass,browser,copyText,createXLSX,downloadFileByArrayBuffer,downloadFileByBolb,downloadFileByUrl,fullScreen,getCookie,getJsFileBaseUrl,getRatio,getRelativePos,getStorage,getWindowSize,infoContainerPosition,libraryFile,observeDomResize,observeDomScroll,observeMouseWheel,pdfToImage,prevent,removeClass,removeCookie,removeElement,removeStorage,replaceClass,setCookie,setStorage,speakText,style,toggleClass};
5
+ import{defualtFormatter,isString,variableHasValue,isArray,forEach,_KvPair,_Number,parseTreeToTableHeader,isNull,getRandom,roundFixed,getType,hexToRgba,rgbaToHex,min,max,split,trim,_String}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 t in records){const e=records[t];e.current=+new Date,e.current-e.start>=e.interval&&(e.start=e.current,records[t].handler())}},17)}function add(t,e){return idName="HI-"+ ++htivId,records[idName]={start:+new Date,current:0,handler:t,interval:e},isStart||startRun(),idName}function remove(t){delete records[t],0===Object.keys(records).length&&stop()}var hpInterval={add:add,remove:remove};function observeDomResize(o,i,n,t,e){e=!1!==e;let r=[0,0,!1],a=[0,0,!1],s=[0,0,!1],l=[0,0,!1];const c=hpInterval.add(h,t=t||500);function h(){if(document.body.contains(o)){let t=!1;var e;n?.includes("position")&&(e=o.getBoundingClientRect(),s[0]=e.left,s[2]=s[0]!==s[1],l[0]=e.top,l[2]=l[0]!==l[1]),r[0]=o.offsetWidth,r[2]=r[0]!==r[1],a[0]=o.offsetHeight,a[2]=a[0]!==a[1],r[2]&&(r[1]=r[0],n?.includes("width")&&(t=!0)),a[2]&&(a[1]=a[0],n?.includes("height")&&(t=!0)),(l[2]||s[2])&&(l[1]=l[0],s[1]=s[0],n?.includes("position")&&(t=!0)),n&&0!==n.length||(r[2]||a[2]||l[2]||s[2])&&(t=!0),t&&i(o)}else d()}function d(){hpInterval.remove(c),r=undefined,a=undefined}return e&&h(),d}function downloadFileByUrl(t,e){const o=document.createElement("a");o.style.display="none",o.download=e,o.setAttribute("href",t),o.setAttribute("target","_blank"),o.setAttribute("download",e),document.body.appendChild(o),o.click(),o.remove()}const $undefinedValue=void 0,$decodeURIComponent=decodeURIComponent,$browserGlobal=window,$headElement=document.getElementsByTagName("head")[0],iUrl=$browserGlobal.URL;function downloadFileByBolb(t,e){t=iUrl.createObjectURL(t);downloadFileByUrl(t,e),iUrl.revokeObjectURL(t),undefined}function downloadFileByArrayBuffer(t,e){downloadFileByBolb(new Blob([t]),e)}function removeElement(t){t.parentNode&&t.parentNode.removeChild(t)}function prevent(t,e,o){t=t||$browserGlobal.event,o=!1!==o,(e=!1!==e)&&$browserGlobal.event?$browserGlobal.event.cancelBubble=!0:t.stopPropagation(),o&&$browserGlobal.event?$browserGlobal.event.returnValue=!1:t.preventDefault()}function getStorage(t){t=localStorage.getItem(t);return defualtFormatter("",t)}function removeStorage(t){localStorage.removeItem(t)}function hpSetStringValue(t){return t=isString(t)?t:JSON.stringify(t)}function setStorage(t,e){localStorage.setItem(t,hpSetStringValue(e))}function getRelativePos(t){var e=t.getBoundingClientRect();return{x:e.left,y:e.top,height:t.offsetHeight,width:t.offsetWidth,clientWidth:t.clientWidth,clientHeight:t.clientHeight}}function getJsFileBaseUrl(t){t=t||0;for(var e="/[^/]*",o=document.scripts,i=0;i<t;i++)e+=e;return o[o.length-1].src.replace(new RegExp(e+"$"),"")}function hpCreateFileLoaderElement(e,o,i,n){if($headElement){let t;if("js"===e?(t=document.createElement("script")).src=o:((t=document.createElement("link")).setAttribute("rel","stylesheet"),t.href=o),n)for(var r in n)t.setAttribute(r,n[r]);t.onload=t.onerror=i,$headElement.appendChild(t)}}const cache={};function loadMultiple(o,i){const n=[];let r=0;for(let e=0;e<o.length;e++)loadSingle(o[e],function(t){n[e]=t,++r===o.length&&i.apply($undefinedValue,n)})}function loadSingle(t,e){var o=t.dependencies&&t.dependencies.length,i=t["with"]&&t["with"].length;cache[t.url]||(cache[t.url]={count:0,dependencies:!o,"with":!i,complete:!1,create:!1,url:t.url});const n=cache[t.url];function r(){return $browserGlobal[t.module]}function a(){n.complete&&n.dependencies&&n["with"]&&(t.module?e(r()):e())}n.count++,!n.dependencies&&o?(n.dependencies=!0,loadMultiple(t.dependencies,function(){loadSingle(t,e)})):!n["with"]&&i?(n["with"]=!0,loadMultiple(t["with"].concat(t),a)):n.create?variableHasValue(function(){return n.complete},a,300):(n.create=!0,hpCreateFileLoaderElement(t.type,t.url,function(){n.complete=!0,t.interceptor&&t.interceptor(r()),a()},t.attribute))}function libraryFile(t,e){(t instanceof Array?loadMultiple:loadSingle)(t,e)}function setObjectToString(t){return t=isString(t)?t:JSON.stringify(t)}function setCookie(t,e,o){e=setObjectToString(e);let i=t+"="+encodeURI(e)+";path=/;";"number"==typeof o&&((t=new Date).setTime(t.getTime()+o),i+="expires="+t.toUTCString()),document.cookie=i}function getCookie(t,e){e=e||document.cookie;let i="";return e.replace(new RegExp("(^|;\\s?)"+t+"=(.*?)($|(;\\s?))"),function(t,e,o){i=$decodeURIComponent(o)}),i}function removeCookie(t){setCookie(t,"",-1)}function removeClass(e,t){isArray(t)?forEach(t,function(t){e.classList.remove(t)}):e.classList.remove(t)}function addClass(e,t){isArray(t)?forEach(t,function(t){e.classList.add(t)}):e.classList.add(t)}function replaceClass(t,e,o){removeClass(t,e),addClass(t,o)}function toggleClass(e,t){isArray(t)?forEach(t,function(t){e.classList.toggle(t)}):e.classList.toggle(t)}const agent=$browserGlobal.navigator.userAgent;var browser={isChrome:/Chrome/.test(agent),isIPhone:/iPhone/.test(agent)};function getRatio(){return window.devicePixelRatio||1}function observeMouseWheel(t,o,i){function e(t){let e;if(e=t.wheelDelta?0<t.wheelDelta?1:-1:t.detail<0?1:-1,o(e),i)return t.preventDefault&&t.preventDefault(),!1}return t.addEventListener("mousewheel",e),t.addEventListener("DOMMouseScroll",e),{dispose:function(){t.removeEventListener("mousewheel",e),t.removeEventListener("DOMMouseScroll",e)}}}function observeDomScroll(o,t){const i=_KvPair(t),n=_Number(i.offetY);let r=!1,a=0;function e(){var t,e;r||(e=(t=o.scrollTop)-a,a=t,0!=e?e<0&&i.onTop&&t<=0+n?(r=!0,i.onTop(function(){r=!1})):0<e&&i.onBottom&&t>=o.scrollHeight-o.offsetHeight-n?(r=!0,i.onBottom(function(){r=!1})):r=!1:(r=!1,console.log("未处理")))}return o.addEventListener("scroll",e),{dispose:function(){o.removeEventListener("scroll",e)}}}const defaultCallback=t=>{};function open(t,e){const o=e||defaultCallback;t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullScreen?t.webkitRequestFullScreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen&&t.msRequestFullscreen(),o(!0)}function close(t){const e=t||defaultCallback,o=document;document.exitFullscreen?document.exitFullscreen().then(function(){e(!0)})["catch"](function(){e(!1)}):o.webkitCancelFullScreen?(o.webkitCancelFullScreen(),e(!0)):o.mozCancelFullScreen?(o.mozCancelFullScreen(),e(!0)):o.msExitFullscreen&&(o.msExitFullscreen(),e(!0))}function fullScreen(t,e,o){e?open(t,o):close(o)}async function createXLSX(t){const e=document.createElement("table"),o=parseTreeToTableHeader(t.header);var i=o.data.map(function(t){return`<tr>${t.map(function(t){if(t&&0!==t.colSpan)return`<td align="center" rowSpan="${t.rowSpan}" colSpan="${t.colSpan}">${t?.title}</td>`}).join("")}</tr>`}).join(""),t=t.body.map(function(i){return`<tr>${o.columns.map(function(t){var e=i.$colField?.[t]??1,o=i.$rowSpan?.[t]??1;if(0!==e&&0!==o)return`<td align="center" colSpan="${e}" rowSpan="${o}">${i[t]??""}</td>`}).filter(function(t){return!isNull(t)}).join("")}</tr>`}).join("");return e.innerHTML=`<thead>${i}</thead><tbody>${t}</tbody>`,e.setAttribute("border","1"),e}async function loadPdfPlugin(e){return new Promise(function(t){libraryFile({type:"js",module:"pdfjsLib",attribute:{type:"module"},url:e.index,interceptor:function(t){t.GlobalWorkerOptions.workerSrc=e.worker}},t)})}async function pdfToImage(t,n,e){const o=await loadPdfPlugin(e);return new Promise(function(i){o.getDocument(t).promise.then(function(t){console.log("pdf",t),t.getPage(1).then(function(t){var e=t.getViewport({scale:1}),o=n.getContext("2d");n.height=e.height,n.width=e.width,t.render({canvasContext:o,viewport:e}).promise.then(function(){i({width:e.width,height:e.height})})})},function(t){console.error(t),i({width:0,height:0})})})}function infoContainerPosition(t){var e=t.mode||"top-right",o=t.width,i=t.height,n=defualtFormatter(10,t.offsetY),r=defualtFormatter(10,t.offsetX),a=defualtFormatter(10,t.padding);let s=t.x,l=t.y;var t=t.targetSize||getWindowSize(),c=[a,t.width-o-a],t=[a,t.height-i-a];return"top-right"===e?(s+=r,l=l-i-n,s<c[0]?s=c[0]:s>c[1]&&(a=s-o-2*r,s=c[0]<a?a:c[1]),l<t[0]?(a=l+i+2*n,l=a<t[1]?a:t[0]):l>t[1]&&(l=l-i-2*n)):"bottom-right"===e?(s+=r,(l+=n)>t[1]&&(a=l-i-2*n,l=a<t[0]?t[1]:a),s>c[1]&&(t=s-o-2*r,s=t<c[0]?c[1]:t)):"top-left"===e&&(s=s-o-r,l=l-i-n),{x:s,y:l}}function hexToRgb(t){for(var e=[],o=1;o<7;o+=2)e.push(parseInt("0x"+t.slice(o,o+2)));return e}class TextRainCanvas{text="abcdefghijklmnopqrstuvwxyz";fontSize=14;color=[0,255,0];reverse=!1;isStop=!1;interval=100;width;height;fontLineHeight;count;oCanvas;ctx;timer;pointList=[];constructor(t,e){this.draw=this.draw.bind(this);var o=t.offsetWidth,i=t.offsetHeight;t.width=o,t.height=i,this.width=o,this.height=i,e&&(this.text=e.text||this.text,this.fontSize=e.fontSize||this.fontSize,this.color=e.color?hexToRgb(e.color):this.color,this.reverse=(null!=e.reverse?e:this).reverse,this.interval=e.interval||this.interval),this.oCanvas=t,this.ctx=t.getContext("2d"),this.fontLineHeight=1.2*this.fontSize,this.count=Math.ceil(this.height/this.fontLineHeight),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((t,e)=>{let o;this.reverse?(o=(e-i.currentIndex)/10,o=1-t.speed*o,e<i.currentIndex&&(o=0)):(o=(i.currentIndex-e)/10,o=1-t.speed*o,e>i.currentIndex&&(o=0)),0<o&&(this.ctx.fillStyle=`rgba(${this.color.join(",")}, ${o})`,this.ctx.fillText(t.text,t.x,t.y))}),this.reverse?(i.currentIndex--,i.currentIndex+10<0&&(i.currentIndex=this.count+getRandom(0,this.count))):(i.currentIndex++,i.currentIndex-10>i.list.length-1&&(i.currentIndex=-getRandom(0,this.count)))}),clearTimeout(this.timer),this.timer=setTimeout(this.draw,this.interval)}createColumn(e,t){const o=[];for(let t=0;t<this.count;t++){var i=getRandom(0,this.text.length-1);o.push({text:this.text[i],x:e,y:Math.floor(t*this.fontLineHeight),speed:1})}return{currentIndex:t,list:o}}dispose(){this.isStop=!0,clearTimeout(this.timer)}start(){this.isStop=!1,this.draw()}getPointList(){const i=[];var n=this.fontSize,t=Math.floor(this.width/n);for(let o=0;o<t;o++){let e=0;for(let t=0;t<this.count&&(t?e+=getRandom(e+10,this.count):e+=getRandom(e,10),!(e>this.count));t++)this.reverse?i.push(this.createColumn(o*n,this.count+e)):i.push(this.createColumn(o*n,-e))}return this.pointList=i}}class SeamlessRolling{_wrapper;_timer;constructor(t){this._wrapper=t,this._updateContent()}_updateContent(){const t=this._wrapper.children[0];var e=t.cloneNode(!0);this._wrapper.appendChild(e),console.log("firstNode",t,e)}_doScroll(){clearTimeout(this._timer),this._timer=setTimeout(()=>{},60)}dispose(){clearTimeout(this._timer)}}function func01(t){return navigator.clipboard.writeText(t)}async function func02(t){const e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}const copyText=$browserGlobal.navigator?.clipboard?.writeText?func01:func02;function rgbStringToList(t){t=t.replace(/^rgba\((.*)\)$/,"$1");const e=split(t,",");return e.map(function(t){return _Number(t)})}function getColorByRadio(t,e,o){o=Math.max(o,0),o=Math.min(o,1);var[t,i,n]=rgbStringToList(hexToRgba(t)),[e,r,a]=rgbStringToList(hexToRgba(e)),e=Math.round(t+(e-t)*o),t=Math.round(i+(r-i)*o),r=Math.round(n+(a-n)*o);return rgbaToHex(`rgba(${e},${t},${r},1)`)}function convertColors(e){e.sort(function(t,e){return t.data-e.data});const o=[];var t=min(e,function(t){return t.data}),i=max(e,function(t){return t.data}),n=i-t;let r=0;for(let t=1;t<e.length;t++){var a=e[t-1],s=e[t],l=(s.data-a.data)/n,c=r+l;o.push({from:{value:a.data,color:a.color,ratio:r},to:{value:s.data,color:s.color,ratio:c},ratio:l,label:a.data+"至"+s.data}),r=c}return{data:o,max:i,min:t}}class LinearGradientColorLegend{_cfg;_canvas;_colorList=[];_ctx;_minValue=0;_maxValue=0;constructor(t){this._cfg=Object.assign({fontSize:14,fontFamily:"Microsoft YaHei",tickWidth:5,paddingTop:10,paddingBottom:10,tickColor:"#92949b",fontColor:"#444",colors:[]},t),this.setColors(this._cfg.colors)}mount(t){this._canvas=t,this._ctx=t.getContext("2d"),this._draw()}_drawAxias(o,t){const i=this._ctx;var{fontFamily:e,fontSize:n,tickWidth:r,paddingTop:a,paddingBottom:s}=this._cfg,l=(i.font=n+"px "+e,3*n),c=t-s-a,h=Math.ceil(c/l),l=c/h;i.textBaseline="middle";let d=0;const u=[];for(let t=0;t<=h;t++){var f=(1-t/h)*(this._maxValue-this._minValue)+this._minValue,f=this._cfg.labelFormatter?this._cfg.labelFormatter(f):roundFixed(f,2),g=i.measureText(f);d=Math.max(g.width,d),u.push({label:f,width:g.width})}for(let e=0;e<u.length;e++){var m=u[e];let t=0;t=0===e?0:e===u.length-1?c-1:Math.floor(e*l),t+=a;var p=o-d-4-r;i.fillStyle=this._cfg.tickColor,i.fillRect(p,t,r,1),i.fillStyle=this._cfg.fontColor,i.fillText(m.label,p+r+4,t)}return{maxLabelWidth:4+d+r}}_draw(){if(!this._canvas||!this._ctx)return this;var{paddingTop:e,paddingBottom:t}=this._cfg,o=this._canvas.offsetWidth,i=this._canvas.offsetHeight,n=(this._canvas.width=o,this._canvas.height=i,this._ctx.clearRect(0,0,o,i),this._drawAxias(o,i))["maxLabelWidth"],r=i-e-t;for(let t=0;t<this._colorList.length;t++){var a=this._colorList[t],s=r*(1-a.to.ratio),l=r*(1-a.from.ratio),s=Math.ceil(s+e),l=Math.ceil(l+e);const c=this._ctx.createLinearGradient(0,s,0,l);c.addColorStop(1,a.from.color),c.addColorStop(0,a.to.color),this._ctx.fillStyle=c,this._ctx.fillRect(0,s,o-n,l-s)}}setColors(t){return t.length<2||(t=convertColors(t),this._colorList=t.data,this._minValue=t.min,this._maxValue=t.max,this._draw()),this}getColor(e){if(!this._colorList.length)return"#0000";!isNaN(e)&&"Number"===getType(e)||(e=this._colorList[0].from.value);var t=this._colorList.find(function(t){return e>=t.from.value&&e<t.to.value});let o;o=t||(e<this._colorList[0].from.value?this._colorList[0]:this._colorList[this._colorList.length-1]);t=e-o.from.value,t=Math.min(t/(o.to.value-o.from.value),1);return getColorByRadio(o.from.color,o.to.color,t)}}const textCanvas=document.createElement("canvas");function createRotatedRectCanvas(t){var e=t.angle*Math.PI/180;const i=textCanvas.getContext("2d");i.font=t.fontSize+"px "+t.fontFamily;let n=0;const r=[],a=(t.text.forEach(function(t){t=i.measureText(t);r.push(t.width),n=Math.max(t.width,n)}),t.fontSize*t.fontLineHeight),s=a*t.text.length;var o=Math.abs(n*Math.cos(e))+Math.abs(s*Math.sin(e)),l=Math.abs(n*Math.sin(e))+Math.abs(s*Math.cos(e));textCanvas.width=o,textCanvas.height=l,i.translate(o/2,l/2),i.rotate(e),i.fillStyle=t.fontBackgroundColor,i.fillRect(-n/2,-s/2,n,s),i.fillStyle=t.fontColor,i.font=t.fontSize+"px "+t.fontFamily,i.textBaseline="top",i.textAlign="left";const c=(a-t.fontSize)/2;return t.text.forEach(function(t,e){var o=n/2-r[e]/2;i.fillText(t,-n/2+o,-s/2+e*a+c)}),{img:textCanvas,width:o,height:l}}class WaterMark{_cfg;_oWrapper;_canvas;constructor(t,e){this._oWrapper=t,this._cfg=Object.assign({fontFamily:"Microsoft YaHei",fontLineHeight:1.4,gapX:20,gapY:0,fontBackgroundColor:"rgba(0,0,0,0)",angle:-45,text:["作者 bestime","2025-04-09"],fontSize:16,fontColor:"red"},e),this._canvas=this._reload(),this._draw()}_reload(){let t=this._canvas;return t||(t=document.createElement("canvas"),this._oWrapper.appendChild(t)),t}setConfig(t){Object.assign(this._cfg,t),this._draw()}_draw(){const t=this._reload();var o=this._oWrapper.offsetWidth*window.devicePixelRatio,i=this._oWrapper.offsetHeight*window.devicePixelRatio;t.width=o,t.height=i,t.style.cssText="position:absolute;left:0;top:0;right:0;bottom:0;z-index: 1;user-select: none;pointer-events: none;",t.style.width=this._oWrapper.offsetWidth+"px",t.style.height=this._oWrapper.offsetHeight+"px";const n=t.getContext("2d");if(n&&(n.clearRect(0,0,o,i),!this._cfg.disabled)){var r=createRotatedRectCanvas(this._cfg);for(let e=0;e<o;e+=r.width+this._cfg.gapX)for(let t=0;t<i;t+=r.height+this._cfg.gapY)n.drawImage(r.img,e,t)}}}function fillHtml(t,e){t.styleSheet?t.styleSheet.cssText=e:t.innerHTML=e}let id=0;function createStyle(t){id++,(t=trim(t))&&!/^[0-9]/.test(t)||(t="bt-style-"+id);var e,n="",o=document.createElement("style");return o.className=t,document.getElementsByTagName("head")[0].appendChild(o),function(t){var i;e=n,_String(t).replace(/(.*?)({.*?})/g,function(t,e,o){return e=trim(e),n=n.replace(new RegExp("("+e+"\\s*?)({.*?})","g"),function(){return i=!0,e+trim(o)}),""}),i?e!==n&&fillHtml(o,n):(n+=_String(t),fillHtml(o,n))}}const oStyle=createStyle("bt-waterflow");function getMinMatrix(t){const e=min(t,function(t){return t.height});var o=Math.max(t.findIndex(t=>t.height===e),0);return{index:o,position:t[o]}}oStyle(`
6
+ .bt-waterflow-wrapper{position:relative;list-style:none;margin:0;padding:0;box-sizing:border-box;}
7
+ .bt-waterflow-item{list-style:none;margin:0;padding:0;position:absolute;bottom:unset;right:unset;left:0;top:0;opacity:0;transition: 0.5s;transform:scale(0) rotateX(45deg);transform-origin:top center;}
8
+ .bt-waterflow-item.rendered{transform:scale(1) rotateX(0);opacity: 1;}
9
+ `);class WaterfallFlow{_cfg;_timer;constructor(t){this._cfg=Object.assign({gap:10},t),addClass(t.el,"bt-waterflow-wrapper")}_autoPlay(){clearTimeout(this._timer),this._cfg.autoResize&&(this._timer=setTimeout(()=>{this.resize()},this._cfg.autoResize))}resize(){clearTimeout(this._timer);var e=this._cfg.el.getElementsByClassName("bt-waterflow-item");if(0!==e.length){var t=this._cfg.el.offsetWidth,o=Math.max(1,Math.floor((t+this._cfg.gap)/(e[0].offsetWidth+this._cfg.gap)));const r=[];var i=(t-(o-1)*this._cfg.gap-e[0].offsetWidth*o)/2;for(let t=0;t<o;t++)r.push({height:0,data:[]});for(let t=0;t<e.length;t++){const a=e[t],s=getMinMatrix(r);var n=0<s.position.height?this._cfg.gap:0,n={left:i+(a.offsetWidth+this._cfg.gap)*s.index,top:s.position.height+n,height:a.offsetHeight};s.position.height=n.height+n.top,s.position.data.push(n),a.style.left=n.left+"px",a.style.top=n.top+"px",addClass(a,"rendered")}t=max(r,function(t){return t.height})??0;this._cfg.el.style.height=t+"px",this._autoPlay()}}pause(){return clearTimeout(this._timer),this}dispose(){clearTimeout(this._timer)}}const style=createStyle("bt-browser-core");export{LinearGradientColorLegend,SeamlessRolling,TextRainCanvas,WaterMark,WaterfallFlow,addClass,browser,copyText,createXLSX,downloadFileByArrayBuffer,downloadFileByBolb,downloadFileByUrl,fullScreen,getCookie,getJsFileBaseUrl,getRatio,getRelativePos,getStorage,getWindowSize,infoContainerPosition,libraryFile,observeDomResize,observeDomScroll,observeMouseWheel,pdfToImage,prevent,removeClass,removeCookie,removeElement,removeStorage,replaceClass,setCookie,setStorage,style,toggleClass};
@@ -19,7 +19,8 @@ declare function observeDomResize(
19
19
  element: HTMLElement,
20
20
  handler: (element: HTMLElement) => void,
21
21
  type?: ('width' | 'height' | 'position')[],
22
- interval?: number
22
+ interval?: number,
23
+ immediate?: boolean
23
24
  ): () => void;
24
25
 
25
26
  /**
@@ -194,7 +195,7 @@ type Direction = 1 | -1;
194
195
  * @param isPrevent 是否阻止原生滚动,仅用来获取滚动方向
195
196
  * @returns
196
197
  */
197
- declare function export_default$1(
198
+ declare function observeMouseWheel(
198
199
  el: HTMLElement,
199
200
  callback: (direction: Direction) => void,
200
201
  isPrevent: boolean
@@ -336,28 +337,13 @@ declare class TextRainCanvas {
336
337
 
337
338
  declare class SeamlessRolling {
338
339
  _wrapper: HTMLDivElement;
339
- _timer: number;
340
+ _timer: any;
340
341
  constructor(wraper: HTMLDivElement);
341
342
  _updateContent(): void;
342
343
  _doScroll(): void;
343
344
  dispose(): void;
344
345
  }
345
346
 
346
- type Tlanguage =
347
- | 'Microsoft Huihui - Chinese (Simplified, PRC)'
348
- | 'Microsoft Kangkang - Chinese (Simplified, PRC)'
349
- | 'Microsoft Kangkang - Chinese (Simplified, PRC)'
350
- | 'Microsoft Yaoyao - Chinese (Simplified, PRC)'
351
- | 'Google 한국의'
352
- | 'Google 日本語'
353
- | 'Google 粤語(香港)';
354
- declare function speakText(
355
- message: string,
356
- options: {
357
- language?: Tlanguage;
358
- }
359
- ): Promise<void>;
360
-
361
347
  declare function func01(text: string): Promise<void>;
362
348
  /**
363
349
  * 复制文本
@@ -376,6 +362,7 @@ interface IOptions$1 {
376
362
  fontColor: string;
377
363
  paddingTop: number;
378
364
  paddingBottom: number;
365
+ labelFormatter?: (data: number) => string;
379
366
  colors: IColorItem[];
380
367
  }
381
368
  interface IUseColorItem {
@@ -441,6 +428,29 @@ declare class WaterMark {
441
428
  _draw(): void;
442
429
  }
443
430
 
431
+ /**
432
+ * 将部分属性变为可选
433
+ */
434
+ type TPartialOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
435
+
436
+ interface IWaterfallFlowConfig {
437
+ el: HTMLElement;
438
+ gap: number;
439
+ /**
440
+ * 自动播放在第一次主动执行 resize 后生效(避免首次渲染过渡动画卡顿)
441
+ */
442
+ autoResize?: number;
443
+ }
444
+ declare class WaterfallFlow {
445
+ private _cfg;
446
+ private _timer;
447
+ constructor(config: TPartialOptional<IWaterfallFlowConfig, 'gap'>);
448
+ _autoPlay(): void;
449
+ resize(): void;
450
+ pause(): this;
451
+ dispose(): void;
452
+ }
453
+
444
454
  declare const style: (str: string) => void;
445
455
 
446
456
  declare global {
@@ -453,6 +463,7 @@ declare global {
453
463
  SeamlessRolling,
454
464
  TextRainCanvas,
455
465
  WaterMark,
466
+ WaterfallFlow,
456
467
  addClass,
457
468
  _default as browser,
458
469
  copyText,
@@ -471,7 +482,7 @@ declare global {
471
482
  libraryFile,
472
483
  observeDomResize,
473
484
  export_default as observeDomScroll,
474
- export_default$1 as observeMouseWheel,
485
+ observeMouseWheel,
475
486
  pdfToImage,
476
487
  prevent,
477
488
  removeClass,
@@ -481,7 +492,6 @@ declare global {
481
492
  replaceClass,
482
493
  setCookie,
483
494
  setStorage,
484
- speakText,
485
495
  style,
486
496
  toggleClass
487
497
  };
@@ -1,5 +1,9 @@
1
1
  /**
2
2
  * 浏览器工具库 => jUtilsBrowser
3
- * @update 2025-04-22 10:03:23
3
+ * @update 2026-01-17 22:11:46
4
4
  */
5
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@bestime/utils_base")):"function"==typeof define&&define.amd?define(["exports","@bestime/utils_base"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jUtilsBrowser={},t.jUtilsBase)}(this,function(t,v){"use strict";function h(){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 u={add:function(t,e){return i="HI-"+ ++n,r[i]={start:+new Date,current:0,handler:t,interval:e},o||(clearInterval(s),o=!0,s=setInterval(function(){for(var t in r){const e=r[t];e.current=+new Date,e.current-e.start>=e.interval&&(e.start=e.current,r[t].handler())}},17)),i},remove:function(t){delete r[t],0===Object.keys(r).length&&(o=!1,clearInterval(s),s=undefined)}};function a(t,e){const n=document.createElement("a");n.style.display="none",n.download=e,n.setAttribute("href",t),n.setAttribute("target","_blank"),n.setAttribute("download",e),document.body.appendChild(n),n.click(),n.remove()}const c=void 0,z=decodeURIComponent,d=window,f=document.getElementsByTagName("head")[0],l=d.URL;function m(t,e){t=l.createObjectURL(t);a(t,e),l.revokeObjectURL(t),undefined}const g={};function p(n,i){const o=[];let r=0;for(let e=0;e<n.length;e++)w(n[e],function(t){o[e]=t,++r===n.length&&i.apply(c,o)})}function w(t,e){var n=t.dependencies&&t.dependencies.length,i=t["with"]&&t["with"].length;g[t.url]||(g[t.url]={count:0,dependencies:!n,"with":!i,complete:!1,create:!1,url:t.url});const o=g[t.url];function r(){return d[t.module]}function s(){o.complete&&o.dependencies&&o["with"]&&(t.module?e(r()):e())}if(o.count++,!o.dependencies&&n)o.dependencies=!0,p(t.dependencies,function(){w(t,e)});else if(!o["with"]&&i)o["with"]=!0,p(t["with"].concat(t),s);else if(o.create)v.variableHasValue(function(){return o.complete},s,300);else{o.create=!0;var n=t.type,i=t.url,a=function(){o.complete=!0,t.interceptor&&t.interceptor(r()),s()},c=t.attribute;if(f){let t;if("js"===n?(t=document.createElement("script")).src=i:((t=document.createElement("link")).setAttribute("rel","stylesheet"),t.href=i),c)for(var l in c)t.setAttribute(l,c[l]);t.onload=t.onerror=a,f.appendChild(t)}}}function x(t,e){(t instanceof Array?p:w)(t,e)}function e(t,e,n){var i;i=e,e=i=v.isString(i)?i:JSON.stringify(i);let o=t+"="+encodeURI(e)+";path=/;";"number"==typeof n&&((i=new Date).setTime(i.getTime()+n),o+="expires="+i.toUTCString()),document.cookie=o}function b(e,t){v.isArray(t)?v.forEach(t,function(t){e.classList.remove(t)}):e.classList.remove(t)}function _(e,t){v.isArray(t)?v.forEach(t,function(t){e.classList.add(t)}):e.classList.add(t)}var y=d.navigator.userAgent,y={isChrome:/Chrome/.test(y),isIPhone:/iPhone/.test(y)};const S=t=>{};class ${text="abcdefghijklmnopqrstuvwxyz";fontSize=14;color=[0,255,0];reverse=!1;isStop=!1;interval=100;width;height;fontLineHeight;count;oCanvas;ctx;timer;pointList=[];constructor(t,e){this.draw=this.draw.bind(this);var n=t.offsetWidth,i=t.offsetHeight;t.width=n,t.height=i,this.width=n,this.height=i,e&&(this.text=e.text||this.text,this.fontSize=e.fontSize||this.fontSize,this.color=e.color?function(t){for(var e=[],n=1;n<7;n+=2)e.push(parseInt("0x"+t.slice(n,n+2)));return e}(e.color):this.color,this.reverse=(null!=e.reverse?e:this).reverse,this.interval=e.interval||this.interval),this.oCanvas=t,this.ctx=t.getContext("2d"),this.fontLineHeight=1.2*this.fontSize,this.count=Math.ceil(this.height/this.fontLineHeight),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((t,e)=>{let n;this.reverse?(n=(e-i.currentIndex)/10,n=1-t.speed*n,e<i.currentIndex&&(n=0)):(n=(i.currentIndex-e)/10,n=1-t.speed*n,e>i.currentIndex&&(n=0)),0<n&&(this.ctx.fillStyle=`rgba(${this.color.join(",")}, ${n})`,this.ctx.fillText(t.text,t.x,t.y))}),this.reverse?(i.currentIndex--,i.currentIndex+10<0&&(i.currentIndex=this.count+v.getRandom(0,this.count))):(i.currentIndex++,i.currentIndex-10>i.list.length-1&&(i.currentIndex=-v.getRandom(0,this.count)))}),clearTimeout(this.timer),this.timer=setTimeout(this.draw,this.interval)}createColumn(e,t){const n=[];for(let t=0;t<this.count;t++){var i=v.getRandom(0,this.text.length-1);n.push({text:this.text[i],x:e,y:Math.floor(t*this.fontLineHeight),speed:1})}return{currentIndex:t,list:n}}dispose(){this.isStop=!0,clearTimeout(this.timer)}start(){this.isStop=!1,this.draw()}getPointList(){const i=[];var o=this.fontSize,t=Math.floor(this.width/o);for(let n=0;n<t;n++){let e=0;for(let t=0;t<this.count&&(t?e+=v.getRandom(e+10,this.count):e+=v.getRandom(e,10),!(e>this.count));t++)this.reverse?i.push(this.createColumn(n*o,this.count+e)):i.push(this.createColumn(n*o,-e))}return this.pointList=i}}class j{_wrapper;_timer=-1;constructor(t){this._wrapper=t,this._updateContent()}_updateContent(){const t=this._wrapper.children[0];var e=t.cloneNode(!0);this._wrapper.appendChild(e),console.log("firstNode",t,e)}_doScroll(){clearTimeout(this._timer),this._timer=setTimeout(()=>{},60)}dispose(){clearTimeout(this._timer)}}var C=window.speechSynthesis,L=new SpeechSynthesisUtterance;let T=[];function E(t){T=C.getVoices()}C.addEventListener("voiceschanged",E),window.addEventListener("beforeunload",function(t){return C.cancel(),C.removeEventListener("voiceschanged",E),!1});var P=d.navigator?.clipboard?.writeText?function(t){return navigator.clipboard.writeText(t)}:async function(t){const e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)};function R(t){t=t.replace(/^rgba\((.*)\)$/,"$1");const e=v.split(t,",");return e.map(function(t){return v._Number(t)})}class A{_cfg;_canvas;_colorList=[];_ctx;_minValue=0;_maxValue=0;constructor(t){this._cfg=Object.assign({fontSize:14,fontFamily:"Microsoft YaHei",tickWidth:5,paddingTop:10,paddingBottom:10,tickColor:"#92949b",fontColor:"#444",colors:[]},t),this.setColors(this._cfg.colors)}mount(t){this._canvas=t,this._ctx=t.getContext("2d"),this._draw()}_drawAxias(n,t){const i=this._ctx;var{fontFamily:e,fontSize:o,tickWidth:r,paddingTop:s,paddingBottom:a}=this._cfg,c=(i.font=o+"px "+e,3*o),l=t-a-s,h=Math.ceil(l/c),c=l/h;i.textBaseline="middle";let u=0;const d=[];for(let t=0;t<=h;t++){var f=1-t/h,f=v.roundFixed(f*(this._maxValue-this._minValue)+this._minValue,2),m=i.measureText(f);u=Math.max(m.width,u),d.push({label:f,width:m.width})}for(let e=0;e<d.length;e++){var g=d[e];let t=0;t=0===e?0:e===d.length-1?l-1:Math.floor(e*c),t+=s;var p=n-u-4-r;i.fillStyle=this._cfg.tickColor,i.fillRect(p,t,r,1),i.fillStyle=this._cfg.fontColor,i.fillText(g.label,p+r+4,t)}return{maxLabelWidth:4+u+r}}_draw(){if(!this._canvas||!this._ctx)return this;var{paddingTop:e,paddingBottom:t}=this._cfg,n=this._canvas.offsetWidth,i=this._canvas.offsetHeight,o=(this._canvas.width=n,this._canvas.height=i,this._ctx.clearRect(0,0,n,i),this._drawAxias(n,i))["maxLabelWidth"],r=i-e-t;for(let t=0;t<this._colorList.length;t++){var s=this._colorList[t],a=r*(1-s.to.ratio),c=r*(1-s.from.ratio),a=Math.ceil(a+e),c=Math.ceil(c+e);const l=this._ctx.createLinearGradient(0,a,0,c);l.addColorStop(1,s.from.color),l.addColorStop(0,s.to.color),this._ctx.fillStyle=l,this._ctx.fillRect(0,a,n-o,c-a)}}setColors(t){return t.length<2||(t=function(e){e.sort(function(t,e){return t.data-e.data});const n=[];var t=v.min(e,function(t){return t.data}),i=v.max(e,function(t){return t.data}),o=i-t;let r=0;for(let t=1;t<e.length;t++){var s=e[t-1],a=e[t],c=(a.data-s.data)/o,l=r+c;n.push({from:{value:s.data,color:s.color,ratio:r},to:{value:a.data,color:a.color,ratio:l},ratio:c,label:s.data+"至"+a.data}),r=l}return console.log("转换",n),{data:n,max:i,min:t}}(t),this._colorList=t.data,this._minValue=t.min,this._maxValue=t.max,this._draw()),this}getColor(e){if(!this._colorList.length)return"#0000";!isNaN(e)&&"Number"===v.getType(e)||(e=this._colorList[0].from.value);var t=this._colorList.find(function(t){return e>=t.from.value&&e<t.to.value})??this._colorList[this._colorList.length-1],n=Math.min(e/(t.to.value-t.from.value),1),i=t.from.color,t=t.to.color,[i,o,r]=(n=Math.min(n,1),R(v.hexToRgba(i))),[t,s,a]=R(v.hexToRgba(t)),t=Math.round(i+(t-i)*n),i=Math.round(o+(s-o)*n),s=Math.round(r+(a-r)*n);return v.rgbaToHex(`rgba(${t},${i},${s},1)`)}}const M=document.createElement("canvas");class N{_cfg;_oWrapper;_canvas;constructor(t,e){this._oWrapper=t,this._cfg=Object.assign({fontFamily:"Microsoft YaHei",fontLineHeight:1.4,gapX:20,gapY:0,fontBackgroundColor:"rgba(0,0,0,0)",angle:-45,text:["作者 bestime","2025-04-09"],fontSize:16,fontColor:"red"},e),this._canvas=this._reload(),this._draw()}_reload(){let t=this._canvas;return t||(t=document.createElement("canvas"),this._oWrapper.appendChild(t)),t}setConfig(t){Object.assign(this._cfg,t),this._draw()}_draw(){const t=this._reload();var n=this._oWrapper.offsetWidth*window.devicePixelRatio,i=this._oWrapper.offsetHeight*window.devicePixelRatio;t.width=n,t.height=i,t.style.cssText="position:absolute;left:0;top:0;right:0;bottom:0;z-index: 1;user-select: none;pointer-events: none;",t.style.width=this._oWrapper.offsetWidth+"px",t.style.height=this._oWrapper.offsetHeight+"px";const o=t.getContext("2d");if(o&&(o.clearRect(0,0,n,i),!this._cfg.disabled)){var r=function(t){var e=t.angle*Math.PI/180;const i=M.getContext("2d");i.font=t.fontSize+"px "+t.fontFamily;let o=0;const r=[],s=(t.text.forEach(function(t){t=i.measureText(t);r.push(t.width),o=Math.max(t.width,o)}),t.fontSize*t.fontLineHeight),a=s*t.text.length;var n=Math.abs(o*Math.cos(e))+Math.abs(a*Math.sin(e)),c=Math.abs(o*Math.sin(e))+Math.abs(a*Math.cos(e));M.width=n,M.height=c,i.translate(n/2,c/2),i.rotate(e),i.fillStyle=t.fontBackgroundColor,i.fillRect(-o/2,-a/2,o,a),i.fillStyle=t.fontColor,i.font=t.fontSize+"px "+t.fontFamily,i.textBaseline="top",i.textAlign="left";const l=(s-t.fontSize)/2;return t.text.forEach(function(t,e){var n=o/2-r[e]/2;i.fillText(t,-o/2+n,-a/2+e*s+l)}),{img:M,width:n,height:c}}(this._cfg);for(let e=0;e<n;e+=r.width+this._cfg.gapX)for(let t=0;t<i;t+=r.height+this._cfg.gapY)o.drawImage(r.img,e,t)}}}function F(t,e){t.styleSheet?t.styleSheet.cssText=e:t.innerHTML=e}let H=0;B="bt-browser-core",H++,(B=v.trim(B))&&!/^[0-9]/.test(B)||(B="bt-style-"+H),W="",(I=document.createElement("style")).className=B,document.getElementsByTagName("head")[0].appendChild(I);var k,W,I,B=function(t){var i;k=W,v._String(t).replace(/(.*?)({.*?})/g,function(t,e,n){return e=v.trim(e),W=W.replace(new RegExp("("+e+"\\s*?)({.*?})","g"),function(){return i=!0,e+v.trim(n)}),""}),i?k!==W&&F(I,W):(W+=v._String(t),F(I,W))};t.LinearGradientColorLegend=A,t.SeamlessRolling=j,t.TextRainCanvas=$,t.WaterMark=N,t.addClass=_,t.browser=y,t.copyText=P,t.createXLSX=async function(t){const e=document.createElement("table"),n=v.parseTreeToTableHeader(t.header);var i=n.data.map(function(t){return`<tr>${t.map(function(t){if(t&&0!==t.colSpan)return`<td align="center" rowSpan="${t.rowSpan}" colSpan="${t.colSpan}">${t?.title}</td>`}).join("")}</tr>`}).join(""),t=t.body.map(function(i){return`<tr>${n.columns.map(function(t){var e=i.$colField?.[t]??1,n=i.$rowSpan?.[t]??1;if(0!==e&&0!==n)return`<td align="center" colSpan="${e}" rowSpan="${n}">${i[t]??""}</td>`}).filter(function(t){return!v.isNull(t)}).join("")}</tr>`}).join("");return e.innerHTML=`<thead>${i}</thead><tbody>${t}</tbody>`,e.setAttribute("border","1"),e},t.downloadFileByArrayBuffer=function(t,e){m(new Blob([t]),e)},t.downloadFileByBolb=m,t.downloadFileByUrl=a,t.fullScreen=function(t,e,n){if(e){e=t;t=n;const i=t||S;e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullScreen?e.webkitRequestFullScreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen(),i(!0)}else{t=n;const o=t||S,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))}},t.getCookie=function(t,e){e=e||document.cookie;let i="";return e.replace(new RegExp("(^|;\\s?)"+t+"=(.*?)($|(;\\s?))"),function(t,e,n){i=z(n)}),i},t.getJsFileBaseUrl=function(t){t=t||0;for(var e="/[^/]*",n=document.scripts,i=0;i<t;i++)e+=e;return n[n.length-1].src.replace(new RegExp(e+"$"),"")},t.getRatio=function(){return window.devicePixelRatio||1},t.getRelativePos=function(t){var e=t.getBoundingClientRect();return{x:e.left,y:e.top,height:t.offsetHeight,width:t.offsetWidth,clientWidth:t.clientWidth,clientHeight:t.clientHeight}},t.getStorage=function(t){return t=localStorage.getItem(t),v.defualtFormatter("",t)},t.getWindowSize=h,t.infoContainerPosition=function(t){var e=t.mode||"top-right",n=t.width,i=t.height,o=v.defualtFormatter(10,t.offsetY),r=v.defualtFormatter(10,t.offsetX),s=v.defualtFormatter(10,t.padding);let a=t.x,c=t.y;var t=t.targetSize||h(),l=[s,t.width-n-s],t=[s,t.height-i-s];return"top-right"===e?(a+=r,c=c-i-o,a<l[0]?a=l[0]:a>l[1]&&(s=a-n-2*r,a=l[0]<s?s:l[1]),c<t[0]?(s=c+i+2*o,c=s<t[1]?s:t[0]):c>t[1]&&(c=c-i-2*o)):"bottom-right"===e?(a+=r,(c+=o)>t[1]&&(s=c-i-2*o,c=s<t[0]?t[1]:s),a>l[1]&&(t=a-n-2*r,a=t<l[0]?l[1]:t)):"top-left"===e&&(a=a-n-r,c=c-i-o),{x:a,y:c}},t.libraryFile=x,t.observeDomResize=function(n,i,o,t){let r=[0,0,!1],s=[0,0,!1],a=[0,0,!1],c=[0,0,!1];const e=u.add(l,t=t||500);function l(){if(document.body.contains(n)){let t=!1;var e;o?.includes("position")&&(e=n.getBoundingClientRect(),a[0]=e.left,a[2]=a[0]!==a[1],c[0]=e.top,c[2]=c[0]!==c[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")&&(t=!0)),s[2]&&(s[1]=s[0],o?.includes("height")&&(t=!0)),(c[2]||a[2])&&(c[1]=c[0],a[1]=a[0],o?.includes("position")&&(t=!0)),o&&0!==o.length||(r[2]||s[2]||c[2]||a[2])&&(t=!0),t&&i(n)}else h()}function h(){u.remove(e),r=undefined,s=undefined}return l(),h},t.observeDomScroll=function(n,t){const i=v._KvPair(t),o=v._Number(i.offetY);let r=!1,s=0;function e(){var t,e;r||(e=(t=n.scrollTop)-s,s=t,0!=e?e<0&&i.onTop&&t<=0+o?(r=!0,i.onTop(function(){r=!1})):0<e&&i.onBottom&&t>=n.scrollHeight-n.offsetHeight-o?(r=!0,i.onBottom(function(){r=!1})):r=!1:(r=!1,console.log("未处理")))}return n.addEventListener("scroll",e),{dispose:function(){n.removeEventListener("scroll",e)}}},t.observeMouseWheel=function(t,n,i){function e(t){let e;if(e=t.wheelDelta?0<t.wheelDelta?1:-1:t.detail<0?1:-1,n(e),i)return t.preventDefault&&t.preventDefault(),!1}return t.addEventListener("mousewheel",e),t.addEventListener("DOMMouseScroll",e),{dispose:function(){t.removeEventListener("mousewheel",e),t.removeEventListener("DOMMouseScroll",e)}}},t.pdfToImage=async function(t,o,e){i=e;const n=await new Promise(function(t){x({type:"js",module:"pdfjsLib",attribute:{type:"module"},url:i.index,interceptor:function(t){t.GlobalWorkerOptions.workerSrc=i.worker}},t)});var i;return new Promise(function(i){n.getDocument(t).promise.then(function(t){console.log("pdf",t),t.getPage(1).then(function(t){var e=t.getViewport({scale:1}),n=o.getContext("2d");o.height=e.height,o.width=e.width,t.render({canvasContext:n,viewport:e}).promise.then(function(){i({width:e.width,height:e.height})})})},function(t){console.error(t),i({width:0,height:0})})})},t.prevent=function(t,e,n){t=t||d.event,n=!1!==n,(e=!1!==e)&&d.event?d.event.cancelBubble=!0:t.stopPropagation(),n&&d.event?d.event.returnValue=!1:t.preventDefault()},t.removeClass=b,t.removeCookie=function(t){e(t,"",-1)},t.removeElement=function(t){t.parentNode&&t.parentNode.removeChild(t)},t.removeStorage=function(t){localStorage.removeItem(t)},t.replaceClass=function(t,e,n){b(t,e),_(t,n)},t.setCookie=e,t.setStorage=function(t,e){localStorage.setItem(t,(t=e,t=v.isString(t)?t:JSON.stringify(t)))},t.speakText=async function(t,e){C.cancel(),L.rate=1,L.pitch=1,await v.variableHasValue["async"](function(){return 0<T.length});var n=T.find(t=>v.trim(t.name,"*")===v.trim(e.language,"*"))||T[0];L.lang=n.lang,await async function(i){function o(t){console.log("朗读错误",t)}L.addEventListener("error",o);let r;return new Promise(function(t){function e(){clearTimeout(r),C.cancel(),L.removeEventListener("error",o),L.removeEventListener("start",e),t()}!function n(){L.voice=i,L.text=1..toString(),C.speak(L),clearTimeout(r),L.removeEventListener("start",e),L.addEventListener("start",e),r=setTimeout(n,1e3)}()})}(n),L.text=t,C.speak(L)},t.style=B,t.toggleClass=function(e,t){v.isArray(t)?v.forEach(t,function(t){e.classList.toggle(t)}):e.classList.toggle(t)}});
5
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@bestime/utils_base")):"function"==typeof define&&define.amd?define(["exports","@bestime/utils_base"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jUtilsBrowser={},t.jUtilsBase)}(this,function(t,v){"use strict";function h(){return{width:document.documentElement.clientWidth||document.body.clientWidth||window.innerWidth||0,height:document.documentElement.clientHeight||document.body.clientHeight||window.innerHeight||0}}let i=0,n,o=!1;const r={};let s;var d={add:function(t,e){return n="HI-"+ ++i,r[n]={start:+new Date,current:0,handler:t,interval:e},o||(clearInterval(s),o=!0,s=setInterval(function(){for(var t in r){const e=r[t];e.current=+new Date,e.current-e.start>=e.interval&&(e.start=e.current,r[t].handler())}},17)),n},remove:function(t){delete r[t],0===Object.keys(r).length&&(o=!1,clearInterval(s),s=undefined)}};function a(t,e){const i=document.createElement("a");i.style.display="none",i.download=e,i.setAttribute("href",t),i.setAttribute("target","_blank"),i.setAttribute("download",e),document.body.appendChild(i),i.click(),i.remove()}const l=void 0,c=decodeURIComponent,u=window,f=document.getElementsByTagName("head")[0],g=u.URL;function m(t,e){t=g.createObjectURL(t);a(t,e),g.revokeObjectURL(t),undefined}const p={};function x(i,n){const o=[];let r=0;for(let e=0;e<i.length;e++)w(i[e],function(t){o[e]=t,++r===i.length&&n.apply(l,o)})}function w(t,e){var i=t.dependencies&&t.dependencies.length,n=t["with"]&&t["with"].length;p[t.url]||(p[t.url]={count:0,dependencies:!i,"with":!n,complete:!1,create:!1,url:t.url});const o=p[t.url];function r(){return u[t.module]}function s(){o.complete&&o.dependencies&&o["with"]&&(t.module?e(r()):e())}if(o.count++,!o.dependencies&&i)o.dependencies=!0,x(t.dependencies,function(){w(t,e)});else if(!o["with"]&&n)o["with"]=!0,x(t["with"].concat(t),s);else if(o.create)v.variableHasValue(function(){return o.complete},s,300);else{o.create=!0;var i=t.type,n=t.url,a=function(){o.complete=!0,t.interceptor&&t.interceptor(r()),s()},l=t.attribute;if(f){let t;if("js"===i?(t=document.createElement("script")).src=n:((t=document.createElement("link")).setAttribute("rel","stylesheet"),t.href=n),l)for(var c in l)t.setAttribute(c,l[c]);t.onload=t.onerror=a,f.appendChild(t)}}}function _(t,e){(t instanceof Array?x:w)(t,e)}function e(t,e,i){var n;n=e,e=n=v.isString(n)?n:JSON.stringify(n);let o=t+"="+encodeURI(e)+";path=/;";"number"==typeof i&&((n=new Date).setTime(n.getTime()+i),o+="expires="+n.toUTCString()),document.cookie=o}function b(e,t){v.isArray(t)?v.forEach(t,function(t){e.classList.remove(t)}):e.classList.remove(t)}function y(e,t){v.isArray(t)?v.forEach(t,function(t){e.classList.add(t)}):e.classList.add(t)}var S=u.navigator.userAgent,S={isChrome:/Chrome/.test(S),isIPhone:/iPhone/.test(S)};const C=t=>{};class L{text="abcdefghijklmnopqrstuvwxyz";fontSize=14;color=[0,255,0];reverse=!1;isStop=!1;interval=100;width;height;fontLineHeight;count;oCanvas;ctx;timer;pointList=[];constructor(t,e){this.draw=this.draw.bind(this);var i=t.offsetWidth,n=t.offsetHeight;t.width=i,t.height=n,this.width=i,this.height=n,e&&(this.text=e.text||this.text,this.fontSize=e.fontSize||this.fontSize,this.color=e.color?function(t){for(var e=[],i=1;i<7;i+=2)e.push(parseInt("0x"+t.slice(i,i+2)));return e}(e.color):this.color,this.reverse=(null!=e.reverse?e:this).reverse,this.interval=e.interval||this.interval),this.oCanvas=t,this.ctx=t.getContext("2d"),this.fontLineHeight=1.2*this.fontSize,this.count=Math.ceil(this.height/this.fontLineHeight),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(n=>{n.list.forEach((t,e)=>{let i;this.reverse?(i=(e-n.currentIndex)/10,i=1-t.speed*i,e<n.currentIndex&&(i=0)):(i=(n.currentIndex-e)/10,i=1-t.speed*i,e>n.currentIndex&&(i=0)),0<i&&(this.ctx.fillStyle=`rgba(${this.color.join(",")}, ${i})`,this.ctx.fillText(t.text,t.x,t.y))}),this.reverse?(n.currentIndex--,n.currentIndex+10<0&&(n.currentIndex=this.count+v.getRandom(0,this.count))):(n.currentIndex++,n.currentIndex-10>n.list.length-1&&(n.currentIndex=-v.getRandom(0,this.count)))}),clearTimeout(this.timer),this.timer=setTimeout(this.draw,this.interval)}createColumn(e,t){const i=[];for(let t=0;t<this.count;t++){var n=v.getRandom(0,this.text.length-1);i.push({text:this.text[n],x:e,y:Math.floor(t*this.fontLineHeight),speed:1})}return{currentIndex:t,list:i}}dispose(){this.isStop=!0,clearTimeout(this.timer)}start(){this.isStop=!1,this.draw()}getPointList(){const n=[];var o=this.fontSize,t=Math.floor(this.width/o);for(let i=0;i<t;i++){let e=0;for(let t=0;t<this.count&&(t?e+=v.getRandom(e+10,this.count):e+=v.getRandom(e,10),!(e>this.count));t++)this.reverse?n.push(this.createColumn(i*o,this.count+e)):n.push(this.createColumn(i*o,-e))}return this.pointList=n}}class T{_wrapper;_timer;constructor(t){this._wrapper=t,this._updateContent()}_updateContent(){const t=this._wrapper.children[0];var e=t.cloneNode(!0);this._wrapper.appendChild(e),console.log("firstNode",t,e)}_doScroll(){clearTimeout(this._timer),this._timer=setTimeout(()=>{},60)}dispose(){clearTimeout(this._timer)}}var R=u.navigator?.clipboard?.writeText?function(t){return navigator.clipboard.writeText(t)}:async function(t){const e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)};function M(t){t=t.replace(/^rgba\((.*)\)$/,"$1");const e=v.split(t,",");return e.map(function(t){return v._Number(t)})}class F{_cfg;_canvas;_colorList=[];_ctx;_minValue=0;_maxValue=0;constructor(t){this._cfg=Object.assign({fontSize:14,fontFamily:"Microsoft YaHei",tickWidth:5,paddingTop:10,paddingBottom:10,tickColor:"#92949b",fontColor:"#444",colors:[]},t),this.setColors(this._cfg.colors)}mount(t){this._canvas=t,this._ctx=t.getContext("2d"),this._draw()}_drawAxias(i,t){const n=this._ctx;var{fontFamily:e,fontSize:o,tickWidth:r,paddingTop:s,paddingBottom:a}=this._cfg,l=(n.font=o+"px "+e,3*o),c=t-a-s,h=Math.ceil(c/l),l=c/h;n.textBaseline="middle";let u=0;const d=[];for(let t=0;t<=h;t++){var f=(1-t/h)*(this._maxValue-this._minValue)+this._minValue,f=this._cfg.labelFormatter?this._cfg.labelFormatter(f):v.roundFixed(f,2),g=n.measureText(f);u=Math.max(g.width,u),d.push({label:f,width:g.width})}for(let e=0;e<d.length;e++){var m=d[e];let t=0;t=0===e?0:e===d.length-1?c-1:Math.floor(e*l),t+=s;var p=i-u-4-r;n.fillStyle=this._cfg.tickColor,n.fillRect(p,t,r,1),n.fillStyle=this._cfg.fontColor,n.fillText(m.label,p+r+4,t)}return{maxLabelWidth:4+u+r}}_draw(){if(!this._canvas||!this._ctx)return this;var{paddingTop:e,paddingBottom:t}=this._cfg,i=this._canvas.offsetWidth,n=this._canvas.offsetHeight,o=(this._canvas.width=i,this._canvas.height=n,this._ctx.clearRect(0,0,i,n),this._drawAxias(i,n))["maxLabelWidth"],r=n-e-t;for(let t=0;t<this._colorList.length;t++){var s=this._colorList[t],a=r*(1-s.to.ratio),l=r*(1-s.from.ratio),a=Math.ceil(a+e),l=Math.ceil(l+e);const c=this._ctx.createLinearGradient(0,a,0,l);c.addColorStop(1,s.from.color),c.addColorStop(0,s.to.color),this._ctx.fillStyle=c,this._ctx.fillRect(0,a,i-o,l-a)}}setColors(t){return t.length<2||(t=function(e){e.sort(function(t,e){return t.data-e.data});const i=[];var t=v.min(e,function(t){return t.data}),n=v.max(e,function(t){return t.data}),o=n-t;let r=0;for(let t=1;t<e.length;t++){var s=e[t-1],a=e[t],l=(a.data-s.data)/o,c=r+l;i.push({from:{value:s.data,color:s.color,ratio:r},to:{value:a.data,color:a.color,ratio:c},ratio:l,label:s.data+"至"+a.data}),r=c}return{data:i,max:n,min:t}}(t),this._colorList=t.data,this._minValue=t.min,this._maxValue=t.max,this._draw()),this}getColor(e){if(!this._colorList.length)return"#0000";!isNaN(e)&&"Number"===v.getType(e)||(e=this._colorList[0].from.value);var t=this._colorList.find(function(t){return e>=t.from.value&&e<t.to.value});let i;i=t||(e<this._colorList[0].from.value?this._colorList[0]:this._colorList[this._colorList.length-1]);var t=e-i.from.value,t=Math.min(t/(i.to.value-i.from.value),1),n=i.from.color,o=i.to.color,[n,r,s]=(t=Math.max(t,0),t=Math.min(t,1),M(v.hexToRgba(n))),[o,a,l]=M(v.hexToRgba(o)),o=Math.round(n+(o-n)*t),n=Math.round(r+(a-r)*t),a=Math.round(s+(l-s)*t);return v.rgbaToHex(`rgba(${o},${n},${a},1)`)}}const E=document.createElement("canvas");class W{_cfg;_oWrapper;_canvas;constructor(t,e){this._oWrapper=t,this._cfg=Object.assign({fontFamily:"Microsoft YaHei",fontLineHeight:1.4,gapX:20,gapY:0,fontBackgroundColor:"rgba(0,0,0,0)",angle:-45,text:["作者 bestime","2025-04-09"],fontSize:16,fontColor:"red"},e),this._canvas=this._reload(),this._draw()}_reload(){let t=this._canvas;return t||(t=document.createElement("canvas"),this._oWrapper.appendChild(t)),t}setConfig(t){Object.assign(this._cfg,t),this._draw()}_draw(){const t=this._reload();var i=this._oWrapper.offsetWidth*window.devicePixelRatio,n=this._oWrapper.offsetHeight*window.devicePixelRatio;t.width=i,t.height=n,t.style.cssText="position:absolute;left:0;top:0;right:0;bottom:0;z-index: 1;user-select: none;pointer-events: none;",t.style.width=this._oWrapper.offsetWidth+"px",t.style.height=this._oWrapper.offsetHeight+"px";const o=t.getContext("2d");if(o&&(o.clearRect(0,0,i,n),!this._cfg.disabled)){var r=function(t){var e=t.angle*Math.PI/180;const n=E.getContext("2d");n.font=t.fontSize+"px "+t.fontFamily;let o=0;const r=[],s=(t.text.forEach(function(t){t=n.measureText(t);r.push(t.width),o=Math.max(t.width,o)}),t.fontSize*t.fontLineHeight),a=s*t.text.length;var i=Math.abs(o*Math.cos(e))+Math.abs(a*Math.sin(e)),l=Math.abs(o*Math.sin(e))+Math.abs(a*Math.cos(e));E.width=i,E.height=l,n.translate(i/2,l/2),n.rotate(e),n.fillStyle=t.fontBackgroundColor,n.fillRect(-o/2,-a/2,o,a),n.fillStyle=t.fontColor,n.font=t.fontSize+"px "+t.fontFamily,n.textBaseline="top",n.textAlign="left";const c=(s-t.fontSize)/2;return t.text.forEach(function(t,e){var i=o/2-r[e]/2;n.fillText(t,-o/2+i,-a/2+e*s+c)}),{img:E,width:i,height:l}}(this._cfg);for(let e=0;e<i;e+=r.width+this._cfg.gapX)for(let t=0;t<n;t+=r.height+this._cfg.gapY)o.drawImage(r.img,e,t)}}}function H(t,e){t.styleSheet?t.styleSheet.cssText=e:t.innerHTML=e}let z=0;function I(t){z++,(t=v.trim(t))&&!/^[0-9]/.test(t)||(t="bt-style-"+z);var e,o="",i=document.createElement("style");return i.className=t,document.getElementsByTagName("head")[0].appendChild(i),function(t){var n;e=o,v._String(t).replace(/(.*?)({.*?})/g,function(t,e,i){return e=v.trim(e),o=o.replace(new RegExp("("+e+"\\s*?)({.*?})","g"),function(){return n=!0,e+v.trim(i)}),""}),n?e!==o&&H(i,o):(o+=v._String(t),H(i,o))}}const k=I("bt-waterflow");k(`
6
+ .bt-waterflow-wrapper{position:relative;list-style:none;margin:0;padding:0;box-sizing:border-box;}
7
+ .bt-waterflow-item{list-style:none;margin:0;padding:0;position:absolute;bottom:unset;right:unset;left:0;top:0;opacity:0;transition: 0.5s;transform:scale(0) rotateX(45deg);transform-origin:top center;}
8
+ .bt-waterflow-item.rendered{transform:scale(1) rotateX(0);opacity: 1;}
9
+ `);class B{_cfg;_timer;constructor(t){this._cfg=Object.assign({gap:10},t),y(t.el,"bt-waterflow-wrapper")}_autoPlay(){clearTimeout(this._timer),this._cfg.autoResize&&(this._timer=setTimeout(()=>{this.resize()},this._cfg.autoResize))}resize(){clearTimeout(this._timer);var e=this._cfg.el.getElementsByClassName("bt-waterflow-item");if(0!==e.length){var t=this._cfg.el.offsetWidth,i=Math.max(1,Math.floor((t+this._cfg.gap)/(e[0].offsetWidth+this._cfg.gap)));const r=[];var n=(t-(i-1)*this._cfg.gap-e[0].offsetWidth*i)/2;for(let t=0;t<i;t++)r.push({height:0,data:[]});for(let t=0;t<e.length;t++){const s=e[t],a=function(t){const e=v.min(t,function(t){return t.height});var i=Math.max(t.findIndex(t=>t.height===e),0);return{index:i,position:t[i]}}(r);var o=0<a.position.height?this._cfg.gap:0,o={left:n+(s.offsetWidth+this._cfg.gap)*a.index,top:a.position.height+o,height:s.offsetHeight};a.position.height=o.height+o.top,a.position.data.push(o),s.style.left=o.left+"px",s.style.top=o.top+"px",y(s,"rendered")}t=v.max(r,function(t){return t.height})??0;this._cfg.el.style.height=t+"px",this._autoPlay()}}pause(){return clearTimeout(this._timer),this}dispose(){clearTimeout(this._timer)}}var $=I("bt-browser-core");t.LinearGradientColorLegend=F,t.SeamlessRolling=T,t.TextRainCanvas=L,t.WaterMark=W,t.WaterfallFlow=B,t.addClass=y,t.browser=S,t.copyText=R,t.createXLSX=async function(t){const e=document.createElement("table"),i=v.parseTreeToTableHeader(t.header);var n=i.data.map(function(t){return`<tr>${t.map(function(t){if(t&&0!==t.colSpan)return`<td align="center" rowSpan="${t.rowSpan}" colSpan="${t.colSpan}">${t?.title}</td>`}).join("")}</tr>`}).join(""),t=t.body.map(function(n){return`<tr>${i.columns.map(function(t){var e=n.$colField?.[t]??1,i=n.$rowSpan?.[t]??1;if(0!==e&&0!==i)return`<td align="center" colSpan="${e}" rowSpan="${i}">${n[t]??""}</td>`}).filter(function(t){return!v.isNull(t)}).join("")}</tr>`}).join("");return e.innerHTML=`<thead>${n}</thead><tbody>${t}</tbody>`,e.setAttribute("border","1"),e},t.downloadFileByArrayBuffer=function(t,e){m(new Blob([t]),e)},t.downloadFileByBolb=m,t.downloadFileByUrl=a,t.fullScreen=function(t,e,i){if(e){e=t;t=i;const n=t||C;e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullScreen?e.webkitRequestFullScreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen(),n(!0)}else{t=i;const o=t||C,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))}},t.getCookie=function(t,e){e=e||document.cookie;let n="";return e.replace(new RegExp("(^|;\\s?)"+t+"=(.*?)($|(;\\s?))"),function(t,e,i){n=c(i)}),n},t.getJsFileBaseUrl=function(t){t=t||0;for(var e="/[^/]*",i=document.scripts,n=0;n<t;n++)e+=e;return i[i.length-1].src.replace(new RegExp(e+"$"),"")},t.getRatio=function(){return window.devicePixelRatio||1},t.getRelativePos=function(t){var e=t.getBoundingClientRect();return{x:e.left,y:e.top,height:t.offsetHeight,width:t.offsetWidth,clientWidth:t.clientWidth,clientHeight:t.clientHeight}},t.getStorage=function(t){return t=localStorage.getItem(t),v.defualtFormatter("",t)},t.getWindowSize=h,t.infoContainerPosition=function(t){var e=t.mode||"top-right",i=t.width,n=t.height,o=v.defualtFormatter(10,t.offsetY),r=v.defualtFormatter(10,t.offsetX),s=v.defualtFormatter(10,t.padding);let a=t.x,l=t.y;var t=t.targetSize||h(),c=[s,t.width-i-s],t=[s,t.height-n-s];return"top-right"===e?(a+=r,l=l-n-o,a<c[0]?a=c[0]:a>c[1]&&(s=a-i-2*r,a=c[0]<s?s:c[1]),l<t[0]?(s=l+n+2*o,l=s<t[1]?s:t[0]):l>t[1]&&(l=l-n-2*o)):"bottom-right"===e?(a+=r,(l+=o)>t[1]&&(s=l-n-2*o,l=s<t[0]?t[1]:s),a>c[1]&&(t=a-i-2*r,a=t<c[0]?c[1]:t)):"top-left"===e&&(a=a-i-r,l=l-n-o),{x:a,y:l}},t.libraryFile=_,t.observeDomResize=function(i,n,o,t,e){e=!1!==e;let r=[0,0,!1],s=[0,0,!1],a=[0,0,!1],l=[0,0,!1];const c=d.add(h,t=t||500);function h(){if(document.body.contains(i)){let t=!1;var e;o?.includes("position")&&(e=i.getBoundingClientRect(),a[0]=e.left,a[2]=a[0]!==a[1],l[0]=e.top,l[2]=l[0]!==l[1]),r[0]=i.offsetWidth,r[2]=r[0]!==r[1],s[0]=i.offsetHeight,s[2]=s[0]!==s[1],r[2]&&(r[1]=r[0],o?.includes("width")&&(t=!0)),s[2]&&(s[1]=s[0],o?.includes("height")&&(t=!0)),(l[2]||a[2])&&(l[1]=l[0],a[1]=a[0],o?.includes("position")&&(t=!0)),o&&0!==o.length||(r[2]||s[2]||l[2]||a[2])&&(t=!0),t&&n(i)}else u()}function u(){d.remove(c),r=undefined,s=undefined}return e&&h(),u},t.observeDomScroll=function(i,t){const n=v._KvPair(t),o=v._Number(n.offetY);let r=!1,s=0;function e(){var t,e;r||(e=(t=i.scrollTop)-s,s=t,0!=e?e<0&&n.onTop&&t<=0+o?(r=!0,n.onTop(function(){r=!1})):0<e&&n.onBottom&&t>=i.scrollHeight-i.offsetHeight-o?(r=!0,n.onBottom(function(){r=!1})):r=!1:(r=!1,console.log("未处理")))}return i.addEventListener("scroll",e),{dispose:function(){i.removeEventListener("scroll",e)}}},t.observeMouseWheel=function(t,i,n){function e(t){let e;if(e=t.wheelDelta?0<t.wheelDelta?1:-1:t.detail<0?1:-1,i(e),n)return t.preventDefault&&t.preventDefault(),!1}return t.addEventListener("mousewheel",e),t.addEventListener("DOMMouseScroll",e),{dispose:function(){t.removeEventListener("mousewheel",e),t.removeEventListener("DOMMouseScroll",e)}}},t.pdfToImage=async function(t,o,e){n=e;const i=await new Promise(function(t){_({type:"js",module:"pdfjsLib",attribute:{type:"module"},url:n.index,interceptor:function(t){t.GlobalWorkerOptions.workerSrc=n.worker}},t)});var n;return new Promise(function(n){i.getDocument(t).promise.then(function(t){console.log("pdf",t),t.getPage(1).then(function(t){var e=t.getViewport({scale:1}),i=o.getContext("2d");o.height=e.height,o.width=e.width,t.render({canvasContext:i,viewport:e}).promise.then(function(){n({width:e.width,height:e.height})})})},function(t){console.error(t),n({width:0,height:0})})})},t.prevent=function(t,e,i){t=t||u.event,i=!1!==i,(e=!1!==e)&&u.event?u.event.cancelBubble=!0:t.stopPropagation(),i&&u.event?u.event.returnValue=!1:t.preventDefault()},t.removeClass=b,t.removeCookie=function(t){e(t,"",-1)},t.removeElement=function(t){t.parentNode&&t.parentNode.removeChild(t)},t.removeStorage=function(t){localStorage.removeItem(t)},t.replaceClass=function(t,e,i){b(t,e),y(t,i)},t.setCookie=e,t.setStorage=function(t,e){localStorage.setItem(t,(t=e,t=v.isString(t)?t:JSON.stringify(t)))},t.style=$,t.toggleClass=function(e,t){v.isArray(t)?v.forEach(t,function(t){e.classList.toggle(t)}):e.classList.toggle(t)}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bestime/utils_browser",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "main": "./dist/esm/index.min.mjs",
5
5
  "module": "./dist/esm/index.min.mjs",
6
6
  "types": "./dist/esm/index.d.ts",