jmini 0.0.2 → 0.0.4

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/declare/core.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { KeyValueDict } from '.';
2
2
  import './primitiveExtension';
3
3
  declare global {
4
- interface JsminExtension {
4
+ interface JminiExtension {
5
5
  }
6
6
  }
7
- declare namespace Jsmin {
7
+ declare namespace Jmini {
8
8
  type Args = any;
9
9
  type ElementableValue = any;
10
10
  type ForFunction = {
@@ -51,7 +51,7 @@ declare namespace Jsmin {
51
51
  abort(): Chains;
52
52
  callback: {
53
53
  (fn: {
54
- (jsmin: Chains): void;
54
+ (jmini: Chains): void;
55
55
  }): Chains;
56
56
  };
57
57
  click(): Chains;
@@ -79,7 +79,7 @@ declare namespace Jsmin {
79
79
  setStyleProperty(property: string, value: string): Chains;
80
80
  val(): string;
81
81
  position(): DOMRect;
82
- jsmin: {
82
+ jmini: {
83
83
  new (v?: Args): Chains;
84
84
  };
85
85
  };
@@ -135,7 +135,7 @@ declare namespace Jsmin {
135
135
  what(v: any): string;
136
136
  exist(v: any): boolean;
137
137
  nullish(val: any): boolean;
138
- jsmin(v: any): v is Methods & Chains;
138
+ jmini(v: any): v is Methods & Chains;
139
139
  string(v: any): v is string;
140
140
  boolean(v: any): v is boolean;
141
141
  number(v: any): v is number;
@@ -164,5 +164,5 @@ declare namespace Jsmin {
164
164
  };
165
165
  };
166
166
  }
167
- declare const Jsmin: Jsmin.Methods & JsminExtension;
168
- export { Jsmin, Jsmin as default };
167
+ declare const Jmini: Jmini.Methods & JminiExtension;
168
+ export { Jmini, Jmini as default };
@@ -1,22 +1,5 @@
1
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 {
2
+ interface JminiExtension {
20
3
  formatCharacter: {
21
4
  postal: {
22
5
  JP(params: string): string;
@@ -45,9 +28,6 @@ declare global {
45
28
  ok: boolean;
46
29
  body: any;
47
30
  }>;
48
- getCurrentLocation: {
49
- (): Promise<JsminExtension.getCurrentLocationOutput>;
50
- };
51
31
  }
52
32
  }
53
- export {};
33
+ export type FileReadAsType = 'dataURL' | 'arrayBuffer' | 'binaryString' | 'text';
@@ -2,13 +2,12 @@ export interface KeyValueDict<T = any> {
2
2
  [key: string]: T | void;
3
3
  }
4
4
  import './primitiveExtension';
5
- import Jsmin from './core';
5
+ import Jmini from './core';
6
6
  import UUID from './uuid';
7
7
  import Time from './time';
8
8
  import Fetcher from './fetcher';
9
9
  import Filer from './filer';
10
10
  import Server from './server';
11
- import './formatCharacter';
12
- import './extension';
11
+ export * from './extension';
13
12
  export { Time, Fetcher, Filer, Server, UUID };
14
- export default Jsmin;
13
+ export default Jmini;
@@ -1,3 +1,4 @@
1
+ import { FileReadAsType } from '.';
1
2
  declare global {
2
3
  /** primitive */
3
4
  interface HTMLElement {
@@ -45,7 +46,6 @@ declare global {
45
46
  getLastChild(): T;
46
47
  }
47
48
  interface File {
48
- convert(readAs?: JsminExtension.FileReadAsType): Promise<ProgressEvent<FileReader>>;
49
+ convert(readAs?: FileReadAsType): Promise<ProgressEvent<FileReader>>;
49
50
  }
50
51
  }
51
- export {};
@@ -8,28 +8,28 @@ declare namespace Server {
8
8
  type Path = string | number | boolean | RegExp | void;
9
9
  type Callback<A = Request, B = Response> = (req: A, res: B, next: express.NextFunction, error: Error) => void;
10
10
  type SetInput = [string, any];
11
- type UseInput = [Path] | [Path, Path] | RestInput | [Callback];
11
+ type UseInput<A = Request, B = Response> = [Path] | [Path, Path] | RestInput | [Callback<A, B>];
12
12
  type RestInput<A = Request, B = Response> = [path: Path, ...fns: Callback<A, B>[]];
13
13
  type ReturnInput<T = any> = {
14
14
  status?: number;
15
15
  body?: T;
16
16
  bodyStringify?: boolean;
17
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>;
18
+ type CustomMethods<A = Request, B = Response, E extends string = ''> = {
19
+ set(...args: SetInput): Omit<Methods<A, B>, E>;
20
+ use(...args: UseInput<A, B>): Omit<Methods<A, B>, E>;
21
+ get(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
22
+ post(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
23
+ put(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
24
+ patch(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
25
+ delete(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
26
+ options(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
27
+ all(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
28
28
  };
29
29
  type CustomExpress = Omit<express.Express, keyof CustomMethods>;
30
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>;
31
+ onPathRouter(getRouter: (path: string) => express.Router): Methods<A, B>;
32
+ pathRouter(path: string): CustomMethods<A, B, 'setRouter' | 'pathRouter'>;
33
33
  exception(fn: (err: any, req: A, res: B, next: express.NextFunction) => void): Methods<A, B>;
34
34
  };
35
35
  type FN = {
package/declare/time.d.ts CHANGED
@@ -1,10 +1,3 @@
1
- declare global {
2
- namespace JsminExtension {
3
- }
4
- interface JsminExtension {
5
- Time: Time.Methods;
6
- }
7
- }
8
1
  declare namespace Time {
9
2
  type Input = any;
10
3
  type DateTrimTypes = 'Y' | 'M' | 'W' | 'D' | 'H' | 'I' | 'S';
@@ -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,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},C=(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 D=(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,w as f,C as g,D as h};
package/esm/core.js CHANGED
@@ -1 +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};
1
+ import{b as J,e as C}from"./chunk-ABA72NWU.js";import{UUID as v}from"./uuid";import"./primitiveExtension";const T=e=>new n.prototype.jmini(e),n=T;n.prototype={},n.extend=function(e,r=n){for(var[s,o]of Object.entries(e))r.prototype[s]=o},n.expando="__jmini_"+v();const m=(e,r)=>(e.queue.push(r),E(e),e),E=e=>C(void 0,null,function*(){if(!e.queueProcess&&e.queue.length){e.queueProcess=!0;let r=e.queue.shift();r&&(yield r()),e.queueProcess=!1,E(e)}}),y=(e,r)=>{for(let s=0;s<e.length;s++)e[s]=null;for(let[s,o]of Object.entries(r))s.match(/queue/)||(e[s]=o);return e},k=(e,r)=>{if(r.length){for(var s=0;s<r.length;s++){let o=r[s];o&&(o[n.expando]||(n.is.element(o)||n.is.shadowRoot(o))&&(o[n.expando]={events:{}})),e[s]=o}e.length=r.length}else e.warn="No Argument(s).",e.length=0;return e.queueProcess=!1,E(e),e};n.extend({constructor:n,jmini:function(e){return this.src=e,this.srcType=n.is.what(e),this.queueProcess=!0,this.queue=[],k(this,n.is.jmini(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.jmini.prototype=n.prototype;{const e=function(t,i,a){let l=[];for(let u=0;u<(t.length||0);u++)l.push(i(t[u],u));return a&&(l=l.filter(u=>u!=null)),l},r=t=>(t.for((i,a)=>{if(!(n.is.element(i)||n.is.shadowRoot(i)))return;let l=i.cloneNode(),u=i.parentNode;u&&u.replaceChild(l,i),t[a]=l}),t),s=(t,i)=>(n(i).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.jmini(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++)s(t[l],a)}}),i),o=(t,i,...a)=>{let{p:l,s:u}={before:{p:"beforebegin",s:""},after:{p:"afterend",s:"nextSibling"}}[i]||{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,i=>i)},for:function(t,i=1){let a=e(this,(l,u)=>t(l,u),1);return i?a:[]},await:function(t){return m(this,()=>new Promise((i,a)=>{setTimeout(()=>{i(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 i=this[t];n.is.element(i)&&i.click()}return this})},focus:function(){return m(this,()=>{for(var t=0;t<this.length;t++){let i=this[t];n.is.element(i)&&i.focus()}return this})},addEvent:function(t){return m(this,()=>{let{eventType:i,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:i,callback:u,options:h},f.addEventListener(i,u,h)}),this})},removeEvent:function(t){return m(this,()=>{let i=n.is.array(t)?t:[t];return this.for(a=>{let{events:l}=a[n.expando];for(let u of i){let h=l[u];h&&a.removeEventListener(h.eventType,h.callback,h.options)}}),this})},html:function(t){return m(this,()=>y(this,s(t,r(this))))},empty:function(){return m(this,()=>y(this,r(this)))},append:function(t){return m(this,()=>{s(t,this)})},remove:function(){return m(this,()=>(this.for((t,i)=>{t&&n.is.element(t)&&(t.remove(),delete this[i])}),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 i=[],a=this[0];a||y(this,n()),(n.is.element(a)||n.is.shadowRoot(a))&&(n.is.string(t)?i=a.querySelectorAll(t):n.is.element(a)&&n(t).for(l=>{let u=a.childNodes;for(let h of u)if(h===l){i.push(h);break}else h.childNodes.length&&(i=[...i,...n(h).find(l).for(f=>f)])})),y(this,n(i))})},parent:function(t){return m(this,()=>{var a,l;let i=n(t?(a=this[0])==null?void 0:a.closest(t):(l=this[0])==null?void 0:l.parentNode);y(this,i)})},children:function(t){return m(this,()=>{let i=this[0].children;n.is.exist(t)&&(t=String(t).replace(/^ : /,""),i=t=="first"?i[0]:t=="last"?i[i.length-1]:i[Number(t)]);let a=n(i);return y(this,a)})},addClass:function(t){return m(this,()=>(t&&this.for(i=>{let a=n.is.string(t)?t.split(" "):t;i&&n.is.element(i)&&i.classList.add(...a)}),this))},removeClass:function(t){return m(this,()=>(t&&this.for(i=>{let a=n.is.string(t)?t.split(" "):t;i&&n.is.element(i)&&i.classList.remove(...a)}),this))},toggleClass:function(t){return m(this,()=>(t&&this.for(i=>{i.classList.toggle(t)}),this))},hasClass:function(t=""){if(this[0])return this[0].classList.contains(t.replace(/^\./,""))},findClass:function(t){let i=[];return this[0]&&(i=[...this[0].classList].filter(a=>a.match(t))),i},css:function(t){return m(this,()=>(this.for(i=>{if(n.is.element(i))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/)){i.style[a]=l+"px";continue}i.style[a]=String(l)}}),this))},getAttribute:function(t){return this[0].getAttribute(String(t))},setAttribute:function(t,i){return m(this,()=>(this.for(a=>a.setAttribute(t,i)),this))},getStyleProperty:function(t){let i=this[0];return i&&n.is.element(i)?getComputedStyle(i).getPropertyValue(t):""},setStyleProperty:function(t,i){let a=this[0];return a&&n.is.element(a)&&a.style.setProperty(t,i),this},val:function(){var i;let t=this[0];return(t==null?void 0:t.value)||((i=t==null?void 0:t.dataset)==null?void 0:i.value)},position:function(){return n.is.element(this[0])?this[0].getBoundingClientRect():{}}})}{n.flatArray=(r,s)=>{if(!n.is.array(r))return[r];let o=[];for(let t of r)o.push(...s=="-R"?n.flatArray(t,"-R"):[t]);return o},n.JsonTo=r=>JSON.stringify(r),n.toJson=r=>{let s;try{s={ok:!0,body:JSON.parse(r)}}catch(o){s={ok:!1,body:o}}return s},n.scope=r=>r(),n.randomNumber=(r=0,s=100,o)=>{if(r>s)return NaN;let t=[],i=r;for(;i<=s;){if(o&&o.length&&o.includes(i)){i++;continue}t.push(i),i++}let a=Math.round(Math.random()*(t.length-1))+0;return t[a]};let e={};n.interval={standBy:(r,s,o)=>{e[r]=setTimeout(o,s)},clear:r=>{clearInterval(e[r])}}}n.createElement=function(e){var g;let{tag:r,className:s="",id:o,html:t,attr:i,style:a,parent:l}=e,u=document.createElement(r||"div");if(s&&u.classList.add(...s.split(" ")),o&&(u.id=o),i)for(let d of Object.entries(i)){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:r}=new URL(location.toString()),{name:s,value:o="",age:t=60*60*24*365,path:i="/",domain:a=r,secure:l=!1}=e,u=`${s}=${o}max-age=${t}path=${i}domain=${a}`;l&&(u+=" Secure"),document.cookie=u},n.getCookie=e=>{let r=document.cookie.match(new RegExp(e+"=[^]*"));return r?r[0].replace(new RegExp(e+"="),""):""},n.setLocalStrageData=(e,r)=>{localStorage.setItem(e,JSON.stringify(r))},n.getLocalStrageData=e=>{let r=localStorage.getItem(e),s=n.toJson(r);return s.ok?s.body:r},n.deleteCookie=e=>{document.cookie=e+"=max-age=0"},n.getScreenSize=()=>{let{innerHeight:e,innerWidth:r,scrollY:s,scrollX:o,pageXOffset:t,pageYOffset:i}=window,a=Number(n(document.body).getStyleProperty("--sat").removeLetters()),l=Number(n(document.body).getStyleProperty("--sab").removeLetters());return{height:e,width:r,pageHeight:e-a-l,scrollY:s,scrollX:o,pageXOffset:t,pageYOffset:i,safeAreaTop:a,safeAreaBottom:l}},n.getCursor=e=>{var o,t,i,a,l,u,h,f;let r=(a=e.pageX)!=null?a:(i=(o=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:o.pageX)!=null?i:(((t=e==null?void 0:e.originalEvent)==null?void 0:t.touches)||[])[0].pageX,s=(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:r,y:s}},n.pending=(e,r)=>new Promise((s,o)=>{e(s),setTimeout(()=>{s(!0)},r)}),n.getLocalIP=e=>{let r="";return n.scope(()=>{if(!e)return;let s=e.networkInterfaces();for(let[o,t]of Object.entries(s))t.forEach(i=>{!i.internal&&i.family==="IPv4"&&!i.address.match(/^(169|127)/)&&(r=i.address)})}),r},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,...r)=>{if(!r.length)return e;const s=r.shift();if(n.is.keyValueDictionary(e)&&n.is.keyValueDictionary(s))for(const o in s)n.is.keyValueDictionary(s[o])?(e[o]||Object.assign(e,{[o]:{}}),n.deepMerge(e[o],s[o])):Object.assign(e,{[o]:s[o]});return n.deepMerge(e,...r)},n.queryParams={get:e=>{let r=new URL(e||location.href),s={};return r.searchParams.forEach((o,t)=>s[t]=o),s},set:(e,r)=>{const s=new URL(r||location.href);return Object.entries(e).forEach(([o,t])=>{s.searchParams.set(o,String(t))}),r||history.replaceState({},"",s.pathname+s.search),s.toString()},delete:(e,r)=>{const s=new URL(r||location.href);return e.forEach(o=>{s.searchParams.delete(o)}),r||history.replaceState({},"",s.pathname+s.search),s.toString()}},n.ellipsisText=(e,r)=>{let s=String(e);return s.length>r&&(s=s.slice(0,r)+" ..."),s},n.is={what:function(e){let r="other";return this.jmini(e)?r="jmini":this.element(e)?r="element":this.elements(e)?r="elements":this.shadowRoot(e)?r="shadowRoot":this.string(e)?r="string":this.number(e)?r="number":this.array(e)?r="array":this.function(e)?r="function":this.date(e)?r="date":typeof e=="undefined"?r="undefined":this.keyValueDictionary(e)?r="keyValueDictionary":e==null?r="null":isNaN(e)&&(r="NaN"),r},exist:function(e){return e===(e!=null?e:!e)},nullish:function(e){return!this.exist(e)},jmini: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 r={}.toString.call(e);return e instanceof Array||r=="[object NodeList]"||r=="[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 r={}.toString.call(e),s=Number(!!e&&typeof e!="string"&&this.array(e)&&r!=="[object Text]");if(s&&r!=="[object NodeList]")for(var o of e)s&=Number(this.element(o));return!!s},shadowRoot:function(e){return e instanceof ShadowRoot},date:function(e){return this.number(new Date(e).getTime())}};export{n as Jmini,n as default};
package/esm/extension.js CHANGED
@@ -1 +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();
1
+ import{e as m}from"./chunk-ABA72NWU.js";import o from"./core";o.copyToClipboard=e=>m(void 0,null,function*(){let r="";o.is.string(e)?r=e:o.is.function(e)&&(r=e());let a={ok:!1,body:"NotSupported"};return yield m(void 0,null,function*(){let n;if(navigator.clipboard){if(n=yield navigator.clipboard.writeText(r).then(()=>!0,()=>!1),!n)return}else{let t=document.createElement("input");if(o(document.body).append(t),t.value=r,t.select(),n=document.execCommand("copy"),document.body.removeChild(t),!n)return}a={ok:!0,body:""}}),a}),o.ImageLoader=(e,r)=>new Promise((a,n)=>{let t=r||new Image;t.onload=()=>a(t),t.onerror=i=>n(i),t.src=e}),o.formatCharacter={postal:{JP:e=>{let r="--";return e=String(e).replace(/\D/ig,""),e.length==7&&(r=e.replace(/^(\d{3})(.*)/,"$1-$2")),r}},tel:{_:e=>{let r=e;return e=String(e).removeLetters(),e.length==11&&(r=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),e.length==10&&(r=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),r},mobile:e=>{let r="--";return e=String(e).removeLetters(),e.length==11&&(r=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),r},fixed:e=>{let r="--";return e=String(e).removeLetters(),e.length==10&&(r=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),r}}},o.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 r=[],a=[],n=!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:l,To:g,name:d}=i;if(l<=e&&e<=g){let s=e-l+1;s==1&&(n=!0,s="\u5143"),a.push(d+s+"\u5E74"),r.push(d)}}),{era:r,value:a,gap:n}}};
package/esm/fetcher.js CHANGED
@@ -1 +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};
1
+ import{b as T,c as B,d as D,e as f,f as w,g as x,h as O}from"./chunk-ABA72NWU.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 CHANGED
@@ -1 +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};
1
+ import{e as i}from"./chunk-ABA72NWU.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};
package/esm/index.js CHANGED
@@ -1 +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};
1
+ import"./chunk-ABA72NWU.js";import"./primitiveExtension";import e from"./core";import o from"./uuid";import t from"./time";import r from"./fetcher";import m from"./filer";import i from"./server";export*from"./extension";r.setDefaultHeaders=()=>({});var c=e;export{r as Fetcher,m as Filer,i as Server,t as Time,o as UUID,c as default};
@@ -1 +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)})});
1
+ import{a as p}from"./chunk-ABA72NWU.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 CHANGED
@@ -1 +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};
1
+ import"./chunk-ABA72NWU.js";import A from"./core";import B from"express";const n=function(u){let t=u,r=null;return t.use((e,s,a)=>{let i=s;i.return=R=>{let{status:x=200,body:o={},bodyStringify:h=!0}=R||{},p=o;return h&&(A.is.string(o)||(p=JSON.stringify(o))),s.status(x).end(p)},a()}),t.onPathRouter=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};let d=n(B()).pathRouter("test");d.post("test");export{n as Server,n as default};
package/esm/time.js CHANGED
@@ -1 +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};
1
+ import"./chunk-ABA72NWU.js";import u from"./core";const l=e=>new n.prototype.time(e),n=l;n.prototype={};const r=function(e,t){e.value=t;let s=u.is.date(t);if(e.validate=s,!s)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 i=new Date(e.year,0,1),a=new Date(i.valueOf());a.setDate(a.getDate()-(i.getDay()+1));let o=t.getTime()-a.getTime(),h=Math.ceil(o/(1e3*60*60*24));e.weekInYear=Math.ceil(h/7)}{let i=new Date(e.year,e.month-1,1),a=new Date(i.valueOf());a.setDate(a.getDate()-(i.getDay()+1));let o=t.getTime()-a.getTime(),h=Math.ceil(o/(1e3*60*60*24)),m=Math.ceil(h/7);e.weekInMonth=m}{let i=new Date(e.year,e.month,0),a=i.getDay(),o=new Date(new Date(i).setDate(i.getDate()-a));e.isLastWeekInMonth=e.date>=o.getDate()}return e.hours=t.getHours(),e.minutes=t.getMinutes(),e.seconds=t.getSeconds(),e};u.extend({constructor:n,time:function(e){n.isTimeObject(e)&&(e=e.value),e||(e===null?e=void 0:e===void 0&&(e=new Date));let t=new Date(e);return r(this,t)}},n),n.prototype.time.prototype=n.prototype,n.isTimeObject=e=>{var t;return((t=e||{})==null?void 0:t.constructor)===n},n.getFromNumberYYYYMMDD=e=>{let t=String(e).replace(/(\d{4})(\d{2})(\d{2})/,"$1/$2/$3");return n(t+" 00:00")},n.getPeriodArray=(e,t,s)=>{let i=[],a=t;if(!t.validate||!s.validate)return i;for(;a.toFormatYMDHMS().toNumber()<=s.toFormatYMDHMS().toNumber();)i.push(a),e=="year"?a=n(a).addYear(1):e=="month"?a=n(a).addMonth(1):e=="week"?a=n(a).addWeek(1):e=="day"?a=n(a).addDate(1):e=="hours"?a=n(a).addHours(1):e=="minutes"?a=n(a).addMinutes(1):e=="seconds"&&(a=n(a).addSeconds(1));return i},u.extend({setYear:function(e){let t=new Date(this.value.valueOf());return t.setFullYear(e),r(this,t)},setMonth:function(e){let t=new Date(this.value.valueOf());return t.setMonth(e-1),r(this,t)},setDate:function(e){let t=new Date(this.value.valueOf());return t.setDate(e),r(this,t)},setHours:function(e){let t=new Date(this.value.valueOf());return t.setHours(e),r(this,t)},setMinutes:function(e){let t=new Date(this.value.valueOf());return t.setMinutes(e),r(this,t)},setSeconds:function(e){let t=new Date(this.value.valueOf());return t.setSeconds(e),r(this,t)},setMilliseconds:function(e){let t=new Date(this.value.valueOf());return t.setMilliseconds(e),r(this,t)},setMidnight:function(){let e=new Date(this.value.valueOf());return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),r(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=n(e);return this.year==t.year},isSameMonth:function(e){let t=n(e);return this.year==t.year&&this.month==t.month},isSameWeek:function(e){let t=n(e);return this.year==t.year&&this.weekInYear==t.weekInYear},isSameDate:function(e){let t=n(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 n(new Date(this.value.getFullYear(),0,1))},getLastDayOfTheYear:function(){return n(new Date(this.value.getFullYear()+1,0,0))},getFirstDayOfTheMonth:function(){return n(new Date(this.value.getFullYear(),this.month-1,1))},getLastDayOfTheMonth:function(){return n(new Date(this.value.getFullYear(),this.month,0))},getFirstDayOfTheWeek:function(){let e=n(this.value);return e.addDate(-e.weekday)},getLastDayOfTheWeek:function(){let e=n(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||n(),s=t.year-this.year;return(this.month>t.month||this.month==t.month&&t.date<this.date)&&s--,s}},n);export{n as Time,n as default};
package/esm/uuid.js CHANGED
@@ -1 +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};
1
+ import"./chunk-ABA72NWU.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmini",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "minified JavaScript Framework",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "git+https://github.com/IkkoKoyama/jsmin.git"
22
+ "url": "git+https://github.com/IkkoKoyama/jmini.git"
23
23
  },
24
24
  "keywords": [
25
25
  "jmini"
@@ -27,9 +27,9 @@
27
27
  "author": "IkkoKoyama <mingoo.master@gmail.com>",
28
28
  "license": "MIT",
29
29
  "bugs": {
30
- "url": "https://github.com/IkkoKoyama/jsmin/issues"
30
+ "url": "https://github.com/IkkoKoyama/jmini/issues"
31
31
  },
32
- "homepage": "https://github.com/IkkoKoyama/jsmin#readme",
32
+ "homepage": "https://github.com/IkkoKoyama/jmini#readme",
33
33
  "devDependencies": {
34
34
  "@types/react": "^18.3.3",
35
35
  "esbuild": "^0.23.0",
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
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};
@@ -1 +0,0 @@
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}}};