raiutils 9.0.4 → 9.0.6
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/dist/router.d.ts +4 -3
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +1 -1
- package/dist/router.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +2 -2
- package/src/router.ts +12 -7
- package/src/utils.ts +1 -1
package/dist/router.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import http from 'http';
|
|
|
2
2
|
import { StringMap } from 'raiutils';
|
|
3
3
|
/** Serve files from a directory
|
|
4
4
|
@param root Root dir to serve web files from
|
|
5
|
-
@param vDir Virtual override paths in the form `{webPath: pathOnDisk}`
|
|
6
|
-
|
|
5
|
+
@param vDir Virtual override paths in the form `{webPath: pathOnDisk}`
|
|
6
|
+
@param headers Custom headers to add */
|
|
7
|
+
declare function handle(root: string, req: http.IncomingMessage, res: http.ServerResponse, vDir?: StringMap, headers?: http.OutgoingHttpHeaders): Promise<void>;
|
|
7
8
|
/** Serve a single file from `path` to the client */
|
|
8
|
-
declare function serve(path: string, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
9
|
+
declare function serve(path: string, req: http.IncomingMessage, res: http.ServerResponse, headers?: http.OutgoingHttpHeaders): Promise<void>;
|
|
9
10
|
/** Convenience method for sending an error page to the client */
|
|
10
11
|
declare function sendCode(res: http.ServerResponse, code: number, msg: string): void;
|
|
11
12
|
declare const _default: {
|
package/dist/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAMA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAqBrC
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAMA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAqBrC;;;uCAGuC;AACvC,iBAAe,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,IAAI,CAAC,cAAc,EACrF,IAAI,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,iBA4CrD;AAED,oDAAoD;AACpD,iBAAe,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,iBAGzH;AASD,iEAAiE;AACjE,iBAAS,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAEpE;;IA8BA,mCAAmC;WAEtB,MAAM;IACnB;;;4DAGwD;cAExC,MAAM,GAAG,OAAO;;;;;;AATjC,wBAWE"}
|
package/dist/router.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"path";import t from"fs/promises";import r from"crypto";import n from"chalk";import a from"./uuid.js";let i=0;const o={".html":"text/html",".php":"text/html",".css":"text/css",".png":"image/png",".svg":"image/svg+xml",".js":"application/javascript",".pdf":"application/pdf",".mp4":"video/mp4",".ogg":"video/ogg",".webm":"video/webm"};let s=!0;async function l(l,
|
|
1
|
+
import e from"path";import t from"fs/promises";import r from"crypto";import n from"chalk";import a from"./uuid.js";let i=0;const o={".html":"text/html",".php":"text/html",".css":"text/css",".png":"image/png",".svg":"image/svg+xml",".js":"application/javascript",".pdf":"application/pdf",".mp4":"video/mp4",".ogg":"video/ogg",".webm":"video/webm"};let s=!0;async function l(l,p,m,u,g){let h;try{let d,f=await async function(r,n,a){if(-1!==n.indexOf(".."))throw"Bad path";let i=function(t,r,n){if(n){let t,a;for(t in n)if(a=t.startsWith("/")?t:"/"+t,r.startsWith(a))return e.join(n[t],r.slice(a.length))}return t+r}(r,n,a);i.endsWith("/")&&(i=i.slice(0,-1));try{return(await t.stat(i)).isDirectory()?e.join(i,"/index.html"):i}catch(t){if(!e.extname(i))return i+".html";throw t}}(l,new URL(p.url,"http://a").pathname,u),w={},y=200,b=e.extname(f),v=o[b],x=p.headers.range;v&&(w["content-type"]=v),h=await t.open(f);let N=await h.stat(),R=N.size;if(x){if(!x.startsWith("bytes=")||2!==(x=x.slice(6).split("-")).length||!x[0])return await c(h,R,x,m);let e=Number(x[0]),t=Number(x[1]);if(t||(t=R-1),e>=R||t>=R||e>=t)return await c(h,R,x,m);d=h.createReadStream({start:e,end:t}),w["accept-ranges"]="bytes",w["content-range"]=`bytes ${e}-${t}/${R}`,y=206}else if("number"==typeof s){if(R<=s){d=await h.readFile();let e=r.createHash("sha1");e.update(d),w.etag=e.digest("base64url")}}else s&&(w.etag=new a(BigInt(N.mtime.getTime())).toString());if(w.etag&&w.etag===p.headers["if-none-match"])return m.sendDate=!1,m.writeHead(304,"",g),m.end(),h.close();if(d||(d=h.createReadStream()),g)for(const e in g)w[e]=g[e];m.writeHead(y,"",w),d instanceof Buffer?(m.write(d),m.end()):d.pipe(m),m.on("close",()=>h.close()),i&&function(e,t){console.log(n.dim("-- Served "+e+(t?" with type "+t:"")))}(f.startsWith(l)?f.slice(l.length):f,v)}catch(e){let t="ENOENT"===e.code;!i&&t||(t?f("-- Not found"):f("-- Read",e)),d(m,t?404:500,t?"Resource Not Found":e),h&&h.close()}}async function c(e,t,r,n){i&&f("-- Bad Range",r);let a={"content-range":"bytes */"+t};n.writeHead(416,"",a),n.end(),e.close()}function d(e,t,r){e.writeHead(t,""),e.write(`<pre style='font-size:16pt'>Error ${t}: ${r}</pre>`),e.end()}function f(e,t){console.error(n.red(e,t))}export default{get debug(){return i},set debug(e){i=e},get etagMode(){return s},set etagMode(e){s=e},handle:l,serve:async function(e,t,r,n){let a=t.url;return t.url="/",l(e,t,r,void 0,n).finally(()=>t.url=a)},sendCode:d,types:o}//# sourceMappingURL=router.js.map
|
package/dist/router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["path","fs","crypto","C","UUID","debug","types","etagMode","async","handle","root","req","res","vDir","f","str","fn","dir","uri","indexOf","v","vs","startsWith","join","slice","length","parseUri","endsWith","stat","isDirectory","e","extname","resolve","URL","url","pathname","hdr","ext","ct","rng","
|
|
1
|
+
{"version":3,"names":["path","fs","crypto","C","UUID","debug","types","etagMode","async","handle","root","req","res","vDir","headers","f","str","fn","dir","uri","indexOf","v","vs","startsWith","join","slice","length","parseUri","endsWith","stat","isDirectory","e","extname","resolve","URL","url","pathname","hdr","ext","ct","rng","range","open","st","dl","size","split","rngErr","rs","Number","re","createReadStream","start","end","readFile","h","createHash","update","etag","digest","BigInt","mtime","getTime","toString","sendDate","writeHead","close","k","Buffer","write","pipe","on","name","console","log","dim","nf","code","err","sendCode","fl","msg","m","error","red","serve","u","undefined","finally"],"sources":["../src/router.ts"],"mappings":"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","ignoreList":[]}
|
package/dist/utils.d.ts
CHANGED
|
@@ -80,7 +80,7 @@ export interface QueryMap {
|
|
|
80
80
|
}
|
|
81
81
|
export declare namespace utils {
|
|
82
82
|
/** Current library version */
|
|
83
|
-
export const VER = "v9.0.
|
|
83
|
+
export const VER = "v9.0.6";
|
|
84
84
|
/** Whether the environment is Node.js or Browser */
|
|
85
85
|
export const isNode: boolean;
|
|
86
86
|
/** Add getter and/or setter for `name` to `obj` */
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t="undefined"==typeof window,e=t?[{},{back:()=>{},forward:()=>{}},class{},class{},class{},class{},()=>{}]:[window,history,DOMRect,HTMLCollection,Element,NodeList,addEventListener];export var utils;!function(n){const[i,o,r,s,a,l,u]=e;function c(t,e,n,i){const o={get:n||void 0,set:i||void 0};if(Array.isArray(e))for(const n of e)Object.defineProperty(t,n,o);else Object.defineProperty(t,e,o)}function f(t,e,n,i,o){const r={value:n,writable:!!o};if(i||(t=t.prototype),Array.isArray(e))for(const n of e)Object.defineProperty(t,n,r);else Object.defineProperty(t,e,r)}function d(t,e,n){let i,o=this.length,r=Math.max(e<0?o+e:e||0,0);for(null!=n&&(o=Math.min(n<0?o+n:n,o));r<o;++r)if("!"===(i=t(this[r],r,o)))this instanceof s?this[r].remove():this.splice(r,1),--r,--o;else if(null!=i)return i}async function h(t,e,n,i=!0){let o,r=this.length,a=e=Math.max(e<0?r+e:e||0,0),l=[];for(null!=n&&(r=Math.min(n<0?r+n:n,r));a<r;++a){if(o=t(this[a],a,r),!i&&(o=await o,"!"!==o&&null!=o))return o;l.push(o)}for(i&&(l=await Promise.all(l)),a=e,o=0;a<r;++a,++o)if("!"===l[o])this instanceof s?this[a].remove():this.splice(a,1),--a,--r;else if(null!=l[o])return l[o]}n.VER="v9.0.4",n.isNode=t,n.define=c,n.proto=f,n.copy=function t(e,n){if(0===n||"object"!=typeof e)return e;let i;if(n=n>0?n-1:void 0,Array.isArray(e))i=Array(e.length),e.forEach((e,o)=>i[o]=t(e,n));else{i={};for(let o in e)i[o]=t(e[o],n)}return i},n.merge=function t(e,...n){let i,o;for(const r of n)for(const n in r){if(i=e[n],o=r[n],i&&o){if(i.length>=0&&o.length>=0){Array.prototype.push.apply(i,o);continue}if("object"==typeof i&&"object"==typeof o){t(i,o);continue}}e[n]=o}return e},n.setProp=function(t,e,n,i=!1){"string"==typeof e&&(e=e.split("."));let o=0,r=e.length-1,s=t;for(;o<r;++o)if(s=s[e[o]],!s||"object"!=typeof s){if(i)return!1;s=t[e[o]]={}}const a=e.at(-1);return!(i&&null!=s[a]||(s[a]=n,0))},n.getProp=function(t,e){"string"==typeof e&&(e=e.split("."));try{for(const n of e)t=t[n];return t}catch(t){}},f(Array,"clean",function(t){for(let e,n=0,i=this.length;n<i;++n)e=this[n],(L(e)||!1===e||!t&&0===e)&&(this.splice(n--,1),--i);return this}),f(Array,"remove",function(t){const e=this.indexOf(t);return-1!==e&&(this.splice(e,1),!0)}),f(Array,"firstEmpty",function(){const t=this.length;for(let e=0;e<t;++e)if(null==this[e])return e;return t}),[Array,s,l].forEach(t=>{f(t,"each",d),f(t,"eachAsync",h)});const p=("undefined"==typeof BigInt?t=>t:BigInt)(0);function m(t,e="$"){if(!t)return e+"0.00";const n=t.toFixed(2).split(".");return e+n[0].split("").reverse().reduce((t,e,n)=>"-"==e?e+t:e+(!n||n%3?"":",")+t,"")+"."+n[1]}n.abs=t=>"bigint"==typeof t?t<p?-t:t:Math.abs(t),n.min=(...t)=>{let e,n;for(e of t)e>n||(n=e);return n},n.max=(...t)=>{let e,n;for(e of t)e<n||(n=e);return n},n.deg=t=>180*t/Math.PI,n.rad=t=>t*Math.PI/180,Math.cot=t=>1/Math.tan(t),n.fixedNum=function(t,e,i=10){"bigint"==typeof e&&(e=Number(e));let o=n.abs(t).toString(i).toUpperCase();return(t<0?"-":"")+(16==i?"0x":2==i?"0b":"")+"0".repeat(Math.max(e-o.length,0))+o},n.bounds=(t,e=0,n=1)=>t>=e?t<=n?t:n:e,n.norm=function(t,e=0,i=1){let o=i-e;return((t+n.abs(e))%o+o)%o+e},n.map=function(t,e,n,i,o,r){let s=(t-e)/(n-e);return(r?r(s):s)*(o-i)+i},n.hexToRgb=function(t){const e=parseInt(t.slice(1),16);return[e>>16&255,e>>8&255,255&e]},n.rgbToHsl=function(t,e,n){let i,o,r=Math.max(t/=255,e/=255,n/=255),s=Math.min(t,e,n),a=(r+s)/2;if(r===s)i=o=0;else{let l=r-s;switch(o=a>.5?l/(2-r-s):l/(r+s),r){case t:i=(e-n)/l+(e<n?6:0);break;case e:i=(n-t)/l+2;break;default:i=(t-e)/l+4}i/=6}return[360*i,100*o,100*a]},n.rand=function(t,e,n=1,i){e*=n,t*=n;let o=Math.random();return Math.round((i?i(o):o)*(e-t)+t)/n},n.formatCost=m,n.Easing={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:(4-2*t)*t-1,easeInCubic:t=>t*t*t,easeOutCubic:t=>--t*t*t+1,easeInOutCubic:t=>t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1,easeInQuart:t=>t*t*t*t,easeOutQuart:t=>1- --t*t*t*t,easeInOutQuart:t=>t<.5?8*t*t*t*t:1-8*--t*t*t*t,easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>1+--t*t*t*t*t,easeInOutQuint:t=>t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t};const y=/[|\\{}()[\]^$+*?.]/g,g=/-/g;"escape"in RegExp||f(RegExp,"escape",t=>t.replace(y,"\\$&").replace(g,"\\x2d"),!0);const b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",x=b.replace("+/","-_"),v={43:62,47:63,48:52,49:53,50:54,51:55,52:56,53:57,54:58,55:59,56:60,57:61,65:0,66:1,67:2,68:3,69:4,70:5,71:6,72:7,73:8,74:9,75:10,76:11,77:12,78:13,79:14,80:15,81:16,82:17,83:18,84:19,85:20,86:21,87:22,88:23,89:24,90:25,97:26,98:27,99:28,100:29,101:30,102:31,103:32,104:33,105:34,106:35,107:36,108:37,109:38,110:39,111:40,112:41,113:42,114:43,115:44,116:45,117:46,118:47,119:48,120:49,121:50,122:51,45:62,95:63};function w(t,e){const n=v[t.charCodeAt(e)];if(null==n)throw"Bad char at "+e;return n}function O(t){let e=t.getBoundingClientRect(),n=getComputedStyle(t);return new R(e.top+parseFloat(n.paddingTop)+parseFloat(n.borderTopWidth),e.bottom-parseFloat(n.paddingBottom)-parseFloat(n.borderBottomWidth),e.left+parseFloat(n.paddingLeft)+parseFloat(n.borderLeftWidth),e.right-parseFloat(n.paddingRight)-parseFloat(n.borderRightWidth))}"toBase64"in Uint8Array.prototype||f(Uint8Array,"toBase64",function(t){let e,n=this.byteLength,i=n%3,o=t&&"base64url"===t.alphabet?x:b,r=0,s="";for(n-=i;r<n;r+=3)e=this[r]<<16|this[r+1]<<8|this[r+2],s+=o[(16515072&e)>>18]+o[(258048&e)>>12]+o[(4032&e)>>6]+o[63&e];return 1===i?(e=this[n],s+=o[(252&e)>>2]+o[(3&e)<<4],t&&t.omitPadding||(s+="=")):2===i&&(e=this[n]<<8|this[n+1],s+=o[(64512&e)>>10]+o[(1008&e)>>4]+o[(15&e)<<2],t&&t.omitPadding||(s+="==")),s}),"fromBase64"in Uint8Array||f(Uint8Array,"fromBase64",t=>{let e=t.length,n=e-1;for(;n>=0&&61===t.charCodeAt(n);--n);e=n+1,n=0;let i=e%4;if(e-=i,1==i)throw"Bad b64 len";let o,r=new Uint8Array(3*e/4+(i?i-1:0)),s=-1;for(;n<e;n+=4)o=w(t,n)<<18|w(t,n+1)<<12|w(t,n+2)<<6|w(t,n+3),r[++s]=o>>16,r[++s]=o>>8,r[++s]=o;return 2==i?r[++s]=w(t,n)<<2|w(t,n+1)>>4:3==i&&(o=w(t,n)<<10|w(t,n+1)<<4|w(t,n+2)>>2,r[++s]=o>>8,r[++s]=o),r},!0),"at"in Array.prototype||f(Array,"at",function(t){const e=this.length,n=t<0?e+t:t;if(n>=0&&n<e)return this[n]}),f(Function,"wrap",function(...t){const e=this;return function(){return e.apply(arguments,t)}},!1,!0),i.TouchList&&f(TouchList,"get",function(t){for(const e of this)if(e.identifier===t)return e}),c(a.prototype,"index",function(){const t=this.parentElement;return t?Array.prototype.indexOf.call(t.children,this):-1}),f(a,"insertChildAt",function(t,e){e<0&&(e=0),e>=this.children.length?this.appendChild(t):this.insertBefore(t,this.children[e])}),n.boundingRect=t=>new R(t.getBoundingClientRect()),n.innerRect=O,c(a.prototype,"boundingRect",function(){return n.boundingRect(this)}),c(a.prototype,"innerRect",function(){return O(this)});class R{constructor(t,e,n,i){const o=Number.isFinite;let s=0,a=0,l=0,u=0;c(this,"x",()=>l,t=>{o(t)&&(u+=t-l,l=t)}),c(this,"y",()=>s,t=>{o(t)&&(a+=t-s,s=t)}),c(this,"top",()=>s,t=>{s=o(t)?t:0}),c(this,["bottom","y2"],()=>a,t=>{a=o(t)?t:0}),c(this,"left",()=>l,t=>{l=o(t)?t:0}),c(this,["right","x2"],()=>u,t=>{u=o(t)?t:0}),c(this,["width","w"],()=>u-l,t=>{u=t>=0?l+t:0}),c(this,["height","h"],()=>a-s,t=>{a=t>=0?s+t:0}),c(this,"centerX",()=>l/2+u/2),c(this,"centerY",()=>s/2+a/2),t instanceof r||t instanceof R?(s=t.top,a=t.bottom,l=t.left,u=t.right):(s=t,a=e,l=n,u=i)}contains(t,e){return t instanceof a?this.contains(t.boundingRect):t instanceof R?t.x>=this.x&&t.x2<=this.x2&&t.y>=this.y&&t.y2<=this.y2:t>=this.x&&t<=this.x2&&e>=this.y&&e<=this.y2}overlaps(t){if(t instanceof a)return this.overlaps(t.boundingRect);if(!(t instanceof R))return!1;let e,n;return e=t.x2-t.x>=this.x2-this.x?this.x>=t.x&&this.x<=t.x2||this.x2>=t.x&&this.x2<=t.x2:t.x>=this.x&&t.x<=this.x2||t.x2>=this.x&&t.x2<=this.x2,n=t.y2-t.y>=this.y2-this.y?this.y>=t.y&&this.y<=t.y2||this.y2>=t.y&&this.y2<=t.y2:t.y>=this.y&&t.y<=this.y2||t.y2>=this.y&&t.y2<=this.y2,e&&n}dist(t,e){if(t instanceof a)return this.dist(t.boundingRect);const n=t instanceof R;return e=Math.abs((n?t.centerY:e)-this.centerY),t=Math.abs((n?t.centerX:t)-this.centerX),Math.sqrt(t*t+e*e)}expand(t){return this.top-=t,this.left-=t,this.bottom+=t,this.right+=t,this}}function A(t){t||(t=navigator.userAgent);const e={};if(!t.startsWith("Mozilla/5.0 "))return e;let n,i,o=t.indexOf(")"),r=e.rawOS=t.slice(13,o);return r.startsWith("Windows")?(n=r.split("; "),e.os="Windows",e.type=-1!==n.indexOf("WOW64")?"x64 PC; x86 Browser":-1!==n.indexOf("x64")?"x64 PC":"x86 PC",n=r.indexOf("Windows NT "),e.version=r.slice(n+11,r.indexOf(";",n+12))):r.startsWith("iP")?(n=r.indexOf("OS"),e.os="iOS",e.type=r.slice(0,r.indexOf(";")),e.version=r.slice(n+3,r.indexOf(" ",n+4)).replace(/_/g,".")):r.startsWith("Macintosh;")?(n=r.indexOf(" Mac OS X"),e.os="MacOS",e.type=r.slice(11,n)+" Mac",e.version=r.slice(n+10).replace(/_/g,".")):-1!==(n=r.indexOf("Android"))?(e.os="Android",e.version=r.slice(n+8,r.indexOf(";",n+9)),n=r.lastIndexOf(";"),i=r.indexOf(" Build",n+2),e.type=r.slice(n+2,-1===i?void 0:i)):r.startsWith("X11;")&&(r=r.slice(5).split(/[;\s]+/),n=r.length,e.os=("Linux"===r[0]?"":"Linux ")+r[0],e.type=r[n-2],e.version=r[n-1]),(n=Number(e.version))&&(e.version=n),n=t.indexOf(" ",o+2),i=t.indexOf(")",n+1),i=-1===i?n+1:i+2,e.engine=t.slice(o+2,n),e.browser=t.slice(i),e.mobile=!!t.match(/Mobi/i),e}n.UtilRect=R,n.deviceInfo=A,n.device=t?null:A(),n.mobile=null===n.device||void 0===n.device?void 0:n.device.mobile;const M=/translate(?:x|y)?\(.+?\)/gi;function C(t){n.onNav&&n.onNav.call(null,t)}function I(t,e,n,i,o){const r=document.createElement(t);if(null!=n&&(r.className=n),null!=o&&(r.innerHTML=o),i&&"object"==typeof i)for(const t in i)t in r.style?r.style[t]=i[t]:r.style.setProperty(t,i[t]);return null!=e&&e.appendChild(r),r}let S;n.center=function(t,e,i){const o=t.style;if("trans"==i){o.position||(o.position="absolute");let t=o.transform.replace(M,"").trim();e&&"x"!==e||(o.left="50%",t+=" translateX(-50%)"),e&&"y"!==e||(o.top="50%",t+=" translateY(-50%)"),o.transform=t}else{const i=n.mkDiv(t.parentNode,null,{display:"flex",top:0,left:0}),o=i.style;i.appendChild(t),e&&"x"!==e||(o.justifyContent="center",o.width="100%"),e&&"y"!==e||(o.alignItems="center",o.height="100%",o.position="absolute")}},n.go=function(t,e){o.pushState(e,"",t),C(e)},u("popstate",t=>C(t.state)),u("load",()=>setTimeout(()=>C(o.state),1)),n.mkEl=I,n.mkDiv=(t,e,n,i)=>I("div",t,e,n,i),n.addText=(t,e)=>t.appendChild(document.createTextNode(e)),n.textWidth=function(t,e){const n=(S||(S=I("canvas"))).getContext("2d");return n.font=e,n.measureText(t).width};const k=/[A-Z]/g,N=t=>"-"+t.toLowerCase();function E(t,e){return!0===e?t:("string"!=typeof e&&(e=JSON.stringify(e)),`${t}=${encodeURIComponent(e)}`)}n.addCSS=function(t,e,n){n||(n=function(){for(const t of document.styleSheets)try{return t.cssRules,t}catch(t){}return I("style",document.head).sheet}());let i,o=[];for(i in e)o.push(`${i.replace(k,N)}:${e[i]}`);n.insertRule(`${t}{${o.join(";")}}`)},n.remCSS=function(t){let e,n;for(e of document.styleSheets){try{n=e.cssRules}catch(t){continue}for(let i=0,o=n.length;i<o;++i)n[i]instanceof CSSStyleRule&&n[i].selectorText===t&&e.deleteRule(i)}},n.setCookie=function(e,n,i,o){let r=`${encodeURIComponent(e)}=${null==n?"":encodeURIComponent(n)};path=/`;return null!=i&&(-1===i&&(i=new Date(9e14)),r+=i instanceof Date?";expires="+i.toUTCString():";max-age="+i),o&&(r+=";secure"),t||(document.cookie=r),r},n.getCookie=function(t,e){null==e&&(e=document.cookie),t=encodeURIComponent(t)+"=";let n,i=e.split("; ");for(n of i)if(n.startsWith(t))return decodeURIComponent(n.slice(t.length))},n.remCookie=function(e){let n=encodeURIComponent(e)+"=;max-age=0";return t||(document.cookie=n),n},n.getCookies=function(t){if(null==t&&(t=document.cookie),!t)return{};let e,n;const i={};for(e of t.split("; "))n=e.indexOf("="),i[decodeURIComponent(e.slice(0,n))]=decodeURIComponent(e.slice(n+1));return i},n.fromQuery=function(t,e="&"){t.startsWith("?")&&(t=t.slice(1));let n,i,o,r,s={};for(n of t.split(e))i=n.indexOf("="),-1===i?(o=n,r=!0):(o=decodeURIComponent(n.slice(0,i)),r=decodeURIComponent(n.slice(i+1))),o in s?(i=s[o],Array.isArray(i)?i.push(r):s[o]=[i,r]):s[o]=r;return s},n.toQuery=function(t,e="&"){let n,i,o=[];for(n in t)if(i=t[n],n=encodeURIComponent(n),Array.isArray(i))for(const t of i)o.push(E(n,t));else o.push(E(n,i));return o.join(e)};const T=/\.0*$/;function U(t){return t<=9?"0"+t:t}function F(t){let e=t%10,n=t%100;return 1==e&&11!=n?t+"st":2==e&&12!=n?t+"nd":3==e&&13!=n?t+"rd":t+"th"}n.numField=function(t,e,i,o,r){const s=t,a=RegExp(`[,${r?RegExp.escape(r):""}]`,"g");function l(t){return"string"==typeof t&&(t=t.replace(a,"")),t=n.bounds(Number(t)||0,e,i),o?Number(t.toFixed(o)):Math.round(t)}return s.type=n.mobile||o||r?"tel":"number",s.setAttribute("pattern","\\d*"),s.step||(s.step=1),s.addEventListener("keydown",t=>{if(t.ctrlKey)return;let a=t.key,l=1===a.length&&Number.isFinite(Number(a)),u=s.ns,c=u.length,f=u.indexOf(".");if("Tab"!==a&&"Enter"!==a){if(l?(-1===f||c-f<o+1)&&(u+=a):"."===a||"*"===a?o&&-1==f&&s.num!=i&&(e>=0||s.num!=e)&&(!c&&e>0?u=Math.floor(e)+".":u+="."):"Backspace"===a||"Delete"===a?u=e>0&&s.num===e&&u.endsWith(".")?"":u.slice(0,-1):"-"===a||"#"===a?e<0&&!c&&(u="-"):"ArrowUp"===a?(u=null,s.set(s.num+Number(s.step))):"ArrowDown"===a&&(u=null,s.set(s.num-Number(s.step))),null!==u&&u!==s.ns){c=u.length,f=u.indexOf(".");let a="-"===u||"-."===u,d=a?"0":u+(u.endsWith(".")?"0":""),h=Number(d),p=n.bounds(h,e,i);(!l||!u||s.num!==p||-1!==f&&c-f<o+1)&&(s.ns=u,s.num=p,s.value=r?a?r+"-0.00":m(p,r):("-"===u[0]?"-":"")+Math.floor(Math.abs(p))+(-1!==f?u.slice(f)+(T.test(u)?"0":""):""),s.onnuminput&&s.onnuminput.call(s,t))}t.preventDefault()}}),s.set=t=>{s.num=l(t),s.ns=s.num.toString(),s.value=r?m(s.num,r):s.ns,s.ns=s.ns.replace(/^(-?)0+/,"$1"),s.onnuminput&&s.onnuminput.call(s)},s.setRange=(t,n,a)=>{e=null==t?Number.MIN_SAFE_INTEGER:t,i=null==n?Number.MAX_SAFE_INTEGER:n,o=null==a?r?2:0:a,l(s.num)!==s.num&&s.set(s.num)},s.addEventListener("input",()=>s.set(s.value)),s.addEventListener("paste",t=>{s.set(t.clipboardData.getData("text")),t.preventDefault()}),s.setRange(e,i,o),s},n.autosize=function(t,e=5,i=1){const o=t;o.set=t=>{o.value=t,s()};let r=o.style;function s(){if(0===o.scrollHeight)return setTimeout(s,1);o.setAttribute("rows",1);let t=getComputedStyle(o);r.setProperty("overflow","hidden","important"),r.width=o.innerRect.w+"px",r.boxSizing="content-box",r.borderWidth=r.paddingInline="0";let a=parseFloat(t.paddingTop)+parseFloat(t.paddingBottom),l="normal"===t.lineHeight?parseFloat(t.height):parseFloat(t.lineHeight),u=Math.round((Math.round(o.scrollHeight)-a)/l);r.overflow=r.width=r.boxSizing=r.borderWidth=r.paddingInline="",o.setAttribute("rows",n.bounds(u,i,e))}r.maxHeight=r.resize="none",r.minHeight="0",r.height="auto",o.setAttribute("rows",i),o.addEventListener("input",s)},n.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n.formatDate=function(t,e={}){let i,o,r="";if(!(null!=t&&t.getDate&&(i=t.getFullYear())>1969))return"[Invalid Date]";if(null==e.time||e.time){let n=t.getHours(),i="";if(e.h24||(i=" AM",n>=12&&(i=" PM",n-=12),n||(n=12)),r=n+":"+U(t.getMinutes())+(e.sec?":"+U(t.getSeconds())+(e.ms?(t.getMilliseconds()/1e3).toFixed(Number.isFinite(e.ms)?e.ms:3).slice(1):""):""),r+=i,e.time)return r}return o=t.getDate(),o=n.months[t.getMonth()]+" "+(null==e.suf||e.suf?F(o):o),null!=e.year&&!e.year||e.year===i||(o=o+", "+i),e.df?o+(r&&(e.sep||" ")+r):(r&&r+(e.sep||" "))+o},n.suffix=F,n.setDateTime=function(t,e){e instanceof Date||(e=new Date(e)),t.value=new Date(e.getTime()-6e4*e.getTimezoneOffset()).toISOString().slice(0,"date"===t.type?10:19)},n.getDateTime=t=>new Date(t.value+("date"===t.type?"T00:00":""));const D=/\S/;function L(t){return null==t||("string"==typeof t?!D.test(t):"object"==typeof t&&("number"==typeof t.length?0===t.length:0===Object.keys(t).length))}let W;async function P(){W||(W=await import("os"))}n.isBlank=L,n.download=async function(t,e){const n=I("a");if("string"==typeof t||t instanceof URL)n.href=t.toString(),n.download=e||n.href.split("/").at(-1),n.click();else{t instanceof Blob||(t=new Blob([t]));const i=URL.createObjectURL(t);n.href=i,n.download=e||"file",n.click(),URL.revokeObjectURL(i)}},n.delay=t=>new Promise(e=>setTimeout(e,t)),n.getIPs=async function(){await P();const t=[],e=W.networkInterfaces();for(let n in e)e[n].forEach(e=>{!e.internal&&"IPv4"==e.family&&"00:00:00:00:00:00"!=e.mac&&e.address&&t.push(e.address)});return t},n.getOS=async function(){var t;let e,n;switch(await P(),W.platform()){case"win32":e="Windows";break;case"darwin":e="MacOS";break;case"linux":e="Linux";break;default:e=W.platform()}switch(W.arch()){case"ia32":n="32-bit";break;case"x64":n="64-bit";break;case"arm":n="ARM";break;default:n=W.arch()}return[e,n,(null===(t=W.cpus()[0])||void 0===t?void 0:t.model)||""]}}(utils||(utils={}));export default utils//# sourceMappingURL=utils.js.map
|
|
1
|
+
const t="undefined"==typeof window,e=t?[{},{back:()=>{},forward:()=>{}},class{},class{},class{},class{},()=>{}]:[window,history,DOMRect,HTMLCollection,Element,NodeList,addEventListener];export var utils;!function(n){const[i,o,r,s,a,l,u]=e;function c(t,e,n,i){const o={get:n||void 0,set:i||void 0};if(Array.isArray(e))for(const n of e)Object.defineProperty(t,n,o);else Object.defineProperty(t,e,o)}function f(t,e,n,i,o){const r={value:n,writable:!!o};if(i||(t=t.prototype),Array.isArray(e))for(const n of e)Object.defineProperty(t,n,r);else Object.defineProperty(t,e,r)}function d(t,e,n){let i,o=this.length,r=Math.max(e<0?o+e:e||0,0);for(null!=n&&(o=Math.min(n<0?o+n:n,o));r<o;++r)if("!"===(i=t(this[r],r,o)))this instanceof s?this[r].remove():this.splice(r,1),--r,--o;else if(null!=i)return i}async function h(t,e,n,i=!0){let o,r=this.length,a=e=Math.max(e<0?r+e:e||0,0),l=[];for(null!=n&&(r=Math.min(n<0?r+n:n,r));a<r;++a){if(o=t(this[a],a,r),!i&&(o=await o,"!"!==o&&null!=o))return o;l.push(o)}for(i&&(l=await Promise.all(l)),a=e,o=0;a<r;++a,++o)if("!"===l[o])this instanceof s?this[a].remove():this.splice(a,1),--a,--r;else if(null!=l[o])return l[o]}n.VER="v9.0.6",n.isNode=t,n.define=c,n.proto=f,n.copy=function t(e,n){if(0===n||"object"!=typeof e)return e;let i;if(n=n>0?n-1:void 0,Array.isArray(e))i=Array(e.length),e.forEach((e,o)=>i[o]=t(e,n));else{i={};for(let o in e)i[o]=t(e[o],n)}return i},n.merge=function t(e,...n){let i,o;for(const r of n)for(const n in r){if(i=e[n],o=r[n],i&&o){if(i.length>=0&&o.length>=0){Array.prototype.push.apply(i,o);continue}if("object"==typeof i&&"object"==typeof o){t(i,o);continue}}e[n]=o}return e},n.setProp=function(t,e,n,i=!1){"string"==typeof e&&(e=e.split("."));let o=0,r=e.length-1,s=t;for(;o<r;++o)if(s=s[e[o]],!s||"object"!=typeof s){if(i)return!1;s=t[e[o]]={}}const a=e.at(-1);return!(i&&null!=s[a]||(s[a]=n,0))},n.getProp=function(t,e){"string"==typeof e&&(e=e.split("."));try{for(const n of e)t=t[n];return t}catch(t){}},f(Array,"clean",function(t){for(let e,n=0,i=this.length;n<i;++n)e=this[n],(L(e)||!1===e||!t&&0===e)&&(this.splice(n--,1),--i);return this}),f(Array,"remove",function(t){const e=this.indexOf(t);return-1!==e&&(this.splice(e,1),!0)}),f(Array,"firstEmpty",function(){const t=this.length;for(let e=0;e<t;++e)if(null==this[e])return e;return t}),[Array,s,l].forEach(t=>{f(t,"each",d),f(t,"eachAsync",h)});const p=("undefined"==typeof BigInt?t=>t:BigInt)(0);function m(t,e="$"){if(!t)return e+"0.00";const n=t.toFixed(2).split(".");return e+n[0].split("").reverse().reduce((t,e,n)=>"-"==e?e+t:e+(!n||n%3?"":",")+t,"")+"."+n[1]}n.abs=t=>"bigint"==typeof t?t<p?-t:t:Math.abs(t),n.min=(...t)=>{let e,n;for(e of t)e>n||(n=e);return n},n.max=(...t)=>{let e,n;for(e of t)e<n||(n=e);return n},n.deg=t=>180*t/Math.PI,n.rad=t=>t*Math.PI/180,Math.cot=t=>1/Math.tan(t),n.fixedNum=function(t,e,i=10){"bigint"==typeof e&&(e=Number(e));let o=n.abs(t).toString(i).toUpperCase();return(t<0?"-":"")+(16==i?"0x":2==i?"0b":"")+"0".repeat(Math.max(e-o.length,0))+o},n.bounds=(t,e=0,n=1)=>t>=e?t<=n?t:n:e,n.norm=function(t,e=0,i=1){let o=i-e;return((t+n.abs(e))%o+o)%o+e},n.map=function(t,e,n,i,o,r){let s=(t-e)/(n-e);return(r?r(s):s)*(o-i)+i},n.hexToRgb=function(t){const e=parseInt(t.slice(1),16);return[e>>16&255,e>>8&255,255&e]},n.rgbToHsl=function(t,e,n){let i,o,r=Math.max(t/=255,e/=255,n/=255),s=Math.min(t,e,n),a=(r+s)/2;if(r===s)i=o=0;else{let l=r-s;switch(o=a>.5?l/(2-r-s):l/(r+s),r){case t:i=(e-n)/l+(e<n?6:0);break;case e:i=(n-t)/l+2;break;default:i=(t-e)/l+4}i/=6}return[360*i,100*o,100*a]},n.rand=function(t,e,n=1,i){e*=n,t*=n;let o=Math.random();return Math.round((i?i(o):o)*(e-t)+t)/n},n.formatCost=m,n.Easing={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:(4-2*t)*t-1,easeInCubic:t=>t*t*t,easeOutCubic:t=>--t*t*t+1,easeInOutCubic:t=>t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1,easeInQuart:t=>t*t*t*t,easeOutQuart:t=>1- --t*t*t*t,easeInOutQuart:t=>t<.5?8*t*t*t*t:1-8*--t*t*t*t,easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>1+--t*t*t*t*t,easeInOutQuint:t=>t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t};const y=/[|\\{}()[\]^$+*?.]/g,g=/-/g;"escape"in RegExp||f(RegExp,"escape",t=>t.replace(y,"\\$&").replace(g,"\\x2d"),!0);const b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",x=b.replace("+/","-_"),v={43:62,47:63,48:52,49:53,50:54,51:55,52:56,53:57,54:58,55:59,56:60,57:61,65:0,66:1,67:2,68:3,69:4,70:5,71:6,72:7,73:8,74:9,75:10,76:11,77:12,78:13,79:14,80:15,81:16,82:17,83:18,84:19,85:20,86:21,87:22,88:23,89:24,90:25,97:26,98:27,99:28,100:29,101:30,102:31,103:32,104:33,105:34,106:35,107:36,108:37,109:38,110:39,111:40,112:41,113:42,114:43,115:44,116:45,117:46,118:47,119:48,120:49,121:50,122:51,45:62,95:63};function w(t,e){const n=v[t.charCodeAt(e)];if(null==n)throw"Bad char at "+e;return n}function O(t){let e=t.getBoundingClientRect(),n=getComputedStyle(t);return new R(e.top+parseFloat(n.paddingTop)+parseFloat(n.borderTopWidth),e.bottom-parseFloat(n.paddingBottom)-parseFloat(n.borderBottomWidth),e.left+parseFloat(n.paddingLeft)+parseFloat(n.borderLeftWidth),e.right-parseFloat(n.paddingRight)-parseFloat(n.borderRightWidth))}"toBase64"in Uint8Array.prototype||f(Uint8Array,"toBase64",function(t){let e,n=this.byteLength,i=n%3,o=t&&"base64url"===t.alphabet?x:b,r=0,s="";for(n-=i;r<n;r+=3)e=this[r]<<16|this[r+1]<<8|this[r+2],s+=o[(16515072&e)>>18]+o[(258048&e)>>12]+o[(4032&e)>>6]+o[63&e];return 1===i?(e=this[n],s+=o[(252&e)>>2]+o[(3&e)<<4],t&&t.omitPadding||(s+="=")):2===i&&(e=this[n]<<8|this[n+1],s+=o[(64512&e)>>10]+o[(1008&e)>>4]+o[(15&e)<<2],t&&t.omitPadding||(s+="==")),s}),"fromBase64"in Uint8Array||f(Uint8Array,"fromBase64",t=>{let e=t.length,n=e-1;for(;n>=0&&61===t.charCodeAt(n);--n);e=n+1,n=0;let i=e%4;if(e-=i,1==i)throw"Bad b64 len";let o,r=new Uint8Array(3*e/4+(i?i-1:0)),s=-1;for(;n<e;n+=4)o=w(t,n)<<18|w(t,n+1)<<12|w(t,n+2)<<6|w(t,n+3),r[++s]=o>>16,r[++s]=o>>8,r[++s]=o;return 2==i?r[++s]=w(t,n)<<2|w(t,n+1)>>4:3==i&&(o=w(t,n)<<10|w(t,n+1)<<4|w(t,n+2)>>2,r[++s]=o>>8,r[++s]=o),r},!0),"at"in Array.prototype||f(Array,"at",function(t){const e=this.length,n=t<0?e+t:t;if(n>=0&&n<e)return this[n]}),f(Function,"wrap",function(...t){const e=this;return function(){return e.apply(arguments,t)}},!1,!0),i.TouchList&&f(TouchList,"get",function(t){for(const e of this)if(e.identifier===t)return e}),c(a.prototype,"index",function(){const t=this.parentElement;return t?Array.prototype.indexOf.call(t.children,this):-1}),f(a,"insertChildAt",function(t,e){e<0&&(e=0),e>=this.children.length?this.appendChild(t):this.insertBefore(t,this.children[e])}),n.boundingRect=t=>new R(t.getBoundingClientRect()),n.innerRect=O,c(a.prototype,"boundingRect",function(){return n.boundingRect(this)}),c(a.prototype,"innerRect",function(){return O(this)});class R{constructor(t,e,n,i){const o=Number.isFinite;let s=0,a=0,l=0,u=0;c(this,"x",()=>l,t=>{o(t)&&(u+=t-l,l=t)}),c(this,"y",()=>s,t=>{o(t)&&(a+=t-s,s=t)}),c(this,"top",()=>s,t=>{s=o(t)?t:0}),c(this,["bottom","y2"],()=>a,t=>{a=o(t)?t:0}),c(this,"left",()=>l,t=>{l=o(t)?t:0}),c(this,["right","x2"],()=>u,t=>{u=o(t)?t:0}),c(this,["width","w"],()=>u-l,t=>{u=t>=0?l+t:0}),c(this,["height","h"],()=>a-s,t=>{a=t>=0?s+t:0}),c(this,"centerX",()=>l/2+u/2),c(this,"centerY",()=>s/2+a/2),t instanceof r||t instanceof R?(s=t.top,a=t.bottom,l=t.left,u=t.right):(s=t,a=e,l=n,u=i)}contains(t,e){return t instanceof a?this.contains(t.boundingRect):t instanceof R?t.x>=this.x&&t.x2<=this.x2&&t.y>=this.y&&t.y2<=this.y2:t>=this.x&&t<=this.x2&&e>=this.y&&e<=this.y2}overlaps(t){if(t instanceof a)return this.overlaps(t.boundingRect);if(!(t instanceof R))return!1;let e,n;return e=t.x2-t.x>=this.x2-this.x?this.x>=t.x&&this.x<=t.x2||this.x2>=t.x&&this.x2<=t.x2:t.x>=this.x&&t.x<=this.x2||t.x2>=this.x&&t.x2<=this.x2,n=t.y2-t.y>=this.y2-this.y?this.y>=t.y&&this.y<=t.y2||this.y2>=t.y&&this.y2<=t.y2:t.y>=this.y&&t.y<=this.y2||t.y2>=this.y&&t.y2<=this.y2,e&&n}dist(t,e){if(t instanceof a)return this.dist(t.boundingRect);const n=t instanceof R;return e=Math.abs((n?t.centerY:e)-this.centerY),t=Math.abs((n?t.centerX:t)-this.centerX),Math.sqrt(t*t+e*e)}expand(t){return this.top-=t,this.left-=t,this.bottom+=t,this.right+=t,this}}function A(t){t||(t=navigator.userAgent);const e={};if(!t.startsWith("Mozilla/5.0 "))return e;let n,i,o=t.indexOf(")"),r=e.rawOS=t.slice(13,o);return r.startsWith("Windows")?(n=r.split("; "),e.os="Windows",e.type=-1!==n.indexOf("WOW64")?"x64 PC; x86 Browser":-1!==n.indexOf("x64")?"x64 PC":"x86 PC",n=r.indexOf("Windows NT "),e.version=r.slice(n+11,r.indexOf(";",n+12))):r.startsWith("iP")?(n=r.indexOf("OS"),e.os="iOS",e.type=r.slice(0,r.indexOf(";")),e.version=r.slice(n+3,r.indexOf(" ",n+4)).replace(/_/g,".")):r.startsWith("Macintosh;")?(n=r.indexOf(" Mac OS X"),e.os="MacOS",e.type=r.slice(11,n)+" Mac",e.version=r.slice(n+10).replace(/_/g,".")):-1!==(n=r.indexOf("Android"))?(e.os="Android",e.version=r.slice(n+8,r.indexOf(";",n+9)),n=r.lastIndexOf(";"),i=r.indexOf(" Build",n+2),e.type=r.slice(n+2,-1===i?void 0:i)):r.startsWith("X11;")&&(r=r.slice(5).split(/[;\s]+/),n=r.length,e.os=("Linux"===r[0]?"":"Linux ")+r[0],e.type=r[n-2],e.version=r[n-1]),(n=Number(e.version))&&(e.version=n),n=t.indexOf(" ",o+2),i=t.indexOf(")",n+1),i=-1===i?n+1:i+2,e.engine=t.slice(o+2,n),e.browser=t.slice(i),e.mobile=!!t.match(/Mobi/i),e}n.UtilRect=R,n.deviceInfo=A,n.device=t?null:A(),n.mobile=null===n.device||void 0===n.device?void 0:n.device.mobile;const M=/translate(?:x|y)?\(.+?\)/gi;function C(t){n.onNav&&n.onNav.call(null,t)}function I(t,e,n,i,o){const r=document.createElement(t);if(null!=n&&(r.className=n),null!=o&&(r.innerHTML=o),i&&"object"==typeof i)for(const t in i)t in r.style?r.style[t]=i[t]:r.style.setProperty(t,i[t]);return null!=e&&e.appendChild(r),r}let S;n.center=function(t,e,i){const o=t.style;if("trans"==i){o.position||(o.position="absolute");let t=o.transform.replace(M,"").trim();e&&"x"!==e||(o.left="50%",t+=" translateX(-50%)"),e&&"y"!==e||(o.top="50%",t+=" translateY(-50%)"),o.transform=t}else{const i=n.mkDiv(t.parentNode,null,{display:"flex",top:0,left:0}),o=i.style;i.appendChild(t),e&&"x"!==e||(o.justifyContent="center",o.width="100%"),e&&"y"!==e||(o.alignItems="center",o.height="100%",o.position="absolute")}},n.go=function(t,e){o.pushState(e,"",t),C(e)},u("popstate",t=>C(t.state)),u("load",()=>setTimeout(()=>C(o.state),1)),n.mkEl=I,n.mkDiv=(t,e,n,i)=>I("div",t,e,n,i),n.addText=(t,e)=>t.appendChild(document.createTextNode(e)),n.textWidth=function(t,e){const n=(S||(S=I("canvas"))).getContext("2d");return n.font=e,n.measureText(t).width};const k=/[A-Z]/g,N=t=>"-"+t.toLowerCase();function E(t,e){return!0===e?t:("string"!=typeof e&&(e=JSON.stringify(e)),`${t}=${encodeURIComponent(e)}`)}n.addCSS=function(t,e,n){n||(n=function(){for(const t of document.styleSheets)try{return t.cssRules,t}catch(t){}return I("style",document.head).sheet}());let i,o=[];for(i in e)o.push(`${i.replace(k,N)}:${e[i]}`);n.insertRule(`${t}{${o.join(";")}}`)},n.remCSS=function(t){let e,n;for(e of document.styleSheets){try{n=e.cssRules}catch(t){continue}for(let i=0,o=n.length;i<o;++i)n[i]instanceof CSSStyleRule&&n[i].selectorText===t&&e.deleteRule(i)}},n.setCookie=function(e,n,i,o){let r=`${encodeURIComponent(e)}=${null==n?"":encodeURIComponent(n)};path=/`;return null!=i&&(-1===i&&(i=new Date(9e14)),r+=i instanceof Date?";expires="+i.toUTCString():";max-age="+i),o&&(r+=";secure"),t||(document.cookie=r),r},n.getCookie=function(t,e){null==e&&(e=document.cookie),t=encodeURIComponent(t)+"=";let n,i=e.split("; ");for(n of i)if(n.startsWith(t))return decodeURIComponent(n.slice(t.length))},n.remCookie=function(e){let n=encodeURIComponent(e)+"=;max-age=0";return t||(document.cookie=n),n},n.getCookies=function(t){if(null==t&&(t=document.cookie),!t)return{};let e,n;const i={};for(e of t.split("; "))n=e.indexOf("="),i[decodeURIComponent(e.slice(0,n))]=decodeURIComponent(e.slice(n+1));return i},n.fromQuery=function(t,e="&"){t.startsWith("?")&&(t=t.slice(1));let n,i,o,r,s={};for(n of t.split(e))i=n.indexOf("="),-1===i?(o=n,r=!0):(o=decodeURIComponent(n.slice(0,i)),r=decodeURIComponent(n.slice(i+1))),o in s?(i=s[o],Array.isArray(i)?i.push(r):s[o]=[i,r]):s[o]=r;return s},n.toQuery=function(t,e="&"){let n,i,o=[];for(n in t)if(i=t[n],n=encodeURIComponent(n),Array.isArray(i))for(const t of i)o.push(E(n,t));else o.push(E(n,i));return o.join(e)};const T=/\.0*$/;function U(t){return t<=9?"0"+t:t}function F(t){let e=t%10,n=t%100;return 1==e&&11!=n?t+"st":2==e&&12!=n?t+"nd":3==e&&13!=n?t+"rd":t+"th"}n.numField=function(t,e,i,o,r){const s=t,a=RegExp(`[,${r?RegExp.escape(r):""}]`,"g");function l(t){return"string"==typeof t&&(t=t.replace(a,"")),t=n.bounds(Number(t)||0,e,i),o?Number(t.toFixed(o)):Math.round(t)}return s.type=n.mobile||o||r?"tel":"number",s.setAttribute("pattern","\\d*"),s.step||(s.step=1),s.addEventListener("keydown",t=>{if(t.ctrlKey)return;let a=t.key,l=1===a.length&&Number.isFinite(Number(a)),u=s.ns,c=u.length,f=u.indexOf(".");if("Tab"!==a&&"Enter"!==a){if(l?(-1===f||c-f<o+1)&&(u+=a):"."===a||"*"===a?o&&-1==f&&s.num!=i&&(e>=0||s.num!=e)&&(!c&&e>0?u=Math.floor(e)+".":u+="."):"Backspace"===a||"Delete"===a?u=e>0&&s.num===e&&u.endsWith(".")?"":u.slice(0,-1):"-"===a||"#"===a?e<0&&!c&&(u="-"):"ArrowUp"===a?(u=null,s.set(s.num+Number(s.step))):"ArrowDown"===a&&(u=null,s.set(s.num-Number(s.step))),null!==u&&u!==s.ns){c=u.length,f=u.indexOf(".");let a="-"===u||"-."===u,d=a?"0":u+(u.endsWith(".")?"0":""),h=Number(d),p=n.bounds(h,e,i);(!l||!u||s.num!==p||-1!==f&&c-f<o+1)&&(s.ns=u,s.num=p,s.value=r?a?r+"-0.00":m(p,r):("-"===u[0]?"-":"")+Math.floor(Math.abs(p))+(-1!==f?u.slice(f)+(T.test(u)?"0":""):""),s.onnuminput&&s.onnuminput.call(s,t))}t.preventDefault()}}),s.set=t=>{s.num=l(t),s.ns=s.num.toString(),s.value=r?m(s.num,r):s.ns,s.ns=s.ns.replace(/^(-?)0+/,"$1"),s.onnuminput&&s.onnuminput.call(s)},s.setRange=(t,n,a)=>{e=null==t?Number.MIN_SAFE_INTEGER:t,i=null==n?Number.MAX_SAFE_INTEGER:n,o=null==a?r?2:0:a,l(s.num)!==s.num&&s.set(s.num)},s.addEventListener("input",()=>s.set(s.value)),s.addEventListener("paste",t=>{s.set(t.clipboardData.getData("text")),t.preventDefault()}),s.setRange(e,i,o),s},n.autosize=function(t,e=5,i=1){const o=t;o.set=t=>{o.value=t,s()};let r=o.style;function s(){if(0===o.scrollHeight)return setTimeout(s,1);o.setAttribute("rows",1);let t=getComputedStyle(o);r.setProperty("overflow","hidden","important"),r.width=o.innerRect.w+"px",r.boxSizing="content-box",r.borderWidth=r.paddingInline="0";let a=parseFloat(t.paddingTop)+parseFloat(t.paddingBottom),l="normal"===t.lineHeight?parseFloat(t.height):parseFloat(t.lineHeight),u=Math.round((Math.round(o.scrollHeight)-a)/l);r.overflow=r.width=r.boxSizing=r.borderWidth=r.paddingInline="",o.setAttribute("rows",n.bounds(u,i,e))}r.maxHeight=r.resize="none",r.minHeight="0",r.height="auto",o.setAttribute("rows",i),o.addEventListener("input",s)},n.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n.formatDate=function(t,e={}){let i,o,r="";if(!(null!=t&&t.getDate&&(i=t.getFullYear())>1969))return"[Invalid Date]";if(null==e.time||e.time){let n=t.getHours(),i="";if(e.h24||(i=" AM",n>=12&&(i=" PM",n-=12),n||(n=12)),r=n+":"+U(t.getMinutes())+(e.sec?":"+U(t.getSeconds())+(e.ms?(t.getMilliseconds()/1e3).toFixed(Number.isFinite(e.ms)?e.ms:3).slice(1):""):""),r+=i,e.time)return r}return o=t.getDate(),o=n.months[t.getMonth()]+" "+(null==e.suf||e.suf?F(o):o),null!=e.year&&!e.year||e.year===i||(o=o+", "+i),e.df?o+(r&&(e.sep||" ")+r):(r&&r+(e.sep||" "))+o},n.suffix=F,n.setDateTime=function(t,e){e instanceof Date||(e=new Date(e)),t.value=new Date(e.getTime()-6e4*e.getTimezoneOffset()).toISOString().slice(0,"date"===t.type?10:19)},n.getDateTime=t=>new Date(t.value+("date"===t.type?"T00:00":""));const D=/\S/;function L(t){return null==t||("string"==typeof t?!D.test(t):"object"==typeof t&&("number"==typeof t.length?0===t.length:0===Object.keys(t).length))}let W;async function P(){W||(W=await import("os"))}n.isBlank=L,n.download=async function(t,e){const n=I("a");if("string"==typeof t||t instanceof URL)n.href=t.toString(),n.download=e||n.href.split("/").at(-1),n.click();else{t instanceof Blob||(t=new Blob([t]));const i=URL.createObjectURL(t);n.href=i,n.download=e||"file",n.click(),URL.revokeObjectURL(i)}},n.delay=t=>new Promise(e=>setTimeout(e,t)),n.getIPs=async function(){await P();const t=[],e=W.networkInterfaces();for(let n in e)e[n].forEach(e=>{!e.internal&&"IPv4"==e.family&&"00:00:00:00:00:00"!=e.mac&&e.address&&t.push(e.address)});return t},n.getOS=async function(){var t;let e,n;switch(await P(),W.platform()){case"win32":e="Windows";break;case"darwin":e="MacOS";break;case"linux":e="Linux";break;default:e=W.platform()}switch(W.arch()){case"ia32":n="32-bit";break;case"x64":n="64-bit";break;case"arm":n="ARM";break;default:n=W.arch()}return[e,n,(null===(t=W.cpus()[0])||void 0===t?void 0:t.model)||""]}}(utils||(utils={}));export default utils//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "raiutils",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The ultimate JavaScript & TypeScript companion library. You'll never need jQuery again!",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"chalk": "^5.4.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@types/node": "^25.
|
|
46
|
+
"@types/node": "^25.5.2",
|
|
47
47
|
"terser": "^5.46.0",
|
|
48
48
|
"typescript": "^5.9.3"
|
|
49
49
|
}
|
package/src/router.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//Node Webserver v3.5, Pecacheu 2025. GNU GPL v3
|
|
1
|
+
//Node Webserver v3.5.1, Pecacheu 2025. GNU GPL v3
|
|
2
2
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import fs from 'fs/promises';
|
|
@@ -29,8 +29,10 @@ let etagMode: boolean | number = true;
|
|
|
29
29
|
|
|
30
30
|
/** Serve files from a directory
|
|
31
31
|
@param root Root dir to serve web files from
|
|
32
|
-
@param vDir Virtual override paths in the form `{webPath: pathOnDisk}`
|
|
33
|
-
|
|
32
|
+
@param vDir Virtual override paths in the form `{webPath: pathOnDisk}`
|
|
33
|
+
@param headers Custom headers to add */
|
|
34
|
+
async function handle(root: string, req: http.IncomingMessage, res: http.ServerResponse,
|
|
35
|
+
vDir?: StringMap, headers?: http.OutgoingHttpHeaders) {
|
|
34
36
|
let f: fs.FileHandle;
|
|
35
37
|
try {
|
|
36
38
|
let fn=await resolve(root, new URL(req.url!,'http://a').pathname, vDir),
|
|
@@ -56,10 +58,13 @@ async function handle(root: string, req: http.IncomingMessage, res: http.ServerR
|
|
|
56
58
|
hdr.etag = h.digest('base64url');
|
|
57
59
|
}} else if(etagMode) hdr.etag = new UUID(BigInt(st.mtime.getTime())).toString();
|
|
58
60
|
|
|
59
|
-
if(hdr.etag && hdr.etag === req.headers['if-none-match'])
|
|
60
|
-
|
|
61
|
+
if(hdr.etag && hdr.etag === req.headers['if-none-match']) {
|
|
62
|
+
res.sendDate=false, res.writeHead(304,'',headers);
|
|
63
|
+
return res.end(),f.close();
|
|
64
|
+
}
|
|
61
65
|
if(!str) str=f.createReadStream();
|
|
62
66
|
|
|
67
|
+
if(headers) for(const k in headers) hdr[k] = headers[k];
|
|
63
68
|
res.writeHead(stat,'',hdr);
|
|
64
69
|
if(str instanceof Buffer) res.write(str),res.end();
|
|
65
70
|
else (str as ReadStream).pipe(res);
|
|
@@ -74,9 +79,9 @@ async function handle(root: string, req: http.IncomingMessage, res: http.ServerR
|
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
/** Serve a single file from `path` to the client */
|
|
77
|
-
async function serve(path: string, req: http.IncomingMessage, res: http.ServerResponse) {
|
|
82
|
+
async function serve(path: string, req: http.IncomingMessage, res: http.ServerResponse, headers?: http.OutgoingHttpHeaders) {
|
|
78
83
|
let u=req.url; req.url='/';
|
|
79
|
-
return handle(path, req, res).finally(() => req.url=u);
|
|
84
|
+
return handle(path, req, res, undefined, headers).finally(() => req.url=u);
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
async function rngErr(f: fs.FileHandle, fl: number, rng: string, res: http.ServerResponse) {
|
package/src/utils.ts
CHANGED
|
@@ -108,7 +108,7 @@ const [window, history, DOMRect, HTMLCollection,
|
|
|
108
108
|
Element, NodeList, addEventListener] = P;
|
|
109
109
|
|
|
110
110
|
/** Current library version */
|
|
111
|
-
export const VER = "v9.0.
|
|
111
|
+
export const VER = "v9.0.6";
|
|
112
112
|
|
|
113
113
|
/** Whether the environment is Node.js or Browser */
|
|
114
114
|
export const isNode = IsNode;
|