@gsc-basic/functions 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # @gsc-basic/functions
2
-
3
- > Functions for Web Dev
4
-
5
- ## 说明
6
-
7
- 常用的前端方法
8
-
9
- 文档参考: [JavaScript functions](https://gsc-open.lenovo.com/zh_CN/gsc_basic/vue/basic-functions.html)
10
-
11
- ## Author & License
12
-
13
- This package is maintained by Lenovo SSG BASD. It is distributed under the LicenseRef-Proprietary license; see LICENSE for details.
1
+ # @gsc-basic/functions
2
+
3
+ > Functions for Web Dev
4
+
5
+ ## 说明
6
+
7
+ 常用的前端方法
8
+
9
+ 文档参考: [JavaScript functions](https://gsc-basic.lenovo.com/gsc-docs/zh_CN/gsc_basic/vue/basic-functions.html)
10
+
11
+ ## Author & License
12
+
13
+ This package is maintained by Lenovo SSG BASD. It is distributed under the LicenseRef-Proprietary license; see LICENSE for details.
package/dist/index.cjs CHANGED
@@ -7,8 +7,8 @@ You shall not disclose such Confidential Information and shall use it only in
7
7
  accordance with the terms of the license agreement.
8
8
 
9
9
  --- Build Info ---
10
- Version: 1.1.2
11
- Build Time: 2026/2/11 18:34:04
12
- Build Commit: 9b4b89872743098216d14081433fa57d7fa73fd3
10
+ Version: 1.2.0
11
+ Build Time: 2026/3/3 17:22:27
12
+ Build Commit: a388255c630130f5e69ede988a8585cdbdc065c1
13
13
  */
14
14
  "use strict";var J=Object.create;var D=Object.defineProperty,X=Object.defineProperties,Z=Object.getOwnPropertyDescriptor,Q=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertyNames,$=Object.getOwnPropertySymbols,et=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty,it=Object.prototype.propertyIsEnumerable;var O=(e,t,i)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,k=(e,t)=>{for(var i in t||(t={}))P.call(t,i)&&O(e,i,t[i]);if($)for(var i of $(t))it.call(t,i)&&O(e,i,t[i]);return e},U=(e,t)=>X(e,Q(t));var nt=(e,t)=>{for(var i in t)D(e,i,{get:t[i],enumerable:!0})},_=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of tt(t))!P.call(e,s)&&s!==i&&D(e,s,{get:()=>t[s],enumerable:!(n=Z(t,s))||n.enumerable});return e};var rt=(e,t,i)=>(i=e!=null?J(et(e)):{},_(t||!e||!e.__esModule?D(i,"default",{value:e,enumerable:!0}):i,e)),st=e=>_(D({},"__esModule",{value:!0}),e);var p=(e,t,i)=>O(e,typeof t!="symbol"?t+"":t,i);var j=(e,t,i)=>new Promise((n,s)=>{var o=u=>{try{a(i.next(u))}catch(l){s(l)}},r=u=>{try{a(i.throw(u))}catch(l){s(l)}},a=u=>u.done?n(u.value):Promise.resolve(u.value).then(o,r);a((i=i.apply(e,t)).next())});var yt={};nt(yt,{IfActivity:()=>I,SolarDay:()=>L.SolarDay,clearWorkerInterval:()=>v.clearInterval,clearWorkerTimeout:()=>v.clearTimeout,getFestival:()=>R,getTerm:()=>K,highlightHtml:()=>V,setFestivalListener:()=>W,setSpecificDayListener:()=>B,setTermListener:()=>z,setWorkerInterval:()=>v.setInterval,setWorkerTimeout:()=>v.setTimeout,toImage:()=>q});module.exports=st(yt);var v=require("worker-timers");var L=require("tyme4ts"),b=require("worker-timers"),x=e=>({year:e.getFullYear(),month:e.getMonth()+1,date:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds()}),C=(e={})=>{let{advance:t=0,delayed:i=0}=e,n=[];return t>0&&n.push(...Array.from({length:t}).map((s,o)=>{let r=new Date;return r.setDate(r.getDate()-(t-o)),x(r)})),n.push(x(new Date)),i>0&&n.push(...Array.from({length:i}).map((s,o)=>{let r=new Date;return r.setDate(r.getDate()+(o+1)),x(r)})),n},M=e=>C(e).map(({year:i,month:n,date:s})=>L.SolarDay.fromYmd(i,n,s)),ot=e=>M(e).map(t=>t.getLunarDay()),K=e=>M(e).map(i=>{var o;return((o=i.getTermDay().dayIndex)!=null?o:0)!==0?void 0:i.getTerm().getName()}),at=e=>M(e).map(t=>{var i;return(i=t.getFestival())==null?void 0:i.getName()}),lt=e=>ot(e).map(t=>{var i;return(i=t.getFestival())==null?void 0:i.getName()}),ut=e=>C(e).map(({month:i,date:n})=>{switch(`${i}-${n}`){case"4-1":return"\u611A\u4EBA\u8282";case"2-14":return"\u60C5\u4EBA\u8282";case"12-24":return"\u5E73\u5B89\u591C";case"12-25":return"\u5723\u8BDE\u8282";default:return}}),R=(e={})=>{let t=at(e),i=lt(e),n=ut(e);return Array.from(new Set([...t,...i,...n])).filter(s=>!!s)},A=({type:e,name:t,listener:i},n={})=>{let{interval:s=10*1e3,immediate:o=!0}=n,r=s>0?s:10*1e3,a,u=()=>{let l=[];e==="festival"?l.push(...R(n)):e==="term"?l.push(...K(n)):e==="date"&&l.push(...C(n).map(({month:g,date:d})=>`${g}-${d}`)),t&&l.includes(t)&&(i==null||i(),(0,b.clearInterval)(a))};return a=(0,b.setInterval)(u,r),o&&u(),{timer:a}},W=(e,t,i={})=>{let{timer:n}=A({type:"festival",name:e,listener:t},i);return()=>(0,b.clearInterval)(n)},z=(e,t,i={})=>{let{timer:n}=A({type:"term",name:e,listener:t},i);return()=>(0,b.clearInterval)(n)},B=(e,t,i={})=>{let{timer:n}=A({type:"date",name:e,listener:t},i);return()=>(0,b.clearInterval)(n)};var dt=(e,t)=>e instanceof RegExp?new RegExp(e.source,e.flags):new RegExp(e,t),gt=(e,t,i="ig")=>{let n=dt(t,i);return[...e.matchAll(n)].map(({index:o=0,0:r})=>({index:o,subString:r}))},mt=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),ht=(e,t)=>{if(!t)return e;let{tagName:i="mark",bgColor:n,color:s,style:o={},renderHighlightKeyword:r}=t;if(typeof r=="function")return r(e);let a=k({},o);n&&(a.backgroundColor=n),s&&(a.color=s);let l=`style="${Object.entries(a).map(([g,d])=>`${mt(g)}:${d!=null?d:""}`).join(";")}"`;return`<${i} ${l}>${e}</${i}>`},ct=(e,t)=>t.reduce((i,n)=>{let{start:s,end:o,option:r}=n,a=e.slice(s,o),u=ht(a,r);return n.subString=u,i+u},""),pt=(e,t)=>{let i=[];return t.forEach(n=>{let s=typeof n=="string"?{keyword:n}:n,{keyword:o,caseSensitive:r=!0}=s;if(!o)return;let a=gt(e,o,r?"g":"gi");i.push({keyword:o,indexList:a,option:s})}),i},ft=(e,t)=>{let i=pt(e,t),n=[],s=(r,a)=>{for(let u=0;u<n.length;u++){let l=n[u];if(!l)continue;if(r>l.start&&r<l.end||r+a>l.start&&r+a<l.end||l.start>r&&l.start<r+a||l.end>r&&l.end<r+a||r===l.start&&r+a===l.end)return-1;if(r+a<=l.start)return u}return n.length};i.forEach(({indexList:r,option:a})=>{r.forEach(({index:u,subString:l})=>{let g={start:u,end:u+l.length,option:a},d=s(u,l.length);d!==-1&&n.splice(d,0,g)})});let o=[];return n.forEach((r,a)=>{if(!r)return;let{start:u,end:l}=r,g=n[a+1];a===0&&u>0&&o.push({start:0,end:u,subString:e.slice(0,u)}),o.push(U(k({},r),{subString:e.slice(u,l)})),(g==null?void 0:g.start)!==void 0&&g.start>l&&o.push({start:l,end:g.start,subString:e.slice(l,g.start)}),a===n.length-1&&l<e.length&&o.push({start:l,end:e.length,subString:e.slice(l,e.length)})}),o.length?o:[{start:0,end:e.length,subString:e}]},V=(e,t)=>{let i=ft(e,t);return{highText:ct(e,i),highList:i}};var c=require("worker-timers");var f="active",F="idle",Y="hidden",T,w,H,h={},m={attach(e,t){h[e]||(h[e]=[]),h[e].push(t)},fire(e,t=[]){h[e]&&h[e].forEach(i=>{i(...t)})},remove(e,t){t||Reflect.deleteProperty(h,e),h[e]&&(h[e]=h[e].filter(i=>t!==i))},dom(e,t,i){if(!H){let n=e;typeof n.addEventListener=="function"?H=(s,o,r)=>{var a;(a=s.addEventListener)==null||a.call(s,o,r,!1)}:typeof n.attachEvent=="function"?H=(s,o,r)=>{var a;(a=s.attachEvent)==null||a.call(s,`on${o}`,r)}:H=(s,o,r)=>{s[`on${o}`]=r}}H(e,t,i)}},N=class{constructor(t,i,n){this.activity=t;this.seconds=i;this.callback=n;p(this,"token");p(this,"stopped",!1);this.start(),this.activity.on("statusChanged",s=>{this.stopped||(s.status===f?this.start():this.pause())})}start(){this.stopped=!1,this.token!==void 0&&(0,c.clearInterval)(this.token),this.token=(0,c.setInterval)(this.callback,this.seconds*1e3)}stop(){this.stopped=!0,this.token!==void 0&&(0,c.clearInterval)(this.token)}resume(){this.start()}pause(){this.stop()}},I=class{constructor(){p(this,"status",f);p(this,"timers",[]);p(this,"idleTime",3e4);p(this,"idleStartedTime",Date.now());p(this,"isLegacyModeOn",!1);if("hidden"in document?(T="hidden",w="visibilitychange"):"mozHidden"in document?(T="mozHidden",w="mozvisibilitychange"):"msHidden"in document?(T="msHidden",w="msvisibilitychange"):"webkitHidden"in document&&(T="webkitHidden",w="webkitvisibilitychange"),!T||!w)this.legacyMode();else{let t=()=>{document[T]?this.blur():this.focus()};t(),m.dom(document,w,t)}this.startIdleTimer(),this.trackIdleStatus()}legacyMode(){this.isLegacyModeOn||(m.dom(window,"blur",()=>this.blur()),m.dom(window,"focus",()=>this.focus()),this.isLegacyModeOn=!0)}startIdleTimer(t){typeof MouseEvent!="undefined"&&t instanceof MouseEvent&&t.movementX===0&&t.movementY===0||(this.timers.forEach(i=>(0,c.clearTimeout)(i)),this.timers.length=0,this.status===F&&this.wakeUp(),this.idleStartedTime=Date.now(),this.timers.push((0,c.setTimeout)(()=>{(this.status===f||this.status===Y)&&this.idle()},this.idleTime)))}trackIdleStatus(){let t=i=>this.startIdleTimer(i);m.dom(document,"mousemove",t),m.dom(document,"mousedown",t),m.dom(document,"keyup",t),m.dom(document,"touchstart",t),m.dom(window,"scroll",t),this.focus(t)}on(t,i){return m.attach(t,i),this}off(t,i){return m.remove(t,i),this}setIdleDuration(t){return this.idleTime=t*1e3,this.startIdleTimer(),this}getIdleDuration(){return this.idleTime}getIdleInfo(){let t=Date.now();if(this.status===F)return{isIdle:!0,idleFor:t-this.idleStartedTime,timeLeft:0,timeLeftPer:100};let i=this.idleStartedTime+this.idleTime-t;return{isIdle:!1,idleFor:t-this.idleStartedTime,timeLeft:i,timeLeftPer:Number.parseFloat((100-i*100/this.idleTime).toFixed(2))}}idle(t){return t?this.on("idle",t):(this.status=F,m.fire("idle"),m.fire("statusChanged",[{status:this.status}])),this}blur(t){return t?this.on("blur",t):(this.status=Y,m.fire("blur"),m.fire("statusChanged",[{status:this.status}])),this}focus(t){return t?this.on("focus",t):this.status!==f&&(this.status=f,m.fire("focus"),m.fire("wakeUp"),m.fire("statusChanged",[{status:this.status}])),this}wakeUp(t){return t?this.on("wakeUp",t):this.status!==f&&(this.status=f,m.fire("wakeUp"),m.fire("statusChanged",[{status:this.status}])),this}onEvery(t,i){return new N(this,t,i)}now(t){return t!==void 0?this.status===t:this.status===f}};var y=rt(require("html-to-image"),1);function q(e){return j(this,null,function*(){let{input:t,type:i="png",quality:n=1,width:s,height:o,backgroundColor:r,pixelRatio:a,style:u,filter:l}=e,g=null,d=null;if(typeof t=="string"){if(!/<[^>]+>/.test(t.trim()))try{g=document.querySelector(t)}catch(G){throw new Error(`htmlToImage: invalid selector, ${String(G)}`)}if(g||(d=document.createElement("div"),d.style.position="fixed",d.style.left="-9999px",d.style.top="-9999px",d.innerHTML=t,document.body.appendChild(d),g=d.firstElementChild),!g)throw d&&d.parentNode&&d.parentNode.removeChild(d),new Error("htmlToImage: unable to resolve input element from selector or html string")}else g=t;let E={backgroundColor:r,style:u,filter:l,pixelRatio:a};typeof s=="number"&&(E.canvasWidth=s),typeof o=="number"&&(E.canvasHeight=o);try{if(i==="png")return yield y.toPng(g,E);if(i==="jpeg")return yield y.toJpeg(g,Object.assign({},E,{quality:n}));if(i==="svg")return yield y.toSvg(g,E);if(i==="blob")return yield y.toBlob(g,E);throw new Error("htmlToImage: unsupported output type")}finally{d&&d.parentNode&&d.parentNode.removeChild(d)}})}0&&(module.exports={IfActivity,SolarDay,clearWorkerInterval,clearWorkerTimeout,getFestival,getTerm,highlightHtml,setFestivalListener,setSpecificDayListener,setTermListener,setWorkerInterval,setWorkerTimeout,toImage});
