ranuts 0.4.0-alpha.2 → 0.4.0-alpha.3
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/CLAUDE.md +40 -4
- package/README.md +11 -16
- package/README.zh-CN.md +11 -16
- package/dist/{color-Bh_QUad2.js → color-DPV7TsVU.js} +1 -1
- package/dist/i18n-Bq-f7htr.js +1 -0
- package/dist/index.js +1 -1
- package/dist/src/node/index.js +1 -1
- package/dist/src/utils/async.d.ts +30 -0
- package/dist/src/utils/behavior.d.ts +0 -14
- package/dist/src/utils/bom.d.ts +2 -22
- package/dist/src/utils/color.d.ts +75 -0
- package/dist/src/utils/device.d.ts +0 -1
- package/dist/src/utils/dom.d.ts +5 -2
- package/dist/src/utils/event.d.ts +34 -0
- package/dist/src/utils/i18n/index.js +1 -1
- package/dist/src/utils/index.d.ts +16 -13
- package/dist/src/utils/index.js +1 -1
- package/dist/src/utils/number.d.ts +60 -0
- package/dist/src/utils/obj.d.ts +0 -11
- package/dist/src/utils/placement.d.ts +40 -0
- package/dist/src/utils/str.d.ts +0 -8
- package/dist/src/utils/time.d.ts +33 -1
- package/dist/src/utils/visual/application.d.ts +10 -0
- package/dist/src/utils/visual/index.d.ts +5 -2
- package/dist/src/utils/visual/index.js +1 -1
- package/dist/src/utils/visual/render/filter.d.ts +43 -0
- package/dist/src/utils/visual/render/render.d.ts +6 -0
- package/dist/src/utils/visual/render/renderTarget.d.ts +13 -0
- package/dist/src/utils/visual/render/utils/earcut.d.ts +45 -0
- package/dist/src/utils/visual/render/webGlRenderer.d.ts +4 -0
- package/dist/test/utils/color-grade.test.d.ts +1 -0
- package/dist/test/utils/event.test.d.ts +1 -0
- package/dist/test/utils/interp.test.d.ts +1 -0
- package/dist/test/utils/placement.test.d.ts +1 -0
- package/dist/test/utils/visual/filter.test.d.ts +1 -0
- package/dist/umd/index.umd.cjs +1 -1
- package/dist/umd/node/node.umd.cjs +1 -1
- package/dist/umd/utils/utils.umd.cjs +1 -1
- package/dist/utils-CYrYCt5o.js +1 -0
- package/docs/API.md +41 -17
- package/package.json +24 -13
- package/dist/i18n-D1p8_7wC.js +0 -1
- package/dist/utils-vTF6lLZZ.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=(e,t=2)=>String(e).padStart(t,"0"),t=e=>null==e?/* @__PURE__ */new Date:new Date(e),n=/YYYY|YY|MM|M|DD|D|HH|H|hh|h|mm|m|ss|s|SSS|A|a|\[([^\]]*)]/g,r=(r,s="YYYY-MM-DD HH:mm:ss")=>{const a=t(r);if(Number.isNaN(a.getTime()))return"Invalid Date";const o=a.getHours(),i=o%12||12,c={YYYY:String(a.getFullYear()),YY:e(a.getFullYear()%100),MM:e(a.getMonth()+1),M:String(a.getMonth()+1),DD:e(a.getDate()),D:String(a.getDate()),HH:e(o),H:String(o),hh:e(i),h:String(i),mm:e(a.getMinutes()),m:String(a.getMinutes()),ss:e(a.getSeconds()),s:String(a.getSeconds()),SSS:e(a.getMilliseconds(),3),A:o<12?"AM":"PM",a:o<12?"am":"pm"};return s.replace(n,(e,t)=>void 0!==t?t:c[e])};function s(e){const t=e?new Date(e):/* @__PURE__ */new Date;return t.format=(e="YYYY-MM-DD HH:mm:ss")=>r(t,e),t}var a=t=>{if(!Number.isFinite(t))return"";const n=Math.max(0,Math.trunc(t)),r=Math.trunc(n/3600),s=Math.trunc(n%3600/60),a=e(n%60);return 0===r?`${e(s)}:${a}`:`${e(r)}:${e(s)}:${a}`},o=e=>a(e),i=/(?:(\d{2,}):)?(\d{2}):(\d{2})\.(\d{3})/,c=e=>{const t=e.trim().match(i);if(!t)return;const[,n,r,s,a]=t;return(n?3600*Number(n):0)+60*Number(r)+Number(s)+Number(a)/1e3},u=e=>{const[t,n]=e.split("--\x3e");if(!t||!n)return;const r=c(t),s=c(n.trim().split(/\s+/)[0]??"");return void 0!==r&&void 0!==s?{start:r,end:s}:void 0},d=[["year",315576e5],["month",26298e5],["week",6048e5],["day",864e5],["hour",36e5],["minute",6e4],["second",1e3]],l={year:"y",quarter:"q",month:"mo",week:"w",day:"d",hour:"h",minute:"m",second:"s"},f=/* @__PURE__ */new Map,h=(e,n={})=>{const{now:r,locale:s,style:a="long",numeric:o="auto"}=n,i=t(e).getTime(),c=t(r).getTime();if(Number.isNaN(i)||Number.isNaN(c))return"";const u=i-c,h=Math.abs(u);let g=d.findIndex(([,e])=>h>=e);-1===g&&(g=d.length-1);const m=u<0?-1:1;let[p,w]=d[g],y=m*Math.round(h/w);if(g>0&&Math.abs(y)*w>=d[g-1][1]&&([p,w]=d[g-1],y=m*Math.round(h/w)),"compact"===a)return`${Math.abs(y)}${l[p]??""}`;const v=((e,t,n)=>{if("undefined"==typeof Intl||"function"!=typeof Intl.RelativeTimeFormat)return;const r=`${String(e)}|${t}|${n}`;let s=f.get(r);return s||(s=new Intl.RelativeTimeFormat(e,{style:t,numeric:n}),f.set(r,s)),s})(s,a,o);if(!v){const e=l[p]??"";return y<0?`${Math.abs(y)}${e} ago`:`in ${y}${e}`}return v.format(y,p)},g=()=>{if("undefined"!=typeof document)return performance.now();if("undefined"!=typeof process){const[e,t]=process.hrtime();return 1e3*e+t/1e6}return Date.now()},m=/* @__PURE__ */function(e){return e.IPAD="ipad",e.ANDROID="android",e.IPhONE="iphone",e.PC="pc",e}({}),p=()=>{if("undefined"!=typeof window){const e=navigator.userAgent.toLowerCase();return/ipad|ipod/.test(e)?"ipad":/android/.test(e)?"android":/iphone/.test(e)?"iphone":"pc"}return"pc"},w="undefined"!=typeof window,y="(max-width: 768px)",v=e=>"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia(e).matches,_=(e,t)=>{if("undefined"==typeof window||"function"!=typeof window.matchMedia)return t(!1),()=>{};const n=window.matchMedia(e),r=()=>t(n.matches);if(r(),"function"==typeof n.addEventListener)return n.addEventListener("change",r),()=>n.removeEventListener("change",r);const s=n;return s.addListener(r),()=>s.removeListener(r)},b=()=>!!w&&window.navigator.userAgent.toLowerCase().includes("micromessenger"),M=()=>{if(!w)return!1;const e=window.navigator.userAgent;return!!/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(e)},x=e=>{const t=document.cookie.split("; ");for(let n=0;n<t.length;n++){const r=t[n].split("=");if(r[0]===e)return decodeURIComponent(r[1])}return""},D=(e,t)=>new Promise(function(n,r){const s=new XMLHttpRequest;s.open(t.method||"GET",e,!0),s.responseType=t.responseType||"arraybuffer",s.onload=function(){200===s.status?n({success:!0,data:s.response,message:""}):r({success:!1,data:s.status,message:`The request status is${s.status}`})},s.onerror=function(e){r({success:!1,data:e,message:""})},s.onprogress=e=>{t.onProgress&&t.onProgress(e)},s.withCredentials=t.withCredentials||!1,t.headers&&Object.keys(t.headers).forEach(function(e){t.headers?.[e]&&s.setRequestHeader(e,t.headers[e])}),s.send(t.body)}),S=e=>{const t=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||1;return(w&&window.devicePixelRatio||1)/t},L=async e=>{if("string"==typeof e)return e;if(e instanceof Blob)return URL.createObjectURL(e);if(e instanceof ArrayBuffer)return URL.createObjectURL(new Blob([e]));if(e instanceof Response){const t=await e.blob();return URL.createObjectURL(t)}return e},k=(e=10)=>{const t=[];let n,r=0;return new Promise(s=>{const a=()=>{const o=g(),i=o-r;0!==r&&t.push(i),r=o,t.length>e&&(s(1/(t.reduce((e,t)=>e+t)/e)),cancelAnimationFrame(n)),n=requestAnimationFrame(a)};t.length<=e&&(n=requestAnimationFrame(a))})},R=e=>{const t={},n=(e=>{const t=e??("undefined"==typeof window?"":window.location.href),n=t.indexOf("?");if(-1===n)return"";const r=t.slice(n+1),s=r.indexOf("#");return-1===s?r:r.slice(0,s)})(e);if(!n)return t;for(const r of n.split("&")){if(!r)continue;const e=r.indexOf("="),n=-1===e?r:r.slice(0,e),s=-1===e?"":r.slice(e+1);if(n)try{t[decodeURIComponent(n.replace(/\+/g," "))]=decodeURIComponent(s.replace(/\+/g," "))}catch{t[n]=s}}return t},$=(e,t)=>{const n=R(t)[e];if(void 0===n)return!1;const r=n.toLowerCase();return""===r||"1"===r||"true"===r},O=()=>{if("undefined"==typeof window)return!1;try{return window.parent!==window}catch{return!0}};function F(e,t={}){let n=e;0===n.indexOf("//")&&(n=n.replace("//","https://"));const r=new URL(n);return t&&Object.keys(t).forEach(e=>{t[e]&&r.searchParams.set(e,t[e])}),r.href}function N(e){if("undefined"!=typeof window){const t=new RegExp(`(^| )${e}(?:=([^;]*))?(;|$)`).exec(document.cookie);if(t&&t[2])return t[2]}return""}var P=()=>"undefined"!=typeof window?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0},Y=()=>{if("undefined"!=typeof window)return window.navigator.connection},I=/(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x7E]|%(?:[^\da-f]|[\da-f][^\da-f]|$))+/gi,A=/(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g;function C(e){return String(e).replace(A,"$1�$2").replace(I,encodeURI)}var H=e=>new Promise((t,n)=>{const r=new Image,s=/* @__PURE__ */(new Date).getTime();r.src=e||`https://github.com/favicon.ico?d=${s}`,r.onload=()=>{t(/* @__PURE__ */(new Date).getTime()-s)},r.onerror=e=>{n(e)}}),B=(e,...t)=>n=>new Promise((r,s)=>{setTimeout(async()=>{try{r(await e(...t))}catch(n){s(n)}},n)}),T=async e=>{const{url:t,duration:n=3e3,count:r=5}=e;let s=0,a=0;const o=[];for(let i=0;i<r;i++){const e=await B(H,t)(n);o.push(e)}return s=Math.max(...o)-Math.min(...o),a=o.reduce((e,t)=>e+t)/o.length,{ping:a,jitter:s}},U=()=>{if("undefined"!=typeof navigator)return navigator.vendor&&navigator.vendor.indexOf("Apple")>-1&&navigator.userAgent&&!navigator.userAgent.includes("CriOS")&&!navigator.userAgent.includes("FxiOS")},j=()=>{try{return"undefined"==typeof localStorage?null:localStorage}catch{return null}},E=(e,t)=>{try{j()?.setItem(e,t)}catch{}},q=e=>{try{return j()?.getItem(e)??""}catch{return""}},z=e=>{try{j()?.removeItem(e)}catch{}},K=(e="")=>{const t=t=>`${e}${t}`;return{keyOf:t,get:(e,n)=>{const r=q(t(e));if(!r)return n;try{return JSON.parse(r)}catch{return n}},set:(e,n)=>{let r;try{r=JSON.stringify(n)}catch{return!1}return E(t(e),r),q(t(e))===r},remove:e=>z(t(e))}},W=(e,t=2e4)=>{const n=e.slice(0,t);let r=0,s=0;for(const a of n){const e=a.codePointAt(0)??0;e>=19968&&e<=40959||e>=13312&&e<=19903?r++:(e>=65&&e<=90||e>=97&&e<=122)&&s++}return 0===r&&0===s?"other":r>=s?"zh":s>3*r?"en":"zh"},J=()=>{if("undefined"==typeof navigator)return"other";const e=(navigator.language||"").toLowerCase();return e.startsWith("zh")?"zh":e.startsWith("en")?"en":"other"},G=e=>{const{supported:t,query:n,cookie:r,storageKey:s,useNavigator:a=!0,url:o}=e,i=e.fallback??t[0]??"en";if(0===t.length)return i;const c=t.map(e=>e.toLowerCase()),u=e=>{if(!e)return;const n=e.trim().toLowerCase();if(!n)return;const r=c.indexOf(n);if(-1!==r)return t[r];const s=n.split("-")[0],a=c.findIndex(e=>e===s||e.split("-")[0]===s);return-1===a?void 0:t[a]},d=[];if(n&&d.push(R(o)[n]),r&&d.push(N(r)),s&&d.push(q(s)),a&&"undefined"!=typeof navigator){const{languages:e,language:t}=navigator;d.push(...e??[],t)}for(const l of d){const e=u(l);if(e)return e}return i},V=Object.freeze({}),X=class{_locale;_fallback;_messages;_persist;_storageKey;_handlers=/* @__PURE__ */new Set;constructor(e={}){this._messages={...e.messages},this._fallback=e.fallbackLocale??"en",this._persist=e.persist??!1,this._storageKey=e.storageKey??"ran-locale",this._locale=this._resolveInitialLocale(e)}_resolveInitialLocale(e){const t=Object.keys(this._messages),n=this._persist&&q(this._storageKey)||null;if(n&&(this._messages[n]||0===t.length))return n;if(e.locale)return e.locale;if(e.detectNavigator){const e=G({supported:t,useNavigator:!0,fallback:""});if(e)return e}return this._fallback}get locale(){return this._locale}getLocale(){return this._locale}setLocale(e){e!==this._locale&&(this._locale=e,this._persist&&E(this._storageKey,e),this._notify())}addMessages(e,t){this._messages[e]={...this._messages[e],...t}}getMessages(e=this._locale){return this._messages[e]??{}}get availableLocales(){return Object.keys(this._messages)}t(e,t){const n=this._messages[this._locale]?.[e]??this._messages[this._fallback]?.[e]??e;return this._interpolate(n,t)}_interpolate(e,t){const n=t??V;return e.replace(/\{\{|\}\}|\{(\w+)\}/g,(e,t)=>"{{"===e?"{":"}}"===e?"}":null!=n[t]?String(n[t]):e)}onChange(e){return this._handlers.add(e),()=>{this._handlers.delete(e)}}_notify(){for(const e of this._handlers)e(this._locale)}destroy(){this._handlers.clear()}},Q=null;function Z(e={}){const t=new X(e);return Q=t,t}function ee(){return Q}export{p as A,c as B,O as C,D,$ as E,_ as F,o as H,r as I,a as L,M,b as N,m as O,v as P,h as R,H as S,T,s as U,g as V,x as _,J as a,S as b,q as c,F as d,Y as f,R as g,C as h,W as i,w as j,y as k,z as l,B as m,Z as n,G as o,L as p,ee as r,K as s,X as t,E as u,N as v,U as w,P as x,k as y,u as z};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as s}from"./enums-BAgbyGdH.js";import{$ as a,A as t,B as n,C as o,D as r,E as m,F as i,G as p,H as f,I as j,J as c,K as l,L as u,M as
|
|
1
|
+
import{i as s}from"./enums-BAgbyGdH.js";import{$ as a,A as t,B as n,C as o,D as r,E as m,F as i,G as p,H as f,I as j,J as c,K as l,L as u,M as h,N as b,O as d,P as e,Q as g,R as v,S as x,T as y,U as _,V as k,W as w,X as z,Y as A,Z as B,_ as C,a as D,at as E,b as F,c as H,d as I,et as L,f as M,g as N,h as P,i as R,it as S,j as T,k as U,l as V,m as q,n as G,nt as J,o as K,ot as O,p as Q,q as W,r as X,rt as Y,s as Z,st as $,t as ss,tt as as,u as ts,v as ns,w as os,x as rs,y as ms,z as is}from"./color-DPV7TsVU.js";import{$ as ps,$t as fs,A as js,At as cs,B as ls,Bt as us,C as hs,Ct as bs,D as ds,Dt as es,E as gs,Et as vs,F as xs,Ft as ys,G as _s,Gt as ks,H as ws,Ht as zs,I as As,It as Bs,J as Cs,Jt as Ds,K as Es,Kt as Fs,L as Hs,Lt as Is,M as Ls,Mt as Ms,N as Ns,Nt as Ps,O as Rs,Ot as Ss,P as Ts,Pt as Us,Q as Vs,Qt as qs,R as Gs,Rt as Js,S as Ks,St as Os,T as Qs,Tt as Ws,U as Xs,Ut as Ys,V as Zs,Vt as $s,W as sa,Wt as aa,X as ta,Xt as na,Y as oa,Yt as ra,Z as ma,Zt as ia,_ as pa,_n as fa,_t as ja,a as ca,an as la,at as ua,b as ha,bn as ba,bt as da,c as ea,cn as ga,ct as va,d as xa,dn as ya,dt as _a,en as ka,et as wa,f as za,fn as Aa,ft as Ba,g as Ca,gn as Da,gt as Ea,h as Fa,hn as Ha,ht as Ia,i as La,in as Ma,it as Na,j as Pa,jt as Ra,k as Sa,kt as Ta,l as Ua,ln as Va,lt as qa,m as Ga,mn as Ja,mt as Ka,n as Oa,nn as Qa,nt as Wa,o as Xa,on as Ya,ot as Za,p as $a,pn as st,pt as at,q as tt,qt as nt,r as ot,rn as rt,rt as mt,s as it,sn as pt,st as ft,t as jt,tn as ct,tt as lt,u as ut,un as ht,ut as bt,v as dt,vn as et,vt as gt,w as vt,wt as xt,x as yt,xt as _t,y as kt,yn as wt,yt as zt,z as At,zt as Bt}from"./utils-CYrYCt5o.js";import{A as Ct,B as Dt,C as Et,D as Ft,E as Ht,F as It,H as Lt,I as Mt,L as Nt,M as Pt,N as Rt,P as St,R as Tt,S as Ut,T as Vt,U as qt,V as Gt,_ as Jt,a as Kt,b as Ot,c as Qt,d as Wt,f as Xt,g as Yt,h as Zt,i as $t,j as sn,k as an,l as tn,m as nn,n as on,o as rn,p as mn,r as pn,s as fn,t as jn,u as cn,v as ln,w as un,x as hn,y as bn,z as dn}from"./i18n-Bq-f7htr.js";import{n as en,t as gn}from"./chain-CTywmh_H.js";export{ta as ADOPTED_SHEET_MARKER,ma as ADOPTED_STYLE_MARKER,Us as AudioRecorder,nt as BRIDGE_MARKER,Ds as BridgeManager,gn as Chain,ra as Client,ss as Color,G as ColorScheme,na as DEFAULT_CHANNEL,zt as EventManager,X as FMT,R as HEX_COLOR_REGEX,D as Hsl,K as Hsla,jn as I18nCore,an as MOBILE_MEDIA_QUERY,la as Mathjs,l as MessageCodec,f as MimeType,Xa as Monitor,ia as Platform,qs as PostMessageBridge,ot as QuestQueue,Z as RGBA_REGEX,H as RGB_REGEX,V as Rgb,ts as Rgba,s as SyncHook,Ra as TOTP,vt as TimeoutError,Cs as WebDB,As as WorkerClient,Fa as ZIP_DEFLATE,Ca as ZIP_STORED,fs as acceptPortBridge,Os as addClassToElement,Ya as addNumSym,Vs as adoptSheetText,ps as adoptStyles,Wt as appendUrl,W as arrayBufferToString,bs as autosizeTextarea,I as blendMultiply,M as blendOverlay,Q as blendScreen,ka as bridgeManager,q as brightnessContrast,_s as buildOffsets,c as checkEncoding,Ba as circ,pt as clamp,A as clearBr,z as clearStr,ys as cloneDeep,P as componentToHex,cs as compose,ws as computePlacement,Xt as connection,wa as convertImageToBase64,N as cosinePalette,pa as crc32,en as create,ut as createData,xt as createDocumentFragment,da as createDoubleTapDetector,oa as createHandoff,on as createI18n,Xs as createLocalePath,mn as createObjectURL,ct as createPortBridge,Qs as createRaceGuard,Ms as createSignal,rt as createSpeechRecognizer,fn as createStore,dt as createZip,at as cubic,Ct as currentDevice,lt as cutRound,Ss as debounce,gs as deferred,ds as delay,$t as detectLanguage,nn as durationHandler,Zt as encodeUrl,Ws as escapeHtml,Ka as expo,Za as fanShapedByArc,Bs as filterObj,ga as fit,Mt as formatDate,Nt as formatDuration,Is as formatJson,Tt as formatRelative,Yt as getAllQueryString,ft as getAngle,va as getArcPointerByDeg,Jt as getCookie,ln as getCookieByName,_ as getExtensions,bn as getFrame,Wa as getImage,qa as getLinearGradient,B as getMatchingSentences,mt as getMatrix,w as getMime,Ga as getPerformance,Ot as getPixelRatio,g as getRandomString,xa as getReportUrl,La as getStatus,bt as getTangentByPointer,hn as getWindow,Ta as handleConsole,_t as handleError,ea as handleFetchHook,Ua as handleXhrHook,C as hexToAlpha,ns as hexToHsb,ms as hexToHsv,F as hexToRgb,rs as hsbToHsl,x as hsbToRgb,o as hslToHsb,os as hslToHsv,y as hslToRgb,m as hsvToHsl,r as hsvToRgb,d as hue2rgb,Ut as imageRequest,Es as indexForOffset,kt as inflateRaw,Va as inverseLerp,sn as isClient,Js as isEqual,Na as isImageSize,Et as isInIframe,Pt as isMobile,un as isSafari,Ma as isSpeechRecognitionSupported,a as isString,js as isUrlCached,Rt as isWeiXin,ht as lerp,U as linearToSrgb,ya as linearstep,jt as loadScript,Qt as localStorageGetItem,tn as localStorageRemoveItem,cn as localStorageSetItem,t as luma,St as matchMediaQuery,Aa as mathjs,L as md5,aa as memoize,Bt as merge,us as mergeExports,Kt as navigatorLanguage,Pa as networkAllowsDownload,Vt as networkSpeed,Ys as noop,ks as once,ua as opacity,Qa as openPortBridge,sa as paginateText,st as parseChineseNumber,Ja as parseEnglishNumber,Ha as parseRomanNumber,dn as parseVttCueTiming,Dt as parseVttTimestamp,Da as perToNum,Gt as performanceTime,Ls as prefetchUrl,Ns as prefetchUrls,Ts as prefetchWhenIdle,Ia as quad,Ea as quart,Ht as queryFlag,$s as querystring,ja as quint,T as randomColor,as as randomString,fa as range,Gs as readFileAsArrayBuffer,At as readFileAsDataURL,ls as readFileAsText,Zs as readFileAsUint8Array,ha as readZipEntries,yt as readZipEntry,et as remap,vs as removeClassToElement,zs as replaceOld,za as report,Ft as requestUrlToBuffer,rn as resolveLocale,Ks as rewriteZip,h as rgbToHex,b as rgbToHsb,e as rgbToHsl,i as rgbToHsv,j as rgbaString,u as rgbaToHex,v as rgbaToRgb,_a as roundRectByArc,is as saturation,Oa as scriptOnLoad,tt as segmentByRanges,Hs as serveWorker,es as setFontSize2html,p as setMime,$a as setReportUrl,gt as sine,Fs as singleFlight,wt as smoothstep,n as srgbToLinear,ca as status,J as strParse,Ps as subscribers,it as throttle,Lt as timeFormat,qt as timestampToTime,Y as toFullWidth,S as toHalfWidth,E as toString,ba as transformNumber,O as transformText,$ as truncate,pn as useI18n,k as vibrance,It as watchMediaQuery,xs as whenIdle,Rs as withTimeout,Sa as withTimeoutFallback,hs as zipHasEntry};
|
package/dist/src/node/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as e,J as t,P as n,r}from"../../color-Bh_QUad2.js";import{Socket as o}from"node:net";import s from"node:http";import i from"node:os";import a,{createReadStream as c,createWriteStream as d,readdir as l,readdirSync as u,stat as f,statSync as h}from"node:fs";import p from"node:tty";import m,{hrtime as w}from"node:process";import g from"node:child_process";import y from"node:readline";import b from"node:https";import E,{join as v,resolve as x}from"node:path";import{promisify as T}from"node:util";import{Buffer as S}from"node:buffer";import P from"node:crypto";function O(){const e=i.networkInterfaces();for(const t in e){const n=e[t];if(n)for(let e=0;e<n.length;e++){const t=n[e];if("IPv4"===t.family&&"127.0.0.1"!==t.address&&!t.internal)return t.address}}}var q=class{middleware;ctx;constructor(){const e=new s.IncomingMessage(new o),t=new s.ServerResponse(e);this.ctx={ipv4:O,req:e,res:t},this.middleware=[]}use(e){if(!e)throw new Error("the use function has an incorrect argument");this.middleware.push(e)}listen(...e){const t=function(e){if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");for(const t of e)if("function"!=typeof t)throw new TypeError("Middleware must be composed of functions!");return function(t,n){let r=-1;function o(s){if(s<=r)return Promise.reject(/* @__PURE__ */new Error("next() called multiple times"));r=s;let i=e[s];if(s===e.length&&n&&(i=n),!i)return Promise.resolve();try{return Promise.resolve(i(t,o.bind(null,s+1)))}catch(a){return Promise.reject(a)}}return o(0)}}(this.middleware);return s.createServer((e,n)=>{this.ctx.req=e,this.ctx.res=n,t(this.ctx).catch(C)}).listen(...e)}};function C(e){console.error(e.stack||e.toString())}var H=a,F=(e,t="utf-8")=>{const n=new AbortController,r=n.signal,o=new Promise((o,s)=>{H.readFile(e,{encoding:t,signal:r},(e,t)=>{e?(n.abort(),s({success:!1,_identification:!1,data:e})):o({success:!0,_identification:!0,data:t})})});return o.abort=n.abort,o},M=(e,t)=>new Promise((n,r)=>{H.appendFile(e,t,t=>{t?r({success:!1,_identification:!1,data:t}):F(e).then(e=>{n(e)})})}),_=m?.env&&!("NO_COLOR"in m.env||m.argv.includes("--no-color"))&&("FORCE_COLOR"in m.env||m.argv.includes("--color")||"win32"===m.platform||p.isatty(1)&&"dumb"!==m.env.TERM||"CI"in m.env),U=(e,t,n=e)=>r=>{const o=""+r,s=o.indexOf(t,e.length);return~s?e+j(o,t,n,s)+t:e+o+t},j=(e,t,n,r)=>{const o=e.substring(0,r)+n,s=e.substring(r+t.length),i=s.indexOf(t);return~i?o+j(s,t,n,i):o+s},k=Object.assign({},((e=_)=>{const t={};return Object.keys(r).forEach(n=>t[n]=e?U(r[n][0],r[n][1]):String),t})(),((e=_)=>({isColorSupported:e,reset:e?e=>`${r.reset[0]}${e}${r.reset[1]}`:String,bold:e?U(r.bold[0],r.bold[1],`${r.bold[1]}${r.bold[0]}`):String,dim:e?U(r.dim[0],r.dim[1],`${r.dim[1]}${r.dim[0]}`):String}))()),$=(e={})=>{const{uploadDir:n=".",encoding:r="",json:o=!0}=e;return(e,s)=>{const{req:i,res:c}=e,{url:d,method:l}=i,[u="",f=""]=d?.split("?")||[],h=f?new URLSearchParams(f):{};e.request||(e.request={}),e.request.method=l,e.request.path=u,e.request.url=d,e.request.query=h;const p=i.headers["content-type"];if("application/json"===p){r?i.setEncoding(r):i.setEncoding("utf-8");let t="";i.on("data",e=>{t+=e}),i.on("end",()=>{c.setHeader("content-type","application/json;charset=UTF-8");try{e.request.body=o?JSON.parse(t):t}catch{e.request.body=t}s()})}if(p?.includes("multipart/form-data;")){const[e,o]=i.headers["content-type"]?.split(";").map(e=>e.trim())||[],[d,l]=o.split("=");r?i.setEncoding(r):i.setEncoding("binary");let u="";i.on("data",e=>{u+=e}),i.on("end",()=>{const e={};u.split("\r\n").slice(0,4).forEach(n=>{Object.assign(e,t(n,";",/=|:/))});const r=e["Content-Type"],o=Buffer.from(e.filename,"latin1").toString("utf8"),i=u.indexOf(r)+r.length,d=u.substring(i).replace(/^\s+/,""),f=d.substring(0,d.indexOf(`--${l}--`));a.writeFile(`${n}/${o}`,f,{encoding:"binary"},e=>{if(e)throw e;c.setHeader("content-type","application/json;charset=UTF-8"),s()})})}}},I=(e,t)=>new Promise((n,r)=>{const o=g.spawn(e,t,{stdio:"inherit",shell:!1});o.on("error",e=>r(e)),o.on("exit",e=>0===e?n():r(/* @__PURE__ */new Error(`Command exited with code ${e}`)))}),A=({message:e,stream:t=process.stderr,defaultResponse:n="Y"})=>{const r=y.createInterface({input:process.stdin,output:t});return new Promise(t=>{r.question(`${e} `,e=>{r.close();const o=(e||n).toLowerCase();t("y"===o||"yes"===o)})})},B=()=>{};function D(e,t,n){return t(e.req,e.res,B),n()}function L(e,t,n){return new Promise((r,o)=>{t(e.req,e.res,e=>{e?o(e):r(n())})})}function R(e){const t=e.length<3?D:L;return function(n,r){return t(n,e,r)}}var N=e=>new Promise((t,n)=>{H.stat(e,(e,r)=>{e?n({success:!1,_identification:!1,data:e}):t({success:!0,_identification:!0,data:r})})}),J=({url:e})=>new Promise((t,n)=>{b.get(e,e=>{const n=[];e.on("data",e=>{n.push(e)}),e.on("end",()=>{const{data:e=[]}=JSON.parse(Buffer.concat(n).toString());e.forEach(e=>{}),t({success:!0,data:e,message:"request success"})})}).on("error",e=>{e.message,n({success:!1,data:e,message:e.message})})}),K=()=>{const e=i.networkInterfaces();for(const t in e){const n=e[t];for(let e=0;e<n.length;e++){const t=n[e];if("IPv4"===t.family&&"127.0.0.1"!==t.address&&!t.internal)return t.address}}};function z(e){const t=e.url;if(void 0===t)return;let n=e._parsedUrl;if(n&&n._raw===t)return n;n={},n.query=n.search=void 0,n.href=n.path=n.pathname=t;const r=t.indexOf("?",1);return-1!==r&&(n.search=t.substring(r),n.query=n.search.substring(1),n.pathname=t.substring(0,r)),n._raw=t,e._parsedUrl=n}var W=e=>{const{dirPath:t}=e;try{return H.readdirSync(t)}catch(n){throw n}},G=class{ctx;map;methods;paths;constructor(){this.map=/* @__PURE__ */new Map,this.methods=/* @__PURE__ */new Set,this.paths=/* @__PURE__ */new Set}get(e,t){this.addHandlerToMap("GET")(e,t)}post(e,t){this.addHandlerToMap("POST")(e,t)}put(e,t){this.addHandlerToMap("PUT")(e,t)}patch(e,t){this.addHandlerToMap("PATCH")(e,t)}del(e,t){this.addHandlerToMap("DELETE")(e,t)}head(e,t){this.addHandlerToMap("HEAD")(e,t)}options(e,t){this.addHandlerToMap("OPTIONS")(e,t)}addHandlerToMap(e){return this.methods.add(e),(t,n)=>{this.paths.add(t);let r=this.map.get(e);r||(r=/* @__PURE__ */new Map,this.map.set(e,r)),r.set(t,n)}}routes(){return(e,t)=>{this.ctx=e;const{path:n,method:r}=e.request,o=this.map.get(r),s=o?o.get(n):t;s&&s(e,t)}}allowedMethods(){return e=>{const{res:t}=e,{path:n,method:r}=e.request;!this.methods.has(r)&&this.paths.has(n)&&(t.statusCode=405,t.end("405, method is not allowed")),this.methods.has(r)&&!this.paths.has(n)&&(t.statusCode=404,t.end("404, the request address does not exist")),this.methods.has(r)||this.paths.has(n)||(t.statusCode=501,t.end("501, not support the functionality needed to satisfy the request"))}}},Y=(t={})=>{const{pathname:r,fileTypes:o={}}=t;return async(t,s)=>{try{const{req:i,res:c}=t;if(i.url){const t="text/html",s=r||process.cwd(),d=E.normalize(E.resolve(s)),l=E.extname(i.url).slice(1);Object.keys(o).forEach(t=>e(t,o[t]));const u=l?n(l):t;if(!Boolean(u))return c.writeHead(404,{"Content-Type":"text/html"}),void c.end("404: File not found");let f=i.url;if("/"===i.url)f="index.html";else if(!l)try{a.accessSync(E.join(d,i.url+".html"),a.constants.F_OK),f=i.url+".html"}catch{f=E.join(i.url,"index.html")}const h=E.join(d,f);if(!E.normalize(E.resolve(h)).startsWith(d))return c.writeHead(404,{"Content-Type":"text/html"}),void c.end("404: File not found");a.readFile(h,(e,t)=>{e?(c.writeHead(404,{"Content-Type":"text/html"}),c.end("404: File not found")):(c.writeHead(200,{"Content-Type":u}),c.end(t))})}await s()}catch{}}},Q=()=>{if("undefined"!=typeof window){const e=window.performance.now();return Symbol.for(`${e}`)}if("undefined"!=typeof process){const e=w.bigint();return Symbol.for(`${e}`)}return Symbol.for(`${Date.now()}`)},V=e=>{const{path:t}=e;if(t)return c(t);throw new Error("path is not defined")},X=e=>{const{path:t}=e;if(t)return d(t);throw new Error("path is not defined")},Z=e=>{const t=Symbol.keyFor(e);return"undefined"!=typeof window&&t?window.performance.now()-Number(t):"undefined"!=typeof process&&t?w.bigint()-BigInt(t):Date.now()-Number(t)},ee=T(f),te=T(l);async function ne(e,t,n=""){e=x(".",e);const r=await te(e);await Promise.all(r.map(async r=>{const o=v(e,r),s=await ee(o);return s.isDirectory()?ne(o,t,v(n,r)):t(v(n,r),o,s)}))}function re(e,t,n=""){e=x(".",e);const r=u(e);let o,s,i=0;for(;i<r.length;i++)o=v(e,r[i]),s=h(o),s.isDirectory()?re(o,t,v(n,r[i])):t(v(n,r[i]),o,s)}var oe=(e,t=20)=>new Promise(n=>{H.watchFile(e,{interval:t},(t,r)=>{t.mtime!==r.mtime?(H.unwatchFile(e),n({success:!0,_identification:!0,data:{},message:"file is changed"})):n({success:!1,_identification:!1,data:{},message:"file is not changed"})})});function se(e,t){const n=S.byteLength(e);let r=null;if(n>65535?(r=S.alloc(10+n),r[1]=127,r.writeUInt32BE(n,6),r.write(e,10)):n>125?(r=S.alloc(4+n),r[1]=126,r.writeUInt16BE(n,2),r.write(e,4)):(r=S.alloc(2+n),r[1]=n,r.write(e,2)),t){const e=t.opcode;e&&e<15&&e>=0&&(r[0]=128|e)}else r[0]=129;return r}function ie(e,t){if(!t)return e;const n=S.from(e);for(let r=0;r<n.length;++r)n[r]=n[r]^t[r%4];return n}function ae(){const e={};this.on=(t,n)=>{e[t]?e[t].push(n):e[t]=[n]},this.off=(t,n)=>{const r=e[t],o=r.indexOf(n);r&&-1!==o&&r.splice(o,1)},this.emit=(t,n)=>{e[t]&&e[t].forEach(e=>e(n))}}function ce(e){ae.call(this);const t=[];this.server=e,this.clients=t,this.broadcast=e=>{t.forEach(t=>{t.send(e)})},e.on("upgrade",(e,n)=>{n.write(["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade","Sec-WebSocket-Accept: "+P.createHash("sha1").update(e.headers["sec-websocket-key"]+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64")].join("\n")+"\n\n");const r={send(e,t){n.write(se(e,t))},ping(){n.write(se("",{opcode:9}))},pong(){n.write(se("",{opcode:10}))},close(){if(-1===t.indexOf(r))return!1;t.splice(t.indexOf(r),1),n.write(se("",{opcode:8})),r.emit("close"),n.destroy()},socket:n};ae.call(r),this.emit("connect",r),t.push(r);let o=S.allocUnsafe(0),s=S.allocUnsafe(0);const i=[];let a=!0;function c(){const e=function(e){const t=S.from(e),n=127&t[1];let r=0,o=0;const s=t[1]>=128;return 127===n?(r=t.readUInt32BE(6),o=10):126===n?(r=t.readUInt16BE(2),o=4):(r=n,o=2),{fin:t[0]>=128,opcode:15&t[0],mask:s,maskKey:s?t.subarray(o,o+(s?4:0)):null,len7:n,len:r,lenMeta:o+(s?4:0)}}(o);i.push({l:e.lenMeta,f:()=>{a=!1,i.push({l:e.len,f:t=>{if(s=S.concat([s,ie(t,e.maskKey)]),a=!0,e.fin){if(8===e.opcode)return r.close();if(9===e.opcode)return r.pong();r.emit("message",s),s=S.allocUnsafe(0)}}})}})}n.on("data",e=>{for(o=S.concat([o,e]),a&&c();i[0]&&o.byteLength>=i[0].l;){const e=i[0].l;i[0].f(o.subarray(0,e)),o=o.subarray(e),i.splice(0,1)}}),n.on("end",()=>{r.close()}),n.on("error",e=>{r.emit("error",e),r.close()})})}var de=(e,t)=>new Promise((n,r)=>{H.writeFile(e,t,{mode:438,flag:"w+",encoding:"utf-8"},o=>{if(o)throw r({success:!1,_identification:!1,data:o}),o;n({success:!0,_identification:!1,data:{path:e,content:t}})})});export{G as Router,q as Server,ce as WSS,M as appendFile,$ as body,k as colors,R as connect,J as get,K as getIPAdress,_ as isColorSupported,z as paresUrl,A as prompt,N as queryFileInfo,W as readDir,F as readFile,V as readStream,I as runCommand,Q as startTask,Y as staticMiddleware,Z as taskEnd,ne as traverse,re as traverseSync,oe as watchFile,de as writeFile,X as writeStream};
|
|
1
|
+
import{G as e,W as t,nt as n,r}from"../../color-DPV7TsVU.js";import{Socket as o}from"node:net";import s from"node:http";import i from"node:os";import a,{createReadStream as c,createWriteStream as d,readdir as l,readdirSync as u,stat as f,statSync as h}from"node:fs";import p from"node:tty";import m,{hrtime as w}from"node:process";import g from"node:child_process";import y from"node:readline";import b from"node:https";import E,{join as v,resolve as x}from"node:path";import{promisify as T}from"node:util";import{Buffer as S}from"node:buffer";import O from"node:crypto";function P(){const e=i.networkInterfaces();for(const t in e){const n=e[t];if(n)for(let e=0;e<n.length;e++){const t=n[e];if("IPv4"===t.family&&"127.0.0.1"!==t.address&&!t.internal)return t.address}}}var q=class{middleware;ctx;constructor(){const e=new s.IncomingMessage(new o),t=new s.ServerResponse(e);this.ctx={ipv4:P,req:e,res:t},this.middleware=[]}use(e){if(!e)throw new Error("the use function has an incorrect argument");this.middleware.push(e)}listen(...e){const t=function(e){if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");for(const t of e)if("function"!=typeof t)throw new TypeError("Middleware must be composed of functions!");return function(t,n){let r=-1;function o(s){if(s<=r)return Promise.reject(/* @__PURE__ */new Error("next() called multiple times"));r=s;let i=e[s];if(s===e.length&&n&&(i=n),!i)return Promise.resolve();try{return Promise.resolve(i(t,o.bind(null,s+1)))}catch(a){return Promise.reject(a)}}return o(0)}}(this.middleware);return s.createServer((e,n)=>{this.ctx.req=e,this.ctx.res=n,t(this.ctx).catch(C)}).listen(...e)}};function C(e){console.error(e.stack||e.toString())}var H=a,M=(e,t="utf-8")=>{const n=new AbortController,r=n.signal,o=new Promise((o,s)=>{H.readFile(e,{encoding:t,signal:r},(e,t)=>{e?(n.abort(),s({success:!1,_identification:!1,data:e})):o({success:!0,_identification:!0,data:t})})});return o.abort=n.abort,o},_=(e,t)=>new Promise((n,r)=>{H.appendFile(e,t,t=>{t?r({success:!1,_identification:!1,data:t}):M(e).then(e=>{n(e)})})}),F=m?.env&&!("NO_COLOR"in m.env||m.argv.includes("--no-color"))&&("FORCE_COLOR"in m.env||m.argv.includes("--color")||"win32"===m.platform||p.isatty(1)&&"dumb"!==m.env.TERM||"CI"in m.env),U=(e,t,n=e)=>r=>{const o=""+r,s=o.indexOf(t,e.length);return~s?e+j(o,t,n,s)+t:e+o+t},j=(e,t,n,r)=>{const o=e.substring(0,r)+n,s=e.substring(r+t.length),i=s.indexOf(t);return~i?o+j(s,t,n,i):o+s},k=Object.assign({},((e=F)=>{const t={};return Object.keys(r).forEach(n=>t[n]=e?U(r[n][0],r[n][1]):String),t})(),((e=F)=>({isColorSupported:e,reset:e?e=>`${r.reset[0]}${e}${r.reset[1]}`:String,bold:e?U(r.bold[0],r.bold[1],`${r.bold[1]}${r.bold[0]}`):String,dim:e?U(r.dim[0],r.dim[1],`${r.dim[1]}${r.dim[0]}`):String}))()),$=(e={})=>{const{uploadDir:t=".",encoding:r="",json:o=!0}=e;return(e,s)=>{const{req:i,res:c}=e,{url:d,method:l}=i,[u="",f=""]=d?.split("?")||[],h=f?new URLSearchParams(f):{};e.request||(e.request={}),e.request.method=l,e.request.path=u,e.request.url=d,e.request.query=h;const p=i.headers["content-type"];if("application/json"===p){r?i.setEncoding(r):i.setEncoding("utf-8");let t="";i.on("data",e=>{t+=e}),i.on("end",()=>{c.setHeader("content-type","application/json;charset=UTF-8");try{e.request.body=o?JSON.parse(t):t}catch{e.request.body=t}s()})}if(p?.includes("multipart/form-data;")){const[e,o]=i.headers["content-type"]?.split(";").map(e=>e.trim())||[],[d,l]=o.split("=");r?i.setEncoding(r):i.setEncoding("binary");let u="";i.on("data",e=>{u+=e}),i.on("end",()=>{const e={};u.split("\r\n").slice(0,4).forEach(t=>{Object.assign(e,n(t,";",/=|:/))});const r=e["Content-Type"],o=Buffer.from(e.filename,"latin1").toString("utf8"),i=u.indexOf(r)+r.length,d=u.substring(i).replace(/^\s+/,""),f=d.substring(0,d.indexOf(`--${l}--`));a.writeFile(`${t}/${o}`,f,{encoding:"binary"},e=>{if(e)throw e;c.setHeader("content-type","application/json;charset=UTF-8"),s()})})}}},I=(e,t)=>new Promise((n,r)=>{const o=g.spawn(e,t,{stdio:"inherit",shell:!1});o.on("error",e=>r(e)),o.on("exit",e=>0===e?n():r(/* @__PURE__ */new Error(`Command exited with code ${e}`)))}),A=({message:e,stream:t=process.stderr,defaultResponse:n="Y"})=>{const r=y.createInterface({input:process.stdin,output:t});return new Promise(t=>{r.question(`${e} `,e=>{r.close();const o=(e||n).toLowerCase();t("y"===o||"yes"===o)})})},B=()=>{};function D(e,t,n){return t(e.req,e.res,B),n()}function L(e,t,n){return new Promise((r,o)=>{t(e.req,e.res,e=>{e?o(e):r(n())})})}function R(e){const t=e.length<3?D:L;return function(n,r){return t(n,e,r)}}var N=e=>new Promise((t,n)=>{H.stat(e,(e,r)=>{e?n({success:!1,_identification:!1,data:e}):t({success:!0,_identification:!0,data:r})})}),K=({url:e})=>new Promise((t,n)=>{b.get(e,e=>{const n=[];e.on("data",e=>{n.push(e)}),e.on("end",()=>{const{data:e=[]}=JSON.parse(Buffer.concat(n).toString());e.forEach(e=>{}),t({success:!0,data:e,message:"request success"})})}).on("error",e=>{e.message,n({success:!1,data:e,message:e.message})})}),W=()=>{const e=i.networkInterfaces();for(const t in e){const n=e[t];for(let e=0;e<n.length;e++){const t=n[e];if("IPv4"===t.family&&"127.0.0.1"!==t.address&&!t.internal)return t.address}}};function z(e){const t=e.url;if(void 0===t)return;let n=e._parsedUrl;if(n&&n._raw===t)return n;n={},n.query=n.search=void 0,n.href=n.path=n.pathname=t;const r=t.indexOf("?",1);return-1!==r&&(n.search=t.substring(r),n.query=n.search.substring(1),n.pathname=t.substring(0,r)),n._raw=t,e._parsedUrl=n}var G=e=>{const{dirPath:t}=e;try{return H.readdirSync(t)}catch(n){throw n}},J=class{ctx;map;methods;paths;constructor(){this.map=/* @__PURE__ */new Map,this.methods=/* @__PURE__ */new Set,this.paths=/* @__PURE__ */new Set}get(e,t){this.addHandlerToMap("GET")(e,t)}post(e,t){this.addHandlerToMap("POST")(e,t)}put(e,t){this.addHandlerToMap("PUT")(e,t)}patch(e,t){this.addHandlerToMap("PATCH")(e,t)}del(e,t){this.addHandlerToMap("DELETE")(e,t)}head(e,t){this.addHandlerToMap("HEAD")(e,t)}options(e,t){this.addHandlerToMap("OPTIONS")(e,t)}addHandlerToMap(e){return this.methods.add(e),(t,n)=>{this.paths.add(t);let r=this.map.get(e);r||(r=/* @__PURE__ */new Map,this.map.set(e,r)),r.set(t,n)}}routes(){return(e,t)=>{this.ctx=e;const{path:n,method:r}=e.request,o=this.map.get(r),s=o?o.get(n):t;s&&s(e,t)}}allowedMethods(){return e=>{const{res:t}=e,{path:n,method:r}=e.request;!this.methods.has(r)&&this.paths.has(n)&&(t.statusCode=405,t.end("405, method is not allowed")),this.methods.has(r)&&!this.paths.has(n)&&(t.statusCode=404,t.end("404, the request address does not exist")),this.methods.has(r)||this.paths.has(n)||(t.statusCode=501,t.end("501, not support the functionality needed to satisfy the request"))}}},Y=(n={})=>{const{pathname:r,fileTypes:o={}}=n;return async(n,s)=>{try{const{req:i,res:c}=n;if(i.url){const n="text/html",s=r||process.cwd(),d=E.normalize(E.resolve(s)),l=E.extname(i.url).slice(1);Object.keys(o).forEach(t=>e(t,o[t]));const u=l?t(l):n;if(!Boolean(u))return c.writeHead(404,{"Content-Type":"text/html"}),void c.end("404: File not found");let f=i.url;if("/"===i.url)f="index.html";else if(!l)try{a.accessSync(E.join(d,i.url+".html"),a.constants.F_OK),f=i.url+".html"}catch{f=E.join(i.url,"index.html")}const h=E.join(d,f);if(!E.normalize(E.resolve(h)).startsWith(d))return c.writeHead(404,{"Content-Type":"text/html"}),void c.end("404: File not found");a.readFile(h,(e,t)=>{e?(c.writeHead(404,{"Content-Type":"text/html"}),c.end("404: File not found")):(c.writeHead(200,{"Content-Type":u}),c.end(t))})}await s()}catch{}}},Q=()=>{if("undefined"!=typeof window){const e=window.performance.now();return Symbol.for(`${e}`)}if("undefined"!=typeof process){const e=w.bigint();return Symbol.for(`${e}`)}return Symbol.for(`${Date.now()}`)},V=e=>{const{path:t}=e;if(t)return c(t);throw new Error("path is not defined")},X=e=>{const{path:t}=e;if(t)return d(t);throw new Error("path is not defined")},Z=e=>{const t=Symbol.keyFor(e);return"undefined"!=typeof window&&t?window.performance.now()-Number(t):"undefined"!=typeof process&&t?w.bigint()-BigInt(t):Date.now()-Number(t)},ee=T(f),te=T(l);async function ne(e,t,n=""){e=x(".",e);const r=await te(e);await Promise.all(r.map(async r=>{const o=v(e,r),s=await ee(o);return s.isDirectory()?ne(o,t,v(n,r)):t(v(n,r),o,s)}))}function re(e,t,n=""){e=x(".",e);const r=u(e);let o,s,i=0;for(;i<r.length;i++)o=v(e,r[i]),s=h(o),s.isDirectory()?re(o,t,v(n,r[i])):t(v(n,r[i]),o,s)}var oe=(e,t=20)=>new Promise(n=>{H.watchFile(e,{interval:t},(t,r)=>{t.mtime!==r.mtime?(H.unwatchFile(e),n({success:!0,_identification:!0,data:{},message:"file is changed"})):n({success:!1,_identification:!1,data:{},message:"file is not changed"})})});function se(e,t){const n=S.byteLength(e);let r=null;if(n>65535?(r=S.alloc(10+n),r[1]=127,r.writeUInt32BE(n,6),r.write(e,10)):n>125?(r=S.alloc(4+n),r[1]=126,r.writeUInt16BE(n,2),r.write(e,4)):(r=S.alloc(2+n),r[1]=n,r.write(e,2)),t){const e=t.opcode;e&&e<15&&e>=0&&(r[0]=128|e)}else r[0]=129;return r}function ie(e,t){if(!t)return e;const n=S.from(e);for(let r=0;r<n.length;++r)n[r]=n[r]^t[r%4];return n}function ae(){const e={};this.on=(t,n)=>{e[t]?e[t].push(n):e[t]=[n]},this.off=(t,n)=>{const r=e[t],o=r.indexOf(n);r&&-1!==o&&r.splice(o,1)},this.emit=(t,n)=>{e[t]&&e[t].forEach(e=>e(n))}}function ce(e){ae.call(this);const t=[];this.server=e,this.clients=t,this.broadcast=e=>{t.forEach(t=>{t.send(e)})},e.on("upgrade",(e,n)=>{n.write(["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade","Sec-WebSocket-Accept: "+O.createHash("sha1").update(e.headers["sec-websocket-key"]+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64")].join("\n")+"\n\n");const r={send(e,t){n.write(se(e,t))},ping(){n.write(se("",{opcode:9}))},pong(){n.write(se("",{opcode:10}))},close(){if(-1===t.indexOf(r))return!1;t.splice(t.indexOf(r),1),n.write(se("",{opcode:8})),r.emit("close"),n.destroy()},socket:n};ae.call(r),this.emit("connect",r),t.push(r);let o=S.allocUnsafe(0),s=S.allocUnsafe(0);const i=[];let a=!0;function c(){const e=function(e){const t=S.from(e),n=127&t[1];let r=0,o=0;const s=t[1]>=128;return 127===n?(r=t.readUInt32BE(6),o=10):126===n?(r=t.readUInt16BE(2),o=4):(r=n,o=2),{fin:t[0]>=128,opcode:15&t[0],mask:s,maskKey:s?t.subarray(o,o+(s?4:0)):null,len7:n,len:r,lenMeta:o+(s?4:0)}}(o);i.push({l:e.lenMeta,f:()=>{a=!1,i.push({l:e.len,f:t=>{if(s=S.concat([s,ie(t,e.maskKey)]),a=!0,e.fin){if(8===e.opcode)return r.close();if(9===e.opcode)return r.pong();r.emit("message",s),s=S.allocUnsafe(0)}}})}})}n.on("data",e=>{for(o=S.concat([o,e]),a&&c();i[0]&&o.byteLength>=i[0].l;){const e=i[0].l;i[0].f(o.subarray(0,e)),o=o.subarray(e),i.splice(0,1)}}),n.on("end",()=>{r.close()}),n.on("error",e=>{r.emit("error",e),r.close()})})}var de=(e,t)=>new Promise((n,r)=>{H.writeFile(e,t,{mode:438,flag:"w+",encoding:"utf-8"},o=>{if(o)throw r({success:!1,_identification:!1,data:o}),o;n({success:!0,_identification:!1,data:{path:e,content:t}})})});export{J as Router,q as Server,ce as WSS,_ as appendFile,$ as body,k as colors,R as connect,K as get,W as getIPAdress,F as isColorSupported,z as paresUrl,A as prompt,N as queryFileInfo,G as readDir,M as readFile,V as readStream,I as runCommand,Q as startTask,Y as staticMiddleware,Z as taskEnd,ne as traverse,re as traverseSync,oe as watchFile,de as writeFile,X as writeStream};
|
|
@@ -79,3 +79,33 @@ export declare const withTimeoutFallback: <T>(promise: Promise<T>, ms: number, f
|
|
|
79
79
|
* @return {Promise<void>}
|
|
80
80
|
*/
|
|
81
81
|
export declare const delay: (ms: number) => Promise<void>;
|
|
82
|
+
export interface RaceGuard {
|
|
83
|
+
/** Call before starting a new async attempt. Returns a token to close over and check later. */
|
|
84
|
+
start: () => number;
|
|
85
|
+
/** True when `token` is still the most recent one `start()` handed out — i.e. nothing newer superseded it. */
|
|
86
|
+
isCurrent: (token: number) => boolean;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* @description: Bump-and-compare guard against a stale async response overwriting a newer
|
|
90
|
+
* one — the "user changed the input again before the first request came back" race. Every
|
|
91
|
+
* `start()` invalidates whatever token came before it; after an `await`, check `isCurrent`
|
|
92
|
+
* before applying the result.
|
|
93
|
+
*
|
|
94
|
+
* This is the same shape hand-rolled at each call site that needs it (a search box re-typed
|
|
95
|
+
* mid-fetch, a lazy-loaded icon/variant whose `name` changes before its chunk resolves, a
|
|
96
|
+
* manifest re-fetched before the first parse finishes) — same bug potential each time if the
|
|
97
|
+
* counter or the comparison is done slightly wrong.
|
|
98
|
+
* @return {RaceGuard}
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* const guard = createRaceGuard();
|
|
102
|
+
*
|
|
103
|
+
* async function search(query: string) {
|
|
104
|
+
* const token = guard.start();
|
|
105
|
+
* const results = await fetchResults(query);
|
|
106
|
+
* if (!guard.isCurrent(token)) return; // a newer search() call already superseded this one
|
|
107
|
+
* render(results);
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare const createRaceGuard: () => RaceGuard;
|
|
@@ -8,17 +8,3 @@
|
|
|
8
8
|
* @return {Function} unsubscribe
|
|
9
9
|
*/
|
|
10
10
|
export declare const handleClick: (hooks?: (event: MouseEvent) => void) => (() => void);
|
|
11
|
-
/**
|
|
12
|
-
* @description: Read the device's latitude and longitude (prompts the user for permission)
|
|
13
|
-
* @return {*}
|
|
14
|
-
*/
|
|
15
|
-
export declare const getRegionalLatitudeAndLongitude: () => Promise<GeolocationPosition>;
|
|
16
|
-
export declare const webglVendor: () => {
|
|
17
|
-
vendor: string;
|
|
18
|
-
renderer: string;
|
|
19
|
-
} | null;
|
|
20
|
-
export declare const canvasVendor: () => string | null;
|
|
21
|
-
/**
|
|
22
|
-
* @description: Audio fingerprint. 1. Generate an audio stream (triangle wave), run an FFT over it and hash the result with SHA. 2. Generate an audio stream (sine wave), run it through dynamic compression and hash with MD5.
|
|
23
|
-
*/
|
|
24
|
-
export declare const audioVendor: () => Promise<string>;
|
package/dist/src/utils/bom.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import { noop } from '@/utils/noop';
|
|
2
|
-
/**
|
|
3
|
-
* @description: Override the browser's back-button behaviour
|
|
4
|
-
* @param {*} callback
|
|
5
|
-
* @return {*}
|
|
6
|
-
*/
|
|
7
|
-
export declare const retain: (callback?: typeof noop) => void;
|
|
8
1
|
/**
|
|
9
2
|
* @description: Read a named cookie
|
|
10
3
|
* @param {string} objName
|
|
@@ -74,21 +67,14 @@ export declare const getFrame: (n?: number) => Promise<number>;
|
|
|
74
67
|
* ```
|
|
75
68
|
*/
|
|
76
69
|
export declare const getAllQueryString: (url?: string) => Record<string, string>;
|
|
77
|
-
/**
|
|
78
|
-
* @description: Alias of [`getAllQueryString`](#getallquerystring). The two used to be
|
|
79
|
-
* byte-identical copies of the same body; this one now forwards so a fix lands in both.
|
|
80
|
-
* @param {string} url full URL or query string; defaults to the current location
|
|
81
|
-
* @return {Record<string, string>}
|
|
82
|
-
*/
|
|
83
|
-
export declare const getQuery: (url?: string) => Record<string, string>;
|
|
84
70
|
/**
|
|
85
71
|
* @description: Read a query parameter as a boolean flag. True for `?k`, `?k=`, `?k=1` and
|
|
86
72
|
* `?k=true` (case-insensitive); false for anything else, including an absent parameter and
|
|
87
73
|
* an explicit `?k=false`.
|
|
88
74
|
*
|
|
89
75
|
* This is the URL spelling of a boolean: `?embed`, `?readonly` and `?debug` are all written
|
|
90
|
-
* without a value most of the time, so a plain `
|
|
91
|
-
* most common form.
|
|
76
|
+
* without a value most of the time, so a plain `getAllQueryString(url).embed` check is wrong
|
|
77
|
+
* for the most common form.
|
|
92
78
|
*
|
|
93
79
|
* @param {string} key parameter name
|
|
94
80
|
* @param {string} url full URL or query string; defaults to the current location
|
|
@@ -117,12 +103,6 @@ export declare const isInIframe: () => boolean;
|
|
|
117
103
|
* @return {*}
|
|
118
104
|
*/
|
|
119
105
|
export declare function appendUrl(url: string, params?: Record<string, string>): string;
|
|
120
|
-
/**
|
|
121
|
-
* @description: Remove the drag event's ghost image
|
|
122
|
-
* @param {DragEvent} event
|
|
123
|
-
* @return {*}
|
|
124
|
-
*/
|
|
125
|
-
export declare const removeGhosting: (event: DragEvent) => void;
|
|
126
106
|
export declare function getCookieByName(name: string): string;
|
|
127
107
|
interface ClientRatio {
|
|
128
108
|
width: number;
|
|
@@ -140,4 +140,79 @@ export declare class ColorScheme {
|
|
|
140
140
|
static Split(colorVal: ColorVal): ColorScheme;
|
|
141
141
|
static Accent(colorVal: ColorVal): ColorScheme;
|
|
142
142
|
}
|
|
143
|
+
/** An RGB triple with each channel in 0..1 (linear or sRGB depending on the operation). */
|
|
144
|
+
export type RGB = [number, number, number];
|
|
145
|
+
/**
|
|
146
|
+
* @description: Convert one sRGB channel (0..1) to linear-light (IEC 61966-2-1 transfer function).
|
|
147
|
+
* @param {number} c sRGB channel, 0..1
|
|
148
|
+
* @return {number} linear-light channel, 0..1
|
|
149
|
+
*/
|
|
150
|
+
export declare const srgbToLinear: (c: number) => number;
|
|
151
|
+
/**
|
|
152
|
+
* @description: Convert one linear-light channel (0..1) to sRGB.
|
|
153
|
+
* @param {number} c linear-light channel, 0..1
|
|
154
|
+
* @return {number} sRGB channel, 0..1
|
|
155
|
+
*/
|
|
156
|
+
export declare const linearToSrgb: (c: number) => number;
|
|
157
|
+
/**
|
|
158
|
+
* @description: Perceived brightness (luma) of an RGB colour using Rec. 601 weights. Channels may be 0..1 or 0..255 — the result keeps that scale.
|
|
159
|
+
* @param {number} r
|
|
160
|
+
* @param {number} g
|
|
161
|
+
* @param {number} b
|
|
162
|
+
* @return {number}
|
|
163
|
+
*/
|
|
164
|
+
export declare const luma: (r: number, g: number, b: number) => number;
|
|
165
|
+
/**
|
|
166
|
+
* @description: Screen blend of two colours (channel-wise `1 - (1 - base)(1 - blend)`). Channels in 0..1.
|
|
167
|
+
* @param {RGB} base
|
|
168
|
+
* @param {RGB} blend
|
|
169
|
+
* @return {RGB}
|
|
170
|
+
*/
|
|
171
|
+
export declare const blendScreen: (base: RGB, blend: RGB) => RGB;
|
|
172
|
+
/**
|
|
173
|
+
* @description: Multiply blend of two colours (channel-wise `base * blend`). Channels in 0..1.
|
|
174
|
+
* @param {RGB} base
|
|
175
|
+
* @param {RGB} blend
|
|
176
|
+
* @return {RGB}
|
|
177
|
+
*/
|
|
178
|
+
export declare const blendMultiply: (base: RGB, blend: RGB) => RGB;
|
|
179
|
+
/**
|
|
180
|
+
* @description: Overlay blend of two colours (multiply in shadows, screen in highlights). Channels in 0..1.
|
|
181
|
+
* @param {RGB} base
|
|
182
|
+
* @param {RGB} blend
|
|
183
|
+
* @return {RGB}
|
|
184
|
+
*/
|
|
185
|
+
export declare const blendOverlay: (base: RGB, blend: RGB) => RGB;
|
|
186
|
+
/**
|
|
187
|
+
* @description: Adjust brightness and contrast of a colour: `(c - 0.5) * contrast + 0.5 + brightness` per channel. Channels in 0..1.
|
|
188
|
+
* @param {RGB} color
|
|
189
|
+
* @param {number} brightness additive, e.g. 0 = none
|
|
190
|
+
* @param {number} contrast multiplicative, e.g. 1 = none
|
|
191
|
+
* @return {RGB}
|
|
192
|
+
*/
|
|
193
|
+
export declare const brightnessContrast: (color: RGB, brightness: number, contrast: number) => RGB;
|
|
194
|
+
/**
|
|
195
|
+
* @description: Adjust saturation by mixing toward the colour's luminance. `amount` 0 = greyscale, 1 = unchanged, >1 = more saturated. Channels in 0..1.
|
|
196
|
+
* @param {RGB} color
|
|
197
|
+
* @param {number} amount
|
|
198
|
+
* @return {RGB}
|
|
199
|
+
*/
|
|
200
|
+
export declare const saturation: (color: RGB, amount: number) => RGB;
|
|
201
|
+
/**
|
|
202
|
+
* @description: Vibrance — saturates muted colours more than already-saturated ones. `amount` > 0 boosts, < 0 mutes. Channels in 0..1.
|
|
203
|
+
* @param {RGB} color
|
|
204
|
+
* @param {number} amount
|
|
205
|
+
* @return {RGB}
|
|
206
|
+
*/
|
|
207
|
+
export declare const vibrance: (color: RGB, amount: number) => RGB;
|
|
208
|
+
/**
|
|
209
|
+
* @description: Inigo Quilez cosine gradient palette: `a + b * cos(2π(c·t + d))`. Each of `a,b,c,d` is an RGB triple; `t` is the position 0..1. Returns an RGB triple.
|
|
210
|
+
* @param {number} t position along the gradient
|
|
211
|
+
* @param {RGB} a base / offset
|
|
212
|
+
* @param {RGB} b amplitude
|
|
213
|
+
* @param {RGB} c frequency
|
|
214
|
+
* @param {RGB} d phase
|
|
215
|
+
* @return {RGB}
|
|
216
|
+
*/
|
|
217
|
+
export declare const cosinePalette: (t: number, a: RGB, b: RGB, c: RGB, d: RGB) => RGB;
|
|
143
218
|
export {};
|
package/dist/src/utils/dom.d.ts
CHANGED
|
@@ -33,8 +33,11 @@ export declare const setFontSize2html: (designWidth?: number) => void;
|
|
|
33
33
|
*
|
|
34
34
|
* Two details make this work where the naive version does not: the height is reset to `auto`
|
|
35
35
|
* before each measurement (`scrollHeight` never reports *less* than the current height, so
|
|
36
|
-
* without the reset the box could only ever grow), and `box-sizing` decides
|
|
37
|
-
*
|
|
36
|
+
* without the reset the box could only ever grow), and `box-sizing` decides what the CSS
|
|
37
|
+
* `height` being set is supposed to mean — `scrollHeight` always includes padding and never
|
|
38
|
+
* the border, but `border-box`'s `height` must cover the border too (so it's added back) while
|
|
39
|
+
* `content-box`'s `height` must exclude the padding `scrollHeight` already baked in (so it's
|
|
40
|
+
* subtracted).
|
|
38
41
|
*
|
|
39
42
|
* @param {HTMLTextAreaElement} element the textarea to manage
|
|
40
43
|
* @return {() => void} detaches the listener and restores the inline height
|
|
@@ -59,3 +59,37 @@ export declare class EventManager {
|
|
|
59
59
|
*/
|
|
60
60
|
abort(): void;
|
|
61
61
|
}
|
|
62
|
+
export interface DoubleTapDetectorOptions {
|
|
63
|
+
/** Max gap between the two taps, in ms. Default `300`. */
|
|
64
|
+
windowMs?: number;
|
|
65
|
+
/** Max 2D distance between the two taps, in px. Default `60`. */
|
|
66
|
+
maxDistancePx?: number;
|
|
67
|
+
}
|
|
68
|
+
export interface DoubleTapDetector {
|
|
69
|
+
/**
|
|
70
|
+
* Record a tap at `(x, y)` and report whether it forms a double-tap with the
|
|
71
|
+
* immediately preceding one. A detected double-tap resets tracking, so a
|
|
72
|
+
* third rapid tap starts a fresh pair rather than counting as part of the
|
|
73
|
+
* same double-tap.
|
|
74
|
+
*/
|
|
75
|
+
check: (x: number, y: number, now?: number) => boolean;
|
|
76
|
+
/** Forget the last recorded tap — e.g. when a gesture other than a tap (a drag) starts. */
|
|
77
|
+
reset: () => void;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @description: Double-tap detection over raw `(x, y, time)` samples — pointer-type-agnostic,
|
|
81
|
+
* so it works the same fed from Pointer/Touch/Mouse events. Built for touch gestures (double-tap
|
|
82
|
+
* to seek, to zoom, to like) where re-deriving the timestamp+distance threshold logic at every
|
|
83
|
+
* call site is easy to get subtly wrong (comparing only one axis, forgetting to reset after a
|
|
84
|
+
* hit so three fast taps count as two overlapping double-taps).
|
|
85
|
+
* @param {DoubleTapDetectorOptions} options `windowMs` (default 300) and `maxDistancePx` (default 60)
|
|
86
|
+
* @return {DoubleTapDetector}
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const detector = createDoubleTapDetector();
|
|
90
|
+
* el.addEventListener('pointerup', (e) => {
|
|
91
|
+
* if (detector.check(e.clientX, e.clientY)) seek();
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function createDoubleTapDetector(options?: DoubleTapDetectorOptions): DoubleTapDetector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as r,r as s,t as a}from"../../../i18n-
|
|
1
|
+
import{n as r,r as s,t as a}from"../../../i18n-Bq-f7htr.js";export{a as I18nCore,r as createI18n,s as useI18n};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { SyncHook } from './subscribe';
|
|
2
|
-
import { Mathjs, addNumSym, mathjs, parseChineseNumber, parseEnglishNumber, parseRomanNumber, perToNum, range, transformNumber } from './number';
|
|
3
|
-
import { MessageCodec, arrayBufferToString,
|
|
2
|
+
import { Mathjs, addNumSym, clamp, fit, inverseLerp, lerp, linearstep, mathjs, parseChineseNumber, parseEnglishNumber, parseRomanNumber, perToNum, range, remap, smoothstep, transformNumber } from './number';
|
|
3
|
+
import { MessageCodec, arrayBufferToString, checkEncoding, clearBr, clearStr, getMatchingSentences, getRandomString, isString, md5, randomString, strParse, toFullWidth, toHalfWidth, toString, transformText, truncate } from './str';
|
|
4
4
|
import type { TransformText, TruncateOptions, TruncatePosition } from './str';
|
|
5
5
|
import { createSpeechRecognizer, isSpeechRecognitionSupported } from './speech';
|
|
6
6
|
import type { SpeechError, SpeechErrorKind, SpeechRecognizer, SpeechRecognizerOptions } from './speech';
|
|
7
|
-
import { appendUrl, connection, createObjectURL, durationHandler, encodeUrl, getAllQueryString, getCookie, getCookieByName, getFrame, getPixelRatio,
|
|
7
|
+
import { appendUrl, connection, createObjectURL, durationHandler, encodeUrl, getAllQueryString, getCookie, getCookieByName, getFrame, getPixelRatio, getWindow, imageRequest, isInIframe, isSafari, networkSpeed, queryFlag, requestUrlToBuffer } from './bom';
|
|
8
8
|
import { BRIDGE_MARKER, BridgeManager, Client, DEFAULT_CHANNEL, Platform, PostMessageBridge, acceptPortBridge, bridgeManager, createPortBridge, openPortBridge } from './bridge';
|
|
9
9
|
import type { AcceptPortBridgeOptions, BridgeManagerOptions, BroadcastPayload, CallToPayload, MessageData, MessageHandler, OpenPortBridgeOptions, PendingRequest, PortBridge } from './bridge';
|
|
10
|
-
import { cloneDeep, filterObj, formatJson, isEqual, merge, mergeExports, querystring, replaceOld
|
|
10
|
+
import { cloneDeep, filterObj, formatJson, isEqual, merge, mergeExports, querystring, replaceOld } from './obj';
|
|
11
11
|
import { MimeType, getExtensions, getMime, setMime } from './mimeType';
|
|
12
12
|
import { AudioRecorder } from './audioRecorder';
|
|
13
13
|
import { createSignal, subscribers } from './signal';
|
|
14
|
-
import { audioVendor, canvasVendor, webglVendor } from './behavior';
|
|
15
14
|
import { TOTP } from './totp/totp';
|
|
16
15
|
import { createStore, localStorageGetItem, localStorageRemoveItem, localStorageSetItem } from './storage';
|
|
17
16
|
import type { JsonStore } from './storage';
|
|
@@ -21,7 +20,8 @@ import { debounce } from './debounce';
|
|
|
21
20
|
import type { Debounced } from './debounce';
|
|
22
21
|
import { Chain, addClassToElement, autosizeTextarea, create, createDocumentFragment, escapeHtml, removeClassToElement, setFontSize2html } from './dom';
|
|
23
22
|
import { handleError } from './error';
|
|
24
|
-
import { EventManager } from './event';
|
|
23
|
+
import { EventManager, createDoubleTapDetector } from './event';
|
|
24
|
+
import type { DoubleTapDetector, DoubleTapDetectorOptions } from './event';
|
|
25
25
|
import { circ, cubic, expo, quad, quart, quint, sine } from './tween';
|
|
26
26
|
import type { EasingFn, SpeedType } from './tween';
|
|
27
27
|
import { convertImageToBase64, cutRound, getImage, getMatrix, isImageSize, opacity } from './img';
|
|
@@ -41,14 +41,16 @@ import { I18nCore, createI18n, useI18n } from './i18n';
|
|
|
41
41
|
import type { I18nConfig, LocaleChangeHandler, LocaleMessages, MessageDict, StringValues, TranslateParams } from './i18n';
|
|
42
42
|
import { createLocalePath } from './localePath';
|
|
43
43
|
import type { LocalePath, LocalePathConfig, LocaleRoute } from './localePath';
|
|
44
|
+
import { computePlacement } from './placement';
|
|
45
|
+
import type { ComputePlacementOptions, ComputedPlacement, Placement, PlacementRect } from './placement';
|
|
44
46
|
import type { ResolveLocaleOptions, TextLanguage } from './lang';
|
|
45
47
|
import { readFileAsArrayBuffer, readFileAsDataURL, readFileAsText, readFileAsUint8Array } from './file';
|
|
46
48
|
import { WorkerClient, serveWorker } from './worker';
|
|
47
49
|
import type { ServeWorkerOptions, WorkerClientOptions, WorkerHandlerContext, WorkerRequestBase, WorkerResponseBase } from './worker';
|
|
48
50
|
import { isUrlCached, networkAllowsDownload, prefetchUrl, prefetchUrls, prefetchWhenIdle, whenIdle } from './prefetch';
|
|
49
51
|
import type { NetworkAllowanceOptions, PrefetchOptions, WhenIdleOptions } from './prefetch';
|
|
50
|
-
import { TimeoutError, deferred, delay, withTimeout, withTimeoutFallback } from './async';
|
|
51
|
-
import type { Deferred } from './async';
|
|
52
|
+
import { TimeoutError, createRaceGuard, deferred, delay, withTimeout, withTimeoutFallback } from './async';
|
|
53
|
+
import type { Deferred, RaceGuard } from './async';
|
|
52
54
|
import { ZIP_DEFLATE, ZIP_STORED, createZip, crc32, inflateRaw, readZipEntries, readZipEntry, rewriteZip, zipHasEntry } from './zip';
|
|
53
55
|
import type { RewriteZipOptions, ZipEntry } from './zip';
|
|
54
56
|
import { Monitor } from './monitor';
|
|
@@ -63,10 +65,11 @@ import { loadScript, scriptOnLoad } from './script';
|
|
|
63
65
|
import type { LoadScriptOptions } from './script';
|
|
64
66
|
import { throttle } from './throttle';
|
|
65
67
|
import type { Throttled } from './throttle';
|
|
66
|
-
import { formatDate, formatDuration, formatRelative, performanceTime, timeFormat, timestampToTime } from './time';
|
|
68
|
+
import { formatDate, formatDuration, formatRelative, parseVttCueTiming, parseVttTimestamp, performanceTime, timeFormat, timestampToTime } from './time';
|
|
67
69
|
import type { DateInput, FormatRelativeOptions, RelativeStyle } from './time';
|
|
68
70
|
import type { CurrentDevice } from './device';
|
|
69
|
-
import { MOBILE_MEDIA_QUERY, currentDevice,
|
|
70
|
-
import { Color, ColorScheme, FMT, HEX_COLOR_REGEX, Hsl, Hsla, RGBA_REGEX, RGB_REGEX, Rgb, Rgba, componentToHex, hexToAlpha, hexToHsb, hexToHsv, hexToRgb, hsbToHsl, hsbToRgb, hslToHsb, hslToHsv, hslToRgb, hsvToHsl, hsvToRgb, hue2rgb, randomColor, rgbToHex, rgbToHsb, rgbToHsl, rgbToHsv, rgbaString, rgbaToHex, rgbaToRgb } from '@/utils/color';
|
|
71
|
-
|
|
72
|
-
export
|
|
71
|
+
import { MOBILE_MEDIA_QUERY, currentDevice, isClient, isMobile, isWeiXin, matchMediaQuery, watchMediaQuery } from './device';
|
|
72
|
+
import { Color, ColorScheme, FMT, HEX_COLOR_REGEX, Hsl, Hsla, RGBA_REGEX, RGB_REGEX, Rgb, Rgba, blendMultiply, blendOverlay, blendScreen, brightnessContrast, componentToHex, cosinePalette, hexToAlpha, hexToHsb, hexToHsv, hexToRgb, hsbToHsl, hsbToRgb, hslToHsb, hslToHsv, hslToRgb, hsvToHsl, hsvToRgb, hue2rgb, linearToSrgb, luma, randomColor, rgbToHex, rgbToHsb, rgbToHsl, rgbToHsv, rgbaString, rgbaToHex, rgbaToRgb, saturation, srgbToLinear, vibrance } from '@/utils/color';
|
|
73
|
+
import type { RGB } from '@/utils/color';
|
|
74
|
+
export { performanceTime, timeFormat, timestampToTime, throttle, SyncHook, clearBr, clearStr, isString, randomString, strParse, scriptOnLoad, handleFetchHook, createData, report, QuestQueue, noop, getPerformance, querystring, formatJson, filterObj, merge, replaceOld, mergeExports, perToNum, range, clamp, lerp, inverseLerp, remap, fit, linearstep, smoothstep, Mathjs, mathjs, getStatus, status, Monitor, MimeType, getExtensions, setMime, getMime, memoize, once, isImageSize, convertImageToBase64, handleError, addClassToElement, removeClassToElement, createDocumentFragment, escapeHtml, isClient, isWeiXin, isMobile, debounce, currentDevice, handleConsole, compose, Color, FMT, Hsl, Hsla, Rgb, Rgba, randomColor, hexToRgb, componentToHex, rgbToHex, rgbToHsl, hue2rgb, hslToRgb, rgbToHsb, hsbToRgb, hsvToRgb, hsvToHsl, ColorScheme, AudioRecorder, getCookie, requestUrlToBuffer, getPixelRatio, createObjectURL, getFrame, getAllQueryString, queryFlag, isInIframe, appendUrl, getCookieByName, getWindow, connection, encodeUrl, imageRequest, durationHandler, networkSpeed, TOTP, localStorageGetItem, localStorageSetItem, localStorageRemoveItem, createStore, setFontSize2html, autosizeTextarea, createSpeechRecognizer, isSpeechRecognitionSupported, Chain, create, isEqual, cloneDeep, createSignal, subscribers, getMatchingSentences, transformNumber, toString, addNumSym, checkEncoding, transformText, isSafari, md5, getRandomString, bridgeManager, Client, BridgeManager, PostMessageBridge, MessageCodec, Platform, openPortBridge, acceptPortBridge, createPortBridge, BRIDGE_MARKER, DEFAULT_CHANNEL, singleFlight, WebDB, createHandoff, buildOffsets, paginateText, indexForOffset, segmentByRanges, detectLanguage, navigatorLanguage, resolveLocale, readFileAsArrayBuffer, readFileAsUint8Array, readFileAsText, readFileAsDataURL, WorkerClient, serveWorker, whenIdle, networkAllowsDownload, isUrlCached, prefetchUrl, prefetchUrls, prefetchWhenIdle, deferred, withTimeout, withTimeoutFallback, delay, TimeoutError, createRaceGuard, crc32, inflateRaw, readZipEntries, readZipEntry, zipHasEntry, rewriteZip, createZip, ZIP_STORED, ZIP_DEFLATE, arrayBufferToString, toHalfWidth, toFullWidth, truncate, parseChineseNumber, parseRomanNumber, parseEnglishNumber, MOBILE_MEDIA_QUERY, matchMediaQuery, watchMediaQuery, createLocalePath, setReportUrl, getReportUrl, formatDate, formatDuration, formatRelative, parseVttCueTiming, parseVttTimestamp, handleXhrHook, EventManager, createDoubleTapDetector, quad, cubic, quart, quint, sine, expo, circ, getImage, cutRound, opacity, getMatrix, getAngle, getArcPointerByDeg, getTangentByPointer, fanShapedByArc, roundRectByArc, getLinearGradient, adoptStyles, adoptSheetText, ADOPTED_STYLE_MARKER, ADOPTED_SHEET_MARKER, rgbToHsv, hexToHsb, hexToHsv, hsbToHsl, hslToHsb, hslToHsv, hexToAlpha, rgbaString, rgbaToRgb, rgbaToHex, srgbToLinear, linearToSrgb, luma, blendScreen, blendMultiply, blendOverlay, brightnessContrast, saturation, vibrance, cosinePalette, HEX_COLOR_REGEX, RGB_REGEX, RGBA_REGEX, loadScript, I18nCore, createI18n, useI18n, computePlacement, };
|
|
75
|
+
export type { RGB, DateInput, FormatRelativeOptions, RelativeStyle, TruncateOptions, TruncatePosition, SpeechError, SpeechErrorKind, SpeechRecognizer, SpeechRecognizerOptions, EasingFn, SpeedType, ImgSource, LoadScriptOptions, I18nConfig, MessageDict, StringValues, LocaleMessages, TranslateParams, LocaleChangeHandler, Debounced, Throttled, BeaconPayload, ReportConfig, LocalePath, LocalePathConfig, LocaleRoute, SingleFlight, IDBCollection, IDBResult, IDBStoreSchema, WebDBOptions, Handoff, HandoffOptions, JsonStore, Deferred, RaceGuard, DoubleTapDetector, DoubleTapDetectorOptions, ZipEntry, RewriteZipOptions, ResolveLocaleOptions, OffsetRange, PaginateOptions, PaginateResult, TextBox, TextGridMetrics, TextPage, Segment, TextLanguage, ServeWorkerOptions, WorkerClientOptions, WorkerHandlerContext, WorkerRequestBase, WorkerResponseBase, WhenIdleOptions, NetworkAllowanceOptions, PrefetchOptions, CurrentDevice, TransformText, MessageHandler, MessageData, PendingRequest, BridgeManagerOptions, BroadcastPayload, CallToPayload, PortBridge, OpenPortBridgeOptions, AcceptPortBridgeOptions, ComputePlacementOptions, ComputedPlacement, Placement, PlacementRect, };
|
package/dist/src/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as s}from"../../enums-BAgbyGdH.js";import{$ as a,A as t,B as n,C as o,D as r,E as m,F as i,G as p,H as f,I as j,J as c,K as l,L as u,M as
|
|
1
|
+
import{i as s}from"../../enums-BAgbyGdH.js";import{$ as a,A as t,B as n,C as o,D as r,E as m,F as i,G as p,H as f,I as j,J as c,K as l,L as u,M as h,N as b,O as d,P as e,Q as g,R as v,S as x,T as y,U as _,V as k,W as w,X as z,Y as A,Z as B,_ as C,a as D,at as E,b as F,c as H,d as I,et as L,f as M,g as N,h as P,i as R,it as S,j as T,k as U,l as V,m as q,n as G,nt as J,o as K,ot as O,p as Q,q as W,r as X,rt as Y,s as Z,st as $,t as ss,tt as as,u as ts,v as ns,w as os,x as rs,y as ms,z as is}from"../../color-DPV7TsVU.js";import{$ as ps,$t as fs,A as js,At as cs,B as ls,Bt as us,C as hs,Ct as bs,D as ds,Dt as es,E as gs,Et as vs,F as xs,Ft as ys,G as _s,Gt as ks,H as ws,Ht as zs,I as As,It as Bs,J as Cs,Jt as Ds,K as Es,Kt as Fs,L as Hs,Lt as Is,M as Ls,Mt as Ms,N as Ns,Nt as Ps,O as Rs,Ot as Ss,P as Ts,Pt as Us,Q as Vs,Qt as qs,R as Gs,Rt as Js,S as Ks,St as Os,T as Qs,Tt as Ws,U as Xs,Ut as Ys,V as Zs,Vt as $s,W as sa,Wt as aa,X as ta,Xt as na,Y as oa,Yt as ra,Z as ma,Zt as ia,_ as pa,_n as fa,_t as ja,a as ca,an as la,at as ua,b as ha,bn as ba,bt as da,c as ea,cn as ga,ct as va,d as xa,dn as ya,dt as _a,en as ka,et as wa,f as za,fn as Aa,ft as Ba,g as Ca,gn as Da,gt as Ea,h as Fa,hn as Ha,ht as Ia,i as La,in as Ma,it as Na,j as Pa,jt as Ra,k as Sa,kt as Ta,l as Ua,ln as Va,lt as qa,m as Ga,mn as Ja,mt as Ka,n as Oa,nn as Qa,nt as Wa,o as Xa,on as Ya,ot as Za,p as $a,pn as st,pt as at,q as tt,qt as nt,r as ot,rn as rt,rt as mt,s as it,sn as pt,st as ft,t as jt,tn as ct,tt as lt,u as ut,un as ht,ut as bt,v as dt,vn as et,vt as gt,w as vt,wt as xt,x as yt,xt as _t,y as kt,yn as wt,yt as zt,z as At,zt as Bt}from"../../utils-CYrYCt5o.js";import{A as Ct,B as Dt,C as Et,D as Ft,E as Ht,F as It,H as Lt,I as Mt,L as Nt,M as Pt,N as Rt,P as St,R as Tt,S as Ut,T as Vt,U as qt,V as Gt,_ as Jt,a as Kt,b as Ot,c as Qt,d as Wt,f as Xt,g as Yt,h as Zt,i as $t,j as sn,k as an,l as tn,m as nn,n as on,o as rn,p as mn,r as pn,s as fn,t as jn,u as cn,v as ln,w as un,x as hn,y as bn,z as dn}from"../../i18n-Bq-f7htr.js";import{n as en,t as gn}from"../../chain-CTywmh_H.js";export{ta as ADOPTED_SHEET_MARKER,ma as ADOPTED_STYLE_MARKER,Us as AudioRecorder,nt as BRIDGE_MARKER,Ds as BridgeManager,gn as Chain,ra as Client,ss as Color,G as ColorScheme,na as DEFAULT_CHANNEL,zt as EventManager,X as FMT,R as HEX_COLOR_REGEX,D as Hsl,K as Hsla,jn as I18nCore,an as MOBILE_MEDIA_QUERY,la as Mathjs,l as MessageCodec,f as MimeType,Xa as Monitor,ia as Platform,qs as PostMessageBridge,ot as QuestQueue,Z as RGBA_REGEX,H as RGB_REGEX,V as Rgb,ts as Rgba,s as SyncHook,Ra as TOTP,vt as TimeoutError,Cs as WebDB,As as WorkerClient,Fa as ZIP_DEFLATE,Ca as ZIP_STORED,fs as acceptPortBridge,Os as addClassToElement,Ya as addNumSym,Vs as adoptSheetText,ps as adoptStyles,Wt as appendUrl,W as arrayBufferToString,bs as autosizeTextarea,I as blendMultiply,M as blendOverlay,Q as blendScreen,ka as bridgeManager,q as brightnessContrast,_s as buildOffsets,c as checkEncoding,Ba as circ,pt as clamp,A as clearBr,z as clearStr,ys as cloneDeep,P as componentToHex,cs as compose,ws as computePlacement,Xt as connection,wa as convertImageToBase64,N as cosinePalette,pa as crc32,en as create,ut as createData,xt as createDocumentFragment,da as createDoubleTapDetector,oa as createHandoff,on as createI18n,Xs as createLocalePath,mn as createObjectURL,ct as createPortBridge,Qs as createRaceGuard,Ms as createSignal,rt as createSpeechRecognizer,fn as createStore,dt as createZip,at as cubic,Ct as currentDevice,lt as cutRound,Ss as debounce,gs as deferred,ds as delay,$t as detectLanguage,nn as durationHandler,Zt as encodeUrl,Ws as escapeHtml,Ka as expo,Za as fanShapedByArc,Bs as filterObj,ga as fit,Mt as formatDate,Nt as formatDuration,Is as formatJson,Tt as formatRelative,Yt as getAllQueryString,ft as getAngle,va as getArcPointerByDeg,Jt as getCookie,ln as getCookieByName,_ as getExtensions,bn as getFrame,Wa as getImage,qa as getLinearGradient,B as getMatchingSentences,mt as getMatrix,w as getMime,Ga as getPerformance,Ot as getPixelRatio,g as getRandomString,xa as getReportUrl,La as getStatus,bt as getTangentByPointer,hn as getWindow,Ta as handleConsole,_t as handleError,ea as handleFetchHook,Ua as handleXhrHook,C as hexToAlpha,ns as hexToHsb,ms as hexToHsv,F as hexToRgb,rs as hsbToHsl,x as hsbToRgb,o as hslToHsb,os as hslToHsv,y as hslToRgb,m as hsvToHsl,r as hsvToRgb,d as hue2rgb,Ut as imageRequest,Es as indexForOffset,kt as inflateRaw,Va as inverseLerp,sn as isClient,Js as isEqual,Na as isImageSize,Et as isInIframe,Pt as isMobile,un as isSafari,Ma as isSpeechRecognitionSupported,a as isString,js as isUrlCached,Rt as isWeiXin,ht as lerp,U as linearToSrgb,ya as linearstep,jt as loadScript,Qt as localStorageGetItem,tn as localStorageRemoveItem,cn as localStorageSetItem,t as luma,St as matchMediaQuery,Aa as mathjs,L as md5,aa as memoize,Bt as merge,us as mergeExports,Kt as navigatorLanguage,Pa as networkAllowsDownload,Vt as networkSpeed,Ys as noop,ks as once,ua as opacity,Qa as openPortBridge,sa as paginateText,st as parseChineseNumber,Ja as parseEnglishNumber,Ha as parseRomanNumber,dn as parseVttCueTiming,Dt as parseVttTimestamp,Da as perToNum,Gt as performanceTime,Ls as prefetchUrl,Ns as prefetchUrls,Ts as prefetchWhenIdle,Ia as quad,Ea as quart,Ht as queryFlag,$s as querystring,ja as quint,T as randomColor,as as randomString,fa as range,Gs as readFileAsArrayBuffer,At as readFileAsDataURL,ls as readFileAsText,Zs as readFileAsUint8Array,ha as readZipEntries,yt as readZipEntry,et as remap,vs as removeClassToElement,zs as replaceOld,za as report,Ft as requestUrlToBuffer,rn as resolveLocale,Ks as rewriteZip,h as rgbToHex,b as rgbToHsb,e as rgbToHsl,i as rgbToHsv,j as rgbaString,u as rgbaToHex,v as rgbaToRgb,_a as roundRectByArc,is as saturation,Oa as scriptOnLoad,tt as segmentByRanges,Hs as serveWorker,es as setFontSize2html,p as setMime,$a as setReportUrl,gt as sine,Fs as singleFlight,wt as smoothstep,n as srgbToLinear,ca as status,J as strParse,Ps as subscribers,it as throttle,Lt as timeFormat,qt as timestampToTime,Y as toFullWidth,S as toHalfWidth,E as toString,ba as transformNumber,O as transformText,$ as truncate,pn as useI18n,k as vibrance,It as watchMediaQuery,xs as whenIdle,Rs as withTimeout,Sa as withTimeoutFallback,hs as zipHasEntry};
|
|
@@ -79,4 +79,64 @@ export declare const parseRomanNumber: (value: string) => number | null;
|
|
|
79
79
|
* ```
|
|
80
80
|
*/
|
|
81
81
|
export declare const parseEnglishNumber: (value: string) => number | null;
|
|
82
|
+
/**
|
|
83
|
+
* @description: Clamp `value` into the inclusive range `[min, max]`.
|
|
84
|
+
* @param {number} value
|
|
85
|
+
* @param {number} min
|
|
86
|
+
* @param {number} max
|
|
87
|
+
* @return {number}
|
|
88
|
+
*/
|
|
89
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
90
|
+
/**
|
|
91
|
+
* @description: Linear interpolation from `a` to `b` by `t` (t=0 → a, t=1 → b). Not clamped.
|
|
92
|
+
* @param {number} a start value
|
|
93
|
+
* @param {number} b end value
|
|
94
|
+
* @param {number} t interpolation factor
|
|
95
|
+
* @return {number}
|
|
96
|
+
*/
|
|
97
|
+
export declare const lerp: (a: number, b: number, t: number) => number;
|
|
98
|
+
/**
|
|
99
|
+
* @description: Inverse of `lerp` — where `value` sits between `a` and `b`, as 0..1. Returns 0 when `a === b`. Not clamped.
|
|
100
|
+
* @param {number} a start value
|
|
101
|
+
* @param {number} b end value
|
|
102
|
+
* @param {number} value probed value
|
|
103
|
+
* @return {number}
|
|
104
|
+
*/
|
|
105
|
+
export declare const inverseLerp: (a: number, b: number, value: number) => number;
|
|
106
|
+
/**
|
|
107
|
+
* @description: Linearly remap `value` from range `[a1, a2]` onto `[b1, b2]`. Not clamped (GLSL-style map).
|
|
108
|
+
* @param {number} value
|
|
109
|
+
* @param {number} a1 input range start
|
|
110
|
+
* @param {number} a2 input range end
|
|
111
|
+
* @param {number} b1 output range start
|
|
112
|
+
* @param {number} b2 output range end
|
|
113
|
+
* @return {number}
|
|
114
|
+
*/
|
|
115
|
+
export declare const remap: (value: number, a1: number, a2: number, b1: number, b2: number) => number;
|
|
116
|
+
/**
|
|
117
|
+
* @description: Remap `value` from `[a1, a2]` onto `[b1, b2]` and clamp to the output range — the shader `fit`.
|
|
118
|
+
* @param {number} value
|
|
119
|
+
* @param {number} a1 input range start
|
|
120
|
+
* @param {number} a2 input range end
|
|
121
|
+
* @param {number} b1 output range start
|
|
122
|
+
* @param {number} b2 output range end
|
|
123
|
+
* @return {number}
|
|
124
|
+
*/
|
|
125
|
+
export declare const fit: (value: number, a1: number, a2: number, b1: number, b2: number) => number;
|
|
126
|
+
/**
|
|
127
|
+
* @description: Linear ramp — 0 below `edge0`, 1 above `edge1`, a straight line between (the shader `linearstep`, no smoothing).
|
|
128
|
+
* @param {number} edge0
|
|
129
|
+
* @param {number} edge1
|
|
130
|
+
* @param {number} x
|
|
131
|
+
* @return {number}
|
|
132
|
+
*/
|
|
133
|
+
export declare const linearstep: (edge0: number, edge1: number, x: number) => number;
|
|
134
|
+
/**
|
|
135
|
+
* @description: Smooth Hermite interpolation between 0 and 1 for `edge0 < x < edge1` (GLSL `smoothstep`).
|
|
136
|
+
* @param {number} edge0
|
|
137
|
+
* @param {number} edge1
|
|
138
|
+
* @param {number} x
|
|
139
|
+
* @return {number}
|
|
140
|
+
*/
|
|
141
|
+
export declare const smoothstep: (edge0: number, edge1: number, x: number) => number;
|
|
82
142
|
export {};
|
package/dist/src/utils/obj.d.ts
CHANGED
|
@@ -64,20 +64,9 @@ export declare function replaceOld(source: any, name: string, replacement: (...a
|
|
|
64
64
|
* @return {Object}
|
|
65
65
|
*/
|
|
66
66
|
export declare const mergeExports: (obj: Record<string, string>, exports: Record<string, string>) => Record<string, string>;
|
|
67
|
-
/**
|
|
68
|
-
* @description: Define a property on the global object
|
|
69
|
-
* @param {string} name
|
|
70
|
-
* @param {string} value
|
|
71
|
-
* @return {*}
|
|
72
|
-
*/
|
|
73
|
-
export declare const setAttributeByGlobal: (name: string, value: unknown) => void;
|
|
74
67
|
/**
|
|
75
68
|
* Deep-compare two values, in the manner of Lodash's isEqual.
|
|
76
69
|
*/
|
|
77
|
-
/**
|
|
78
|
-
* Whether two primitives are the same value, handling the special cases NaN and -0/+0.
|
|
79
|
-
*/
|
|
80
|
-
export declare function sameValueZero(x: any, y: any): boolean;
|
|
81
70
|
/**
|
|
82
71
|
* Whether the value is object-like
|
|
83
72
|
*/
|