jmini 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +1 -0
- package/declare/core.d.ts +168 -0
- package/declare/extension.d.ts +53 -0
- package/declare/fetcher.d.ts +87 -0
- package/declare/filer.d.ts +40 -0
- package/declare/formatCharacter.d.ts +1 -0
- package/declare/index.d.ts +14 -0
- package/declare/primitiveExtension.d.ts +51 -0
- package/declare/server.d.ts +40 -0
- package/declare/time.d.ts +79 -0
- package/declare/uuid.d.ts +13 -0
- package/esm/chunk-RWEMGXH3.js +1 -0
- package/esm/core.js +1 -0
- package/esm/extension.js +1 -0
- package/esm/fetcher.js +1 -0
- package/esm/filer.js +1 -0
- package/esm/formatCharacter.js +1 -0
- package/esm/index.js +1 -0
- package/esm/primitiveExtension.js +1 -0
- package/esm/server.js +1 -0
- package/esm/time.js +1 -0
- package/esm/uuid.js +1 -0
- package/package.json +46 -0
package/cjs/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var ee=Object.create;var R=Object.defineProperty,te=Object.defineProperties,ne=Object.getOwnPropertyDescriptor,re=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertyNames,J=Object.getOwnPropertySymbols,ie=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var A=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var F=Math.pow,j=(e,t,r)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,k=(e,t)=>{for(var r in t||(t={}))B.call(t,r)&&j(e,r,t[r]);if(J)for(var r of J(t))V.call(t,r)&&j(e,r,t[r]);return e},q=(e,t)=>te(e,re(t));var $=(e,t)=>{var r={};for(var s in e)B.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&J)for(var s of J(e))t.indexOf(s)<0&&V.call(e,s)&&(r[s]=e[s]);return r};var I=(e,t)=>()=>(e&&(t=e(e=0)),t);var ae=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),oe=(e,t)=>{for(var r in t)R(e,r,{get:t[r],enumerable:!0})},W=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of se(t))!B.call(e,n)&&n!==r&&R(e,n,{get:()=>t[n],enumerable:!(s=ne(t,n))||s.enumerable});return e};var ue=(e,t,r)=>(r=e!=null?ee(ie(e)):{},W(t||!e||!e.__esModule?R(r,"default",{value:e,enumerable:!0}):r,e)),le=e=>W(R({},"__esModule",{value:!0}),e);var d=(e,t,r)=>new Promise((s,n)=>{var i=l=>{try{u(r.next(l))}catch(m){n(m)}},o=l=>{try{u(r.throw(l))}catch(m){n(m)}},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},K=(e,t,r)=>{var s=(o,u,l,m)=>{try{var c=r[o](u),g=(u=c.value)instanceof O,b=c.done;Promise.resolve(g?u[0]:u).then(h=>g?s(o==="return"?o:"next",u[1]?{done:h.done,value:h.value}:h,l,m):l({value:h,done:b})).catch(h=>s("throw",h,l,m))}catch(h){m(h)}},n=o=>i[o]=u=>new Promise((l,m)=>s(o,u,l,m)),i={};return r=r.apply(e,t),i[A("asyncIterator")]=()=>i,n("next"),n("throw"),n("return"),i};var z=(e,t,r)=>(t=e[A("asyncIterator")])?t.call(e):(e=e[A("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(m=>o({value:m,done:l}),u)))),r("next"),r("return"),t);var N=I(()=>{"use strict";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(/+/,"+")});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)=>{if(!t)return;let s=t;for(let n of r){if(!s)break;s=s[n]}return s};Array.prototype.order=function(t){let{direction:r="ASC",keys:s=[],numeral:n=!1}=t,i=[];return s.length?n?i=this.sort((o,u)=>+(Number(e(o,s))>Number(e(u,s)))*2-1):i=this.sort((o,u)=>{let l=String(e(o,s)).replace(/(\d+)/g,c=>c.padStart(18,"0")),m=String(e(u,s)).replace(/(\d+)/g,c=>c.padStart(18,"0"));return+(l>m)*2-1}):n?i=this.sort((o,u)=>+(o>u)*2-1):i=this.sort((o,u)=>{let l=String(o).replace(/(\d+)/g,c=>c.padStart(18,"0")),m=String(u).replace(/(\d+)/g,c=>c.padStart(18,"0"));return+(l>m)*2-1}),r=="DESC"&&(i=i.reverse()),i},Array.prototype.getLastChild=function(){let t=this.length-1;return this[t]}}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 me,M,P=I(()=>{"use strict";me=(e=24)=>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(""),M=me;M.gen128Binary=()=>Array.from({length:128}).map((e,t)=>"01"[Math.round(Math.random()*1)]).join("");M.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};M.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 he,a,y,U,v,ce,w=I(()=>{"use strict";P();N();he=e=>new a.prototype.jsmin(e),a=he;a.prototype={};a.extend=function(e,t=a){for(var[r,s]of Object.entries(e))t.prototype[r]=s};a.expando="__jsmin_"+M();y=(e,t)=>(e.queue.push(t),U(e),e),U=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,U(e)}}),v=(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},ce=(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,U(e),e};a.extend({constructor:a,jsmin:function(e){return this.src=e,this.srcType=a.is.what(e),this.queueProcess=!0,this.queue=[],ce(this,a.is.jsmin(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.jsmin.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.jsmin(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(m=>{if(a.is.string(o[0]))m.insertAdjacentHTML(u,o[0]);else{if(!m.parentNode)return;a(o[0]).for(g=>{o[1]&&(g=g.cloneNode(!0)),m.parentNode.insertBefore(g,m[l]||m)})}}),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=M(),target:u,callback:l,options:m}=n;return m=k({passive:!0,capture:!1},m),this.for(c=>{if(!(a.is.element(c)||a.is.shadowRoot(c)))return;let{events:g}=c[a.expando];if(u){let b=l;l=h=>{if(h.target){if(a.is.string(u)){let T=h.target.closest(u);T&&(!T||b.call(T,h))}else if(a.is.elements(u)){for(let C of u)if(h.target==C)return b.call(C,h)}}}}if(g[o]){let b=g[o];c.removeEventListener(b.eventType,b.callback,b.options)}g[o]={eventType:i,callback:l,options:m},c.addEventListener(i,l,m)}),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 m=u[l];m&&o.removeEventListener(m.eventType,m.callback,m.options)}}),this})},html:function(n){return y(this,()=>v(this,r(n,t(this))))},empty:function(){return y(this,()=>v(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,()=>v(this,s(this,"before",...n)))},after:function(...n){return y(this,()=>v(this,s(this,"after",...n)))},find:function(n){return y(this,()=>{let i=[],o=this[0];o||v(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 m of l)if(m===u){i.push(m);break}else m.childNodes.length&&(i=[...i,...a(m).find(u).for(c=>c)])})),v(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);v(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 v(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=(t,r)=>{if(!a.is.array(t))return[t];let s=[];for(let n of t)s.push(...r=="-R"?a.flatArray(n,"-R"):[n]);return s},a.JsonTo=t=>JSON.stringify(t),a.toJson=t=>{let r;try{r={ok:!0,body:JSON.parse(t)}}catch(s){r={ok:!1,body:s}}return r},a.scope=t=>t(),a.randomNumber=(t=0,r=100,s)=>{if(t>r)return NaN;let n=[],i=t;for(;i<=r;){if(s&&s.length&&s.includes(i)){i++;continue}n.push(i),i++}let o=Math.round(Math.random()*(n.length-1))+0;return n[o]};let e={};a.interval={standBy:(t,r,s)=>{e[t]=setTimeout(s,r)},clear:t=>{clearInterval(e[t])}}}a.createElement=function(e){var g;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 b of Object.entries(i)){let h=b[0],C=(g=b[1])!=null?g:"";if(h=="data"&&a.is.keyValueDictionary(C))for(let[T,E]of Object.entries(C))l.dataset[T]=E;else h=="for"?h="htmlFor":h=="tabindex"?h="tabIndex":h=="aria-label"&&(h="ariaLabel"),l[h]=C}if(n&&a(l).append(n),o)for(var[m,c]of Object.entries(o))l.style[m]=c;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.setLocalStrageData=(e,t)=>{localStorage.setItem(e,JSON.stringify(t))},a.getLocalStrageData=e=>{let t=localStorage.getItem(e),r=a.toJson(t);return r.ok?r.body: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,m,c;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=(c=e.pageY)!=null?c:(m=(u=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:u.pageY)!=null?m:(((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),setTimeout(()=>{r(!0)},t)}),a.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},a.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]||"IP UNDEFINED"},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.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={what:function(e){let t="other";return this.jsmin(e)?t="jsmin":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)},jsmin: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.jsmin(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 G=ae(H=>{"use strict";w();a.copyToClipboard=e=>d(H,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(H,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.getCurrentLocation=()=>new Promise((e,t)=>{navigator.geolocation.getCurrentPosition(r=>{let{latitude:s,longitude:n}=r.coords;e({ok:!0,status:200,body:{lat:s,lng:n}})},r=>{e({ok:!1,status:500,body:{reason: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})});var pe={};oe(pe,{Fetcher:()=>f,Filer:()=>L,Server:()=>X,Time:()=>p,UUID:()=>M,default:()=>de});module.exports=le(pe);N();w();P();w();var fe=e=>new p.prototype.time(e),p=fe;p.prototype={};var D=function(e,t){e.value=t;let r=a.is.date(t);if(e.validate=r,!r)return e.ms=-1,e.year=-1,e.month=-1,e.weekday=-1,e.weekInYear=-1,e.date=-1,e.hours=-1,e.minutes=-1,e.seconds=-1,e;e.ms=t.getTime(),e.weekday=t.getDay(),e.year=t.getFullYear(),e.month=t.getMonth()+1,e.date=t.getDate();{let s=new Date(e.year,0,1),n=new Date(s.valueOf());n.setDate(n.getDate()-(s.getDay()+1));let i=t.getTime()-n.getTime(),o=Math.ceil(i/(1e3*60*60*24));e.weekInYear=Math.ceil(o/7)}{let s=new Date(e.year,e.month-1,1),n=new Date(s.valueOf());n.setDate(n.getDate()-(s.getDay()+1));let i=t.getTime()-n.getTime(),o=Math.ceil(i/(1e3*60*60*24)),u=Math.ceil(o/7);e.weekInMonth=u}{let s=new Date(e.year,e.month,0),n=s.getDay(),i=new Date(new Date(s).setDate(s.getDate()-n));e.isLastWeekInMonth=e.date>=i.getDate()}return e.hours=t.getHours(),e.minutes=t.getMinutes(),e.seconds=t.getSeconds(),e};a.extend({constructor:p,time:function(e){p.isTimeObject(e)&&(e=e.value),e||(e===null?e=void 0:e===void 0&&(e=new Date));let t=new Date(e);return D(this,t)}},p);p.prototype.time.prototype=p.prototype;p.isTimeObject=e=>{var t;return((t=e||{})==null?void 0:t.constructor)===p};p.getFromNumberYYYYMMDD=e=>{let t=String(e).replace(/(\d{4})(\d{2})(\d{2})/,"$1/$2/$3");return p(t+" 00:00")};p.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=p(n).addYear(1):e=="month"?n=p(n).addMonth(1):e=="week"?n=p(n).addWeek(1):e=="day"?n=p(n).addDate(1):e=="hours"?n=p(n).addHours(1):e=="minutes"?n=p(n).addMinutes(1):e=="seconds"&&(n=p(n).addSeconds(1));return s};a.extend({setYear:function(e){let t=new Date(this.value.valueOf());return t.setFullYear(e),D(this,t)},setMonth:function(e){let t=new Date(this.value.valueOf());return t.setMonth(e-1),D(this,t)},setDate:function(e){let t=new Date(this.value.valueOf());return t.setDate(e),D(this,t)},setHours:function(e){let t=new Date(this.value.valueOf());return t.setHours(e),D(this,t)},setMinutes:function(e){let t=new Date(this.value.valueOf());return t.setMinutes(e),D(this,t)},setSeconds:function(e){let t=new Date(this.value.valueOf());return t.setSeconds(e),D(this,t)},setMilliseconds:function(e){let t=new Date(this.value.valueOf());return t.setMilliseconds(e),D(this,t)},setMidnight:function(){let e=new Date(this.value.valueOf());return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),D(this,e)},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)},isSameYear:function(e){let t=a.Time(e);return this.year==t.year},isSameMonth:function(e){let t=a.Time(e);return this.year==t.year&&this.month==t.month},isSameWeek:function(e){let t=a.Time(e);return this.year==t.year&&this.weekInYear==t.weekInYear},isSameDate:function(e){let t=a.Time(e);return this.year==t.year&&this.month==t.month&&this.date==t.date},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%m\u5206"):this.toFormat("%h:%i"):""},toFormatYMDHM:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%m\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"):""},getFirstDayOfTheYear:function(){return a.Time(new Date(this.value.getFullYear(),0,1))},getLastDayOfTheYear:function(){return a.Time(new Date(this.value.getFullYear()+1,0,0))},getFirstDayOfTheMonth:function(){return a.Time(new Date(this.value.getFullYear(),this.month-1,1))},getLastDayOfTheMonth:function(){return a.Time(new Date(this.value.getFullYear(),this.month,0))},getFirstDayOfTheWeek:function(){let e=a.Time(this.value);return e.addDate(-e.weekday)},getLastDayOfTheWeek:function(){let e=a.Time(this.value);return e.addDate(6-e.weekday)},diff:function(e){let t=this.ms-e.ms;return{years:this.year-e.year,months:(this.year-e.year)*12+(this.month-e.month),dates:Math.floor(t/(60*60*24*1e3)),hours:Math.floor(t/(60*60*1e3)),minutes:Math.floor(t/(60*1e3)),seconds:Math.floor(t/1e3)}},getAge:function(e){let t=e||a.Time(),r=t.year-this.year;return(this.month>t.month||this.month==t.month&&t.date<this.date)&&r--,r}},p);a.Time=p;w();P();var f=(e,t)=>new f.prototype.instance(e,t);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}}});a.extend({constructor:f,instance:function(e,t){var n;t=t||{};let r=t.body;t.body&&!a.is.string(t.body)&&((n=t.bodyStringify)==null||n)&&(r=JSON.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=q(k({key:M(),response_format:"json",timeout:f.setDefaultTimeout,trafficControl:f.setDefaultTrafficControl,preventMultiRequest:!0},t),{headers:k(k({"Content-Type":"application/json"},f.setDefaultHeaders&&f.setDefaultHeaders()),t.headers),body:r}),this},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},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 K(this,null,function*(){if(!t.ok){a.scope(()=>d(this,null,function*(){let{ok:C,done:T,data:E}=yield f.streamToContext(o,{reader:n,decoder:i});C&&r(E)}));return}let h=!1;for(;!h;){let{ok:C,done:T,data:E}=yield new O(f.streamToContext(o,{reader:n,decoder:i}));u.streamStatus=="abort"?(u.streamStatus="closed",n.cancel(),T=!0):u.streamStatus=="closed"&&(T=!0),T&&(h=T,n.releaseLock()),s(E,T)}})};try{for(var m=z(l()),c,g,b;c=!(g=yield m.next()).done;c=!1){let h=g.value;;}}catch(g){b=[g]}finally{try{c&&(g=m.return)&&(yield g.call(m))}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 d(this,null,function*(){var b;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={},m=null;try{f.setDefaultOnStart&&f.setDefaultOnStart(e),this.onStartCB&&this.onStartCB(e);let g=e,{key:h,response_format:C,trafficControl:T,preventMultiRequest:E,timeout:ye,queries:Q}=g,Y=$(g,["key","response_format","trafficControl","preventMultiRequest","timeout","queries"]);Y.method=this.method;let Z=f.waitList.includes(h);if(E&&Z)throw o=429,new Error("TooManyRequests");f.waitList=[...f.waitList,h];let _=a.queryParams.set(k({},Q),String(this.url));l=yield fetch(_,Y).then(x=>d(this,null,function*(){return i=x.ok,o=x.status,u=x.statusText,m=x,C=="none"||C=="stream"?x:x[C]()})).catch(x=>{throw new Error(x)})}catch(h){o==200&&(o=500,i=!1),o==429&&(u="TooManyRequests"),s.signal.aborted&&(o=408,u="Timeout"),o==500&&(u=String(h)||u),l={errorCode:String(h)}}finally{clearTimeout(n),r=performance.now()-t}e.trafficControl&&(yield a.pending(()=>{},e.trafficControl)),f.waitList.splice(f.waitList.findIndex(h=>h==e.key),1);let c={ok:i,status:o,statusText:u,body:l,requestTime:r,rawData:m};if(!i&&this.onErrorCB&&this.onErrorCB(c.body),i&&this.onStreamCB&&e.response_format=="stream"){let h=(b=m.body)==null?void 0:b.getReader();this.onStreamProcess({errorCB:this.onErrorCB,streamCB:this.onStreamCB,response:c,reader:h,decoder:new TextDecoder("utf-8")})}return i&&this.onCompleteCB&&this.onCompleteCB(c.body),this.onResultCB&&this.onResultCB(c,e),f.setDefaultOnEnd&&f.setDefaultOnEnd(c,e),c})},abortStream:function(){this.streamStatus="abort"}},f);f.prototype.instance.prototype=f.prototype;w();var S=e=>new S.prototype.instance(e);S.prototype={};a.extend({constructor:S,instance: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},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 e;return(e=(yield this.file.convert("dataURL")).target)==null?void 0:e.result})},toAarrayBuffer:function(){return d(this,null,function*(){var e;return(e=(yield this.file.convert("arrayBuffer")).target)==null?void 0:e.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}},S);S.prototype.instance.prototype=S.prototype;var L={fromFile:e=>d(void 0,null,function*(){return S(e)}),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 S(n)}),fromArrayBuffer:(e,t)=>d(void 0,null,function*(){return L.fromBlob(new Blob([e],{type:(t==null?void 0:t.mimeType)||""}),t)}),fromObjectURL:(e,t)=>d(void 0,null,function*(){let r=yield f(e,{response_format:"blob"}).get();return r.ok?L.fromBlob(r.body,t):S({})}),fromDataURL:(e,t)=>d(void 0,null,function*(){let r=yield e.toBlob((t==null?void 0:t.mimeType)||"");return r?L.fromBlob(r,t):S({})})};w();var X=function(e){let t=e,r=null;return t.use((s,n,i)=>{let o=n;o.return=u=>{let{status:l=200,body:m={},bodyStringify:c=!0}=u||{},g=m;return c&&(a.is.string(m)||(g=JSON.stringify(m))),n.status(l).end(g)},i()}),t.setRouter=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};w();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 m=e-o+1;m==1&&(s=!0,m="\u5143"),r.push(l+m+"\u5E74"),t.push(l)}}),{era:t,value:r,gap:s}}};var Xe=ue(G());f.setDefaultHeaders=()=>({});var de=a;0&&(module.exports={Fetcher,Filer,Server,Time,UUID});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { KeyValueDict } from '.';
|
|
2
|
+
import './primitiveExtension';
|
|
3
|
+
declare global {
|
|
4
|
+
interface JsminExtension {
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
declare namespace Jsmin {
|
|
8
|
+
type Args = any;
|
|
9
|
+
type ElementableValue = any;
|
|
10
|
+
type ForFunction = {
|
|
11
|
+
(element: HTMLElement, index: number): void;
|
|
12
|
+
};
|
|
13
|
+
namespace Events {
|
|
14
|
+
type CustomEventListener<K extends keyof WindowEventMap> = {
|
|
15
|
+
(this: HTMLElement, event: WindowEventMap[K]): void;
|
|
16
|
+
};
|
|
17
|
+
type EventType = keyof WindowEventMap;
|
|
18
|
+
type AddEventInput<K extends keyof WindowEventMap> = {
|
|
19
|
+
eventType: K;
|
|
20
|
+
eventID?: string;
|
|
21
|
+
target?: string | Chains | HTMLElement;
|
|
22
|
+
callback: CustomEventListener<K>;
|
|
23
|
+
options?: AddEventListenerOptions;
|
|
24
|
+
};
|
|
25
|
+
type RemoveEventInput = string | string[];
|
|
26
|
+
}
|
|
27
|
+
type CreateElementInput = {
|
|
28
|
+
tag?: string;
|
|
29
|
+
className?: string;
|
|
30
|
+
id?: string;
|
|
31
|
+
html?: ElementableValue;
|
|
32
|
+
attr?: KeyValueDict;
|
|
33
|
+
parent?: ElementableValue;
|
|
34
|
+
style?: React.CSSProperties;
|
|
35
|
+
};
|
|
36
|
+
type Chains = {
|
|
37
|
+
[Symbol.iterator](): void;
|
|
38
|
+
[index: number]: HTMLElement;
|
|
39
|
+
length: number;
|
|
40
|
+
queue: Function[];
|
|
41
|
+
queueProcess: boolean;
|
|
42
|
+
synchronous: boolean;
|
|
43
|
+
warn?: string;
|
|
44
|
+
src?: Args;
|
|
45
|
+
srcType?: string;
|
|
46
|
+
get(v?: number): HTMLElement | HTMLElement[];
|
|
47
|
+
for(v: {
|
|
48
|
+
(element: HTMLElement, index: number): void;
|
|
49
|
+
}, n?: number): any[];
|
|
50
|
+
await(time: number): Chains;
|
|
51
|
+
abort(): Chains;
|
|
52
|
+
callback: {
|
|
53
|
+
(fn: {
|
|
54
|
+
(jsmin: Chains): void;
|
|
55
|
+
}): Chains;
|
|
56
|
+
};
|
|
57
|
+
click(): Chains;
|
|
58
|
+
focus(): Chains;
|
|
59
|
+
addEvent<K extends keyof WindowEventMap>(args: Events.AddEventInput<K>): Chains;
|
|
60
|
+
removeEvent(args: Events.RemoveEventInput): Chains;
|
|
61
|
+
html(v: ElementableValue): Chains;
|
|
62
|
+
empty(): Chains;
|
|
63
|
+
append(v: ElementableValue): Chains;
|
|
64
|
+
remove(): Chains;
|
|
65
|
+
before(...v: ElementableValue[]): Chains;
|
|
66
|
+
after(...v: ElementableValue[]): Chains;
|
|
67
|
+
find(v: ElementableValue): Chains;
|
|
68
|
+
parent(v?: string): Chains;
|
|
69
|
+
children(v?: string | 'first' | 'last' | number): Chains;
|
|
70
|
+
addClass(v: string | string[]): Chains;
|
|
71
|
+
removeClass(v: string | string[]): Chains;
|
|
72
|
+
toggleClass(v: string): Chains;
|
|
73
|
+
hasClass(v: string): boolean;
|
|
74
|
+
findClass(v: RegExp): string[];
|
|
75
|
+
css(v: React.CSSProperties): Chains;
|
|
76
|
+
getAttribute(key: string): string;
|
|
77
|
+
setAttribute(key: string, value: string): Chains;
|
|
78
|
+
getStyleProperty(property: string): string;
|
|
79
|
+
setStyleProperty(property: string, value: string): Chains;
|
|
80
|
+
val(): string;
|
|
81
|
+
position(): DOMRect;
|
|
82
|
+
jsmin: {
|
|
83
|
+
new (v?: Args): Chains;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
type Methods = {
|
|
87
|
+
expando: string;
|
|
88
|
+
prototype: Chains;
|
|
89
|
+
(v?: Args): Chains;
|
|
90
|
+
extend(v: KeyValueDict, t?: Methods | any): void;
|
|
91
|
+
createElement: (v: CreateElementInput) => HTMLElement;
|
|
92
|
+
setCookie(props: {
|
|
93
|
+
name: string;
|
|
94
|
+
value: string;
|
|
95
|
+
age?: number;
|
|
96
|
+
path?: string;
|
|
97
|
+
domain?: string;
|
|
98
|
+
secure?: boolean;
|
|
99
|
+
}): void;
|
|
100
|
+
getCookie(name: string): string;
|
|
101
|
+
setLocalStrageData(key: string, value: any): any;
|
|
102
|
+
getLocalStrageData(key: string): any;
|
|
103
|
+
deleteCookie(name: string): void;
|
|
104
|
+
pending(callback: {
|
|
105
|
+
(resolve: {
|
|
106
|
+
(result: boolean): void;
|
|
107
|
+
}): void;
|
|
108
|
+
}, seconds: number): Promise<boolean>;
|
|
109
|
+
getLocalIP(os: any): string;
|
|
110
|
+
getIp(req: any): string;
|
|
111
|
+
getCursor(event: Event): {
|
|
112
|
+
x: number;
|
|
113
|
+
y: number;
|
|
114
|
+
};
|
|
115
|
+
getScreenSize(): {
|
|
116
|
+
height: number;
|
|
117
|
+
width: number;
|
|
118
|
+
pageHeight: number;
|
|
119
|
+
scrollY: number;
|
|
120
|
+
scrollX: number;
|
|
121
|
+
pageYOffset: number;
|
|
122
|
+
pageXOffset: number;
|
|
123
|
+
safeAreaTop: number;
|
|
124
|
+
safeAreaBottom: number;
|
|
125
|
+
};
|
|
126
|
+
queryParams: {
|
|
127
|
+
get(url?: string): KeyValueDict;
|
|
128
|
+
set(searchParams: {
|
|
129
|
+
[key: string]: string | number;
|
|
130
|
+
}, url?: string): string;
|
|
131
|
+
delete(keys: string[], url?: string): string;
|
|
132
|
+
};
|
|
133
|
+
ellipsisText(value: string, length: number): string;
|
|
134
|
+
is: {
|
|
135
|
+
what(v: any): string;
|
|
136
|
+
exist(v: any): boolean;
|
|
137
|
+
nullish(val: any): boolean;
|
|
138
|
+
jsmin(v: any): v is Methods & Chains;
|
|
139
|
+
string(v: any): v is string;
|
|
140
|
+
boolean(v: any): v is boolean;
|
|
141
|
+
number(v: any): v is number;
|
|
142
|
+
array(v: any): v is any[];
|
|
143
|
+
function(v: any): v is Function;
|
|
144
|
+
keyValueDictionary(v: any): v is KeyValueDict;
|
|
145
|
+
element(v: any): v is HTMLElement;
|
|
146
|
+
elements(v: any): v is HTMLElement[];
|
|
147
|
+
shadowRoot(v: any): v is ShadowRoot;
|
|
148
|
+
date(v: any): v is Date;
|
|
149
|
+
};
|
|
150
|
+
flatArray(v: any, regression?: '-R'): any[];
|
|
151
|
+
deepMerge<T>(target: T, ...args: T[]): T;
|
|
152
|
+
JsonTo(value: any): string;
|
|
153
|
+
toJson<T = any>(value: any): {
|
|
154
|
+
ok: boolean;
|
|
155
|
+
body: T;
|
|
156
|
+
};
|
|
157
|
+
scope<T>(fn: {
|
|
158
|
+
(): T;
|
|
159
|
+
}): T;
|
|
160
|
+
randomNumber(min?: number, max?: number, notIn?: number[]): number;
|
|
161
|
+
interval: {
|
|
162
|
+
standBy(key: string, ms: number, callback: Function): void;
|
|
163
|
+
clear(key: string): void;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
declare const Jsmin: Jsmin.Methods & JsminExtension;
|
|
168
|
+
export { Jsmin, Jsmin as default };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
namespace JsminExtension {
|
|
3
|
+
type FileReadAsType = 'dataURL' | 'arrayBuffer' | 'binaryString' | 'text';
|
|
4
|
+
type getCurrentLocationOutput = {
|
|
5
|
+
ok: false;
|
|
6
|
+
status: number;
|
|
7
|
+
body: {
|
|
8
|
+
reason: any;
|
|
9
|
+
};
|
|
10
|
+
} | {
|
|
11
|
+
ok: true;
|
|
12
|
+
status: 200;
|
|
13
|
+
body: {
|
|
14
|
+
lat: number;
|
|
15
|
+
lng: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
interface JsminExtension {
|
|
20
|
+
formatCharacter: {
|
|
21
|
+
postal: {
|
|
22
|
+
JP(params: string): string;
|
|
23
|
+
};
|
|
24
|
+
tel: {
|
|
25
|
+
_(params: string): string;
|
|
26
|
+
mobile(params: string): string;
|
|
27
|
+
fixed(params: string): string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
transformer: {
|
|
31
|
+
weekday: {
|
|
32
|
+
JP(params: number): string;
|
|
33
|
+
shortJP(params: number): string;
|
|
34
|
+
};
|
|
35
|
+
wareki(value: number): {
|
|
36
|
+
era: string[];
|
|
37
|
+
value: string[];
|
|
38
|
+
gap: boolean;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
ImageLoader: {
|
|
42
|
+
(dataUrl: string, img?: HTMLImageElement): Promise<HTMLImageElement>;
|
|
43
|
+
};
|
|
44
|
+
copyToClipboard(data: any): Promise<{
|
|
45
|
+
ok: boolean;
|
|
46
|
+
body: any;
|
|
47
|
+
}>;
|
|
48
|
+
getCurrentLocation: {
|
|
49
|
+
(): Promise<JsminExtension.getCurrentLocationOutput>;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
declare namespace Fetcher {
|
|
2
|
+
type urlInput = string | URL | globalThis.Request;
|
|
3
|
+
type Input = Omit<RequestInit, 'body'> & {
|
|
4
|
+
key?: string;
|
|
5
|
+
body?: any;
|
|
6
|
+
bodyStringify?: boolean;
|
|
7
|
+
queries?: Record<string, string | number>;
|
|
8
|
+
response_format?: 'text' | 'json' | 'formData' | 'blob' | 'arrayBuffer' | 'stream' | 'none';
|
|
9
|
+
preventMultiRequest?: boolean;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
trafficControl?: number;
|
|
12
|
+
};
|
|
13
|
+
type Output<T = any> = {
|
|
14
|
+
status: number;
|
|
15
|
+
statusText: string;
|
|
16
|
+
requestTime: number;
|
|
17
|
+
rawData: Response;
|
|
18
|
+
ok: boolean;
|
|
19
|
+
body: T;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
};
|
|
22
|
+
namespace onStream {
|
|
23
|
+
type ProcessArgs = {
|
|
24
|
+
response: Output<any>;
|
|
25
|
+
errorCB: (...params: any) => void;
|
|
26
|
+
streamCB: (...params: any) => void;
|
|
27
|
+
reader: ReadableStreamDefaultReader<Uint8Array>;
|
|
28
|
+
decoder: TextDecoder;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
type SystemMethods = {
|
|
32
|
+
onStreamProcess(params: onStream.ProcessArgs): void;
|
|
33
|
+
onStartCB(params: Input): void;
|
|
34
|
+
onStreamCB?<T = any>(data: T, done: boolean): void;
|
|
35
|
+
onResultCB<T = any>(result: Output<T>, params: Input): void;
|
|
36
|
+
onCompleteCB<T = any>(result: T): void;
|
|
37
|
+
onErrorCB<T = any>(error: T): void;
|
|
38
|
+
instance: {
|
|
39
|
+
new (url: urlInput, v?: Input): Chains;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type UsageChains = {
|
|
43
|
+
params: Input;
|
|
44
|
+
url: urlInput;
|
|
45
|
+
method: string;
|
|
46
|
+
streamStatus: 'open' | 'abort' | 'closed';
|
|
47
|
+
get<T = any>(): Promise<Output<T>>;
|
|
48
|
+
head<T = any>(): Promise<Output<T>>;
|
|
49
|
+
post<T = any>(): Promise<Output<T>>;
|
|
50
|
+
put<T = any>(): Promise<Output<T>>;
|
|
51
|
+
delete<T = any>(): Promise<Output<T>>;
|
|
52
|
+
patch<T = any>(): Promise<Output<T>>;
|
|
53
|
+
options<T = any>(): Promise<Output<T>>;
|
|
54
|
+
send<T = any>(): Promise<Output<T>>;
|
|
55
|
+
abortStream(): void;
|
|
56
|
+
onStart(cb: (params: Input) => void): UsageChains;
|
|
57
|
+
onStream<T = any>(callback: (data: T, done: boolean) => void, options?: {
|
|
58
|
+
decoder?: TextDecoder;
|
|
59
|
+
}): UsageChains;
|
|
60
|
+
onResult<T = any>(cb: (result: Output<T>, params: Input) => void): UsageChains;
|
|
61
|
+
onComplete<T = any>(cb: (result: T) => void): UsageChains;
|
|
62
|
+
onError<T = any>(cb: (error: T) => void): UsageChains;
|
|
63
|
+
};
|
|
64
|
+
type Chains = SystemMethods & UsageChains;
|
|
65
|
+
type Methods = {
|
|
66
|
+
prototype: Chains;
|
|
67
|
+
waitList: string[];
|
|
68
|
+
setDefaultTrafficControl: number;
|
|
69
|
+
setDefaultTimeout: number;
|
|
70
|
+
setDefaultHeaders?: () => HeadersInit;
|
|
71
|
+
setDefaultOnStart?: (params: Input) => void;
|
|
72
|
+
setDefaultOnEnd?: (result: Output<any>, params: Input) => void;
|
|
73
|
+
isReadableStream(v: any): boolean;
|
|
74
|
+
isReadableStreamReader(v: any): boolean;
|
|
75
|
+
streamToContext(streamData: ReadableStream<Uint8Array>, options?: {
|
|
76
|
+
reader?: ReadableStreamDefaultReader<Uint8Array>;
|
|
77
|
+
decoder?: TextDecoder;
|
|
78
|
+
}): Promise<{
|
|
79
|
+
ok: boolean;
|
|
80
|
+
done: boolean;
|
|
81
|
+
data: any;
|
|
82
|
+
}>;
|
|
83
|
+
(url: urlInput, v?: Input): UsageChains;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
declare const Fetcher: Fetcher.Methods;
|
|
87
|
+
export { Fetcher, Fetcher as default };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
declare namespace Filer {
|
|
2
|
+
type FileType = 'dataURL' | 'blob' | 'arrayBuffer' | 'objectURL';
|
|
3
|
+
type Options = {
|
|
4
|
+
fileName?: string;
|
|
5
|
+
extension?: string;
|
|
6
|
+
mimeType?: string;
|
|
7
|
+
};
|
|
8
|
+
type SystemMethods = {
|
|
9
|
+
instance: {
|
|
10
|
+
new (v: any): any;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
type UsageChains = {
|
|
14
|
+
extension: string;
|
|
15
|
+
type: string;
|
|
16
|
+
file: File;
|
|
17
|
+
toBlob(): Promise<Blob>;
|
|
18
|
+
toDataURL(): Promise<string>;
|
|
19
|
+
toAarrayBuffer(): Promise<ArrayBuffer>;
|
|
20
|
+
toObjectURL(): Promise<string>;
|
|
21
|
+
isValid(): boolean;
|
|
22
|
+
updateFileName(fileName: string): void;
|
|
23
|
+
updateMimeType(mimeType: string): void;
|
|
24
|
+
updateExtension(extension: string): void;
|
|
25
|
+
};
|
|
26
|
+
type Chains = SystemMethods & UsageChains;
|
|
27
|
+
type ClassMethods = {
|
|
28
|
+
prototype: Chains;
|
|
29
|
+
(v: any): UsageChains;
|
|
30
|
+
};
|
|
31
|
+
type Methods = {
|
|
32
|
+
fromFile(file: File): Promise<UsageChains>;
|
|
33
|
+
fromBlob(file: Blob, options?: Options): Promise<UsageChains>;
|
|
34
|
+
fromDataURL(dataURL: string, options?: Options): Promise<UsageChains>;
|
|
35
|
+
fromArrayBuffer(arrayBuffer: ArrayBuffer, options?: Options): Promise<UsageChains>;
|
|
36
|
+
fromObjectURL(objectURL: string, options?: Options): Promise<UsageChains>;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
declare const Filer: Filer.Methods;
|
|
40
|
+
export { Filer, Filer as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface KeyValueDict<T = any> {
|
|
2
|
+
[key: string]: T | void;
|
|
3
|
+
}
|
|
4
|
+
import './primitiveExtension';
|
|
5
|
+
import Jsmin from './core';
|
|
6
|
+
import UUID from './uuid';
|
|
7
|
+
import Time from './time';
|
|
8
|
+
import Fetcher from './fetcher';
|
|
9
|
+
import Filer from './filer';
|
|
10
|
+
import Server from './server';
|
|
11
|
+
import './formatCharacter';
|
|
12
|
+
import './extension';
|
|
13
|
+
export { Time, Fetcher, Filer, Server, UUID };
|
|
14
|
+
export default Jsmin;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
/** primitive */
|
|
3
|
+
interface HTMLElement {
|
|
4
|
+
[index: string]: any;
|
|
5
|
+
style: {
|
|
6
|
+
[index: string]: string;
|
|
7
|
+
};
|
|
8
|
+
position(): DOMRect;
|
|
9
|
+
}
|
|
10
|
+
interface Number {
|
|
11
|
+
zeroEmbed(digit: number): string;
|
|
12
|
+
ratio(base: number, floatings?: number): number;
|
|
13
|
+
rate(base: number, floatings?: number): number;
|
|
14
|
+
rank(floatings?: number): string;
|
|
15
|
+
rankJp(): string;
|
|
16
|
+
toDate(separate?: string): string;
|
|
17
|
+
}
|
|
18
|
+
interface String {
|
|
19
|
+
compress(): string;
|
|
20
|
+
encode(): string;
|
|
21
|
+
decode(): string;
|
|
22
|
+
toLower(): string;
|
|
23
|
+
toUpper(): string;
|
|
24
|
+
toCapital(): string;
|
|
25
|
+
clip(from: number, to?: number): string;
|
|
26
|
+
partReplace(begin: number, string: string): string;
|
|
27
|
+
toBlob(mimeType: any): Blob | false;
|
|
28
|
+
toNumber(): number;
|
|
29
|
+
removeLetters(): string;
|
|
30
|
+
removeSpecifics(): string;
|
|
31
|
+
removeJP(): string;
|
|
32
|
+
zen2hanNumber(): string;
|
|
33
|
+
}
|
|
34
|
+
namespace Array {
|
|
35
|
+
type OrderInput = {
|
|
36
|
+
direction: 'ASC' | 'DESC';
|
|
37
|
+
keys?: (string | number)[];
|
|
38
|
+
numeral?: boolean;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
interface Array<T> {
|
|
42
|
+
order: {
|
|
43
|
+
(params: Array.OrderInput): Array<T>;
|
|
44
|
+
};
|
|
45
|
+
getLastChild(): T;
|
|
46
|
+
}
|
|
47
|
+
interface File {
|
|
48
|
+
convert(readAs?: JsminExtension.FileReadAsType): Promise<ProgressEvent<FileReader>>;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
declare namespace Server {
|
|
3
|
+
interface Request extends express.Request {
|
|
4
|
+
}
|
|
5
|
+
interface Response extends express.Response {
|
|
6
|
+
return(p?: ReturnInput): Response;
|
|
7
|
+
}
|
|
8
|
+
type Path = string | number | boolean | RegExp | void;
|
|
9
|
+
type Callback<A = Request, B = Response> = (req: A, res: B, next: express.NextFunction, error: Error) => void;
|
|
10
|
+
type SetInput = [string, any];
|
|
11
|
+
type UseInput = [Path] | [Path, Path] | RestInput | [Callback];
|
|
12
|
+
type RestInput<A = Request, B = Response> = [path: Path, ...fns: Callback<A, B>[]];
|
|
13
|
+
type ReturnInput<T = any> = {
|
|
14
|
+
status?: number;
|
|
15
|
+
body?: T;
|
|
16
|
+
bodyStringify?: boolean;
|
|
17
|
+
};
|
|
18
|
+
type CustomMethods<A = Request, B = Response> = {
|
|
19
|
+
set(...args: SetInput): Methods<A, B>;
|
|
20
|
+
use(...args: UseInput): Methods<A, B>;
|
|
21
|
+
get(...args: RestInput<A, B>): Methods<A, B>;
|
|
22
|
+
post(...args: RestInput<A, B>): Methods<A, B>;
|
|
23
|
+
put(...args: RestInput<A, B>): Methods<A, B>;
|
|
24
|
+
patch(...args: RestInput<A, B>): Methods<A, B>;
|
|
25
|
+
delete(...args: RestInput<A, B>): Methods<A, B>;
|
|
26
|
+
options(...args: RestInput<A, B>): Methods<A, B>;
|
|
27
|
+
all(...args: RestInput<A, B>): Methods<A, B>;
|
|
28
|
+
};
|
|
29
|
+
type CustomExpress = Omit<express.Express, keyof CustomMethods>;
|
|
30
|
+
type Methods<A = Request, B = Response> = CustomExpress & CustomMethods<A, B> & {
|
|
31
|
+
setRouter(getRouter: (path: string) => express.Router): Methods<A, B>;
|
|
32
|
+
pathRouter(path: string): CustomMethods<A, B>;
|
|
33
|
+
exception(fn: (err: any, req: A, res: B, next: express.NextFunction) => void): Methods<A, B>;
|
|
34
|
+
};
|
|
35
|
+
type FN = {
|
|
36
|
+
<A = Request, B = Response>(express: express.Express): Methods<A, B>;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
declare const Server: Server.FN;
|
|
40
|
+
export { Server, Server as default };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
namespace JsminExtension {
|
|
3
|
+
}
|
|
4
|
+
interface JsminExtension {
|
|
5
|
+
Time: Time.Methods;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
declare namespace Time {
|
|
9
|
+
type Input = any;
|
|
10
|
+
type DateTrimTypes = 'Y' | 'M' | 'W' | 'D' | 'H' | 'I' | 'S';
|
|
11
|
+
type Chains = {
|
|
12
|
+
value: Date;
|
|
13
|
+
validate: boolean;
|
|
14
|
+
ms: number;
|
|
15
|
+
weekday: number;
|
|
16
|
+
weekInMonth: number;
|
|
17
|
+
weekInYear: number;
|
|
18
|
+
isLastWeekInMonth: boolean;
|
|
19
|
+
year: number;
|
|
20
|
+
month: number;
|
|
21
|
+
date: number;
|
|
22
|
+
hours: number;
|
|
23
|
+
minutes: number;
|
|
24
|
+
seconds: number;
|
|
25
|
+
isSameYear(v: any): boolean;
|
|
26
|
+
isSameMonth(v: any): boolean;
|
|
27
|
+
isSameWeek(v: any): boolean;
|
|
28
|
+
isSameDate(v: any): boolean;
|
|
29
|
+
setYear(v: number): Chains;
|
|
30
|
+
setMonth(v: number): Chains;
|
|
31
|
+
setDate(v: number): Chains;
|
|
32
|
+
setHours(v: number): Chains;
|
|
33
|
+
setMinutes(v: number): Chains;
|
|
34
|
+
setSeconds(v: number): Chains;
|
|
35
|
+
setMilliseconds(v: number): Chains;
|
|
36
|
+
setMidnight(): Chains;
|
|
37
|
+
addYear(v: number): Chains;
|
|
38
|
+
addMonth(v: number): Chains;
|
|
39
|
+
addWeek(v: number): Chains;
|
|
40
|
+
addDate(v: number): Chains;
|
|
41
|
+
addHours(v: number): Chains;
|
|
42
|
+
addMinutes(v: number): Chains;
|
|
43
|
+
addSeconds(v: number): Chains;
|
|
44
|
+
toFormat(format: string): string;
|
|
45
|
+
toFormatYMD(lang?: 'JP'): string;
|
|
46
|
+
toFormatYM(lang?: 'JP'): string;
|
|
47
|
+
toFormatMD(lang?: 'JP'): string;
|
|
48
|
+
toFormatHM(lang?: 'JP'): string;
|
|
49
|
+
toFormatYMDHM(lang?: 'JP'): string;
|
|
50
|
+
toFormatYMDHMS(lang?: 'JP'): string;
|
|
51
|
+
getFirstDayOfTheYear(): Chains;
|
|
52
|
+
getLastDayOfTheYear(): Chains;
|
|
53
|
+
getFirstDayOfTheMonth(): Chains;
|
|
54
|
+
getLastDayOfTheMonth(): Chains;
|
|
55
|
+
getFirstDayOfTheWeek(): Chains;
|
|
56
|
+
getLastDayOfTheWeek(): Chains;
|
|
57
|
+
diff(v: Chains): {
|
|
58
|
+
years: number;
|
|
59
|
+
months: number;
|
|
60
|
+
dates: number;
|
|
61
|
+
hours: number;
|
|
62
|
+
minutes: number;
|
|
63
|
+
seconds: number;
|
|
64
|
+
};
|
|
65
|
+
getAge(date?: Time.Chains): number;
|
|
66
|
+
time: {
|
|
67
|
+
new (v?: Input): Chains;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
type Methods = {
|
|
71
|
+
prototype: Chains;
|
|
72
|
+
(v?: Time.Input): Chains;
|
|
73
|
+
isTimeObject(v: any): boolean;
|
|
74
|
+
getFromNumberYYYYMMDD(v: number): Time.Chains;
|
|
75
|
+
getPeriodArray(type: 'seconds' | 'minutes' | 'hours' | 'day' | 'week' | 'month' | 'year', from: Time.Chains, to: Time.Chains): Time.Chains[];
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
declare const Time: Time.Methods;
|
|
79
|
+
export { Time, Time as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare namespace UUID {
|
|
2
|
+
namespace Methods {
|
|
3
|
+
type FN = (length?: number) => string;
|
|
4
|
+
type Chains = {
|
|
5
|
+
gen128Binary(): string;
|
|
6
|
+
gen32Hex(type?: 'Formatted' | 'None', separate?: string): string;
|
|
7
|
+
to32Format(v: string, separate?: string): string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
type Methods = Methods.FN & Methods.Chains;
|
|
11
|
+
}
|
|
12
|
+
declare const UUID: UUID.Methods;
|
|
13
|
+
export { UUID, UUID as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=Object.defineProperty,u=Object.defineProperties;var v=Object.getOwnPropertyDescriptors;var l=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;var m=(a,b)=>(b=Symbol[a])?b:Symbol.for("Symbol."+a);var x=Math.pow,p=(a,b,c)=>b in a?t(a,b,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[b]=c,y=(a,b)=>{for(var c in b||(b={}))q.call(b,c)&&p(a,c,b[c]);if(l)for(var c of l(b))r.call(b,c)&&p(a,c,b[c]);return a},z=(a,b)=>u(a,v(b));var A=(a,b)=>{var c={};for(var d in a)q.call(a,d)&&b.indexOf(d)<0&&(c[d]=a[d]);if(a!=null&&l)for(var d of l(a))b.indexOf(d)<0&&r.call(a,d)&&(c[d]=a[d]);return c};var B=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var C=(a,b,c)=>new Promise((d,j)=>{var g=e=>{try{f(c.next(e))}catch(h){j(h)}},i=e=>{try{f(c.throw(e))}catch(h){j(h)}},f=e=>e.done?d(e.value):Promise.resolve(e.value).then(g,i);f((c=c.apply(a,b)).next())}),w=function(a,b){this[0]=a,this[1]=b},D=(a,b,c)=>{var d=(i,f,e,h)=>{try{var n=c[i](f),o=(f=n.value)instanceof w,s=n.done;Promise.resolve(o?f[0]:f).then(k=>o?d(i==="return"?i:"next",f[1]?{done:k.done,value:k.value}:k,e,h):e({value:k,done:s})).catch(k=>d("throw",k,e,h))}catch(k){h(k)}},j=i=>g[i]=f=>new Promise((e,h)=>d(i,f,e,h)),g={};return c=c.apply(a,b),g[m("asyncIterator")]=()=>g,j("next"),j("throw"),j("return"),g};var E=(a,b,c)=>(b=a[m("asyncIterator")])?b.call(a):(a=a[m("iterator")](),b={},c=(d,j)=>(j=a[d])&&(b[d]=g=>new Promise((i,f,e)=>(g=j.call(a,g),e=g.done,Promise.resolve(g.value).then(h=>i({value:h,done:e}),f)))),c("next"),c("return"),b);export{x as a,y as b,z as c,A as d,B as e,C as f,w as g,D as h,E as i};
|
package/esm/core.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as J,f as C}from"./chunk-RWEMGXH3.js";import{UUID as v}from"./uuid";import"./primitiveExtension";const T=e=>new n.prototype.jsmin(e),n=T;n.prototype={},n.extend=function(e,i=n){for(var[r,o]of Object.entries(e))i.prototype[r]=o},n.expando="__jsmin_"+v();const m=(e,i)=>(e.queue.push(i),E(e),e),E=e=>C(void 0,null,function*(){if(!e.queueProcess&&e.queue.length){e.queueProcess=!0;let i=e.queue.shift();i&&(yield i()),e.queueProcess=!1,E(e)}}),y=(e,i)=>{for(let r=0;r<e.length;r++)e[r]=null;for(let[r,o]of Object.entries(i))r.match(/queue/)||(e[r]=o);return e},k=(e,i)=>{if(i.length){for(var r=0;r<i.length;r++){let o=i[r];o&&(o[n.expando]||(n.is.element(o)||n.is.shadowRoot(o))&&(o[n.expando]={events:{}})),e[r]=o}e.length=i.length}else e.warn="No Argument(s).",e.length=0;return e.queueProcess=!1,E(e),e};n.extend({constructor:n,jsmin:function(e){return this.src=e,this.srcType=n.is.what(e),this.queueProcess=!0,this.queue=[],k(this,n.is.jsmin(e)?e.get():n.is.element(e)?[e]:n.is.elements(e)?e:n.is.shadowRoot(e)?[e]:n.is.string(e)?e.match(/^#[^\.\s]*$/)?[document.getElementById(e.replace(/#/,""))]:document.querySelectorAll(e):[])}}),n.prototype[String(Symbol.iterator)]=[][Symbol.iterator],n.prototype.jsmin.prototype=n.prototype;{const e=function(t,s,a){let l=[];for(let u=0;u<(t.length||0);u++)l.push(s(t[u],u));return a&&(l=l.filter(u=>u!=null)),l},i=t=>(t.for((s,a)=>{if(!(n.is.element(s)||n.is.shadowRoot(s)))return;let l=s.cloneNode(),u=s.parentNode;u&&u.replaceChild(l,s),t[a]=l}),t),r=(t,s)=>(n(s).for(a=>{if(t&&(n.is.element(a)||n.is.shadowRoot(a)))if(n.is.string(t)||n.is.number(t))t=String(t),a.insertAdjacentHTML("beforeend",String(t));else if(n.is.element(t))a.appendChild(t);else{n.is.jsmin(t)?t=t.get():n.is.element(t)?t=[t]:n.is.keyValueDictionary(t)&&(t=[n(t)]);for(var l=0;l<t.length;l++)r(t[l],a)}}),s),o=(t,s,...a)=>{let{p:l,s:u}={before:{p:"beforebegin",s:""},after:{p:"afterend",s:"nextSibling"}}[s]||{p:"",s:""};return t.for(h=>{if(n.is.string(a[0]))h.insertAdjacentHTML(l,a[0]);else{if(!h.parentNode)return;n(a[0]).for(g=>{a[1]&&(g=g.cloneNode(!0)),h.parentNode.insertBefore(g,h[u]||h)})}}),t};n.extend({get:function(t){return t?this[0]:e(this,s=>s)},for:function(t,s=1){let a=e(this,(l,u)=>t(l,u),1);return s?a:[]},await:function(t){return m(this,()=>new Promise((s,a)=>{setTimeout(()=>{s(this)},t)}))},abort:function(){return m(this,()=>C(this,null,function*(){return this.queue=[],this}))},callback:function(t){return m(this,()=>C(this,null,function*(){return yield t(this),this}))},click:function(){return m(this,()=>{for(var t=0;t<this.length;t++){let s=this[t];n.is.element(s)&&s.click()}return this})},focus:function(){return m(this,()=>{for(var t=0;t<this.length;t++){let s=this[t];n.is.element(s)&&s.focus()}return this})},addEvent:function(t){return m(this,()=>{let{eventType:s,eventID:a=v(),target:l,callback:u,options:h}=t;return h=J({passive:!0,capture:!1},h),this.for(f=>{if(!(n.is.element(f)||n.is.shadowRoot(f)))return;let{events:g}=f[n.expando];if(l){let d=u;u=c=>{if(c.target){if(n.is.string(l)){let b=c.target.closest(l);b&&(!b||d.call(b,c))}else if(n.is.elements(l)){for(let p of l)if(c.target==p)return d.call(p,c)}}}}if(g[a]){let d=g[a];f.removeEventListener(d.eventType,d.callback,d.options)}g[a]={eventType:s,callback:u,options:h},f.addEventListener(s,u,h)}),this})},removeEvent:function(t){return m(this,()=>{let s=n.is.array(t)?t:[t];return this.for(a=>{let{events:l}=a[n.expando];for(let u of s){let h=l[u];h&&a.removeEventListener(h.eventType,h.callback,h.options)}}),this})},html:function(t){return m(this,()=>y(this,r(t,i(this))))},empty:function(){return m(this,()=>y(this,i(this)))},append:function(t){return m(this,()=>{r(t,this)})},remove:function(){return m(this,()=>(this.for((t,s)=>{t&&n.is.element(t)&&(t.remove(),delete this[s])}),this.length=0,this.warn="Object(s?) were all removed.",this))},before:function(...t){return m(this,()=>y(this,o(this,"before",...t)))},after:function(...t){return m(this,()=>y(this,o(this,"after",...t)))},find:function(t){return m(this,()=>{let s=[],a=this[0];a||y(this,n()),(n.is.element(a)||n.is.shadowRoot(a))&&(n.is.string(t)?s=a.querySelectorAll(t):n.is.element(a)&&n(t).for(l=>{let u=a.childNodes;for(let h of u)if(h===l){s.push(h);break}else h.childNodes.length&&(s=[...s,...n(h).find(l).for(f=>f)])})),y(this,n(s))})},parent:function(t){return m(this,()=>{var a,l;let s=n(t?(a=this[0])==null?void 0:a.closest(t):(l=this[0])==null?void 0:l.parentNode);y(this,s)})},children:function(t){return m(this,()=>{let s=this[0].children;n.is.exist(t)&&(t=String(t).replace(/^ : /,""),s=t=="first"?s[0]:t=="last"?s[s.length-1]:s[Number(t)]);let a=n(s);return y(this,a)})},addClass:function(t){return m(this,()=>(t&&this.for(s=>{let a=n.is.string(t)?t.split(" "):t;s&&n.is.element(s)&&s.classList.add(...a)}),this))},removeClass:function(t){return m(this,()=>(t&&this.for(s=>{let a=n.is.string(t)?t.split(" "):t;s&&n.is.element(s)&&s.classList.remove(...a)}),this))},toggleClass:function(t){return m(this,()=>(t&&this.for(s=>{s.classList.toggle(t)}),this))},hasClass:function(t=""){if(this[0])return this[0].classList.contains(t.replace(/^\./,""))},findClass:function(t){let s=[];return this[0]&&(s=[...this[0].classList].filter(a=>a.match(t))),s},css:function(t){return m(this,()=>(this.for(s=>{if(n.is.element(s))for(let[a,l]of Object.entries(t)){if(n.is.number(l)&&a.match(/width|height|top|right|bottom|left|padding|margin|gap|border-.*radius/)){s.style[a]=l+"px";continue}s.style[a]=String(l)}}),this))},getAttribute:function(t){return this[0].getAttribute(String(t))},setAttribute:function(t,s){return m(this,()=>(this.for(a=>a.setAttribute(t,s)),this))},getStyleProperty:function(t){let s=this[0];return s&&n.is.element(s)?getComputedStyle(s).getPropertyValue(t):""},setStyleProperty:function(t,s){let a=this[0];return a&&n.is.element(a)&&a.style.setProperty(t,s),this},val:function(){var s;let t=this[0];return(t==null?void 0:t.value)||((s=t==null?void 0:t.dataset)==null?void 0:s.value)},position:function(){return n.is.element(this[0])?this[0].getBoundingClientRect():{}}})}{n.flatArray=(i,r)=>{if(!n.is.array(i))return[i];let o=[];for(let t of i)o.push(...r=="-R"?n.flatArray(t,"-R"):[t]);return o},n.JsonTo=i=>JSON.stringify(i),n.toJson=i=>{let r;try{r={ok:!0,body:JSON.parse(i)}}catch(o){r={ok:!1,body:o}}return r},n.scope=i=>i(),n.randomNumber=(i=0,r=100,o)=>{if(i>r)return NaN;let t=[],s=i;for(;s<=r;){if(o&&o.length&&o.includes(s)){s++;continue}t.push(s),s++}let a=Math.round(Math.random()*(t.length-1))+0;return t[a]};let e={};n.interval={standBy:(i,r,o)=>{e[i]=setTimeout(o,r)},clear:i=>{clearInterval(e[i])}}}n.createElement=function(e){var g;let{tag:i,className:r="",id:o,html:t,attr:s,style:a,parent:l}=e,u=document.createElement(i||"div");if(r&&u.classList.add(...r.split(" ")),o&&(u.id=o),s)for(let d of Object.entries(s)){let c=d[0],p=(g=d[1])!=null?g:"";if(c=="data"&&n.is.keyValueDictionary(p))for(let[b,L]of Object.entries(p))u.dataset[b]=L;else c=="for"?c="htmlFor":c=="tabindex"?c="tabIndex":c=="aria-label"&&(c="ariaLabel"),u[c]=p}if(t&&n(u).append(t),a)for(var[h,f]of Object.entries(a))u.style[h]=f;return l&&n(l).append(u),u},n.setCookie=e=>{let{hostname:i}=new URL(location.toString()),{name:r,value:o="",age:t=60*60*24*365,path:s="/",domain:a=i,secure:l=!1}=e,u=`${r}=${o}max-age=${t}path=${s}domain=${a}`;l&&(u+=" Secure"),document.cookie=u},n.getCookie=e=>{let i=document.cookie.match(new RegExp(e+"=[^]*"));return i?i[0].replace(new RegExp(e+"="),""):""},n.setLocalStrageData=(e,i)=>{localStorage.setItem(e,JSON.stringify(i))},n.getLocalStrageData=e=>{let i=localStorage.getItem(e),r=n.toJson(i);return r.ok?r.body:i},n.deleteCookie=e=>{document.cookie=e+"=max-age=0"},n.getScreenSize=()=>{let{innerHeight:e,innerWidth:i,scrollY:r,scrollX:o,pageXOffset:t,pageYOffset:s}=window,a=Number(n(document.body).getStyleProperty("--sat").removeLetters()),l=Number(n(document.body).getStyleProperty("--sab").removeLetters());return{height:e,width:i,pageHeight:e-a-l,scrollY:r,scrollX:o,pageXOffset:t,pageYOffset:s,safeAreaTop:a,safeAreaBottom:l}},n.getCursor=e=>{var o,t,s,a,l,u,h,f;let i=(a=e.pageX)!=null?a:(s=(o=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:o.pageX)!=null?s:(((t=e==null?void 0:e.originalEvent)==null?void 0:t.touches)||[])[0].pageX,r=(f=e.pageY)!=null?f:(h=(l=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:l.pageY)!=null?h:(((u=e==null?void 0:e.originalEvent)==null?void 0:u.touches)||[])[0].pageY;return{x:i,y:r}},n.pending=(e,i)=>new Promise((r,o)=>{e(r),setTimeout(()=>{r(!0)},i)}),n.getLocalIP=e=>{let i="";return n.scope(()=>{if(!e)return;let r=e.networkInterfaces();for(let[o,t]of Object.entries(r))t.forEach(s=>{!s.internal&&s.family==="IPv4"&&!s.address.match(/^(169|127)/)&&(i=s.address)})}),i},n.getIp=function(e){var o;return(((e==null?void 0:e.headers["x-forwarded-for"])||((o=e==null?void 0:e.socket)==null?void 0:o.remoteAddress)||"").toString().match(new RegExp(/(::ffff:)?(\d+\.\d+.\d+\.\d+(:\d+)?)/))||[])[2]||"IP UNDEFINED"},n.deepMerge=(e,...i)=>{if(!i.length)return e;const r=i.shift();if(n.is.keyValueDictionary(e)&&n.is.keyValueDictionary(r))for(const o in r)n.is.keyValueDictionary(r[o])?(e[o]||Object.assign(e,{[o]:{}}),n.deepMerge(e[o],r[o])):Object.assign(e,{[o]:r[o]});return n.deepMerge(e,...i)},n.queryParams={get:e=>{let i=new URL(e||location.href),r={};return i.searchParams.forEach((o,t)=>r[t]=o),r},set:(e,i)=>{const r=new URL(i||location.href);return Object.entries(e).forEach(([o,t])=>{r.searchParams.set(o,String(t))}),i||history.replaceState({},"",r.pathname+r.search),r.toString()},delete:(e,i)=>{const r=new URL(i||location.href);return e.forEach(o=>{r.searchParams.delete(o)}),i||history.replaceState({},"",r.pathname+r.search),r.toString()}},n.ellipsisText=(e,i)=>{let r=String(e);return r.length>i&&(r=r.slice(0,i)+" ..."),r},n.is={what:function(e){let i="other";return this.jsmin(e)?i="jsmin":this.element(e)?i="element":this.elements(e)?i="elements":this.shadowRoot(e)?i="shadowRoot":this.string(e)?i="string":this.number(e)?i="number":this.array(e)?i="array":this.function(e)?i="function":this.date(e)?i="date":typeof e=="undefined"?i="undefined":this.keyValueDictionary(e)?i="keyValueDictionary":e==null?i="null":isNaN(e)&&(i="NaN"),i},exist:function(e){return e===(e!=null?e:!e)},nullish:function(e){return!this.exist(e)},jsmin:function(e){return(e||{}).constructor===n},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 i={}.toString.call(e);return e instanceof Array||i=="[object NodeList]"||i=="[object HTMLCollection]"},function:function(e){return typeof e=="function"},keyValueDictionary:function(e){return{}.toString.call(e)==="[object Object]"&&!this.jsmin(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 i={}.toString.call(e),r=Number(!!e&&typeof e!="string"&&this.array(e)&&i!=="[object Text]");if(r&&i!=="[object NodeList]")for(var o of e)r&=Number(this.element(o));return!!r},shadowRoot:function(e){return e instanceof ShadowRoot},date:function(e){return this.number(new Date(e).getTime())}};export{n as Jsmin,n as default};
|
package/esm/extension.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as u,f as i}from"./chunk-RWEMGXH3.js";import o from"./core";var l=u(s=>{o.copyToClipboard=t=>i(s,null,function*(){let r="";o.is.string(t)?r=t:o.is.function(t)&&(r=t());let n={ok:!1,body:"NotSupported"};return yield i(s,null,function*(){let a;if(navigator.clipboard){if(a=yield navigator.clipboard.writeText(r).then(()=>!0,()=>!1),!a)return}else{let e=document.createElement("input");if(o(document.body).append(e),e.value=r,e.select(),a=document.execCommand("copy"),document.body.removeChild(e),!a)return}n={ok:!0,body:""}}),n}),o.getCurrentLocation=()=>new Promise((t,r)=>{navigator.geolocation.getCurrentPosition(n=>{let{latitude:a,longitude:e}=n.coords;t({ok:!0,status:200,body:{lat:a,lng:e}})},n=>{t({ok:!1,status:500,body:{reason:n}})})}),o.ImageLoader=(t,r)=>new Promise((n,a)=>{let e=r||new Image;e.onload=()=>n(e),e.onerror=m=>a(m),e.src=t})});export default l();
|
package/esm/fetcher.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as T,c as B,d as D,f,g as w,h as x,i as O}from"./chunk-RWEMGXH3.js";import p from"./core";import{UUID as F}from"./uuid";const e=(t,r)=>new e.prototype.instance(t,r);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)=>f(void 0,null,function*(){try{const a=(r==null?void 0:r.reader)||t.getReader();if(!e.isReadableStreamReader(a))return{ok:!1,done:!0,data:null};if(!a)return{ok:!1,done:!0,data:null};const i=(r==null?void 0:r.decoder)||new TextDecoder("utf-8");let o=yield a.read();return{ok:!0,done:o.done,data:i.decode(o.value)}}catch(a){return{ok:!1,done:!0,data:a}}}),p.extend({constructor:e,instance:function(t,r){var o;r=r||{};let a=r.body;r.body&&!p.is.string(r.body)&&((o=r.bodyStringify)==null||o)&&(a=JSON.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=B(T({key:F(),response_format:"json",timeout:e.setDefaultTimeout,trafficControl:e.setDefaultTrafficControl,preventMultiRequest:!0},r),{headers:T(T({"Content-Type":"application/json"},e.setDefaultHeaders&&e.setDefaultHeaders()),r.headers),body:a}),this},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},onError:function(t){return this.onErrorCB=t,this},onStreamProcess:function(t){return f(this,null,function*(){let{response:r,errorCB:a,streamCB:i,reader:o,decoder:d}=t,s=r.body,u=this;const y=function(){return x(this,null,function*(){if(!r.ok){p.scope(()=>f(this,null,function*(){let{ok:m,done:h,data:C}=yield e.streamToContext(s,{reader:o,decoder:d});m&&a(C)}));return}let n=!1;for(;!n;){let{ok:m,done:h,data:C}=yield new w(e.streamToContext(s,{reader:o,decoder:d}));u.streamStatus=="abort"?(u.streamStatus="closed",o.cancel(),h=!0):u.streamStatus=="closed"&&(h=!0),h&&(n=h,o.releaseLock()),i(C,h)}})};try{for(var b=O(y()),c,S,R;c=!(S=yield b.next()).done;c=!1){let n=S.value;;}}catch(S){R=[S]}finally{try{c&&(S=b.return)&&(yield S.call(b))}finally{if(R)throw R[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 f(this,null,function*(){var R;let t=this.params,r=performance.now(),a=0,i=new AbortController,o=setTimeout(()=>{i.abort()},t.timeout);t.signal=i.signal;let d=!1,s=500,u="InternalServerError",y={},b=null;try{e.setDefaultOnStart&&e.setDefaultOnStart(t),this.onStartCB&&this.onStartCB(t);let S=t,{key:n,response_format:m,trafficControl:h,preventMultiRequest:C,timeout:k,queries:v}=S,g=D(S,["key","response_format","trafficControl","preventMultiRequest","timeout","queries"]);g.method=this.method;let I=e.waitList.includes(n);if(C&&I)throw s=429,new Error("TooManyRequests");e.waitList=[...e.waitList,n];let P=p.queryParams.set(T({},v),String(this.url));y=yield fetch(P,g).then(l=>f(this,null,function*(){return d=l.ok,s=l.status,u=l.statusText,b=l,m=="none"||m=="stream"?l:l[m]()})).catch(l=>{throw new Error(l)})}catch(n){s==200&&(s=500,d=!1),s==429&&(u="TooManyRequests"),i.signal.aborted&&(s=408,u="Timeout"),s==500&&(u=String(n)||u),y={errorCode:String(n)}}finally{clearTimeout(o),a=performance.now()-r}t.trafficControl&&(yield p.pending(()=>{},t.trafficControl)),e.waitList.splice(e.waitList.findIndex(n=>n==t.key),1);let c={ok:d,status:s,statusText:u,body:y,requestTime:a,rawData:b};if(!d&&this.onErrorCB&&this.onErrorCB(c.body),d&&this.onStreamCB&&t.response_format=="stream"){let n=(R=b.body)==null?void 0:R.getReader();this.onStreamProcess({errorCB:this.onErrorCB,streamCB:this.onStreamCB,response:c,reader:n,decoder:new TextDecoder("utf-8")})}return d&&this.onCompleteCB&&this.onCompleteCB(c.body),this.onResultCB&&this.onResultCB(c,t),e.setDefaultOnEnd&&e.setDefaultOnEnd(c,t),c})},abortStream:function(){this.streamStatus="abort"}},e),e.prototype.instance.prototype=e.prototype;export{e as Fetcher,e as default};
|
package/esm/filer.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as i}from"./chunk-RWEMGXH3.js";import l from"./core";import f from"./fetcher";const r=e=>new r.prototype.instance(e);r.prototype={},l.extend({constructor:r,instance:function(e){this.ok=!0;try{let[t,s]=e.name.replace(/\s/,"").replace(/(.*)\.(.*)$/,"$1 $2").split(" ");this.file=e,this.extension=s,this.fileName=t,this.type=e.type}catch(t){console.log(t),this.ok=!1}return this},isValid:function(){return this.ok},toBlob:function(){return i(this,null,function*(){return new Blob([this.file,{type:this.type}])})},toDataURL:function(){return i(this,null,function*(){var e;return(e=(yield this.file.convert("dataURL")).target)==null?void 0:e.result})},toAarrayBuffer:function(){return i(this,null,function*(){var e;return(e=(yield this.file.convert("arrayBuffer")).target)==null?void 0:e.result})},toObjectURL:function(){return i(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}},r),r.prototype.instance.prototype=r.prototype;const a={fromFile:e=>i(void 0,null,function*(){return r(e)}),fromBlob:(e,t)=>i(void 0,null,function*(){let s=(t==null?void 0:t.fileName)||"file",n=(t==null?void 0:t.extension)||"",o=new File([e],s+"."+n,{type:t==null?void 0:t.mimeType});return r(o)}),fromArrayBuffer:(e,t)=>i(void 0,null,function*(){return a.fromBlob(new Blob([e],{type:(t==null?void 0:t.mimeType)||""}),t)}),fromObjectURL:(e,t)=>i(void 0,null,function*(){let s=yield f(e,{response_format:"blob"}).get();return s.ok?a.fromBlob(s.body,t):r({})}),fromDataURL:(e,t)=>i(void 0,null,function*(){let s=yield e.toBlob((t==null?void 0:t.mimeType)||"");return s?a.fromBlob(s,t):r({})})};export{a as Filer,a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import a from"./core";a.formatCharacter={postal:{JP:r=>{let e="--";return r=String(r).replace(/\D/ig,""),r.length==7&&(e=r.replace(/^(\d{3})(.*)/,"$1-$2")),e}},tel:{_:r=>{let e=r;return r=String(r).removeLetters(),r.length==11&&(e=r.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),r.length==10&&(e=r.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),e},mobile:r=>{let e="--";return r=String(r).removeLetters(),r.length==11&&(e=r.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),e},fixed:r=>{let e="--";return r=String(r).removeLetters(),r.length==10&&(e=r.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),e}}},a.transformer={weekday:{JP:r=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][r]+"\u66DC\u65E5",shortJP:r=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][r]},wareki:r=>{let e=[],n=[],o=!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(s=>{let{From:i,To:d,name:m}=s;if(i<=r&&r<=d){let t=r-i+1;t==1&&(o=!0,t="\u5143"),n.push(m+t+"\u5E74"),e.push(m)}}),{era:e,value:n,gap:o}}};
|
package/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-RWEMGXH3.js";import"./primitiveExtension";import e from"./core";import t from"./uuid";import o from"./time";import r from"./fetcher";import m from"./filer";import i from"./server";import"./formatCharacter";import"./extension";r.setDefaultHeaders=()=>({});var x=e;export{r as Fetcher,m as Filer,i as Server,o as Time,t as UUID,x as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p}from"./chunk-RWEMGXH3.js";if(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(/^.*,/,"")),n=new Uint8Array(t.length);for(var r=0;r<t.length;r++)n[r]=t.charCodeAt(r);try{var o=new Blob([n.buffer],{type:e})}catch(i){return!1}return o},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(/+/,"+")}),typeof Number!="undefined"&&(Number.prototype.zeroEmbed=function(e){return String(this).padStart(e||2,"0")},Number.prototype.ratio=function(e,t=2){let n=p(10,t);return Math.round(this/e*n*100)/n},Number.prototype.rate=function(e,t=2){let n=p(10,t);return Math.round(this/e*n)/n},Number.prototype.rank=function(e=1){let t=p(10,e),n=Number(this),r=n.toLocaleString().replace(/\d/ig,"").length;return Math.round(n/p(1e3,r)*t)/t+("KMGTPEZY"[r-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),n=t.slice(0,4),r=t.slice(4,6),o=t.slice(6,8),i=[];return n.length!=4||i.push(n),r.length!=2||i.push(r),o.length!=2||i.push(o),i.join(e)}),typeof Array!="undefined"){const e=(t,n)=>{if(!t)return;let r=t;for(let o of n){if(!r)break;r=r[o]}return r};Array.prototype.order=function(t){let{direction:n="ASC",keys:r=[],numeral:o=!1}=t,i=[];return r.length?o?i=this.sort((s,a)=>+(Number(e(s,r))>Number(e(a,r)))*2-1):i=this.sort((s,a)=>{const l=String(e(s,r)).replace(/(\d+)/g,u=>u.padStart(18,"0")),g=String(e(a,r)).replace(/(\d+)/g,u=>u.padStart(18,"0"));return+(l>g)*2-1}):o?i=this.sort((s,a)=>+(s>a)*2-1):i=this.sort((s,a)=>{const l=String(s).replace(/(\d+)/g,u=>u.padStart(18,"0")),g=String(a).replace(/(\d+)/g,u=>u.padStart(18,"0"));return+(l>g)*2-1}),n=="DESC"&&(i=i.reverse()),i},Array.prototype.getLastChild=function(){let t=this.length-1;return this[t]}}typeof File!="undefined"&&(File.prototype.convert=function(e){return e=e||"dataURL",new Promise((t,n)=>{let r=new FileReader;r.onload=i=>t(i),r.onerror=i=>n(i);let o="readAs"+(e==null?void 0:e.toCapital());r[o](this)})});
|
package/esm/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-RWEMGXH3.js";import h from"./core";const p=function(u){let t=u,r=null;return t.use((e,s,a)=>{let R=s;R.return=i=>{let{status:x=200,body:o={},bodyStringify:d=!0}=i||{},n=o;return d&&(h.is.string(o)||(n=JSON.stringify(o))),s.status(x).end(n)},a()}),t.setRouter=function(e){return r=e,this},t.pathRouter=function(e){if(!r)return;let s=r(e);return s.route(e),t.use(e,s),s},t.exception=function(e){return t.use(e),this},t};export{p as Server,p as default};
|
package/esm/time.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-RWEMGXH3.js";import i from"./core";const l=e=>new a.prototype.time(e),a=l;a.prototype={};const o=function(e,t){e.value=t;let r=i.is.date(t);if(e.validate=r,!r)return e.ms=-1,e.year=-1,e.month=-1,e.weekday=-1,e.weekInYear=-1,e.date=-1,e.hours=-1,e.minutes=-1,e.seconds=-1,e;e.ms=t.getTime(),e.weekday=t.getDay(),e.year=t.getFullYear(),e.month=t.getMonth()+1,e.date=t.getDate();{let s=new Date(e.year,0,1),n=new Date(s.valueOf());n.setDate(n.getDate()-(s.getDay()+1));let h=t.getTime()-n.getTime(),m=Math.ceil(h/(1e3*60*60*24));e.weekInYear=Math.ceil(m/7)}{let s=new Date(e.year,e.month-1,1),n=new Date(s.valueOf());n.setDate(n.getDate()-(s.getDay()+1));let h=t.getTime()-n.getTime(),m=Math.ceil(h/(1e3*60*60*24)),u=Math.ceil(m/7);e.weekInMonth=u}{let s=new Date(e.year,e.month,0),n=s.getDay(),h=new Date(new Date(s).setDate(s.getDate()-n));e.isLastWeekInMonth=e.date>=h.getDate()}return e.hours=t.getHours(),e.minutes=t.getMinutes(),e.seconds=t.getSeconds(),e};i.extend({constructor:a,time:function(e){a.isTimeObject(e)&&(e=e.value),e||(e===null?e=void 0:e===void 0&&(e=new Date));let t=new Date(e);return o(this,t)}},a),a.prototype.time.prototype=a.prototype,a.isTimeObject=e=>{var t;return((t=e||{})==null?void 0:t.constructor)===a},a.getFromNumberYYYYMMDD=e=>{let t=String(e).replace(/(\d{4})(\d{2})(\d{2})/,"$1/$2/$3");return a(t+" 00:00")},a.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=a(n).addYear(1):e=="month"?n=a(n).addMonth(1):e=="week"?n=a(n).addWeek(1):e=="day"?n=a(n).addDate(1):e=="hours"?n=a(n).addHours(1):e=="minutes"?n=a(n).addMinutes(1):e=="seconds"&&(n=a(n).addSeconds(1));return s},i.extend({setYear:function(e){let t=new Date(this.value.valueOf());return t.setFullYear(e),o(this,t)},setMonth:function(e){let t=new Date(this.value.valueOf());return t.setMonth(e-1),o(this,t)},setDate:function(e){let t=new Date(this.value.valueOf());return t.setDate(e),o(this,t)},setHours:function(e){let t=new Date(this.value.valueOf());return t.setHours(e),o(this,t)},setMinutes:function(e){let t=new Date(this.value.valueOf());return t.setMinutes(e),o(this,t)},setSeconds:function(e){let t=new Date(this.value.valueOf());return t.setSeconds(e),o(this,t)},setMilliseconds:function(e){let t=new Date(this.value.valueOf());return t.setMilliseconds(e),o(this,t)},setMidnight:function(){let e=new Date(this.value.valueOf());return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),o(this,e)},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)},isSameYear:function(e){let t=i.Time(e);return this.year==t.year},isSameMonth:function(e){let t=i.Time(e);return this.year==t.year&&this.month==t.month},isSameWeek:function(e){let t=i.Time(e);return this.year==t.year&&this.weekInYear==t.weekInYear},isSameDate:function(e){let t=i.Time(e);return this.year==t.year&&this.month==t.month&&this.date==t.date},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%m\u5206"):this.toFormat("%h:%i"):""},toFormatYMDHM:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%m\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"):""},getFirstDayOfTheYear:function(){return i.Time(new Date(this.value.getFullYear(),0,1))},getLastDayOfTheYear:function(){return i.Time(new Date(this.value.getFullYear()+1,0,0))},getFirstDayOfTheMonth:function(){return i.Time(new Date(this.value.getFullYear(),this.month-1,1))},getLastDayOfTheMonth:function(){return i.Time(new Date(this.value.getFullYear(),this.month,0))},getFirstDayOfTheWeek:function(){let e=i.Time(this.value);return e.addDate(-e.weekday)},getLastDayOfTheWeek:function(){let e=i.Time(this.value);return e.addDate(6-e.weekday)},diff:function(e){let t=this.ms-e.ms;return{years:this.year-e.year,months:(this.year-e.year)*12+(this.month-e.month),dates:Math.floor(t/(60*60*24*1e3)),hours:Math.floor(t/(60*60*1e3)),minutes:Math.floor(t/(60*1e3)),seconds:Math.floor(t/1e3)}},getAge:function(e){let t=e||i.Time(),r=t.year-this.year;return(this.month>t.month||this.month==t.month&&t.date<this.date)&&r--,r}},a),i.Time=a;export{a as Time,a as default};
|
package/esm/uuid.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-RWEMGXH3.js";const s=(e=24)=>Array.from({length:e}).map((n,t)=>{let o=t==0?25:35,a=Math.round(Math.random());return"abcdefghijkrmnopqrstuvwxyz0123456789"[Math.round(Math.random()*o)][a?"toUpper":"toLower"]()}).join(""),r=s;r.gen128Binary=()=>Array.from({length:128}).map((e,n)=>"01"[Math.round(Math.random()*1)]).join(""),r.gen32Hex=(e="Formatted",n="-")=>{let t=Array.from({length:32}).map((o,a)=>"0123456789abcdef"[Math.round(Math.random()*15)]).join("").toUpper();return e=="Formatted"&&(t=[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20,32)].join(n)),t},r.to32Format=e=>[e.slice(0,8),e.slice(8,12),e.slice(12,16),e.slice(16,20),e.slice(20,32)].join("-").toUpper();export{r as UUID,r as default};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jmini",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "minified JavaScript Framework",
|
|
5
|
+
"main": "cjs/index.js",
|
|
6
|
+
"module": "esm/index.js",
|
|
7
|
+
"types": "declare/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"cjs",
|
|
10
|
+
"esm",
|
|
11
|
+
"declare"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"start": "run-p clean build:*",
|
|
15
|
+
"clean": "rimraf cjs esm declare",
|
|
16
|
+
"build:cjs": "nodemon --config nodemon.cjs.json",
|
|
17
|
+
"build:esm": "nodemon --config nodemon.esm.json",
|
|
18
|
+
"build:declare": "nodemon --config nodemon.declare.json"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/IkkoKoyama/jsmin.git"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"jmini"
|
|
26
|
+
],
|
|
27
|
+
"author": "IkkoKoyama <mingoo.master@gmail.com>",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/IkkoKoyama/jsmin/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/IkkoKoyama/jsmin#readme",
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/react": "^18.3.3",
|
|
35
|
+
"esbuild": "^0.23.0",
|
|
36
|
+
"nodemon": "^3.1.4",
|
|
37
|
+
"npm-run-all": "^4.1.5",
|
|
38
|
+
"rimraf": "^6.0.1",
|
|
39
|
+
"ts-loader": "^9.5.1",
|
|
40
|
+
"typescript": "^5.5.4"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@types/express": "^4.17.21",
|
|
44
|
+
"express": "^4.21.0"
|
|
45
|
+
}
|
|
46
|
+
}
|