jmini 0.0.44 → 0.0.45
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/cjs/index.js +1 -1
- package/declare/fetcher.d.ts +25 -21
- package/esm/fetcher.js +1 -1
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty,W=Object.defineProperties,z=Object.getOwnPropertyDescriptor,X=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var B=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var I=Math.pow,Y=(e,t,r)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,S=(e,t)=>{for(var r in t||(t={}))O.call(t,r)&&Y(e,r,t[r]);if(P)for(var r of P(t))_.call(t,r)&&Y(e,r,t[r]);return e},A=(e,t)=>W(e,X(t));var j=(e,t)=>{var r={};for(var s in e)O.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&P)for(var s of P(e))t.indexOf(s)<0&&_.call(e,s)&&(r[s]=e[s]);return r};var Q=(e,t)=>{for(var r in t)k(e,r,{get:t[r],enumerable:!0})},Z=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of G(t))!O.call(e,n)&&n!==r&&k(e,n,{get:()=>t[n],enumerable:!(s=z(t,n))||s.enumerable});return e};var ee=e=>Z(k({},"__esModule",{value:!0}),e);var d=(e,t,r)=>new Promise((s,n)=>{var i=l=>{try{u(r.next(l))}catch(h){n(h)}},o=l=>{try{u(r.throw(l))}catch(h){n(h)}},u=l=>l.done?s(l.value):Promise.resolve(l.value).then(i,o);u((r=r.apply(e,t)).next())}),J=function(e,t){this[0]=e,this[1]=t},U=(e,t,r)=>{var s=(o,u,l,h)=>{try{var p=r[o](u),b=(u=p.value)instanceof J,C=p.done;Promise.resolve(b?u[0]:u).then(m=>b?s(o==="return"?o:"next",u[1]?{done:m.done,value:m.value}:m,l,h):l({value:m,done:C})).catch(m=>s("throw",m,l,h))}catch(m){h(m)}},n=o=>i[o]=u=>new Promise((l,h)=>s(o,u,l,h)),i={};return r=r.apply(e,t),i[B("asyncIterator")]=()=>i,n("next"),n("throw"),n("return"),i};var V=(e,t,r)=>(t=e[B("asyncIterator")])?t.call(e):(e=e[B("iterator")](),t={},r=(s,n)=>(n=e[s])&&(t[s]=i=>new Promise((o,u,l)=>(i=n.call(e,i),l=i.done,Promise.resolve(i.value).then(h=>o({value:h,done:l}),u)))),r("next"),r("return"),t);var pe={};Q(pe,{Fetcher:()=>c,Filer:()=>g,Server:()=>L,Time:()=>f,UUID:()=>D,default:()=>ce,useStore:()=>F});module.exports=ee(pe);typeof HTMLElement!="undefined"&&(HTMLElement.prototype.position=function(){return this.getBoundingClientRect()});typeof String!="undefined"&&(String.prototype.compress=function(){return this.trim().replace(/(\s|\n|\t)/ig,"")},String.prototype.encode=function(){return encodeURIComponent(this)},String.prototype.decode=function(){return decodeURIComponent(this)},String.prototype.toUpper=function(){return this.toLocaleUpperCase()},String.prototype.toLower=function(){return this.toLocaleLowerCase()},String.prototype.toCapital=function(){let e=this;return e&&(e=e.replace(/^./,this[0].toUpper()).replace(/(\s|_|-)[a-z]{1}/ig,t=>t[1].toUpper())),e},String.prototype.clip=function(e,t){return this.slice(e,t)},String.prototype.partReplace=function(e,t){return this.slice(0,e)+t+this.slice(e+t.length)},String.prototype.toBlob=function(e){let t=atob(this.replace(/^.*,/,"")),r=new Uint8Array(t.length);for(var s=0;s<t.length;s++)r[s]=t.charCodeAt(s);try{var n=new Blob([r.buffer],{type:e})}catch(i){return!1}return n},String.prototype.toNumber=function(){return Number(this.removeLetters())},String.prototype.removeLetters=function(){return this.replace(/[\D]/ig,"")},String.prototype.removeSpecifics=function(){return this.replace(/[^\w\s\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Han}]|_/uig,"")},String.prototype.removeJP=function(){return this.replace(/[\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Han}]+/uig,"")},String.prototype.zen2hanNumber=function(){return this.replace(/[0-9]/g,function(e){return String.fromCharCode(e.charCodeAt(0)-65248)}).replace(/[--﹣−‐⁃‑‒–—﹘―⎯⏤ーー─━]/g,"-").replace(/¥/,"\xA5").replace(/、/,",").replace(/(/,"(").replace(/)/,")").replace(/+/,"+")},String.prototype.escapeRegExChar=function(){return this.replace(/\\/g,"\\\\").replace(/(\?|\^|\$|\.|\||\*|\+|\(|\)|\{|\}|\[|\])/g,"\\$1")});typeof Number!="undefined"&&(Number.prototype.zeroEmbed=function(e){return String(this).padStart(e||2,"0")},Number.prototype.ratio=function(e,t=2){let r=I(10,t);return Math.round(this/e*r*100)/r},Number.prototype.rate=function(e,t=2){let r=I(10,t);return Math.round(this/e*r)/r},Number.prototype.rank=function(e=1){let t=I(10,e),r=Number(this),s=r.toLocaleString().replace(/\d/ig,"").length;return Math.round(r/I(1e3,s)*t)/t+("KMGTPEZY"[s-1]||"")},Number.prototype.rankJp=function(){let e=Number(this),t="";return e>=1e12?t=`${e/1e12}\u5146`:e>=1e8?t=`${e/1e8}\u5104`:e>=1e4?t=`${e/1e4}\u4E07`:e>=1e3?t=`${e/1e3}\u5343`:t=`${e.toLocaleString()}`,t},Number.prototype.toDate=function(e="/"){let t=String(this),r=t.slice(0,4),s=t.slice(4,6),n=t.slice(6,8),i=[];return r.length!=4||i.push(r),s.length!=2||i.push(s),n.length!=2||i.push(n),i.join(e)});if(typeof Array!="undefined"){let e=(t,r)=>{var n;let s=t;for(let i of r){if(!i)break;s=(n=(s||{})[i||""])!=null?n:null}return s};Array.prototype.toASC=function(...t){return(!t||!(t!=null&&t.length))&&(t=[""]),this.sort((r,s)=>{for(let n of t){let i=String(n||""),o=this.every(h=>{let p=Number(e(h,i.split(".")));return typeof p=="number"&&!isNaN(p)}),u=e(r,i.split(".")),l=e(s,i.split("."));if(o){if(u=Number(u),l=Number(l),u>l)return 1;if(u<l)return-1}else{if(u=String(u).replace(/(\d+)/g,h=>h.padStart(18,"0")),l=String(l).replace(/(\d+)/g,h=>h.padStart(18,"0")),u>l)return 1;if(u<l)return-1}}return 0})},Array.prototype.toDESC=function(...t){return this.toASC(...t).reverse()}}typeof File!="undefined"&&(File.prototype.convert=function(e){return e=e||"dataURL",new Promise((t,r)=>{let s=new FileReader;s.onload=i=>t(i),s.onerror=i=>r(i);let n="readAs"+(e==null?void 0:e.toCapital());s[n](this)})});var te=(e=26)=>Array.from({length:e}).map((t,r)=>{let s=r==0?25:35,n=Math.round(Math.random());return"abcdefghijkrmnopqrstuvwxyz0123456789"[Math.round(Math.random()*s)][n?"toUpper":"toLower"]()}).join(""),D=te;D.gen128Binary=()=>Array.from({length:128}).map((e,t)=>"01"[Math.round(Math.random()*1)]).join("");D.gen32Hex=(e="Formatted",t="-")=>{let r=Array.from({length:32}).map((s,n)=>"0123456789abcdef"[Math.round(Math.random()*15)]).join("").toUpper();return e=="Formatted"&&(r=[r.slice(0,8),r.slice(8,12),r.slice(12,16),r.slice(16,20),r.slice(20,32)].join(t)),r};D.to32Format=e=>[e.slice(0,8),e.slice(8,12),e.slice(12,16),e.slice(16,20),e.slice(20,32)].join("-").toUpper();var re=e=>new a.prototype.jmini(e),a=re;a.prototype={};a.extend=function(e,t=a){for(var[r,s]of Object.entries(e))t.prototype[r]=s};a.expando="__jmini_"+D();var y=(e,t)=>(e.queue.push(t),N(e),e),N=e=>d(void 0,null,function*(){if(!e.queueProcess&&e.queue.length){e.queueProcess=!0;let t=e.queue.shift();t&&(yield t()),e.queueProcess=!1,N(e)}}),E=(e,t)=>{for(let r=0;r<e.length;r++)e[r]=null;for(let[r,s]of Object.entries(t))r.match(/queue/)||(e[r]=s);return e},ne=(e,t)=>{if(t.length){for(var r=0;r<t.length;r++){let s=t[r];s&&(s[a.expando]||(a.is.element(s)||a.is.shadowRoot(s))&&(s[a.expando]={events:{}})),e[r]=s}e.length=t.length}else e.warn="No Argument(s).",e.length=0;return e.queueProcess=!1,N(e),e};a.extend({constructor:a,jmini:function(e){return this.src=e,this.srcType=a.is.what(e),this.queueProcess=!0,this.queue=[],ne(this,a.is.jmini(e)?e.get():a.is.element(e)?[e]:a.is.elements(e)?e:a.is.shadowRoot(e)?[e]:a.is.string(e)?e.match(/^#[^\.\s]*$/)?[document.getElementById(e.replace(/#/,""))]:document.querySelectorAll(e):[])}});a.prototype[String(Symbol.iterator)]=[][Symbol.iterator];a.prototype.jmini.prototype=a.prototype;{let e=function(n,i,o){let u=[];for(let l=0;l<(n.length||0);l++)u.push(i(n[l],l));return o&&(u=u.filter(l=>l!=null)),u},t=n=>(n.for((i,o)=>{if(!(a.is.element(i)||a.is.shadowRoot(i)))return;let u=i.cloneNode(),l=i.parentNode;l&&l.replaceChild(u,i),n[o]=u}),n),r=(n,i)=>(a(i).for(o=>{if(n&&(a.is.element(o)||a.is.shadowRoot(o)))if(a.is.string(n)||a.is.number(n))n=String(n),o.insertAdjacentHTML("beforeend",String(n));else if(a.is.element(n))o.appendChild(n);else{a.is.jmini(n)?n=n.get():a.is.element(n)?n=[n]:a.is.keyValueDictionary(n)&&(n=[a(n)]);for(var u=0;u<n.length;u++)r(n[u],o)}}),i),s=(n,i,...o)=>{let{p:u,s:l}={before:{p:"beforebegin",s:""},after:{p:"afterend",s:"nextSibling"}}[i]||{p:"",s:""};return n.for(h=>{if(a.is.string(o[0]))h.insertAdjacentHTML(u,o[0]);else{if(!h.parentNode)return;a(o[0]).for(b=>{o[1]&&(b=b.cloneNode(!0)),h.parentNode.insertBefore(b,h[l]||h)})}}),n};a.extend({get:function(n){return n?this[0]:e(this,i=>i)},for:function(n,i=1){let o=e(this,(u,l)=>n(u,l),1);return i?o:[]},await:function(n){return y(this,()=>new Promise((i,o)=>{setTimeout(()=>{i(this)},n)}))},abort:function(){return y(this,()=>d(this,null,function*(){return this.queue=[],this}))},callback:function(n){return y(this,()=>d(this,null,function*(){return yield n(this),this}))},click:function(){return y(this,()=>{for(var n=0;n<this.length;n++){let i=this[n];a.is.element(i)&&i.click()}return this})},focus:function(){return y(this,()=>{for(var n=0;n<this.length;n++){let i=this[n];a.is.element(i)&&i.focus()}return this})},addEvent:function(n){return y(this,()=>{let{eventType:i,eventID:o=D(),target:u,callback:l,options:h}=n;return h=S({passive:!0,capture:!1},h),this.for(p=>{if(!(a.is.element(p)||a.is.shadowRoot(p)))return;let{events:b}=p[a.expando];if(u){let C=l;l=m=>{if(m.target){if(a.is.string(u)){let T=m.target.closest(u);T&&(!T||C.call(T,m))}else if(a.is.elements(u)){for(let M of u)if(m.target==M)return C.call(M,m)}}}}if(b[o]){let C=b[o];p.removeEventListener(C.eventType,C.callback,C.options)}b[o]={eventType:i,callback:l,options:h},p.addEventListener(i,l,h)}),this})},removeEvent:function(n){return y(this,()=>{let i=a.is.array(n)?n:[n];return this.for(o=>{let{events:u}=o[a.expando];for(let l of i){let h=u[l];h&&o.removeEventListener(h.eventType,h.callback,h.options)}}),this})},html:function(n){return y(this,()=>E(this,r(n,t(this))))},empty:function(){return y(this,()=>E(this,t(this)))},append:function(n){return y(this,()=>{r(n,this)})},remove:function(){return y(this,()=>(this.for((n,i)=>{n&&a.is.element(n)&&(n.remove(),delete this[i])}),this.length=0,this.warn="Object(s?) were all removed.",this))},before:function(...n){return y(this,()=>E(this,s(this,"before",...n)))},after:function(...n){return y(this,()=>E(this,s(this,"after",...n)))},find:function(n){return y(this,()=>{let i=[],o=this[0];o||E(this,a()),(a.is.element(o)||a.is.shadowRoot(o))&&(a.is.string(n)?i=o.querySelectorAll(n):a.is.element(o)&&a(n).for(u=>{let l=o.childNodes;for(let h of l)if(h===u){i.push(h);break}else h.childNodes.length&&(i=[...i,...a(h).find(u).for(p=>p)])})),E(this,a(i))})},parent:function(n){return y(this,()=>{var o,u;let i=a(n?(o=this[0])==null?void 0:o.closest(n):(u=this[0])==null?void 0:u.parentNode);E(this,i)})},children:function(n){return y(this,()=>{let i=this[0].children;a.is.exist(n)&&(n=String(n).replace(/^ : /,""),i=n=="first"?i[0]:n=="last"?i[i.length-1]:i[Number(n)]);let o=a(i);return E(this,o)})},addClass:function(n){return y(this,()=>(n&&this.for(i=>{let o=a.is.string(n)?n.split(" "):n;i&&a.is.element(i)&&i.classList.add(...o)}),this))},removeClass:function(n){return y(this,()=>(n&&this.for(i=>{let o=a.is.string(n)?n.split(" "):n;i&&a.is.element(i)&&i.classList.remove(...o)}),this))},toggleClass:function(n){return y(this,()=>(n&&this.for(i=>{i.classList.toggle(n)}),this))},hasClass:function(n=""){if(this[0])return this[0].classList.contains(n.replace(/^\./,""))},findClass:function(n){let i=[];return this[0]&&(i=[...this[0].classList].filter(o=>o.match(n))),i},css:function(n){return y(this,()=>(this.for(i=>{if(a.is.element(i))for(let[o,u]of Object.entries(n)){if(a.is.number(u)&&o.match(/width|height|top|right|bottom|left|padding|margin|gap|border-.*radius/)){i.style[o]=u+"px";continue}i.style[o]=String(u)}}),this))},getAttribute:function(n){return this[0].getAttribute(String(n))},setAttribute:function(n,i){return y(this,()=>(this.for(o=>o.setAttribute(n,i)),this))},getStyleProperty:function(n){let i=this[0];return i&&a.is.element(i)?getComputedStyle(i).getPropertyValue(n):""},setStyleProperty:function(n,i){let o=this[0];return o&&a.is.element(o)&&o.style.setProperty(n,i),this},val:function(){var i;let n=this[0];return(n==null?void 0:n.value)||((i=n==null?void 0:n.dataset)==null?void 0:i.value)},position:function(){return a.is.element(this[0])?this[0].getBoundingClientRect():{}}})}a.flatArray=(e,t)=>{if(!a.is.array(e))return[e];let r=[];for(let s of e)r.push(...t=="-R"?a.flatArray(s,"-R"):[s]);return r};a.uniqueArray=(e,t)=>{let r=e;return t?r=Array.from(new Map(e.map(s=>[a.getKeyValue(s,t||"0"),s])).values()):r=Array.from(new Set(e)),r};a.getKeyValue=(e,t)=>{let r={},s=e;return t.split(".").forEach(n=>{s=s==null?void 0:s[n],r=s}),r};a.Stringify=(...e)=>{let[t,r,s]=e;return JSON.stringify(t,r!=null?r:(()=>{let n=new WeakSet;return(i,o)=>{if(typeof o=="object"&&o!==null){if(n.has(o))return"[Circular Reference]";n.add(o)}return o}})(),s)};a.Objectify=(e,t)=>{try{return JSON.parse(e)}catch(r){return t!=null?t:null}};a.randomNumber=(e=0,t=100,r)=>{if(e>t)return NaN;let s=[],n=e;for(;n<=t;){if(r&&r.length&&r.includes(n)){n++;continue}s.push(n),n++}let i=Math.round(Math.random()*(s.length-1))+0;return s[i]};a.try=e=>{try{return[e(),!0]}catch(t){return[t,!1]}};a.trySync=e=>d(void 0,null,function*(){try{return[yield e(),!0]}catch(t){return[t,!1]}});a.scope=e=>e();a.scopeSync=e=>d(void 0,null,function*(){return yield e()});a.createElement=function(e){var b;let{tag:t,className:r="",id:s,html:n,attr:i,style:o,parent:u}=e,l=document.createElement(t||"div");if(r&&l.classList.add(...r.split(" ")),s&&(l.id=s),i)for(let C of Object.entries(i)){let m=C[0],M=(b=C[1])!=null?b:"";if(m=="data"&&a.is.keyValueDictionary(M))for(let[T,w]of Object.entries(M))l.dataset[T]=w;else m=="for"?m="htmlFor":m=="tabindex"?m="tabIndex":m=="aria-label"&&(m="ariaLabel"),l[m]=M}if(n&&a(l).append(n),o)for(var[h,p]of Object.entries(o))l.style[h]=p;return u&&a(u).append(l),l};a.setCookie=e=>{let{hostname:t}=new URL(location.toString()),{name:r,value:s="",age:n=60*60*24*365,path:i="/",domain:o=t,secure:u=!1}=e,l=`${r}=${s}max-age=${n}path=${i}domain=${o}`;u&&(l+=" Secure"),document.cookie=l};a.getCookie=e=>{let t=document.cookie.match(new RegExp(e+"=[^]*"));return t?t[0].replace(new RegExp(e+"="),""):""};a.localStrage={set:(e,t)=>{localStorage.setItem(e,a.Stringify(t))},get:e=>{let t=localStorage.getItem(e);return a.Objectify(t,t)}};a.deleteCookie=e=>{document.cookie=e+"=max-age=0"};a.getScreenSize=()=>{let{innerHeight:e,innerWidth:t,scrollY:r,scrollX:s,pageXOffset:n,pageYOffset:i}=window,o=Number(a(document.body).getStyleProperty("--sat").removeLetters()),u=Number(a(document.body).getStyleProperty("--sab").removeLetters());return{height:e,width:t,pageHeight:e-o-u,scrollY:r,scrollX:s,pageXOffset:n,pageYOffset:i,safeAreaTop:o,safeAreaBottom:u}};a.getCursor=e=>{var s,n,i,o,u,l,h,p;let t=(o=e.pageX)!=null?o:(i=(s=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:s.pageX)!=null?i:(((n=e==null?void 0:e.originalEvent)==null?void 0:n.touches)||[])[0].pageX,r=(p=e.pageY)!=null?p:(h=(u=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:u.pageY)!=null?h:(((l=e==null?void 0:e.originalEvent)==null?void 0:l.touches)||[])[0].pageY;return{x:t,y:r}};a.pending=(e,t)=>new Promise((r,s)=>{e(r),t&&setTimeout(()=>{r(!0)},t)});a.deepMerge=(e,...t)=>{if(!t.length)return e;let r=t.shift();if(a.is.keyValueDictionary(e)&&a.is.keyValueDictionary(r))for(let s in r)a.is.keyValueDictionary(r[s])?(e[s]||Object.assign(e,{[s]:{}}),a.deepMerge(e[s],r[s])):Object.assign(e,{[s]:r[s]});return a.deepMerge(e,...t)};a.deepCopy=e=>{if(a.is.array(e))return e.map(t=>a.deepCopy(t));if(a.is.keyValueDictionary(e)){let t={};return Object.entries(e).forEach(([r,s])=>{t[r]=a.deepCopy(s)}),t}return e};a.queryParams={get:e=>{let t=new URL(e||location.href),r={};return t.searchParams.forEach((s,n)=>r[n]=s),r},set:(e,t)=>{let r=new URL(t||location.href);return Object.entries(e).forEach(([s,n])=>{r.searchParams.set(s,String(n))}),t||history.replaceState({},"",r.pathname+r.search),r.toString()},delete:(e,t)=>{let r=new URL(t||location.href);return e.forEach(s=>{r.searchParams.delete(s)}),t||history.replaceState({},"",r.pathname+r.search),r.toString()}};a.ellipsisText=(e,t)=>{let r=String(e);return r.length>t&&(r=r.slice(0,t)+" ..."),r};a.is={equal:function(e,t,r){return r==null||r?a.Stringify(e)===a.Stringify(t):e===t},what:function(e){let t="other";return this.jmini(e)?t="jmini":this.element(e)?t="element":this.elements(e)?t="elements":this.shadowRoot(e)?t="shadowRoot":this.string(e)?t="string":this.number(e)?t="number":this.array(e)?t="array":this.function(e)?t="function":this.date(e)?t="date":typeof e=="undefined"?t="undefined":this.keyValueDictionary(e)?t="keyValueDictionary":e==null?t="null":isNaN(e)&&(t="NaN"),t},exist:function(e){return e===(e!=null?e:!e)},nullish:function(e){return!this.exist(e)},jmini:function(e){return(e||{}).constructor===a},string:function(e){return typeof e=="string"},boolean:function(e){return typeof e=="boolean"},number:function(e){return!isNaN(e)&&typeof e=="number"},array:function(e){let t={}.toString.call(e);return e instanceof Array||t=="[object NodeList]"||t=="[object HTMLCollection]"},function:function(e){return typeof e=="function"},keyValueDictionary:function(e){return{}.toString.call(e)==="[object Object]"&&!this.jmini(e)},element:function(e){return e&&(e.nodeType==1&&typeof e.style=="object"&&typeof e.ownerDocument=="object"||[window,document].includes(e))},elements:function(e){let t={}.toString.call(e),r=Number(!!e&&typeof e!="string"&&this.array(e)&&t!=="[object Text]");if(r&&t!=="[object NodeList]")for(var s of e)r&=Number(this.element(s));return!!r},shadowRoot:function(e){return e instanceof ShadowRoot},date:function(e){return this.number(new Date(e).getTime())}};var se=e=>new f.prototype.Time(e),f=se;f.prototype={};var ie=function(e){f.isTimeObject(e)&&(e=e.value),e||(e===null?e=void 0:e===void 0&&(e=new Date));let t=new Date(e);return this.set(t)};a.extend({value:new Date,validate:!1,ms:-1,weekday:-1,weekInMonth:-1,weekInYear:-1,isLastWeekInMonth:!1,year:-1,month:-1,date:-1,hours:-1,minutes:-1,seconds:-1,constructor:f,Time:ie,clone:function(){return f(this)},set:function(e){this.value=e;let t=a.is.date(e);if(this.validate=t,!t)return this.ms=-1,this.year=-1,this.month=-1,this.weekday=-1,this.weekInYear=-1,this.date=-1,this.hours=-1,this.minutes=-1,this.seconds=-1,this;this.ms=e.getTime(),this.weekday=e.getDay(),this.year=e.getFullYear(),this.month=e.getMonth()+1,this.date=e.getDate();{let r=new Date(this.year,0,1),s=new Date(r.valueOf());s.setDate(s.getDate()-(r.getDay()+1));let n=e.getTime()-s.getTime(),i=Math.ceil(n/(1e3*60*60*24));this.weekInYear=Math.ceil(i/7)}{let r=new Date(this.year,this.month-1,1),s=new Date(r.valueOf());s.setDate(s.getDate()-(r.getDay()+1));let n=e.getTime()-s.getTime(),i=Math.ceil(n/(1e3*60*60*24)),o=Math.ceil(i/7);this.weekInMonth=o}{let r=new Date(this.year,this.month,0),s=r.getDay(),n=new Date(new Date(r).setDate(r.getDate()-s));this.isLastWeekInMonth=this.date>=n.getDate()}return this.hours=e.getHours(),this.minutes=e.getMinutes(),this.seconds=e.getSeconds(),this},isPast:function(){let e=f();return this.value.valueOf()<e.value.valueOf()},isSameYear:function(e){let t=f(e);return this.year==t.year},isSameMonth:function(e){let t=f(e);return this.year==t.year&&this.month==t.month},isSameWeek:function(e){let t=f(e);return this.year==t.year&&this.weekInYear==t.weekInYear},isSameDate:function(e){let t=f(e);return this.year==t.year&&this.month==t.month&&this.date==t.date},setYear:function(e){let t=new Date(this.value.valueOf());return t.setFullYear(e),this.set(t)},setMonth:function(e){let t=new Date(this.value.valueOf());return t.setMonth(e-1),this.set(t)},setDate:function(e){let t=new Date(this.value.valueOf());return t.setDate(e),this.set(t)},setHours:function(e){let t=new Date(this.value.valueOf());return t.setHours(e),this.set(t)},setMinutes:function(e){let t=new Date(this.value.valueOf());return t.setMinutes(e),this.set(t)},setSeconds:function(e){let t=new Date(this.value.valueOf());return t.setSeconds(e),this.set(t)},setMilliseconds:function(e){let t=new Date(this.value.valueOf());return t.setMilliseconds(e),this.set(t)},addYear:function(e){return this.setYear(this.year+e)},addMonth:function(e){return this.setMonth(this.month+e)},addWeek:function(e){return this.addDate(7*e)},addDate:function(e){return this.setDate(this.date+e)},addHours:function(e){return this.setHours(this.hours+e)},addMinutes:function(e){return this.setMinutes(this.minutes+e)},addSeconds:function(e){return this.setSeconds(this.seconds+e)},toFormat:function(e){return this.validate?e.replace(/\%y/ig,this.year.zeroEmbed(4)).replace(/\%m/ig,this.month.zeroEmbed(2)).replace(/\%d/ig,this.date.zeroEmbed(2)).replace(/\%w/ig,this.weekInYear.zeroEmbed(2)).replace(/\%h/ig,this.hours.zeroEmbed(2)).replace(/\%i/ig,this.minutes.zeroEmbed(2)).replace(/\%s/ig,this.seconds.zeroEmbed(2)):""},toFormatYMD:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5"):this.toFormat("%Y/%M/%D"):""},toFormatYM:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708"):this.toFormat("%Y/%M"):""},toFormatMD:function(e){return this.validate?e=="JP"?this.toFormat("%M\u6708%D\u65E5"):this.toFormat("%M/%D"):""},toFormatHM:function(e){return this.validate?e=="JP"?this.toFormat("%h\u6642%i\u5206"):this.toFormat("%h:%i"):""},toFormatYMDHM:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%i\u5206"):this.toFormat("%Y/%M/%D %h:%i"):""},toFormatYMDHMS:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%m\u5206%s\u79D2"):this.toFormat("%Y/%M/%D %h:%i:%s"):""},toLangYMD:function(e){if(!this.validate)return"";let t=f(),r=t.diff(this);return r.dates==0?"\u4ECA\u65E5":r.dates==1?"\u6628\u65E5":r.dates>=-7&&r.dates<0?-1*r.dates+"\u65E5\u5F8C":r.dates<=7&&r.dates>0?r.dates+"\u65E5\u524D":this.isSameYear(t)?e=="JP"?this.toFormat("%M\u6708%D\u65E5"):this.toFormat("%M/%D"):e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5"):this.toFormat("%Y/%M/%D")},setFirstOfTheDay:function(){let e=new Date(this.value.valueOf());return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),this.set(e)},setLastOfTheDay:function(){let e=new Date(this.value.valueOf());return e.setHours(23),e.setMinutes(59),e.setSeconds(59),e.setMilliseconds(999),this.set(e)},setFromFormatHHMM:function(e){let t=String(e).removeLetters().removeSpecifics().toNumber().zeroEmbed(4).replace(/(\d{2})(\d{2})/,"$1:$2"),[r,s]=t.split(":"),n=new Date(this.value.valueOf());return n.setHours(Number(r)),n.setMinutes(Number(s)),this.set(n)},setFromFormatHHMMSS:function(e){let t=String(e).removeLetters().removeSpecifics().toNumber().zeroEmbed(4).replace(/(\d{2})(\d{2})(\d{2})/,"$1:$2:$3"),[r,s,n]=t.split(":"),i=new Date(this.value.valueOf());return i.setHours(Number(r)),i.setMinutes(Number(s)),i.setSeconds(Number(n)),this.set(i)},getFirstDayOfTheYear:function(){return f(new Date(this.value.getFullYear(),0,1))},getLastDayOfTheYear:function(){return f(new Date(this.value.getFullYear()+1,0,0))},getFirstDayOfTheMonth:function(){return f(new Date(this.value.getFullYear(),this.month-1,1))},getLastDayOfTheMonth:function(){return f(new Date(this.value.getFullYear(),this.month,0))},getFirstDayOfTheWeek:function(){let e=f(this.value);return e.addDate(-e.weekday)},getLastDayOfTheWeek:function(){let e=f(this.value);return e.addDate(6-e.weekday)},diff:function(e){return{years:this.year-e.year,months:(this.year-e.year)*12+(this.month-e.month),dates:a.scope(()=>{let t=864e5,r=this.clone().setFirstOfTheDay(),s=e.clone().setFirstOfTheDay();return Math.floor((r.ms-s.ms)/t)}),hours:a.scope(()=>{let t=36e5,r=this.clone().setMinutes(0).setSeconds(0).setMilliseconds(0),s=e.clone().setMinutes(0).setSeconds(0).setMilliseconds(0);return Math.floor((r.ms-s.ms)/t)}),minutes:a.scope(()=>{let t=6e4,r=this.clone().setSeconds(0).setMilliseconds(0),s=e.clone().setSeconds(0).setMilliseconds(0);return Math.floor((r.ms-s.ms)/t)}),seconds:a.scope(()=>{let t=this.clone().setMilliseconds(0),r=e.clone().setMilliseconds(0);return Math.floor((t.ms-r.ms)/1e3)}),ms:this.ms-e.ms}},getAge:function(e){let t=e||f(),r=t.year-this.year;return(this.month>t.month||this.month==t.month&&t.date<this.date)&&r--,r}},f);f.isTimeObject=e=>{var t;return((t=e||{})==null?void 0:t.constructor)===f};f.getFromNumberYYYYMMDD=e=>{let t=Number(e).zeroEmbed(8).replace(/(\d{4})(\d{2})(\d{2})/,"$1/$2/$3");return f(t+" 00:00:00")};f.getShortYMDs=(e,t)=>{let r="",s="";return e.year==t.year&&e.year==f().year?r=e.toFormatMD():r=e.toFormatYMD(),e.year!=t.year?s=t.toFormatYMD():s=t.toFormatMD(),[r,s]};f.getPeriodArray=(e,t,r)=>{let s=[],n=t;if(!t.validate||!r.validate)return s;for(;n.toFormatYMDHMS().toNumber()<=r.toFormatYMDHMS().toNumber();)s.push(n),e=="year"?n=f(n).addYear(1):e=="month"?n=f(n).addMonth(1):e=="week"?n=f(n).addWeek(1):e=="day"?n=f(n).addDate(1):e=="hours"?n=f(n).addHours(1):e=="minutes"?n=f(n).addMinutes(1):e=="seconds"&&(n=f(n).addSeconds(1));return s};f.prototype.Time.prototype=f.prototype;var x={},F={set:(e,t)=>{let r=!0;return Object.entries(e).forEach(([s,n])=>{let i=x[s]||{};i&&i.privateKey&&i.privateKey!=t&&(r=!1),x[s]={privateKey:t,value:n}}),r},update:(e,t)=>{let r=!0;return Object.entries(e).forEach(([s,n])=>{var o;let i=x[s]||{};i&&i.privateKey&&i.privateKey!=t&&(r=!1),x[s]=A(S({},x[s]),{value:S(S({},(o=x[s])==null?void 0:o.value),n)})}),r},get:(e,t)=>{let r=x[e];if(!(r&&r.privateKey&&r.privateKey!=t))return r==null?void 0:r.value},delete:(e,t)=>{let r=x[e];return r&&r.privateKey&&r.privateKey!=t?!1:(delete x[e],!0)}};var ae=(...[e,t,r])=>new v.prototype.Interval(e,t,r),v=ae;v.prototype={};var oe=function(...[e,t,r]){return this.fn=e,this.ms=t,this.key=r,v.abort(this.key),this.store(),this};a.extend({key:"",ms:0,timeoutIndex:-1,fn:null,Interval:oe,store:function(){F.set({["Interval_"+this.key]:this})},once:function(){return this.fn&&(this.timeoutIndex=setTimeout(this.fn,this.ms)),this.store(),this},start:function(){return this.fn&&(this.timeoutIndex=setInterval(this.fn,this.ms)),this.store(),this},abort:function(){return v.abort(this.timeoutIndex),this},set_ms:function(e){return this.ms=e,this.store(),this},set_fn:function(e){return this.fn=e,this.store(),this}},v);v.abort=e=>{if(a.is.number(e))return clearInterval(e);let t=F.get("Interval_"+e);t&&clearInterval(t.timeoutIndex)};v.get=e=>F.get("Interval_"+e);v.once=(e,t,r)=>v(e,t,r).once();v.start=(e,t,r)=>v(e,t,r).start();v.prototype.Interval.prototype=v.prototype;var ue=(e,t)=>new c.prototype.Fetcher(e,t),c=ue;c.prototype={};c.waitList=[];c.setDefaultTrafficControl=0;c.setDefaultTimeout=1e3*60*10;c.isReadableStream=e=>e instanceof ReadableStream;c.isReadableStreamReader=e=>e instanceof ReadableStreamDefaultReader;c.streamToContext=(e,t)=>d(void 0,null,function*(){try{let r=(t==null?void 0:t.reader)||e.getReader();if(!c.isReadableStreamReader(r))return{ok:!1,done:!0,data:null};if(!r)return{ok:!1,done:!0,data:null};let s=(t==null?void 0:t.decoder)||new TextDecoder("utf-8"),n=yield r.read();return{ok:!0,done:n.done,data:s.decode(n.value)}}catch(r){return{ok:!1,done:!0,data:r}}});var le=function(e,t){var n;t=t||{};let r=t.body;t.body&&!a.is.string(t.body)&&((n=t.bodyStringify)==null||n)&&(r=a.Stringify(t.body||{}));let s=e;return a.is.string(e)&&!e.match(/https?:/)&&(s=location.origin+"/"+e.replace(/^\//,"")),this.url=s,this.method=t.method||"get",this.streamStatus="open",this.params=A(S({key:D(),response_format:"json",timeout:c.setDefaultTimeout,trafficControl:c.setDefaultTrafficControl,preventMultiRequest:!0},t),{headers:S(S({"Content-Type":"application/json"},c.setDefaultHeaders&&c.setDefaultHeaders()),t.headers),body:r}),this};a.extend({Fetcher:le,params:{},url:"",method:"GET",streamStatus:"closed",onStartCB:()=>{},onCompleteCB:()=>{},onRetryCB:()=>d(void 0,null,function*(){return null}),isRetry:!1,onErrorCB:()=>{},onResultCB:()=>{},onStreamCB:()=>{},onStart:function(e){return this.onStartCB=e,this},onStream:function(e){return this.onStreamCB=e,this},onResult:function(e){return this.onResultCB=e,this},onComplete:function(e){return this.onCompleteCB=e,this},onRetry:function(e){return this.onRetryCB=e,this},onError:function(e){return this.onErrorCB=e,this},onStreamProcess:function(e){return d(this,null,function*(){let{response:t,errorCB:r,streamCB:s,reader:n,decoder:i}=e,o=t.body,u=this,l=function(){return U(this,null,function*(){if(!t.ok){a.scope(()=>d(this,null,function*(){let{ok:M,done:T,data:w}=yield c.streamToContext(o,{reader:n,decoder:i});M&&r(w)}));return}let m=!1;for(;!m;){let{ok:M,done:T,data:w}=yield new J(c.streamToContext(o,{reader:n,decoder:i}));u.streamStatus=="abort"?(u.streamStatus="closed",n.cancel(),T=!0):u.streamStatus=="closed"&&(T=!0),T&&(m=T,n.releaseLock()),s(w,T)}})};try{for(var h=V(l()),p,b,C;p=!(b=yield h.next()).done;p=!1){let m=b.value;;}}catch(b){C=[b]}finally{try{p&&(b=h.return)&&(yield b.call(h))}finally{if(C)throw C[0]}}})},get:function(){return this.method="GET",this.send()},head:function(){return this.method="HEAD",this.send()},post:function(){return this.method="POST",this.send()},put:function(){return this.method="PUT",this.send()},delete:function(){return this.method="DELETE",this.send()},patch:function(){return this.method="PATCH",this.send()},options:function(){return this.method="OPTIONS",this.send()},send:function(){return d(this,null,function*(){var C;let e=this.params,t=performance.now(),r=0,s=new AbortController,n=setTimeout(()=>{s.abort()},e.timeout);e.signal=s.signal;let i=!1,o=500,u="InternalServerError",l={},h=null;try{c.setDefaultOnStart&&c.setDefaultOnStart(e),this.onStartCB&&this.onStartCB(e);let b=e,{key:m,response_format:M,trafficControl:T,preventMultiRequest:w,timeout:de,queries:$}=b,H=j(b,["key","response_format","trafficControl","preventMultiRequest","timeout","queries"]);H.method=this.method;let K=c.waitList.includes(m);if(w&&K)throw o=429,new Error("TooManyRequests");c.waitList=[...c.waitList,m];let q=a.queryParams.set(S({},$),String(this.url));l=yield fetch(q,H).then(R=>d(this,null,function*(){return i=R.ok,o=R.status,u=R.statusText,h=R,M=="none"||M=="stream"?R:R[M]()})).catch(R=>{throw new Error(R)})}catch(m){o==200&&(o=500,i=!1),o==429&&(u="TooManyRequests"),s.signal.aborted&&(o=408,u="Timeout"),o==500&&(u=String(m)||u),l={errorCode:String(m)}}finally{clearTimeout(n),r=performance.now()-t}e.trafficControl&&(yield a.pending(()=>{},e.trafficControl)),c.waitList.splice(c.waitList.findIndex(m=>m==e.key),1);let p={ok:i,status:o,statusText:u,body:l,requestTime:r,rawData:h};if(!i){if(this.onRetryCB&&!this.isRetry){this.isRetry=!0;let m=yield this.onRetryCB(p.body,this.params);if(m)return this.params=m,this.send()}this.onErrorCB&&this.onErrorCB(p.body)}if(i&&this.onStreamCB&&e.response_format=="stream"){let m=(C=h.body)==null?void 0:C.getReader();this.onStreamProcess({errorCB:this.onErrorCB,streamCB:this.onStreamCB,response:p,reader:m,decoder:new TextDecoder("utf-8")})}return i&&this.onCompleteCB&&this.onCompleteCB(p.body),this.onResultCB&&this.onResultCB(p,e),c.setDefaultOnEnd&&c.setDefaultOnEnd(p,e),p})},abortStream:function(){this.streamStatus="abort"}},c);c.prototype.Fetcher.prototype=c.prototype;var he=e=>new g.prototype.Filer(e),g=he;g.prototype={};var me=function(e){this.ok=!0;try{let[t,r]=e.name.replace(/\s/,"").replace(/(.*)\.(.*)$/,"$1 $2").split(" ");this.file=e,this.extension=r,this.fileName=t,this.type=e.type}catch(t){console.log(t),this.ok=!1}return this};a.extend({ok:!1,extension:"",type:"",file:{},fileName:"",Filer:me,isValid:function(){return this.ok},toBlob:function(){return d(this,null,function*(){return new Blob([this.file,{type:this.type}])})},toDataURL:function(){return d(this,null,function*(){var t;return(t=(yield this.file.convert("dataURL")).target)==null?void 0:t.result})},toAarrayBuffer:function(){return d(this,null,function*(){var t;return(t=(yield this.file.convert("arrayBuffer")).target)==null?void 0:t.result})},toObjectURL:function(){return d(this,null,function*(){return URL.createObjectURL(this.file)})},updateFileName:function(e){let t=new File([this.file],e+"."+this.extension);return this.file=t,this.fileName=e,this},updateMimeType:function(e){return this.file=new File([this.file],this.fileName+"."+this.extension,{type:e}),this.type=e,this},updateExtension:function(e){let t=new File([this.file],this.fileName+"."+e);return this.file=t,this.extension=e,this}},g);g.fromFile=e=>d(void 0,null,function*(){return g(e)});g.fromBlob=(e,t)=>d(void 0,null,function*(){let r=(t==null?void 0:t.fileName)||"file",s=(t==null?void 0:t.extension)||"",n=new File([e],r+"."+s,{type:t==null?void 0:t.mimeType});return g(n)});g.fromArrayBuffer=(e,t)=>d(void 0,null,function*(){return g.fromBlob(new Blob([e],{type:(t==null?void 0:t.mimeType)||""}),t)});g.fromObjectURL=(e,t)=>d(void 0,null,function*(){let r=yield c(e,{response_format:"blob"}).get();return r.ok?g.fromBlob(r.body,t):g({})});g.fromDataURL=(e,t)=>d(void 0,null,function*(){let r=yield e.toBlob((t==null?void 0:t.mimeType)||"");return r?g.fromBlob(r,t):g({})});g.prototype.Filer.prototype=g.prototype;var fe=function(e){let t=e,r=null;return t.use((s,n,i)=>{let o=n;o.return=u=>{let{ok:l,status:h,body:p={},bodyStringify:b=!0}=u||{};h=h!=null?h:(l!=null?l:!0)&&200||403;let C=p;return b&&!a.is.string(p)&&(C=a.Stringify(p)),n.status(h).end(C)},i()}),t.onPathRouter=function(s){return r=s,this},t.pathRouter=function(s){if(!r)return;let n=r(s);return n.route(s),t.use(s,n),n},t.exception=function(s){return t.use(s),this},t},L=fe;L.getLocalIP=e=>{let t="";return a.scope(()=>{if(!e)return;let r=e.networkInterfaces();for(let[s,n]of Object.entries(r))n.forEach(i=>{!i.internal&&i.family==="IPv4"&&!i.address.match(/^(169|127)/)&&(t=i.address)})}),t};L.getIP=function(e){var s;return(((e==null?void 0:e.headers["x-forwarded-for"])||((s=e==null?void 0:e.socket)==null?void 0:s.remoteAddress)||"").toString().match(new RegExp(/(::ffff:)?(\d+\.\d+.\d+\.\d+(:\d+)?)/))||[])[2]||"UNKNOWN IP"};a.copyToClipboard=e=>d(void 0,null,function*(){let t="";a.is.string(e)?t=e:a.is.function(e)&&(t=e());let r={ok:!1,body:"NotSupported"};return yield d(void 0,null,function*(){let s;if(navigator.clipboard){if(s=yield navigator.clipboard.writeText(t).then(()=>!0,()=>!1),!s)return}else{let n=document.createElement("input");if(a(document.body).append(n),n.value=t,n.select(),s=document.execCommand("copy"),document.body.removeChild(n),!s)return}r={ok:!0,body:""}}),r});a.ImageLoader=(e,t)=>new Promise((r,s)=>{let n=t||new Image;n.onload=()=>r(n),n.onerror=i=>s(i),n.src=e});a.formatCharacter={postal:{JP:e=>{let t="--";return e=String(e).replace(/\D/ig,""),e.length==7&&(t=e.replace(/^(\d{3})(.*)/,"$1-$2")),t}},tel:{_:e=>{let t=e;return e=String(e).removeLetters(),e.length==11&&(t=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),e.length==10&&(t=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),t},mobile:e=>{let t="--";return e=String(e).removeLetters(),e.length==11&&(t=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),t},fixed:e=>{let t="--";return e=String(e).removeLetters(),e.length==10&&(t=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),t}}};a.transformer={weekday:{JP:e=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][e]+"\u66DC\u65E5",shortJP:e=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][e]},wareki:e=>{let t=[],r=[],s=!1;return[{From:1868,To:1912,name:"\u660E\u6CBB"},{From:1912,To:1926,name:"\u5927\u6B63"},{From:1926,To:1989,name:"\u662D\u548C"},{From:1989,To:2019,name:"\u5E73\u6210"},{From:2019,To:1e5,name:"\u4EE4\u548C"}].forEach(i=>{let{From:o,To:u,name:l}=i;if(o<=e&&e<=u){let h=e-o+1;h==1&&(s=!0,h="\u5143"),r.push(l+h+"\u5E74"),t.push(l)}}),{era:t,value:r,gap:s}}};a.interval=v;c.setDefaultHeaders=()=>({});var ce=a;0&&(module.exports={Fetcher,Filer,Server,Time,UUID,useStore});
|
|
1
|
+
"use strict";var P=Object.defineProperty,W=Object.defineProperties,z=Object.getOwnPropertyDescriptor,X=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var L=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var F=Math.pow,H=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,T=(e,t)=>{for(var r in t||(t={}))_.call(t,r)&&H(e,r,t[r]);if(I)for(var r of I(t))Y.call(t,r)&&H(e,r,t[r]);return e},k=(e,t)=>W(e,X(t));var V=(e,t)=>{var r={};for(var s in e)_.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&I)for(var s of I(e))t.indexOf(s)<0&&Y.call(e,s)&&(r[s]=e[s]);return r};var Q=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},Z=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of G(t))!_.call(e,n)&&n!==r&&P(e,n,{get:()=>t[n],enumerable:!(s=z(t,n))||s.enumerable});return e};var ee=e=>Z(P({},"__esModule",{value:!0}),e);var d=(e,t,r)=>new Promise((s,n)=>{var i=l=>{try{u(r.next(l))}catch(h){n(h)}},o=l=>{try{u(r.throw(l))}catch(h){n(h)}},u=l=>l.done?s(l.value):Promise.resolve(l.value).then(i,o);u((r=r.apply(e,t)).next())}),O=function(e,t){this[0]=e,this[1]=t},j=(e,t,r)=>{var s=(o,u,l,h)=>{try{var p=r[o](u),b=(u=p.value)instanceof O,C=p.done;Promise.resolve(b?u[0]:u).then(m=>b?s(o==="return"?o:"next",u[1]?{done:m.done,value:m.value}:m,l,h):l({value:m,done:C})).catch(m=>s("throw",m,l,h))}catch(m){h(m)}},n=o=>i[o]=u=>new Promise((l,h)=>s(o,u,l,h)),i={};return r=r.apply(e,t),i[L("asyncIterator")]=()=>i,n("next"),n("throw"),n("return"),i};var U=(e,t,r)=>(t=e[L("asyncIterator")])?t.call(e):(e=e[L("iterator")](),t={},r=(s,n)=>(n=e[s])&&(t[s]=i=>new Promise((o,u,l)=>(i=n.call(e,i),l=i.done,Promise.resolve(i.value).then(h=>o({value:h,done:l}),u)))),r("next"),r("return"),t);var pe={};Q(pe,{Fetcher:()=>f,Filer:()=>g,Server:()=>B,Time:()=>c,UUID:()=>D,default:()=>fe,useStore:()=>A});module.exports=ee(pe);typeof HTMLElement!="undefined"&&(HTMLElement.prototype.position=function(){return this.getBoundingClientRect()});typeof String!="undefined"&&(String.prototype.compress=function(){return this.trim().replace(/(\s|\n|\t)/ig,"")},String.prototype.encode=function(){return encodeURIComponent(this)},String.prototype.decode=function(){return decodeURIComponent(this)},String.prototype.toUpper=function(){return this.toLocaleUpperCase()},String.prototype.toLower=function(){return this.toLocaleLowerCase()},String.prototype.toCapital=function(){let e=this;return e&&(e=e.replace(/^./,this[0].toUpper()).replace(/(\s|_|-)[a-z]{1}/ig,t=>t[1].toUpper())),e},String.prototype.clip=function(e,t){return this.slice(e,t)},String.prototype.partReplace=function(e,t){return this.slice(0,e)+t+this.slice(e+t.length)},String.prototype.toBlob=function(e){let t=atob(this.replace(/^.*,/,"")),r=new Uint8Array(t.length);for(var s=0;s<t.length;s++)r[s]=t.charCodeAt(s);try{var n=new Blob([r.buffer],{type:e})}catch(i){return!1}return n},String.prototype.toNumber=function(){return Number(this.removeLetters())},String.prototype.removeLetters=function(){return this.replace(/[\D]/ig,"")},String.prototype.removeSpecifics=function(){return this.replace(/[^\w\s\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Han}]|_/uig,"")},String.prototype.removeJP=function(){return this.replace(/[\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Han}]+/uig,"")},String.prototype.zen2hanNumber=function(){return this.replace(/[0-9]/g,function(e){return String.fromCharCode(e.charCodeAt(0)-65248)}).replace(/[--﹣−‐⁃‑‒–—﹘―⎯⏤ーー─━]/g,"-").replace(/¥/,"\xA5").replace(/、/,",").replace(/(/,"(").replace(/)/,")").replace(/+/,"+")},String.prototype.escapeRegExChar=function(){return this.replace(/\\/g,"\\\\").replace(/(\?|\^|\$|\.|\||\*|\+|\(|\)|\{|\}|\[|\])/g,"\\$1")});typeof Number!="undefined"&&(Number.prototype.zeroEmbed=function(e){return String(this).padStart(e||2,"0")},Number.prototype.ratio=function(e,t=2){let r=F(10,t);return Math.round(this/e*r*100)/r},Number.prototype.rate=function(e,t=2){let r=F(10,t);return Math.round(this/e*r)/r},Number.prototype.rank=function(e=1){let t=F(10,e),r=Number(this),s=r.toLocaleString().replace(/\d/ig,"").length;return Math.round(r/F(1e3,s)*t)/t+("KMGTPEZY"[s-1]||"")},Number.prototype.rankJp=function(){let e=Number(this),t="";return e>=1e12?t=`${e/1e12}\u5146`:e>=1e8?t=`${e/1e8}\u5104`:e>=1e4?t=`${e/1e4}\u4E07`:e>=1e3?t=`${e/1e3}\u5343`:t=`${e.toLocaleString()}`,t},Number.prototype.toDate=function(e="/"){let t=String(this),r=t.slice(0,4),s=t.slice(4,6),n=t.slice(6,8),i=[];return r.length!=4||i.push(r),s.length!=2||i.push(s),n.length!=2||i.push(n),i.join(e)});if(typeof Array!="undefined"){let e=(t,r)=>{var n;let s=t;for(let i of r){if(!i)break;s=(n=(s||{})[i||""])!=null?n:null}return s};Array.prototype.toASC=function(...t){return(!t||!(t!=null&&t.length))&&(t=[""]),this.sort((r,s)=>{for(let n of t){let i=String(n||""),o=this.every(h=>{let p=Number(e(h,i.split(".")));return typeof p=="number"&&!isNaN(p)}),u=e(r,i.split(".")),l=e(s,i.split("."));if(o){if(u=Number(u),l=Number(l),u>l)return 1;if(u<l)return-1}else{if(u=String(u).replace(/(\d+)/g,h=>h.padStart(18,"0")),l=String(l).replace(/(\d+)/g,h=>h.padStart(18,"0")),u>l)return 1;if(u<l)return-1}}return 0})},Array.prototype.toDESC=function(...t){return this.toASC(...t).reverse()}}typeof File!="undefined"&&(File.prototype.convert=function(e){return e=e||"dataURL",new Promise((t,r)=>{let s=new FileReader;s.onload=i=>t(i),s.onerror=i=>r(i);let n="readAs"+(e==null?void 0:e.toCapital());s[n](this)})});var te=(e=26)=>Array.from({length:e}).map((t,r)=>{let s=r==0?25:35,n=Math.round(Math.random());return"abcdefghijkrmnopqrstuvwxyz0123456789"[Math.round(Math.random()*s)][n?"toUpper":"toLower"]()}).join(""),D=te;D.gen128Binary=()=>Array.from({length:128}).map((e,t)=>"01"[Math.round(Math.random()*1)]).join("");D.gen32Hex=(e="Formatted",t="-")=>{let r=Array.from({length:32}).map((s,n)=>"0123456789abcdef"[Math.round(Math.random()*15)]).join("").toUpper();return e=="Formatted"&&(r=[r.slice(0,8),r.slice(8,12),r.slice(12,16),r.slice(16,20),r.slice(20,32)].join(t)),r};D.to32Format=e=>[e.slice(0,8),e.slice(8,12),e.slice(12,16),e.slice(16,20),e.slice(20,32)].join("-").toUpper();var re=e=>new a.prototype.jmini(e),a=re;a.prototype={};a.extend=function(e,t=a){for(var[r,s]of Object.entries(e))t.prototype[r]=s};a.expando="__jmini_"+D();var y=(e,t)=>(e.queue.push(t),J(e),e),J=e=>d(void 0,null,function*(){if(!e.queueProcess&&e.queue.length){e.queueProcess=!0;let t=e.queue.shift();t&&(yield t()),e.queueProcess=!1,J(e)}}),E=(e,t)=>{for(let r=0;r<e.length;r++)e[r]=null;for(let[r,s]of Object.entries(t))r.match(/queue/)||(e[r]=s);return e},ne=(e,t)=>{if(t.length){for(var r=0;r<t.length;r++){let s=t[r];s&&(s[a.expando]||(a.is.element(s)||a.is.shadowRoot(s))&&(s[a.expando]={events:{}})),e[r]=s}e.length=t.length}else e.warn="No Argument(s).",e.length=0;return e.queueProcess=!1,J(e),e};a.extend({constructor:a,jmini:function(e){return this.src=e,this.srcType=a.is.what(e),this.queueProcess=!0,this.queue=[],ne(this,a.is.jmini(e)?e.get():a.is.element(e)?[e]:a.is.elements(e)?e:a.is.shadowRoot(e)?[e]:a.is.string(e)?e.match(/^#[^\.\s]*$/)?[document.getElementById(e.replace(/#/,""))]:document.querySelectorAll(e):[])}});a.prototype[String(Symbol.iterator)]=[][Symbol.iterator];a.prototype.jmini.prototype=a.prototype;{let e=function(n,i,o){let u=[];for(let l=0;l<(n.length||0);l++)u.push(i(n[l],l));return o&&(u=u.filter(l=>l!=null)),u},t=n=>(n.for((i,o)=>{if(!(a.is.element(i)||a.is.shadowRoot(i)))return;let u=i.cloneNode(),l=i.parentNode;l&&l.replaceChild(u,i),n[o]=u}),n),r=(n,i)=>(a(i).for(o=>{if(n&&(a.is.element(o)||a.is.shadowRoot(o)))if(a.is.string(n)||a.is.number(n))n=String(n),o.insertAdjacentHTML("beforeend",String(n));else if(a.is.element(n))o.appendChild(n);else{a.is.jmini(n)?n=n.get():a.is.element(n)?n=[n]:a.is.keyValueDictionary(n)&&(n=[a(n)]);for(var u=0;u<n.length;u++)r(n[u],o)}}),i),s=(n,i,...o)=>{let{p:u,s:l}={before:{p:"beforebegin",s:""},after:{p:"afterend",s:"nextSibling"}}[i]||{p:"",s:""};return n.for(h=>{if(a.is.string(o[0]))h.insertAdjacentHTML(u,o[0]);else{if(!h.parentNode)return;a(o[0]).for(b=>{o[1]&&(b=b.cloneNode(!0)),h.parentNode.insertBefore(b,h[l]||h)})}}),n};a.extend({get:function(n){return n?this[0]:e(this,i=>i)},for:function(n,i=1){let o=e(this,(u,l)=>n(u,l),1);return i?o:[]},await:function(n){return y(this,()=>new Promise((i,o)=>{setTimeout(()=>{i(this)},n)}))},abort:function(){return y(this,()=>d(this,null,function*(){return this.queue=[],this}))},callback:function(n){return y(this,()=>d(this,null,function*(){return yield n(this),this}))},click:function(){return y(this,()=>{for(var n=0;n<this.length;n++){let i=this[n];a.is.element(i)&&i.click()}return this})},focus:function(){return y(this,()=>{for(var n=0;n<this.length;n++){let i=this[n];a.is.element(i)&&i.focus()}return this})},addEvent:function(n){return y(this,()=>{let{eventType:i,eventID:o=D(),target:u,callback:l,options:h}=n;return h=T({passive:!0,capture:!1},h),this.for(p=>{if(!(a.is.element(p)||a.is.shadowRoot(p)))return;let{events:b}=p[a.expando];if(u){let C=l;l=m=>{if(m.target){if(a.is.string(u)){let S=m.target.closest(u);S&&(!S||C.call(S,m))}else if(a.is.elements(u)){for(let M of u)if(m.target==M)return C.call(M,m)}}}}if(b[o]){let C=b[o];p.removeEventListener(C.eventType,C.callback,C.options)}b[o]={eventType:i,callback:l,options:h},p.addEventListener(i,l,h)}),this})},removeEvent:function(n){return y(this,()=>{let i=a.is.array(n)?n:[n];return this.for(o=>{let{events:u}=o[a.expando];for(let l of i){let h=u[l];h&&o.removeEventListener(h.eventType,h.callback,h.options)}}),this})},html:function(n){return y(this,()=>E(this,r(n,t(this))))},empty:function(){return y(this,()=>E(this,t(this)))},append:function(n){return y(this,()=>{r(n,this)})},remove:function(){return y(this,()=>(this.for((n,i)=>{n&&a.is.element(n)&&(n.remove(),delete this[i])}),this.length=0,this.warn="Object(s?) were all removed.",this))},before:function(...n){return y(this,()=>E(this,s(this,"before",...n)))},after:function(...n){return y(this,()=>E(this,s(this,"after",...n)))},find:function(n){return y(this,()=>{let i=[],o=this[0];o||E(this,a()),(a.is.element(o)||a.is.shadowRoot(o))&&(a.is.string(n)?i=o.querySelectorAll(n):a.is.element(o)&&a(n).for(u=>{let l=o.childNodes;for(let h of l)if(h===u){i.push(h);break}else h.childNodes.length&&(i=[...i,...a(h).find(u).for(p=>p)])})),E(this,a(i))})},parent:function(n){return y(this,()=>{var o,u;let i=a(n?(o=this[0])==null?void 0:o.closest(n):(u=this[0])==null?void 0:u.parentNode);E(this,i)})},children:function(n){return y(this,()=>{let i=this[0].children;a.is.exist(n)&&(n=String(n).replace(/^ : /,""),i=n=="first"?i[0]:n=="last"?i[i.length-1]:i[Number(n)]);let o=a(i);return E(this,o)})},addClass:function(n){return y(this,()=>(n&&this.for(i=>{let o=a.is.string(n)?n.split(" "):n;i&&a.is.element(i)&&i.classList.add(...o)}),this))},removeClass:function(n){return y(this,()=>(n&&this.for(i=>{let o=a.is.string(n)?n.split(" "):n;i&&a.is.element(i)&&i.classList.remove(...o)}),this))},toggleClass:function(n){return y(this,()=>(n&&this.for(i=>{i.classList.toggle(n)}),this))},hasClass:function(n=""){if(this[0])return this[0].classList.contains(n.replace(/^\./,""))},findClass:function(n){let i=[];return this[0]&&(i=[...this[0].classList].filter(o=>o.match(n))),i},css:function(n){return y(this,()=>(this.for(i=>{if(a.is.element(i))for(let[o,u]of Object.entries(n)){if(a.is.number(u)&&o.match(/width|height|top|right|bottom|left|padding|margin|gap|border-.*radius/)){i.style[o]=u+"px";continue}i.style[o]=String(u)}}),this))},getAttribute:function(n){return this[0].getAttribute(String(n))},setAttribute:function(n,i){return y(this,()=>(this.for(o=>o.setAttribute(n,i)),this))},getStyleProperty:function(n){let i=this[0];return i&&a.is.element(i)?getComputedStyle(i).getPropertyValue(n):""},setStyleProperty:function(n,i){let o=this[0];return o&&a.is.element(o)&&o.style.setProperty(n,i),this},val:function(){var i;let n=this[0];return(n==null?void 0:n.value)||((i=n==null?void 0:n.dataset)==null?void 0:i.value)},position:function(){return a.is.element(this[0])?this[0].getBoundingClientRect():{}}})}a.flatArray=(e,t)=>{if(!a.is.array(e))return[e];let r=[];for(let s of e)r.push(...t=="-R"?a.flatArray(s,"-R"):[s]);return r};a.uniqueArray=(e,t)=>{let r=e;return t?r=Array.from(new Map(e.map(s=>[a.getKeyValue(s,t||"0"),s])).values()):r=Array.from(new Set(e)),r};a.getKeyValue=(e,t)=>{let r={},s=e;return t.split(".").forEach(n=>{s=s==null?void 0:s[n],r=s}),r};a.Stringify=(...e)=>{let[t,r,s]=e;return JSON.stringify(t,r!=null?r:(()=>{let n=new WeakSet;return(i,o)=>{if(typeof o=="object"&&o!==null){if(n.has(o))return"[Circular Reference]";n.add(o)}return o}})(),s)};a.Objectify=(e,t)=>{try{return JSON.parse(e)}catch(r){return t!=null?t:null}};a.randomNumber=(e=0,t=100,r)=>{if(e>t)return NaN;let s=[],n=e;for(;n<=t;){if(r&&r.length&&r.includes(n)){n++;continue}s.push(n),n++}let i=Math.round(Math.random()*(s.length-1))+0;return s[i]};a.try=e=>{try{return[e(),!0]}catch(t){return[t,!1]}};a.trySync=e=>d(void 0,null,function*(){try{return[yield e(),!0]}catch(t){return[t,!1]}});a.scope=e=>e();a.scopeSync=e=>d(void 0,null,function*(){return yield e()});a.createElement=function(e){var b;let{tag:t,className:r="",id:s,html:n,attr:i,style:o,parent:u}=e,l=document.createElement(t||"div");if(r&&l.classList.add(...r.split(" ")),s&&(l.id=s),i)for(let C of Object.entries(i)){let m=C[0],M=(b=C[1])!=null?b:"";if(m=="data"&&a.is.keyValueDictionary(M))for(let[S,w]of Object.entries(M))l.dataset[S]=w;else m=="for"?m="htmlFor":m=="tabindex"?m="tabIndex":m=="aria-label"&&(m="ariaLabel"),l[m]=M}if(n&&a(l).append(n),o)for(var[h,p]of Object.entries(o))l.style[h]=p;return u&&a(u).append(l),l};a.setCookie=e=>{let{hostname:t}=new URL(location.toString()),{name:r,value:s="",age:n=60*60*24*365,path:i="/",domain:o=t,secure:u=!1}=e,l=`${r}=${s}max-age=${n}path=${i}domain=${o}`;u&&(l+=" Secure"),document.cookie=l};a.getCookie=e=>{let t=document.cookie.match(new RegExp(e+"=[^]*"));return t?t[0].replace(new RegExp(e+"="),""):""};a.localStrage={set:(e,t)=>{localStorage.setItem(e,a.Stringify(t))},get:e=>{let t=localStorage.getItem(e);return a.Objectify(t,t)}};a.deleteCookie=e=>{document.cookie=e+"=max-age=0"};a.getScreenSize=()=>{let{innerHeight:e,innerWidth:t,scrollY:r,scrollX:s,pageXOffset:n,pageYOffset:i}=window,o=Number(a(document.body).getStyleProperty("--sat").removeLetters()),u=Number(a(document.body).getStyleProperty("--sab").removeLetters());return{height:e,width:t,pageHeight:e-o-u,scrollY:r,scrollX:s,pageXOffset:n,pageYOffset:i,safeAreaTop:o,safeAreaBottom:u}};a.getCursor=e=>{var s,n,i,o,u,l,h,p;let t=(o=e.pageX)!=null?o:(i=(s=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:s.pageX)!=null?i:(((n=e==null?void 0:e.originalEvent)==null?void 0:n.touches)||[])[0].pageX,r=(p=e.pageY)!=null?p:(h=(u=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:u.pageY)!=null?h:(((l=e==null?void 0:e.originalEvent)==null?void 0:l.touches)||[])[0].pageY;return{x:t,y:r}};a.pending=(e,t)=>new Promise((r,s)=>{e(r),t&&setTimeout(()=>{r(!0)},t)});a.deepMerge=(e,...t)=>{if(!t.length)return e;let r=t.shift();if(a.is.keyValueDictionary(e)&&a.is.keyValueDictionary(r))for(let s in r)a.is.keyValueDictionary(r[s])?(e[s]||Object.assign(e,{[s]:{}}),a.deepMerge(e[s],r[s])):Object.assign(e,{[s]:r[s]});return a.deepMerge(e,...t)};a.deepCopy=e=>{if(a.is.array(e))return e.map(t=>a.deepCopy(t));if(a.is.keyValueDictionary(e)){let t={};return Object.entries(e).forEach(([r,s])=>{t[r]=a.deepCopy(s)}),t}return e};a.queryParams={get:e=>{let t=new URL(e||location.href),r={};return t.searchParams.forEach((s,n)=>r[n]=s),r},set:(e,t)=>{let r=new URL(t||location.href);return Object.entries(e).forEach(([s,n])=>{r.searchParams.set(s,String(n))}),t||history.replaceState({},"",r.pathname+r.search),r.toString()},delete:(e,t)=>{let r=new URL(t||location.href);return e.forEach(s=>{r.searchParams.delete(s)}),t||history.replaceState({},"",r.pathname+r.search),r.toString()}};a.ellipsisText=(e,t)=>{let r=String(e);return r.length>t&&(r=r.slice(0,t)+" ..."),r};a.is={equal:function(e,t,r){return r==null||r?a.Stringify(e)===a.Stringify(t):e===t},what:function(e){let t="other";return this.jmini(e)?t="jmini":this.element(e)?t="element":this.elements(e)?t="elements":this.shadowRoot(e)?t="shadowRoot":this.string(e)?t="string":this.number(e)?t="number":this.array(e)?t="array":this.function(e)?t="function":this.date(e)?t="date":typeof e=="undefined"?t="undefined":this.keyValueDictionary(e)?t="keyValueDictionary":e==null?t="null":isNaN(e)&&(t="NaN"),t},exist:function(e){return e===(e!=null?e:!e)},nullish:function(e){return!this.exist(e)},jmini:function(e){return(e||{}).constructor===a},string:function(e){return typeof e=="string"},boolean:function(e){return typeof e=="boolean"},number:function(e){return!isNaN(e)&&typeof e=="number"},array:function(e){let t={}.toString.call(e);return e instanceof Array||t=="[object NodeList]"||t=="[object HTMLCollection]"},function:function(e){return typeof e=="function"},keyValueDictionary:function(e){return{}.toString.call(e)==="[object Object]"&&!this.jmini(e)},element:function(e){return e&&(e.nodeType==1&&typeof e.style=="object"&&typeof e.ownerDocument=="object"||[window,document].includes(e))},elements:function(e){let t={}.toString.call(e),r=Number(!!e&&typeof e!="string"&&this.array(e)&&t!=="[object Text]");if(r&&t!=="[object NodeList]")for(var s of e)r&=Number(this.element(s));return!!r},shadowRoot:function(e){return e instanceof ShadowRoot},date:function(e){return this.number(new Date(e).getTime())}};var se=e=>new c.prototype.Time(e),c=se;c.prototype={};var ie=function(e){c.isTimeObject(e)&&(e=e.value),e||(e===null?e=void 0:e===void 0&&(e=new Date));let t=new Date(e);return this.set(t)};a.extend({value:new Date,validate:!1,ms:-1,weekday:-1,weekInMonth:-1,weekInYear:-1,isLastWeekInMonth:!1,year:-1,month:-1,date:-1,hours:-1,minutes:-1,seconds:-1,constructor:c,Time:ie,clone:function(){return c(this)},set:function(e){this.value=e;let t=a.is.date(e);if(this.validate=t,!t)return this.ms=-1,this.year=-1,this.month=-1,this.weekday=-1,this.weekInYear=-1,this.date=-1,this.hours=-1,this.minutes=-1,this.seconds=-1,this;this.ms=e.getTime(),this.weekday=e.getDay(),this.year=e.getFullYear(),this.month=e.getMonth()+1,this.date=e.getDate();{let r=new Date(this.year,0,1),s=new Date(r.valueOf());s.setDate(s.getDate()-(r.getDay()+1));let n=e.getTime()-s.getTime(),i=Math.ceil(n/(1e3*60*60*24));this.weekInYear=Math.ceil(i/7)}{let r=new Date(this.year,this.month-1,1),s=new Date(r.valueOf());s.setDate(s.getDate()-(r.getDay()+1));let n=e.getTime()-s.getTime(),i=Math.ceil(n/(1e3*60*60*24)),o=Math.ceil(i/7);this.weekInMonth=o}{let r=new Date(this.year,this.month,0),s=r.getDay(),n=new Date(new Date(r).setDate(r.getDate()-s));this.isLastWeekInMonth=this.date>=n.getDate()}return this.hours=e.getHours(),this.minutes=e.getMinutes(),this.seconds=e.getSeconds(),this},isPast:function(){let e=c();return this.value.valueOf()<e.value.valueOf()},isSameYear:function(e){let t=c(e);return this.year==t.year},isSameMonth:function(e){let t=c(e);return this.year==t.year&&this.month==t.month},isSameWeek:function(e){let t=c(e);return this.year==t.year&&this.weekInYear==t.weekInYear},isSameDate:function(e){let t=c(e);return this.year==t.year&&this.month==t.month&&this.date==t.date},setYear:function(e){let t=new Date(this.value.valueOf());return t.setFullYear(e),this.set(t)},setMonth:function(e){let t=new Date(this.value.valueOf());return t.setMonth(e-1),this.set(t)},setDate:function(e){let t=new Date(this.value.valueOf());return t.setDate(e),this.set(t)},setHours:function(e){let t=new Date(this.value.valueOf());return t.setHours(e),this.set(t)},setMinutes:function(e){let t=new Date(this.value.valueOf());return t.setMinutes(e),this.set(t)},setSeconds:function(e){let t=new Date(this.value.valueOf());return t.setSeconds(e),this.set(t)},setMilliseconds:function(e){let t=new Date(this.value.valueOf());return t.setMilliseconds(e),this.set(t)},addYear:function(e){return this.setYear(this.year+e)},addMonth:function(e){return this.setMonth(this.month+e)},addWeek:function(e){return this.addDate(7*e)},addDate:function(e){return this.setDate(this.date+e)},addHours:function(e){return this.setHours(this.hours+e)},addMinutes:function(e){return this.setMinutes(this.minutes+e)},addSeconds:function(e){return this.setSeconds(this.seconds+e)},toFormat:function(e){return this.validate?e.replace(/\%y/ig,this.year.zeroEmbed(4)).replace(/\%m/ig,this.month.zeroEmbed(2)).replace(/\%d/ig,this.date.zeroEmbed(2)).replace(/\%w/ig,this.weekInYear.zeroEmbed(2)).replace(/\%h/ig,this.hours.zeroEmbed(2)).replace(/\%i/ig,this.minutes.zeroEmbed(2)).replace(/\%s/ig,this.seconds.zeroEmbed(2)):""},toFormatYMD:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5"):this.toFormat("%Y/%M/%D"):""},toFormatYM:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708"):this.toFormat("%Y/%M"):""},toFormatMD:function(e){return this.validate?e=="JP"?this.toFormat("%M\u6708%D\u65E5"):this.toFormat("%M/%D"):""},toFormatHM:function(e){return this.validate?e=="JP"?this.toFormat("%h\u6642%i\u5206"):this.toFormat("%h:%i"):""},toFormatYMDHM:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%i\u5206"):this.toFormat("%Y/%M/%D %h:%i"):""},toFormatYMDHMS:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%m\u5206%s\u79D2"):this.toFormat("%Y/%M/%D %h:%i:%s"):""},toLangYMD:function(e){if(!this.validate)return"";let t=c(),r=t.diff(this);return r.dates==0?"\u4ECA\u65E5":r.dates==1?"\u6628\u65E5":r.dates>=-7&&r.dates<0?-1*r.dates+"\u65E5\u5F8C":r.dates<=7&&r.dates>0?r.dates+"\u65E5\u524D":this.isSameYear(t)?e=="JP"?this.toFormat("%M\u6708%D\u65E5"):this.toFormat("%M/%D"):e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5"):this.toFormat("%Y/%M/%D")},setFirstOfTheDay:function(){let e=new Date(this.value.valueOf());return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),this.set(e)},setLastOfTheDay:function(){let e=new Date(this.value.valueOf());return e.setHours(23),e.setMinutes(59),e.setSeconds(59),e.setMilliseconds(999),this.set(e)},setFromFormatHHMM:function(e){let t=String(e).removeLetters().removeSpecifics().toNumber().zeroEmbed(4).replace(/(\d{2})(\d{2})/,"$1:$2"),[r,s]=t.split(":"),n=new Date(this.value.valueOf());return n.setHours(Number(r)),n.setMinutes(Number(s)),this.set(n)},setFromFormatHHMMSS:function(e){let t=String(e).removeLetters().removeSpecifics().toNumber().zeroEmbed(4).replace(/(\d{2})(\d{2})(\d{2})/,"$1:$2:$3"),[r,s,n]=t.split(":"),i=new Date(this.value.valueOf());return i.setHours(Number(r)),i.setMinutes(Number(s)),i.setSeconds(Number(n)),this.set(i)},getFirstDayOfTheYear:function(){return c(new Date(this.value.getFullYear(),0,1))},getLastDayOfTheYear:function(){return c(new Date(this.value.getFullYear()+1,0,0))},getFirstDayOfTheMonth:function(){return c(new Date(this.value.getFullYear(),this.month-1,1))},getLastDayOfTheMonth:function(){return c(new Date(this.value.getFullYear(),this.month,0))},getFirstDayOfTheWeek:function(){let e=c(this.value);return e.addDate(-e.weekday)},getLastDayOfTheWeek:function(){let e=c(this.value);return e.addDate(6-e.weekday)},diff:function(e){return{years:this.year-e.year,months:(this.year-e.year)*12+(this.month-e.month),dates:a.scope(()=>{let t=864e5,r=this.clone().setFirstOfTheDay(),s=e.clone().setFirstOfTheDay();return Math.floor((r.ms-s.ms)/t)}),hours:a.scope(()=>{let t=36e5,r=this.clone().setMinutes(0).setSeconds(0).setMilliseconds(0),s=e.clone().setMinutes(0).setSeconds(0).setMilliseconds(0);return Math.floor((r.ms-s.ms)/t)}),minutes:a.scope(()=>{let t=6e4,r=this.clone().setSeconds(0).setMilliseconds(0),s=e.clone().setSeconds(0).setMilliseconds(0);return Math.floor((r.ms-s.ms)/t)}),seconds:a.scope(()=>{let t=this.clone().setMilliseconds(0),r=e.clone().setMilliseconds(0);return Math.floor((t.ms-r.ms)/1e3)}),ms:this.ms-e.ms}},getAge:function(e){let t=e||c(),r=t.year-this.year;return(this.month>t.month||this.month==t.month&&t.date<this.date)&&r--,r}},c);c.isTimeObject=e=>{var t;return((t=e||{})==null?void 0:t.constructor)===c};c.getFromNumberYYYYMMDD=e=>{let t=Number(e).zeroEmbed(8).replace(/(\d{4})(\d{2})(\d{2})/,"$1/$2/$3");return c(t+" 00:00:00")};c.getShortYMDs=(e,t)=>{let r="",s="";return e.year==t.year&&e.year==c().year?r=e.toFormatMD():r=e.toFormatYMD(),e.year!=t.year?s=t.toFormatYMD():s=t.toFormatMD(),[r,s]};c.getPeriodArray=(e,t,r)=>{let s=[],n=t;if(!t.validate||!r.validate)return s;for(;n.toFormatYMDHMS().toNumber()<=r.toFormatYMDHMS().toNumber();)s.push(n),e=="year"?n=c(n).addYear(1):e=="month"?n=c(n).addMonth(1):e=="week"?n=c(n).addWeek(1):e=="day"?n=c(n).addDate(1):e=="hours"?n=c(n).addHours(1):e=="minutes"?n=c(n).addMinutes(1):e=="seconds"&&(n=c(n).addSeconds(1));return s};c.prototype.Time.prototype=c.prototype;var x={},A={set:(e,t)=>{let r=!0;return Object.entries(e).forEach(([s,n])=>{let i=x[s]||{};i&&i.privateKey&&i.privateKey!=t&&(r=!1),x[s]={privateKey:t,value:n}}),r},update:(e,t)=>{let r=!0;return Object.entries(e).forEach(([s,n])=>{var o;let i=x[s]||{};i&&i.privateKey&&i.privateKey!=t&&(r=!1),x[s]=k(T({},x[s]),{value:T(T({},(o=x[s])==null?void 0:o.value),n)})}),r},get:(e,t)=>{let r=x[e];if(!(r&&r.privateKey&&r.privateKey!=t))return r==null?void 0:r.value},delete:(e,t)=>{let r=x[e];return r&&r.privateKey&&r.privateKey!=t?!1:(delete x[e],!0)}};var ae=(...[e,t,r])=>new v.prototype.Interval(e,t,r),v=ae;v.prototype={};var oe=function(...[e,t,r]){return this.fn=e,this.ms=t,this.key=r,v.abort(this.key),this.store(),this};a.extend({key:"",ms:0,timeoutIndex:-1,fn:null,Interval:oe,store:function(){A.set({["Interval_"+this.key]:this})},once:function(){return this.fn&&(this.timeoutIndex=setTimeout(this.fn,this.ms)),this.store(),this},start:function(){return this.fn&&(this.timeoutIndex=setInterval(this.fn,this.ms)),this.store(),this},abort:function(){return v.abort(this.timeoutIndex),this},set_ms:function(e){return this.ms=e,this.store(),this},set_fn:function(e){return this.fn=e,this.store(),this}},v);v.abort=e=>{if(a.is.number(e))return clearInterval(e);let t=A.get("Interval_"+e);t&&clearInterval(t.timeoutIndex)};v.get=e=>A.get("Interval_"+e);v.once=(e,t,r)=>v(e,t,r).once();v.start=(e,t,r)=>v(e,t,r).start();v.prototype.Interval.prototype=v.prototype;var ue=(e,t)=>new f.prototype.Fetcher(e,t),f=ue;f.prototype={};f.waitList=[];f.setDefaultTrafficControl=0;f.setDefaultTimeout=1e3*60*10;f.isReadableStream=e=>e instanceof ReadableStream;f.isReadableStreamReader=e=>e instanceof ReadableStreamDefaultReader;f.streamToContext=(e,t)=>d(void 0,null,function*(){try{let r=(t==null?void 0:t.reader)||e.getReader();if(!f.isReadableStreamReader(r))return{ok:!1,done:!0,data:null};if(!r)return{ok:!1,done:!0,data:null};let s=(t==null?void 0:t.decoder)||new TextDecoder("utf-8"),n=yield r.read();return{ok:!0,done:n.done,data:s.decode(n.value)}}catch(r){return{ok:!1,done:!0,data:r}}});var le=function(e,t){var n;t=t||{};let r=t.body;t.body&&!a.is.string(t.body)&&((n=t.bodyStringify)==null||n)&&(r=a.Stringify(t.body||{}));let s=e;return a.is.string(e)&&!e.match(/https?:/)&&(s=location.origin+"/"+e.replace(/^\//,"")),this.url=s,this.method=t.method||"get",this.streamStatus="open",this.params=k(T({key:D(),response_format:"json",timeout:f.setDefaultTimeout,trafficControl:f.setDefaultTrafficControl,preventMultiRequest:!0},t),{headers:T(T({"Content-Type":"application/json"},f.setDefaultHeaders&&f.setDefaultHeaders()),t.headers),body:r}),this};a.extend({Fetcher:le,params:{},url:"",method:"GET",streamStatus:"closed",onStartCB:()=>{},onCompleteCB:()=>{},onRetryCB:()=>d(void 0,null,function*(){return null}),isRetry:!1,extraBody:{},setExtraBody:function(e){return this.extraBody=T(T({},this.extraBody),e),this},onErrorCB:()=>{},onResultCB:()=>{},onStreamCB:()=>{},onStart:function(e){return this.onStartCB=e,this},onStream:function(e){return this.onStreamCB=e,this},onResult:function(e){return this.onResultCB=e,this},onComplete:function(e){return this.onCompleteCB=e,this},onRetry:function(e){return this.onRetryCB=e,this},onError:function(e){return this.onErrorCB=e,this},onStreamProcess:function(e){return d(this,null,function*(){let{response:t,errorCB:r,streamCB:s,reader:n,decoder:i}=e,o=t.body,u=this,l=function(){return j(this,null,function*(){if(!t.ok){a.scope(()=>d(this,null,function*(){let{ok:M,done:S,data:w}=yield f.streamToContext(o,{reader:n,decoder:i});M&&r(w)}));return}let m=!1;for(;!m;){let{ok:M,done:S,data:w}=yield new O(f.streamToContext(o,{reader:n,decoder:i}));u.streamStatus=="abort"?(u.streamStatus="closed",n.cancel(),S=!0):u.streamStatus=="closed"&&(S=!0),S&&(m=S,n.releaseLock()),s(w,S)}})};try{for(var h=U(l()),p,b,C;p=!(b=yield h.next()).done;p=!1){let m=b.value;;}}catch(b){C=[b]}finally{try{p&&(b=h.return)&&(yield b.call(h))}finally{if(C)throw C[0]}}})},get:function(){return this.method="GET",this.send()},head:function(){return this.method="HEAD",this.send()},post:function(){return this.method="POST",this.send()},put:function(){return this.method="PUT",this.send()},delete:function(){return this.method="DELETE",this.send()},patch:function(){return this.method="PATCH",this.send()},options:function(){return this.method="OPTIONS",this.send()},send:function(){return d(this,null,function*(){var C;let e=this.params,t=performance.now(),r=0,s=new AbortController,n=setTimeout(()=>{s.abort()},e.timeout);e.signal=s.signal;let i=!1,o=500,u="InternalServerError",l={},h=null;try{f.setDefaultOnStart&&f.setDefaultOnStart(e),this.onStartCB&&this.onStartCB(e);let b=e,{key:m,response_format:M,trafficControl:S,preventMultiRequest:w,timeout:de,queries:$}=b,N=V(b,["key","response_format","trafficControl","preventMultiRequest","timeout","queries"]);N.method=this.method;let K=f.waitList.includes(m);if(w&&K)throw o=429,new Error("TooManyRequests");f.waitList=[...f.waitList,m];let q=a.queryParams.set(T({},$),String(this.url));l=yield fetch(q,N).then(R=>d(this,null,function*(){return i=R.ok,o=R.status,u=R.statusText,h=R,M=="none"||M=="stream"?R:R[M]()})).catch(R=>{throw new Error(R)})}catch(m){o==200&&(o=500,i=!1),o==429&&(u="TooManyRequests"),s.signal.aborted&&(o=408,u="Timeout"),o==500&&(u=String(m)||u),l={errorCode:String(m)}}finally{clearTimeout(n),r=performance.now()-t}e.trafficControl&&(yield a.pending(()=>{},e.trafficControl)),f.waitList.splice(f.waitList.findIndex(m=>m==e.key),1);let p={ok:i,status:o,statusText:u,body:l,additionalBody:this.extraBody,requestTime:r,rawData:h};if(!i){if(this.onRetryCB&&!this.isRetry){this.isRetry=!0;let m=yield this.onRetryCB(p.body,this.params,this);if(m)return this.params=m,this.send()}this.onErrorCB&&this.onErrorCB(p.body)}if(i&&this.onStreamCB&&e.response_format=="stream"){let m=(C=h.body)==null?void 0:C.getReader();this.onStreamProcess({errorCB:this.onErrorCB,streamCB:this.onStreamCB,response:p,reader:m,decoder:new TextDecoder("utf-8")})}return i&&this.onCompleteCB&&this.onCompleteCB(p.body),this.onResultCB&&this.onResultCB(p,e),f.setDefaultOnEnd&&f.setDefaultOnEnd(p,e),p})},abortStream:function(){this.streamStatus="abort"}},f);f.prototype.Fetcher.prototype=f.prototype;var he=e=>new g.prototype.Filer(e),g=he;g.prototype={};var me=function(e){this.ok=!0;try{let[t,r]=e.name.replace(/\s/,"").replace(/(.*)\.(.*)$/,"$1 $2").split(" ");this.file=e,this.extension=r,this.fileName=t,this.type=e.type}catch(t){console.log(t),this.ok=!1}return this};a.extend({ok:!1,extension:"",type:"",file:{},fileName:"",Filer:me,isValid:function(){return this.ok},toBlob:function(){return d(this,null,function*(){return new Blob([this.file,{type:this.type}])})},toDataURL:function(){return d(this,null,function*(){var t;return(t=(yield this.file.convert("dataURL")).target)==null?void 0:t.result})},toAarrayBuffer:function(){return d(this,null,function*(){var t;return(t=(yield this.file.convert("arrayBuffer")).target)==null?void 0:t.result})},toObjectURL:function(){return d(this,null,function*(){return URL.createObjectURL(this.file)})},updateFileName:function(e){let t=new File([this.file],e+"."+this.extension);return this.file=t,this.fileName=e,this},updateMimeType:function(e){return this.file=new File([this.file],this.fileName+"."+this.extension,{type:e}),this.type=e,this},updateExtension:function(e){let t=new File([this.file],this.fileName+"."+e);return this.file=t,this.extension=e,this}},g);g.fromFile=e=>d(void 0,null,function*(){return g(e)});g.fromBlob=(e,t)=>d(void 0,null,function*(){let r=(t==null?void 0:t.fileName)||"file",s=(t==null?void 0:t.extension)||"",n=new File([e],r+"."+s,{type:t==null?void 0:t.mimeType});return g(n)});g.fromArrayBuffer=(e,t)=>d(void 0,null,function*(){return g.fromBlob(new Blob([e],{type:(t==null?void 0:t.mimeType)||""}),t)});g.fromObjectURL=(e,t)=>d(void 0,null,function*(){let r=yield f(e,{response_format:"blob"}).get();return r.ok?g.fromBlob(r.body,t):g({})});g.fromDataURL=(e,t)=>d(void 0,null,function*(){let r=yield e.toBlob((t==null?void 0:t.mimeType)||"");return r?g.fromBlob(r,t):g({})});g.prototype.Filer.prototype=g.prototype;var ce=function(e){let t=e,r=null;return t.use((s,n,i)=>{let o=n;o.return=u=>{let{ok:l,status:h,body:p={},bodyStringify:b=!0}=u||{};h=h!=null?h:(l!=null?l:!0)&&200||403;let C=p;return b&&!a.is.string(p)&&(C=a.Stringify(p)),n.status(h).end(C)},i()}),t.onPathRouter=function(s){return r=s,this},t.pathRouter=function(s){if(!r)return;let n=r(s);return n.route(s),t.use(s,n),n},t.exception=function(s){return t.use(s),this},t},B=ce;B.getLocalIP=e=>{let t="";return a.scope(()=>{if(!e)return;let r=e.networkInterfaces();for(let[s,n]of Object.entries(r))n.forEach(i=>{!i.internal&&i.family==="IPv4"&&!i.address.match(/^(169|127)/)&&(t=i.address)})}),t};B.getIP=function(e){var s;return(((e==null?void 0:e.headers["x-forwarded-for"])||((s=e==null?void 0:e.socket)==null?void 0:s.remoteAddress)||"").toString().match(new RegExp(/(::ffff:)?(\d+\.\d+.\d+\.\d+(:\d+)?)/))||[])[2]||"UNKNOWN IP"};a.copyToClipboard=e=>d(void 0,null,function*(){let t="";a.is.string(e)?t=e:a.is.function(e)&&(t=e());let r={ok:!1,body:"NotSupported"};return yield d(void 0,null,function*(){let s;if(navigator.clipboard){if(s=yield navigator.clipboard.writeText(t).then(()=>!0,()=>!1),!s)return}else{let n=document.createElement("input");if(a(document.body).append(n),n.value=t,n.select(),s=document.execCommand("copy"),document.body.removeChild(n),!s)return}r={ok:!0,body:""}}),r});a.ImageLoader=(e,t)=>new Promise((r,s)=>{let n=t||new Image;n.onload=()=>r(n),n.onerror=i=>s(i),n.src=e});a.formatCharacter={postal:{JP:e=>{let t="--";return e=String(e).replace(/\D/ig,""),e.length==7&&(t=e.replace(/^(\d{3})(.*)/,"$1-$2")),t}},tel:{_:e=>{let t=e;return e=String(e).removeLetters(),e.length==11&&(t=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),e.length==10&&(t=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),t},mobile:e=>{let t="--";return e=String(e).removeLetters(),e.length==11&&(t=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),t},fixed:e=>{let t="--";return e=String(e).removeLetters(),e.length==10&&(t=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),t}}};a.transformer={weekday:{JP:e=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][e]+"\u66DC\u65E5",shortJP:e=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][e]},wareki:e=>{let t=[],r=[],s=!1;return[{From:1868,To:1912,name:"\u660E\u6CBB"},{From:1912,To:1926,name:"\u5927\u6B63"},{From:1926,To:1989,name:"\u662D\u548C"},{From:1989,To:2019,name:"\u5E73\u6210"},{From:2019,To:1e5,name:"\u4EE4\u548C"}].forEach(i=>{let{From:o,To:u,name:l}=i;if(o<=e&&e<=u){let h=e-o+1;h==1&&(s=!0,h="\u5143"),r.push(l+h+"\u5E74"),t.push(l)}}),{era:t,value:r,gap:s}}};a.interval=v;f.setDefaultHeaders=()=>({});var fe=a;0&&(module.exports={Fetcher,Filer,Server,Time,UUID,useStore});
|
package/declare/fetcher.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KeyValueDict } from 'src';
|
|
1
2
|
declare namespace Fetcher {
|
|
2
3
|
type urlInput = string | URL | globalThis.Request;
|
|
3
4
|
type Input = Omit<RequestInit, 'body'> & {
|
|
@@ -10,10 +11,11 @@ declare namespace Fetcher {
|
|
|
10
11
|
timeout?: number;
|
|
11
12
|
trafficControl?: number;
|
|
12
13
|
};
|
|
13
|
-
type Output<R = any, E = any> = {
|
|
14
|
+
type Output<R = any, E = any, A = any> = {
|
|
14
15
|
statusText: string;
|
|
15
16
|
requestTime: number;
|
|
16
17
|
rawData: Response;
|
|
18
|
+
additionalBody?: KeyValueDict<A>;
|
|
17
19
|
[key: string]: any;
|
|
18
20
|
} & ({
|
|
19
21
|
status: 200;
|
|
@@ -36,43 +38,45 @@ declare namespace Fetcher {
|
|
|
36
38
|
type SystemMethods = {
|
|
37
39
|
onStreamProcess(params: onStream.ProcessArgs): void;
|
|
38
40
|
onStartCB(params: Input): void;
|
|
39
|
-
onStreamCB
|
|
40
|
-
onResultCB
|
|
41
|
-
onCompleteCB
|
|
42
|
-
onRetryCB
|
|
41
|
+
onStreamCB?(data: any, done: boolean): void;
|
|
42
|
+
onResultCB(result: Output<any>, params: Input): void;
|
|
43
|
+
onCompleteCB(result: any): void;
|
|
44
|
+
onRetryCB?(result: any, current_params: Input, _this: Chains): Promise<Input | null>;
|
|
45
|
+
extraBody?: KeyValueDict;
|
|
43
46
|
isRetry: boolean;
|
|
44
|
-
onErrorCB
|
|
47
|
+
onErrorCB(error: any): void;
|
|
45
48
|
Fetcher: {
|
|
46
|
-
new <R = any, E = any>(url: urlInput, v?: Input): Chains<R, E>;
|
|
49
|
+
new <R = any, E = any, A = any>(url: urlInput, v?: Input): Chains<R, E, A>;
|
|
47
50
|
};
|
|
48
51
|
};
|
|
49
|
-
type Chains<R = any, E = any> = {
|
|
52
|
+
type Chains<R = any, E = any, A = any> = {
|
|
50
53
|
params: Input;
|
|
51
54
|
url: urlInput;
|
|
52
55
|
method: string;
|
|
53
56
|
streamStatus: 'open' | 'abort' | 'closed';
|
|
54
|
-
get<_R = R, _E = E>(): Promise<Output<_R, _E>>;
|
|
55
|
-
head<_R = R, _E = E>(): Promise<Output<_R, _E>>;
|
|
56
|
-
post<_R = R, _E = E>(): Promise<Output<_R, _E>>;
|
|
57
|
-
put<_R = R, _E = E>(): Promise<Output<_R, _E>>;
|
|
58
|
-
delete<_R = R, _E = E>(): Promise<Output<_R, _E>>;
|
|
59
|
-
patch<_R = R, _E = E>(): Promise<Output<_R, _E>>;
|
|
60
|
-
options<_R = R, _E = E>(): Promise<Output<_R, _E>>;
|
|
61
|
-
|
|
57
|
+
get<_R = R, _E = E, _A = A>(): Promise<Output<_R, _E, _A>>;
|
|
58
|
+
head<_R = R, _E = E, _A = A>(): Promise<Output<_R, _E, _A>>;
|
|
59
|
+
post<_R = R, _E = E, _A = A>(): Promise<Output<_R, _E, _A>>;
|
|
60
|
+
put<_R = R, _E = E, _A = A>(): Promise<Output<_R, _E, _A>>;
|
|
61
|
+
delete<_R = R, _E = E, _A = A>(): Promise<Output<_R, _E, _A>>;
|
|
62
|
+
patch<_R = R, _E = E, _A = A>(): Promise<Output<_R, _E, _A>>;
|
|
63
|
+
options<_R = R, _E = E, _A = A>(): Promise<Output<_R, _E, _A>>;
|
|
64
|
+
setExtraBody(body: KeyValueDict): Chains<R, E, A>;
|
|
65
|
+
send<_R = R, _E = E, _A = A>(): Promise<Output<_R, _E>>;
|
|
62
66
|
abortStream(): void;
|
|
63
67
|
onStart(cb: (params: Input) => void): Chains;
|
|
64
68
|
onStream<T = any>(callback: (data: T, done: boolean) => void, options?: {
|
|
65
69
|
decoder?: TextDecoder;
|
|
66
70
|
}): Chains;
|
|
67
|
-
onResult<_R = R, _E = E>(cb: (result: Output<_R, _E>, params: Input) => void): Chains
|
|
68
|
-
onComplete<_R = R, _E = E>(cb: (result: _R) => void): Chains
|
|
69
|
-
onRetry<_R = R, _E = E>(cb: (result: _E, current_params: Input) => Promise<Input | null>): Chains
|
|
70
|
-
onError<_R = R, _E = E>(cb: (error: _E) => void): Chains
|
|
71
|
+
onResult<_R = R, _E = E, _A = A>(cb: (result: Output<_R, _E, _A>, params: Input) => void): Chains<_R, _E, _A>;
|
|
72
|
+
onComplete<_R = R, _E = E, _A = A>(cb: (result: _R) => void): Chains<_R, _E, _A>;
|
|
73
|
+
onRetry<_R = R, _E = E, _A = A>(cb: (result: _E, current_params: Input, _this: Chains<_R, _E, _A>) => Promise<Input | null>): Chains<_R, _E, _A>;
|
|
74
|
+
onError<_R = R, _E = E, _A = A>(cb: (error: _E) => void): Chains<_R, _E, _A>;
|
|
71
75
|
};
|
|
72
76
|
type Property = SystemMethods & Chains;
|
|
73
77
|
type Methods = {
|
|
74
78
|
prototype: Property;
|
|
75
|
-
<R = any, E = any>(url: urlInput, v?: Input): Chains<R, E>;
|
|
79
|
+
<R = any, E = any, A = any>(url: urlInput, v?: Input): Chains<R, E, A>;
|
|
76
80
|
waitList: string[];
|
|
77
81
|
setDefaultTrafficControl: number;
|
|
78
82
|
setDefaultTimeout: number;
|
package/esm/fetcher.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as m,c as A,d as B,e as c,f as T,g as D,h as x}from"./chunk-ABA72NWU.js";import p from"./core";import{UUID as I}from"./uuid";const v=(t,r)=>new e.prototype.Fetcher(t,r),e=v;e.prototype={},e.waitList=[],e.setDefaultTrafficControl=0,e.setDefaultTimeout=1e3*60*10,e.isReadableStream=t=>t instanceof ReadableStream,e.isReadableStreamReader=t=>t instanceof ReadableStreamDefaultReader,e.streamToContext=(t,r)=>c(void 0,null,function*(){try{const o=(r==null?void 0:r.reader)||t.getReader();if(!e.isReadableStreamReader(o))return{ok:!1,done:!0,data:null};if(!o)return{ok:!1,done:!0,data:null};const i=(r==null?void 0:r.decoder)||new TextDecoder("utf-8");let n=yield o.read();return{ok:!0,done:n.done,data:i.decode(n.value)}}catch(o){return{ok:!1,done:!0,data:o}}});const O=function(t,r){var n;r=r||{};let o=r.body;r.body&&!p.is.string(r.body)&&((n=r.bodyStringify)==null||n)&&(o=p.Stringify(r.body||{}));let i=t;return p.is.string(t)&&!t.match(/https?:/)&&(i=location.origin+"/"+t.replace(/^\//,"")),this.url=i,this.method=r.method||"get",this.streamStatus="open",this.params=A(m({key:I(),response_format:"json",timeout:e.setDefaultTimeout,trafficControl:e.setDefaultTrafficControl,preventMultiRequest:!0},r),{headers:m(m({"Content-Type":"application/json"},e.setDefaultHeaders&&e.setDefaultHeaders()),r.headers),body:o}),this};p.extend({Fetcher:O,params:{},url:"",method:"GET",streamStatus:"closed",onStartCB:()=>{},onCompleteCB:()=>{},onRetryCB:()=>c(void 0,null,function*(){return null}),isRetry:!1,extraBody:{},setExtraBody:function(t){return this.extraBody=m(m({},this.extraBody),t),this},onErrorCB:()=>{},onResultCB:()=>{},onStreamCB:()=>{},onStart:function(t){return this.onStartCB=t,this},onStream:function(t){return this.onStreamCB=t,this},onResult:function(t){return this.onResultCB=t,this},onComplete:function(t){return this.onCompleteCB=t,this},onRetry:function(t){return this.onRetryCB=t,this},onError:function(t){return this.onErrorCB=t,this},onStreamProcess:function(t){return c(this,null,function*(){let{response:r,errorCB:o,streamCB:i,reader:n,decoder:l}=t,s=r.body,u=this;const R=function(){return D(this,null,function*(){if(!r.ok){p.scope(()=>c(this,null,function*(){let{ok:f,done:y,data:_}=yield e.streamToContext(s,{reader:n,decoder:l});f&&o(_)}));return}let a=!1;for(;!a;){let{ok:f,done:y,data:_}=yield new T(e.streamToContext(s,{reader:n,decoder:l}));u.streamStatus=="abort"?(u.streamStatus="closed",n.cancel(),y=!0):u.streamStatus=="closed"&&(y=!0),y&&(a=y,n.releaseLock()),i(_,y)}})};try{for(var C=x(R()),h,E,b;h=!(E=yield C.next()).done;h=!1){let a=E.value;;}}catch(E){b=[E]}finally{try{h&&(E=C.return)&&(yield E.call(C))}finally{if(b)throw b[0]}}})},get:function(){return this.method="GET",this.send()},head:function(){return this.method="HEAD",this.send()},post:function(){return this.method="POST",this.send()},put:function(){return this.method="PUT",this.send()},delete:function(){return this.method="DELETE",this.send()},patch:function(){return this.method="PATCH",this.send()},options:function(){return this.method="OPTIONS",this.send()},send:function(){return c(this,null,function*(){var b;let t=this.params,r=performance.now(),o=0,i=new AbortController,n=setTimeout(()=>{i.abort()},t.timeout);t.signal=i.signal;let l=!1,s=500,u="InternalServerError",R={},C=null;try{e.setDefaultOnStart&&e.setDefaultOnStart(t),this.onStartCB&&this.onStartCB(t);let E=t,{key:a,response_format:f,trafficControl:y,preventMultiRequest:_,timeout:k,queries:P}=E,S=B(E,["key","response_format","trafficControl","preventMultiRequest","timeout","queries"]);S.method=this.method;let g=e.waitList.includes(a);if(_&&g)throw s=429,new Error("TooManyRequests");e.waitList=[...e.waitList,a];let w=p.queryParams.set(m({},P),String(this.url));R=yield fetch(w,S).then(d=>c(this,null,function*(){return l=d.ok,s=d.status,u=d.statusText,C=d,f=="none"||f=="stream"?d:d[f]()})).catch(d=>{throw new Error(d)})}catch(a){s==200&&(s=500,l=!1),s==429&&(u="TooManyRequests"),i.signal.aborted&&(s=408,u="Timeout"),s==500&&(u=String(a)||u),R={errorCode:String(a)}}finally{clearTimeout(n),o=performance.now()-r}t.trafficControl&&(yield p.pending(()=>{},t.trafficControl)),e.waitList.splice(e.waitList.findIndex(a=>a==t.key),1);let h={ok:l,status:s,statusText:u,body:R,additionalBody:this.extraBody,requestTime:o,rawData:C};if(!l){if(this.onRetryCB&&!this.isRetry){this.isRetry=!0;let a=yield this.onRetryCB(h.body,this.params,this);if(a)return this.params=a,this.send()}this.onErrorCB&&this.onErrorCB(h.body)}if(l&&this.onStreamCB&&t.response_format=="stream"){let a=(b=C.body)==null?void 0:b.getReader();this.onStreamProcess({errorCB:this.onErrorCB,streamCB:this.onStreamCB,response:h,reader:a,decoder:new TextDecoder("utf-8")})}return l&&this.onCompleteCB&&this.onCompleteCB(h.body),this.onResultCB&&this.onResultCB(h,t),e.setDefaultOnEnd&&e.setDefaultOnEnd(h,t),h})},abortStream:function(){this.streamStatus="abort"}},e),e.prototype.Fetcher.prototype=e.prototype;export{e as Fetcher,e as default};
|