package/dist/index.js CHANGED
@@ -7,8 +7,8 @@ You shall not disclose such Confidential Information and shall use it only in
7
7
  accordance with the terms of the license agreement.
8
8
 
9
9
  --- Build Info ---
10
- Version: 1.1.2
11
- Build Time: 2026/2/11 18:34:04
12
- Build Commit: 9b4b89872743098216d14081433fa57d7fa73fd3
10
+ Version: 1.2.0
11
+ Build Time: 2026/3/3 17:22:27
12
+ Build Commit: a388255c630130f5e69ede988a8585cdbdc065c1
13
13
  */
14
14
  var j=Object.defineProperty,W=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var I=(e,t,i)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,S=(e,t)=>{for(var i in t||(t={}))B.call(t,i)&&I(e,i,t[i]);if(K)for(var i of K(t))V.call(t,i)&&I(e,i,t[i]);return e},R=(e,t)=>W(e,z(t));var c=(e,t,i)=>I(e,typeof t!="symbol"?t+"":t,i);var A=(e,t,i)=>new Promise((n,s)=>{var o=u=>{try{a(i.next(u))}catch(l){s(l)}},r=u=>{try{a(i.throw(u))}catch(l){s(l)}},a=u=>u.done?n(u.value):Promise.resolve(u.value).then(o,r);a((i=i.apply(e,t)).next())});import{clearInterval as Mt,clearTimeout as Kt,setInterval as Rt,setTimeout as At}from"worker-timers";import{SolarDay as F}from"tyme4ts";import{clearInterval as D,setInterval as Y}from"worker-timers";var L=e=>({year:e.getFullYear(),month:e.getMonth()+1,date:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds()}),O=(e={})=>{let{advance:t=0,delayed:i=0}=e,n=[];return t>0&&n.push(...Array.from({length:t}).map((s,o)=>{let r=new Date;return r.setDate(r.getDate()-(t-o)),L(r)})),n.push(L(new Date)),i>0&&n.push(...Array.from({length:i}).map((s,o)=>{let r=new Date;return r.setDate(r.getDate()+(o+1)),L(r)})),n},k=e=>O(e).map(({year:i,month:n,date:s})=>F.fromYmd(i,n,s)),q=e=>k(e).map(t=>t.getLunarDay()),N=e=>k(e).map(i=>{var o;return((o=i.getTermDay().dayIndex)!=null?o:0)!==0?void 0:i.getTerm().getName()}),G=e=>k(e).map(t=>{var i;return(i=t.getFestival())==null?void 0:i.getName()}),J=e=>q(e).map(t=>{var i;return(i=t.getFestival())==null?void 0:i.getName()}),X=e=>O(e).map(({month:i,date:n})=>{switch(`${i}-${n}`){case"4-1":return"\u611A\u4EBA\u8282";case"2-14":return"\u60C5\u4EBA\u8282";case"12-24":return"\u5E73\u5B89\u591C";case"12-25":return"\u5723\u8BDE\u8282";default:return}}),$=(e={})=>{let t=G(e),i=J(e),n=X(e);return Array.from(new Set([...t,...i,...n])).filter(s=>!!s)},x=({type:e,name:t,listener:i},n={})=>{let{interval:s=10*1e3,immediate:o=!0}=n,r=s>0?s:10*1e3,a,u=()=>{let l=[];e==="festival"?l.push(...$(n)):e==="term"?l.push(...N(n)):e==="date"&&l.push(...O(n).map(({month:g,date:d})=>`${g}-${d}`)),t&&l.includes(t)&&(i==null||i(),D(a))};return a=Y(u,r),o&&u(),{timer:a}},Z=(e,t,i={})=>{let{timer:n}=x({type:"festival",name:e,listener:t},i);return()=>D(n)},Q=(e,t,i={})=>{let{timer:n}=x({type:"term",name:e,listener:t},i);return()=>D(n)},tt=(e,t,i={})=>{let{timer:n}=x({type:"date",name:e,listener:t},i);return()=>D(n)};var et=(e,t)=>e instanceof RegExp?new RegExp(e.source,e.flags):new RegExp(e,t),it=(e,t,i="ig")=>{let n=et(t,i);return[...e.matchAll(n)].map(({index:o=0,0:r})=>({index:o,subString:r}))},nt=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),rt=(e,t)=>{if(!t)return e;let{tagName:i="mark",bgColor:n,color:s,style:o={},renderHighlightKeyword:r}=t;if(typeof r=="function")return r(e);let a=S({},o);n&&(a.backgroundColor=n),s&&(a.color=s);let l=`style="${Object.entries(a).map(([g,d])=>`${nt(g)}:${d!=null?d:""}`).join(";")}"`;return`<${i} ${l}>${e}</${i}>`},st=(e,t)=>t.reduce((i,n)=>{let{start:s,end:o,option:r}=n,a=e.slice(s,o),u=rt(a,r);return n.subString=u,i+u},""),ot=(e,t)=>{let i=[];return t.forEach(n=>{let s=typeof n=="string"?{keyword:n}:n,{keyword:o,caseSensitive:r=!0}=s;if(!o)return;let a=it(e,o,r?"g":"gi");i.push({keyword:o,indexList:a,option:s})}),i},at=(e,t)=>{let i=ot(e,t),n=[],s=(r,a)=>{for(let u=0;u<n.length;u++){let l=n[u];if(!l)continue;if(r>l.start&&r<l.end||r+a>l.start&&r+a<l.end||l.start>r&&l.start<r+a||l.end>r&&l.end<r+a||r===l.start&&r+a===l.end)return-1;if(r+a<=l.start)return u}return n.length};i.forEach(({indexList:r,option:a})=>{r.forEach(({index:u,subString:l})=>{let g={start:u,end:u+l.length,option:a},d=s(u,l.length);d!==-1&&n.splice(d,0,g)})});let o=[];return n.forEach((r,a)=>{if(!r)return;let{start:u,end:l}=r,g=n[a+1];a===0&&u>0&&o.push({start:0,end:u,subString:e.slice(0,u)}),o.push(R(S({},r),{subString:e.slice(u,l)})),(g==null?void 0:g.start)!==void 0&&g.start>l&&o.push({start:l,end:g.start,subString:e.slice(l,g.start)}),a===n.length-1&&l<e.length&&o.push({start:l,end:e.length,subString:e.slice(l,e.length)})}),o.length?o:[{start:0,end:e.length,subString:e}]},lt=(e,t)=>{let i=at(e,t);return{highText:st(e,i),highList:i}};import{clearInterval as P,clearTimeout as ut,setInterval as dt,setTimeout as gt}from"worker-timers";var p="active",C="idle",U="hidden",v,b,E,h={},m={attach(e,t){h[e]||(h[e]=[]),h[e].push(t)},fire(e,t=[]){h[e]&&h[e].forEach(i=>{i(...t)})},remove(e,t){t||Reflect.deleteProperty(h,e),h[e]&&(h[e]=h[e].filter(i=>t!==i))},dom(e,t,i){if(!E){let n=e;typeof n.addEventListener=="function"?E=(s,o,r)=>{var a;(a=s.addEventListener)==null||a.call(s,o,r,!1)}:typeof n.attachEvent=="function"?E=(s,o,r)=>{var a;(a=s.attachEvent)==null||a.call(s,`on${o}`,r)}:E=(s,o,r)=>{s[`on${o}`]=r}}E(e,t,i)}},M=class{constructor(t,i,n){this.activity=t;this.seconds=i;this.callback=n;c(this,"token");c(this,"stopped",!1);this.start(),this.activity.on("statusChanged",s=>{this.stopped||(s.status===p?this.start():this.pause())})}start(){this.stopped=!1,this.token!==void 0&&P(this.token),this.token=dt(this.callback,this.seconds*1e3)}stop(){this.stopped=!0,this.token!==void 0&&P(this.token)}resume(){this.start()}pause(){this.stop()}},H=class{constructor(){c(this,"status",p);c(this,"timers",[]);c(this,"idleTime",3e4);c(this,"idleStartedTime",Date.now());c(this,"isLegacyModeOn",!1);if("hidden"in document?(v="hidden",b="visibilitychange"):"mozHidden"in document?(v="mozHidden",b="mozvisibilitychange"):"msHidden"in document?(v="msHidden",b="msvisibilitychange"):"webkitHidden"in document&&(v="webkitHidden",b="webkitvisibilitychange"),!v||!b)this.legacyMode();else{let t=()=>{document[v]?this.blur():this.focus()};t(),m.dom(document,b,t)}this.startIdleTimer(),this.trackIdleStatus()}legacyMode(){this.isLegacyModeOn||(m.dom(window,"blur",()=>this.blur()),m.dom(window,"focus",()=>this.focus()),this.isLegacyModeOn=!0)}startIdleTimer(t){typeof MouseEvent!="undefined"&&t instanceof MouseEvent&&t.movementX===0&&t.movementY===0||(this.timers.forEach(i=>ut(i)),this.timers.length=0,this.status===C&&this.wakeUp(),this.idleStartedTime=Date.now(),this.timers.push(gt(()=>{(this.status===p||this.status===U)&&this.idle()},this.idleTime)))}trackIdleStatus(){let t=i=>this.startIdleTimer(i);m.dom(document,"mousemove",t),m.dom(document,"mousedown",t),m.dom(document,"keyup",t),m.dom(document,"touchstart",t),m.dom(window,"scroll",t),this.focus(t)}on(t,i){return m.attach(t,i),this}off(t,i){return m.remove(t,i),this}setIdleDuration(t){return this.idleTime=t*1e3,this.startIdleTimer(),this}getIdleDuration(){return this.idleTime}getIdleInfo(){let t=Date.now();if(this.status===C)return{isIdle:!0,idleFor:t-this.idleStartedTime,timeLeft:0,timeLeftPer:100};let i=this.idleStartedTime+this.idleTime-t;return{isIdle:!1,idleFor:t-this.idleStartedTime,timeLeft:i,timeLeftPer:Number.parseFloat((100-i*100/this.idleTime).toFixed(2))}}idle(t){return t?this.on("idle",t):(this.status=C,m.fire("idle"),m.fire("statusChanged",[{status:this.status}])),this}blur(t){return t?this.on("blur",t):(this.status=U,m.fire("blur"),m.fire("statusChanged",[{status:this.status}])),this}focus(t){return t?this.on("focus",t):this.status!==p&&(this.status=p,m.fire("focus"),m.fire("wakeUp"),m.fire("statusChanged",[{status:this.status}])),this}wakeUp(t){return t?this.on("wakeUp",t):this.status!==p&&(this.status=p,m.fire("wakeUp"),m.fire("statusChanged",[{status:this.status}])),this}onEvery(t,i){return new M(this,t,i)}now(t){return t!==void 0?this.status===t:this.status===p}};import*as f from"html-to-image";function mt(e){return A(this,null,function*(){let{input:t,type:i="png",quality:n=1,width:s,height:o,backgroundColor:r,pixelRatio:a,style:u,filter:l}=e,g=null,d=null;if(typeof t=="string"){if(!/<[^>]+>/.test(t.trim()))try{g=document.querySelector(t)}catch(_){throw new Error(`htmlToImage: invalid selector, ${String(_)}`)}if(g||(d=document.createElement("div"),d.style.position="fixed",d.style.left="-9999px",d.style.top="-9999px",d.innerHTML=t,document.body.appendChild(d),g=d.firstElementChild),!g)throw d&&d.parentNode&&d.parentNode.removeChild(d),new Error("htmlToImage: unable to resolve input element from selector or html string")}else g=t;let y={backgroundColor:r,style:u,filter:l,pixelRatio:a};typeof s=="number"&&(y.canvasWidth=s),typeof o=="number"&&(y.canvasHeight=o);try{if(i==="png")return yield f.toPng(g,y);if(i==="jpeg")return yield f.toJpeg(g,Object.assign({},y,{quality:n}));if(i==="svg")return yield f.toSvg(g,y);if(i==="blob")return yield f.toBlob(g,y);throw new Error("htmlToImage: unsupported output type")}finally{d&&d.parentNode&&d.parentNode.removeChild(d)}})}export{H as IfActivity,F as SolarDay,Mt as clearWorkerInterval,Kt as clearWorkerTimeout,$ as getFestival,N as getTerm,lt as highlightHtml,Z as setFestivalListener,tt as setSpecificDayListener,Q as setTermListener,Rt as setWorkerInterval,At as setWorkerTimeout,mt as toImage};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gsc-basic/functions",
3
3
  "type": "module",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "description": "Functions for Web Dev",
6
6
  "author": "Lenovo SSG BASD <-GSC_Scaffolding_Support@lenovo.com>",
7
7
  "license": "LicenseRef-Proprietary",