@huxy/router
Advanced tools
+2
-2
@@ -107,3 +107,3 @@ import*as D from"react";var Qe={670:(e,t,n)=>{n.d(t,{A:()=>i});var s=n(758),r=n.n(s),o=n(935),c=n.n(o),a=c()(r());a.push([e.id,`@keyframes before { | ||
| `,""]);var i="Iuy_e",l="D3oJg";const u=a},935:e=>{e.exports=function(t){var n=[];return n.toString=function(){return this.map(function(r){var o="",c=typeof r[5]<"u";return r[4]&&(o+="@supports (".concat(r[4],") {")),r[2]&&(o+="@media ".concat(r[2]," {")),c&&(o+="@layer".concat(r[5].length>0?" ".concat(r[5]):""," {")),o+=t(r),c&&(o+="}"),r[2]&&(o+="}"),r[4]&&(o+="}"),o}).join("")},n.i=function(r,o,c,a,i){typeof r=="string"&&(r=[[null,r,void 0]]);var l={};if(c)for(var u=0;u<this.length;u++){var p=this[u][0];p!=null&&(l[p]=!0)}for(var h=0;h<r.length;h++){var f=[].concat(r[h]);c&&l[f[0]]||(typeof i<"u"&&(typeof f[5]>"u"||(f[1]="@layer".concat(f[5].length>0?" ".concat(f[5]):""," {").concat(f[1],"}")),f[5]=i),o&&(f[2]&&(f[1]="@media ".concat(f[2]," {").concat(f[1],"}")),f[2]=o),a&&(f[4]?(f[1]="@supports (".concat(f[4],") {").concat(f[1],"}"),f[4]=a):f[4]="".concat(a)),n.push(f))}},n}},758:e=>{e.exports=function(t){return t[1]}},197:(e,t)=>{var n;var s=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(c,a,i){var l=null;if(i!==void 0&&(l=""+i),a.key!==void 0&&(l=""+a.key),"key"in a){i={};for(var u in a)u!=="key"&&(i[u]=a[u])}else i=a;return a=i.ref,{$$typeof:s,type:c,key:l,ref:a!==void 0?a:null,props:i}}n=r,t.jsx=o,t.jsxs=o},85:(e,t,n)=>{e.exports=n(197)},591:e=>{var t=[];function n(o){for(var c=-1,a=0;a<t.length;a++)if(t[a].identifier===o){c=a;break}return c}function s(o,c){for(var a={},i=[],l=0;l<o.length;l++){var u=o[l],p=c.base?u[0]+c.base:u[0],h=a[p]||0,f="".concat(p," ").concat(h);a[p]=h+1;var d=n(f),g={css:u[1],media:u[2],sourceMap:u[3],supports:u[4],layer:u[5]};if(d!==-1)t[d].references++,t[d].updater(g);else{var _=r(g,c);c.byIndex=l,t.splice(l,0,{identifier:f,updater:_,references:1})}i.push(f)}return i}function r(o,c){var a=c.domAPI(c);a.update(o);var i=function(u){if(u){if(u.css===o.css&&u.media===o.media&&u.sourceMap===o.sourceMap&&u.supports===o.supports&&u.layer===o.layer)return;a.update(o=u)}else a.remove()};return i}e.exports=function(o,c){c=c||{},o=o||[];var a=s(o,c);return function(l){l=l||[];for(var u=0;u<a.length;u++){var p=a[u],h=n(p);t[h].references--}for(var f=s(l,c),d=0;d<a.length;d++){var g=a[d],_=n(g);t[_].references===0&&(t[_].updater(),t.splice(_,1))}a=f}}},128:e=>{var t={};function n(r){if(typeof t[r]>"u"){var o=document.querySelector(r);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch{o=null}t[r]=o}return t[r]}function s(r,o){var c=n(r);if(!c)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");c.appendChild(o)}e.exports=s},51:e=>{function t(n){var s=document.createElement("style");return n.setAttributes(s,n.attributes),n.insert(s,n.options),s}e.exports=t},855:(e,t,n)=>{function s(r){var o=n.nc;o&&r.setAttribute("nonce",o)}e.exports=s},740:e=>{function t(r,o,c){var a="";c.supports&&(a+="@supports (".concat(c.supports,") {")),c.media&&(a+="@media ".concat(c.media," {"));var i=typeof c.layer<"u";i&&(a+="@layer".concat(c.layer.length>0?" ".concat(c.layer):""," {")),a+=c.css,i&&(a+="}"),c.media&&(a+="}"),c.supports&&(a+="}");var l=c.sourceMap;l&&typeof btoa<"u"&&(a+=` | ||
| /*# sourceMappingURL=data:application/json;base64,`.concat(btoa(unescape(encodeURIComponent(JSON.stringify(l))))," */")),o.styleTagTransform(a,r,o.options)}function n(r){if(r.parentNode===null)return!1;r.parentNode.removeChild(r)}function s(r){if(typeof document>"u")return{update:function(){},remove:function(){}};var o=r.insertStyleElement(r);return{update:function(a){t(o,r,a)},remove:function(){n(o)}}}e.exports=s},656:e=>{function t(n,s){if(s.styleSheet)s.styleSheet.cssText=n;else{for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(document.createTextNode(n))}}e.exports=t}},Ee={};function b(e){var t=Ee[e];if(t!==void 0)return t.exports;var n=Ee[e]={id:e,exports:{}};return Qe[e](n,n.exports,b),n.exports}b.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return b.d(t,{a:t}),t},b.d=(e,t)=>{for(var n in t)b.o(t,n)&&!b.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},b.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),b.nc=void 0;var w={};b.d(w,{N_:()=>yr,vY:()=>Cr,aM:()=>Er,RY:()=>Le,oe:()=>ge,jd:()=>jt,lq:()=>xr,rd:()=>_r});var Ze=e=>{var t={};return b.d(t,e),t},Fr=e=>()=>e;const v=Ze({Suspense:()=>D.Suspense,default:()=>D.default,useCallback:()=>D.useCallback,useEffect:()=>D.useEffect,useRef:()=>D.useRef,useState:()=>D.useState}),Ke=(e=null)=>{const t=(0,v.useRef)(e);return()=>t},K=Ke,et=e=>Object.prototype.toString.call(e).slice(8,-1).toLowerCase(),ee=et,tt=e=>ee(e)==="array",M=tt,rt=e=>ee(e)==="object",A=rt,nt=e=>e?.$$typeof&&typeof e.$$typeof=="symbol"&&e.$$typeof.description?.indexOf("react.")===0,ie=nt,st=e=>e?.__v_isVNode,ot=st,ct=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),Ce=ct,Se=e=>{if(!M(e)&&!A(e))return e;const t=M(e)?[]:{};for(const n in e)if(Ce(e,n)){const s=e[n];t[n]=ie(s)||ot(s)||typeof s!="object"?s:s!==e?Se(s):"cyclic"}else Object.setPrototypeOf(t,{[n]:e[n]});return t},Y=Se,at=e=>ee(e)==="function",le=at,ut=e=>ee(e)==="promise"||A(e)&&le(e.then),J=ut,it=(e,t=3e5,n="\u8BF7\u6C42\u8D85\u65F6\uFF01")=>{if(!J(e))return{};let s=null,r=null;return{promiseFn:new Promise((c,a)=>{s=(i="canceled")=>{clearTimeout(r),c({canceled:!0,errMsg:i})},t&&(t=typeof t!="number"?12e4:t,r=setTimeout(()=>s(n),t)),e.then(i=>{clearTimeout(r),c({result:i,errMsg:!1})}).catch(i=>{clearTimeout(r),a(i)})}),cancelFn:s}},Re=it,lt=e=>e?e.charAt(e.length-1)==="/"?e.slice(0,-1):e:"",Ae=lt;var C=b(85);const ft=(e,t)=>(0,C.jsx)("div",{dangerouslySetInnerHTML:{__html:e},...t}),pt=ft,dt=e=>{const{error:t={},info:n=""}=e||{},{message:s,stack:r,errMsg:o}=t;let c=o||r||t.toString();c=`${c} | ||
| ${n}`.replace(/\r|\n|\r\n/g,"<br/>"),c=c.replace(/\t/g," "),c=c.replace(/\s/g," ");const a=s?.slice(0,120).split(". ").slice(0,2).join(". ");return(0,C.jsxs)("div",{style:{padding:"15px 20px",backgroundColor:"#fff",wordWrap:"break-word"},children:[pt(c,{style:{color:"red"}}),a&&(0,C.jsxs)("a",{style:{display:"inline-block",padding:"15px",color:"#00b4cf"},href:`https://stackoverflow.com/search?q=${a}`,target:"_blank",children:[" ","--> \u53BB\u7F51\u4E0A\u67E5\u627E\u9519\u8BEF\u539F\u56E0\uFF1F"]})]})},te=dt,_t=e=>/^https?:\/\/[^\s/?.#]+\.[^\s]+/.test(e),V=_t,mt=()=>{const e={};return{on:(r,o)=>{e[r]||(e[r]=[]),e[r].indexOf(o)===-1&&e[r].push(o)},emit:(r,o)=>{e[r]&&e[r].map(c=>c(o))},off:(r,o=null)=>{if(e[r]){if(typeof o!="function")return delete e[r];const c=e[r].indexOf(o);c>-1&&(e[r].splice(c,1),e[r].length||delete e[r])}}}},X=mt,Pe=e=>{const t={};for(let n in e)Ce(e,n)||(t[n]=e[n]);return t},ht=(e,t)=>{if(!A(e))return t;if(!A(t))return e;const n={...Pe(e),...Pe(t)},s={...e,...t};return Object.keys(n).map(r=>{Object.setPrototypeOf(s,{[r]:n[r]})}),s},gt=ht,vt=(e=X())=>{const{on:t,emit:n,off:s}=e,r={};return{getState:l=>Y(r[l]),setState:(l,u=!1)=>{if(typeof l=="function"&&(l=l(Y(r))),!A(l))throw TypeError("\u5FC5\u987B\u4F20\u5165object\u5BF9\u8C61\uFF01");const p=Y(l);Object.keys(p).map(h=>{const f=r[h],d=p[h],g=A(d)&&A(f)?gt(f,d):d;!u&&n(h,g),r[h]=g})},subscribe:(l,u)=>(t(l,u),()=>s(l,u)),unsubscribe:s,clean:l=>{typeof l=="string"?r[l]=void 0:Array.isArray(l)?l.map(u=>r[u]=void 0):Object.keys(r).map(u=>r[u]=void 0)}}},re=vt,yt=e=>(t,n)=>{const[s,r]=(0,v.useState)(()=>{const i=e?.getState(t);return i!==void 0?i:(n!==void 0&&e?.setState({[t]:n},!0),n)}),o=(0,v.useCallback)(i=>e?.setState({[t]:typeof i=="function"?i(e?.getState(t)):i}),[]),c=(0,v.useCallback)(i=>e?.subscribe(t,i),[]),a=(0,v.useCallback)((i=i)=>e?.clean(i),[]);return(0,v.useEffect)(()=>{e?.subscribe(t,i=>r(i))},[]),[s,o,c,a]},ke=yt,bt=re(),Tr=ke(bt),$r=X(),Ir=X(),Dr="push-emitter",Br="replace-emitter",Lr="useRoute-emitter",fe={delay:8e3,timeoutMsg:"\u8BF7\u6C42\u8D85\u65F6\uFF01",cancelMsg:"\u8BF7\u6C42\u5DF2\u53D6\u6D88\uFF01"},pe="/404",xt={getState:()=>history.state,go:e=>history.go(e),forward:()=>history.forward(),back:()=>history.back()},we=(e,t,n,s,r=[])=>{const o=i=>{for(let l=0,u=i.length;l<u;l++){const p=i[l],h=p[s].split("?")[0];if(new RegExp("^"+h.replace(/:[^/]+/g,"[^/]+")+"$").test(t)&&!p.childSameRouteLevel)return p;if(M(p[n])){const d=o(p[n]);if(d)return d}}},c=o(e);if(!c)return pe;const{redirect:a}=c;return a?V(a)?a:r.includes(a)?r:(r.push(a),we(e,a.split("?")[0],n,s,r)):r[r.length-1]},Et=(e,t,n,s,r)=>{if(!M(e))return null;const o=u=>{const p=u.split("/"),h=t.split("/"),f={};return p.map((d,g)=>d.indexOf(":")===0&&(f[d.slice(1)]=h[g])),f},c=(u,p)=>{const h=[],f=p.split("/:")[0];for(let d=0,g=u.length;d<g;d++){const _=u[d];if(_[r]===f){_.active=!0;const{name:m,title:y,icon:E,params:x}=_;h.push({name:m,title:y,icon:E,params:x,[r]:f})}else if(p.indexOf(`${_[r]}/`)===0){_.active=!0;const m=o(_[r]),y=Object.keys(m).map(O=>m[O]).join("/"),{name:E,title:x,icon:S}=_,R=y?`${f}/${y}`:_[r];h.push({name:E,title:x,icon:S,[r]:R,params:{..._.params,...m}})}else if(_[r]===p){_.active=!0;const m=o(_[r]),{[s]:y,...E}=_;h.push({...E,[r]:t,params:{...E.params,...n,...m}})}}return h},a=(u,p)=>{for(let h=0,f=u.length;h<f;h++){const d=u[h];if(p.indexOf(`${d[r]}/`)===0){d.active=!0;return}}},i=u=>{for(let p=0,h=u.length;p<h;p++){const f=u[p],d=(f[r]||"").split("?")[0];if(d===t){if(f.childSameRouteLevel){f.active=!0,f.open=!0;const{[s]:y,...E}=f;return[E,...i(f[s])]}f.hideMenu&&a(u,f.parentPath||d),f.active=!0;const{[s]:_,...m}=f;return[{...m,params:{...m.params,...n}}]}if(new RegExp("^"+d.replace(/:[^/]+/g,"[^/]+")+"$").test(t))return c(u,d);if(M(f[s])){const _=i(f[s]);if(_){f.active=!0,f.open=!0;const{[s]:m,...y}=f;return[y,..._]}}}},l=i(e)||[];return{result:e,current:l}},Me=(e,t,n)=>e.filter(s=>s.hideMenu||s[n].indexOf("/:")>-1?!1:(M(s[t])&&(s[t]=Me(s[t],t,n)),!0)),Ct=(e,t,n,s="children",r="path")=>{const o=we(e,t,s,r);if(o)return{redirect:o};const{result:c,current:a}=Et(e,t,n,s,r),i=Me(c,s,r);return{current:a,menu:i}},St=Ct,Rt=e=>M(e)&&!!e.length,Oe=Rt,de=(e,t)=>{const n=["#/","/"],s=n[!!t-0];if(!e||n.includes(e))return s;const r=e.charAt(e.length-1)==="/"?e.slice(0,-1):e;return t||r.indexOf("#/")>-1?r:`#${r}`},q=(e,t,n,s=!1)=>{const r=de(t,n);return s?r:n?e&&r==="/"?e:`${e}${r}`:e?`${e}/${r}`:r},At=(e,t,n,s,r,o)=>{if(!Oe(e))return e;const c=(a,i="",l=0)=>a.filter(u=>!u.denied).map(u=>{if(!o&&!u.exact&&!V(u[s])){(!u[s]||u[s]==="javascript:;")&&(u[s]="");const p=u[s].charAt(0)==="/"&&i.charAt(i.length-1)==="/"?u[s].slice(1):u[s].charAt(0)!=="/"&&i.charAt(i.length-1)!=="/"?`/${u[s]}`:u[s];u[s]=i?i+p:q(r,p,t)}if(u.redirect&&!V(u.redirect)&&(u.redirect=q(r,u.redirect,t)),Oe(u[n])&&(u[n]=c(u[n],u[s],l+1),!u.redirect)){const p=u[n].findIndex(h=>h[s]===u[s]);p&&(u.redirect=u[n][0][s]),p>-1&&(u.childSameRouteLevel=l+1)}return u});return c(e)},Pt=e=>{if(!A(e))return"";const t=[];return Object.keys(e).map((n,s)=>{const r=s>0?"&":"?";t.push(`${r}${n}=${e[n]}`)}),t.join("")},Fe=Pt,kt=(e="")=>{const[t,n]=e.split("?");if(n){const s={};return n.split("&").map(o=>{const[c,a]=o.split("=");s[c]=a}),{path:t,params:s}}return{path:t}},_e=kt,wt=()=>{document.documentElement.scrollTop?document.documentElement.scrollTop=0:document.body.scrollTop&&(document.body.scrollTop=0)},Mt=(e,t,n={})=>{const s=n.description??"";for(let r=e.length-1,o;o=e[r--];){const{title:c,name:a}=o;if(typeof c=="string"&&c.length)return document.title=c,document.getElementsByTagName("meta").description.content=`${s??""}${c}`,c;if((c==null||c===!0)&&a){const i=t?`${a}-${t}`:a;return document.title=i,document.getElementsByTagName("meta").description.content=`${s??""}${i}`,i}if(t)return document.title=t,document.getElementsByTagName("meta").description.content=`${s??""}${t}`,t}},Ot=e=>{const{pathname:t,search:n,hash:s}=location;if(e){const i=de(t,e),l=decodeURIComponent(`${i}${n}`),{params:u}=_e(l);return{path:l,params:u}}const r=decodeURIComponent(de(s,e)),{params:o}=_e(r),c=Ae(t);return{path:c?`${c}/${r}`:r,params:o}},me=(e,t,n)=>{typeof e=="function"&&e({...t,stay:new Date-n})},Te=(e,t,n,s)=>{let r=typeof e=="string"?e:e.path??"";const o=Fe(e.query);V(r)||(r=q(n,r,s,e.exact)),window?.open(`${r}${o}`,t)},Ft=(e,t,n,s)=>{if(e.target||V(e.path)){Te(e,e.target,t,n);return}let r,o,c;if(typeof e=="string")r=e;else if(A(e))r=e.path,o=e.params,c=e.query;else return;!r||r==="."||r==="./"?r=s:r.indexOf("./")===0?r=`${s.split("?")[0]}${r.replace("./","/")}`:r.indexOf("../")===0&&(r=`${s.split("?")[0].split("/").slice(0,-1).join("/")}${r.replace("../","/")}`),r=q(t,r,n,e?.exact);const a=_e(r);r=a.path;const i={...a.params,...c},l=Fe(i);return r=`${r}${l}`,o={...o,...i},r===s?!1:{path:r,params:o}},$e=(e,t)=>{const n=e.split(t);return n.length>1?["","/"].includes(n[1].slice(0,1)):!1},Tt=X(),$t=e=>{const{on:t,emit:n,off:s}=Tt;return{on:r=>t(e,r),emit:r=>n(e,r),off:r=>s(e,r)}},Ie=$t,It=(e=re())=>(t,n)=>{const{getState:s,setState:r,subscribe:o,unsubscribe:c,clean:a}=e;return n!==void 0&&r({[t]:n},!0),{getState:()=>s(t),setState:(i,l)=>r({[t]:i},l),subscribe:i=>o(t,i),unsubscribe:()=>c(t),clean:()=>a(t)}},De=It,Dt=re(),Bt=De(Dt),Lt=Bt,he=Ie("push-emitter"),Be=Ie("replace-emitter"),B=Lt("route-store"),Le=X(),je=re(Le),ge=De(je),jt=ke(je),Nt=()=>![typeof window,typeof document].includes("undefined"),Ut=Nt,Wt=e=>{if(!Ut())return;const t=document.createElement("div");return t.innerHTML=e,t.children[0]},Ht=Wt;class Yt extends v.default.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){const{errorReport:s}=this.props;typeof s=="function"&&s({error:t,info:n.componentStack})}componentDidUpdate(t,n){n.error&&this.setState({error:null})}render(){const{error:t}=this.state,{fallback:n,children:s}=this.props;return t?n?.(t)??t:s}}const Jt=({children:e,report:t})=>(0,C.jsx)(Yt,{fallback:(n,s)=>te({error:n,info:s}),errorReport:t,children:e}),Vt=Jt;var Xt=b(591),Ne=b.n(Xt),qt=b(740),Ue=b.n(qt),zt=b(128),We=b.n(zt),Gt=b(855),He=b.n(Gt),Qt=b(51),Ye=b.n(Qt),Zt=b(656),Je=b.n(Zt),ne=b(670),L={};L.styleTagTransform=Je(),L.setAttributes=He(),L.insert=We().bind(null,"head"),L.domAPI=Ue(),L.insertStyleElement=Ye();var jr=Ne()(ne.A,L);const Nr=ne.A&&ne.A.locals?ne.A.locals:void 0,Kt=({global:e,absolute:t})=>(0,C.jsx)("div",{className:`spinner${e?" global":""}${t?" absolute":""}`,children:(0,C.jsx)("figure",{className:"spinning"})}),er=Kt,tr=()=>{const e=(0,v.useRef)([]);return(0,v.useEffect)(()=>()=>{e.current.map(t=>t.cancelFn()),e.current=[]},[]),(0,v.useCallback)((t,n=!0)=>{const s=Re(t,n);return e.current.indexOf(s)===-1&&e.current.push(s),s.promiseFn},[])},rr=tr,nr=(e={})=>{const t=rr(),[n,s]=(0,v.useState)(e),r=(0,v.useRef)({}),o=(0,v.useRef)({}),c=(0,v.useCallback)((i=null)=>{Array.isArray(i)&&i.length?i.map(l=>r.current[l]=e[l]):r.current=e},[]),a=(0,v.useCallback)((i,l,u=!1)=>{const p=Object.keys(i),h=JSON.stringify(p.sort());if(!o.current[h]){o.current[h]=!0,u&&c(Array.isArray(u)?u:p),p.map(f=>{r.current[f]||(r.current[f]={}),r.current[f].pending=!0}),s({...r.current});for(let f=0,d=p.length;f<d;f++){const g=p[f];t(i[g]).then(_=>{let{result:m,errMsg:y}=_;f===d-1&&(o.current[h]=!1),typeof l=="function"&&(m=l(m)||m),r.current[g]={...m,pending:!1},y===!1&&s({...r.current})}).catch(_=>{throw f===d-1&&(o.current[h]=!1),r.current[g]={error:_,pending:!1},s({...r.current}),_})}}},[]);return[n,a,c]},Ve=nr,se=e=>Object.keys(e).length,sr=e=>{const{Comp:t,restResolve:n,loadPromise:s,params:r,children:o}=e,[c,a]=Ve(),[i,l]=Ve();return(0,v.useEffect)(()=>{se(n)&&a(n),se(s)&&l(s)},[n,s]),(0,v.useEffect)(()=>{const u=se(c);u&&u===se(n)&&ge.setState(c)},[c]),(0,C.jsx)(t,{...r,...c,...i,children:o})},or=sr,cr=e=>e===!1?null:ie(e)?e:le(e)?(0,C.jsx)(e,{}):(0,C.jsx)(er,{}),ar=({Loading:e,ErrorBoundary:t,loadedComp:n})=>{const s=(0,C.jsx)(v.Suspense,{fallback:cr(e),children:n});return t===!1?s:le(t)?(0,C.jsx)(t,{children:s}):(0,C.jsx)(Vt,{children:s})},ur=({Comp:e,routerProps:t,children:n})=>{const{params:s,...r}=t,{loading:o,errorBoundary:c,...a}=s,i=(0,C.jsx)(or,{Comp:e,...r,params:a,children:n});return ar({Loading:o,ErrorBoundary:c,loadedComp:i})},Xe=ur,ve={},ye=(e,t,n,s)=>J(n)?n.then(r=>Xe({Comp:e,routerProps:t,children:r.default??r})):Xe({Comp:e,routerProps:t,children:n}),ir=(e,t)=>{const n={},s={};return A(e)?(Object.keys(e).map(r=>{const o=ge.getState(r);o==null?s[r]=e[r](t):n[r]=o}),{cachedResolve:n,restResolve:s}):{cachedResolve:n,restResolve:s}},lr=(e,t)=>{if(!A(e))return{};const n={};return Object.keys(e).map(s=>n[s]=e[s](t)),n},fr=e=>{const{current:t,menu:n,...s}=e,r=t.map(a=>{const{component:i,resolve:l,loadData:u,loading:p,errorBoundary:h,icon:f,...d}=a;return d}),o=[...t].filter(a=>a.component),c=(a=0)=>{if(!o.length)return null;const i=o.shift(),{component:l,resolve:u,loadData:p,icon:h,key:f,...d}=i;if(typeof l=="function"||J(l)){const g=`${d.path}${d.childSameRouteLevel??""}`;let _=ve[g];const{cachedResolve:m,restResolve:y}=ir(u,d),x={loadPromise:lr(p,d),restResolve:y,params:{current:r,...s,...d,...m}},S=c(a+1);if(_)return ye(_,x,S,g);try{_=l(),_=ie(_)?l:_}catch{_=l}return J(_)?_.then(R=>(_=R.default??R,ve[g]=_,ye(_,x,S,g))):(ve[g]=_,ye(_,x,S,g))}return typeof l=="string"?Ht(l):l};return c()},pr=fr,dr=e=>{const[t,n]=(0,v.useState)(e),[s,r]=(0,v.useState)(),[o,c]=(0,v.useState)(),a=K()(),i=K()(),l=K()(),u=K()(),p=()=>{typeof a.current=="function"&&(a.current({cancel:fe.cancelMsg}),a.current=null)},h=(0,v.useCallback)(m=>{typeof m=="function"?n(y=>({...y,...m(y)})):A(m)&&n(y=>({...y,...m}))},[]),f=(m,y="pushState")=>{const{basepath:E,browserRouter:x}=u.current,S=l.current,R=Ft(m,E,x,S);if(!R)return;const{path:O,params:I}=R;_({inputPath:O,inputParams:I},()=>history[y](m?.state,"",O))},d=(0,v.useCallback)(m=>f(m),[]),g=(0,v.useCallback)(m=>f(m,"replaceState"),[]),_=(0,v.useCallback)(({inputPath:m="",inputParams:y={}},E)=>{const x=+new Date,{browserRouter:S,childKey:R,idKey:O,title:I,metas:z,routers:G,beforeRender:N,afterRender:U,basepath:W,allowedNotFound:k,...qe}=u.current;if(!m){const{path:P,params:F}=Ot(S);m=P,y={...y,...F}}const oe=l.current;new Promise((P,F)=>{G?.length||F("\u8DEF\u7531\u4E3A\u7A7A\uFF01"),m!==l.current&&typeof N=="function"?N({path:m,params:y,prevPath:oe},P,F):P()}).then(P=>{if(P===!1)return;const F=P?.path;if(F&&q(W,F,S)!==m){g(P);return}i.current=i.current??m;const{redirect:T,current:H,menu:ze}=St(Y(G),m.split("?")[0],y,R,O);if(T){if(k&&T===pe&&(typeof k=="boolean"||typeof k=="string"&&$e(i.current,k)||M(k)&&k.find(ae=>$e(i.current,ae))))return;if(M(T)){console.error(`\u522B\u95F9\uFF0C[${[m,...T].join(" -> ")}] \u91CD\u5B9A\u5411\u6B7B\u5FAA\u73AF\uFF01\uFF01\uFF01`);return}return T===pe?g({path:T}):d({path:T,exact:!0})}E?.(),m?.split("?")[0]!==l.current?.split("?")[0]&&wt(),Mt(H,I,z);const be={...qe,updateRouter:h,router:{push:d,replace:g},current:H,menu:ze,inputPath:i.current,prevPath:oe,browserRouter:S,basepath:W,title:I,history:{...xt,goBack:Q=>d({...Q,path:oe})}};B.setState(be);const ce=pr(be);if(l.current=m,i.current=null,p(),J(ce)){const{promiseFn:Q,cancelFn:ae}=Re(ce,{delay:fe.delay,msg:{timeout:fe.timeoutMsg}});return a.current=ae,c(!0),Q.then(Z=>{a.current=null;const{result:Ge,errMsg:ue}=Z,xe=ue===!1?Ge:ue?.timeout?te({error:{errMsg:`${m} ${ue.timeout}`}}):null;xe&&(c(!1),me(U,H.slice(-1)[0],x),r(xe))}).catch(Z=>{throw a.current=null,c(!1),me(U,H.slice(-1)[0],x),r(te({error:Z})),Z})}me(U,H.slice(-1)[0],x),r(ce)}).catch(P=>{throw r(te({error:P})),P})},[]);return(0,v.useEffect)(()=>{const m={description:document.getElementsByTagName("meta").description.content??""},{childKey:y="children",idKey:E="path",browserRouter:x=!1,routers:S=[],basepath:R="",exact:O=!1,inputPath:I="",inputParams:z={},...G}=t,N=Ae(R),U=At(Y(S),x,y,E,N,O);u.current={...G,childKey:y,idKey:E,browserRouter:x,routers:U,basepath:N,metas:m};const W=x?"popstate":"hashchange",k=()=>_({});return _({inputPath:I,inputParams:z}),he.on(d),Be.on(g),window.addEventListener(W,k,!1),()=>{p(),he.off(d),Be.off(g),window.removeEventListener(W,k,!1)}},[t]),{updateRouter:h,output:s,loading:o}},_r=dr,mr=e=>{const{to:t,onClick:n,preventDefault:s,stopPropagation:r=!0,exact:o=!0,target:c,...a}=e,i=()=>{const u=typeof t=="string"?{exact:o,path:t}:{exact:o,...t};he.emit(u)};return u=>{if(u.preventDefault(),r&&u.stopPropagation(),!a?.disabled){if(!s){if(c){const{browserRouter:p,basepath:h}=B.getState();Te(t,c,h,p);return}i()}typeof n=="function"&&n()}}},hr=mr;var $=b(845),j={};j.styleTagTransform=Je(),j.setAttributes=He(),j.insert=We().bind(null,"head"),j.domAPI=Ue(),j.insertStyleElement=Ye();var Ur=Ne()($.Ay,j);const Wr=$.Ay&&$.Ay.locals?$.Ay.locals:void 0,gr=e=>{if(!e)return $.nf;const t=e.trim().split(" ").filter(Boolean),s=t.find(r=>r==="active")?[$.vu]:[];return[$.nf,...s,...t].join(" ")},vr=e=>{const{to:t,onClick:n,preventDefault:s,stopPropagation:r,exact:o,target:c,className:a,...i}=e;return(0,C.jsx)("span",{onClick:hr(e),className:gr(a),...i})},yr=vr,br=()=>{const[e,t]=(0,v.useState)(B.getState());return(0,v.useEffect)(()=>B.subscribe(n=>t(n)),[]),e},xr=br,Er=B.getState,Cr=B.subscribe;var Sr=w.N_,Rr=w.vY,Ar=w.aM,Pr=w.RY,kr=w.oe,wr=w.jd,Mr=w.lq,Or=w.rd;export{Sr as Link,Rr as emitRoute,Ar as getRoute,Pr as huxyBus,kr as huxyStore,wr as useHuxyStore,Mr as useRoute,Or as useRouter}; | ||
| /*# sourceMappingURL=data:application/json;base64,`.concat(btoa(unescape(encodeURIComponent(JSON.stringify(l))))," */")),o.styleTagTransform(a,r,o.options)}function n(r){if(r.parentNode===null)return!1;r.parentNode.removeChild(r)}function s(r){if(typeof document>"u")return{update:function(){},remove:function(){}};var o=r.insertStyleElement(r);return{update:function(a){t(o,r,a)},remove:function(){n(o)}}}e.exports=s},656:e=>{function t(n,s){if(s.styleSheet)s.styleSheet.cssText=n;else{for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(document.createTextNode(n))}}e.exports=t}},Ee={};function b(e){var t=Ee[e];if(t!==void 0)return t.exports;var n=Ee[e]={id:e,exports:{}};return Qe[e](n,n.exports,b),n.exports}b.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return b.d(t,{a:t}),t},b.d=(e,t)=>{for(var n in t)b.o(t,n)&&!b.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},b.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),b.nc=void 0;var w={};b.d(w,{N_:()=>yr,vY:()=>Cr,aM:()=>Er,RY:()=>Le,oe:()=>ge,jd:()=>jt,lq:()=>xr,rd:()=>_r});var Ze=e=>{var t={};return b.d(t,e),t},Tr=e=>()=>e;const v=Ze({Suspense:()=>D.Suspense,default:()=>D.default,useCallback:()=>D.useCallback,useEffect:()=>D.useEffect,useRef:()=>D.useRef,useState:()=>D.useState}),Ke=(e=null)=>{const t=(0,v.useRef)(e);return()=>t},K=Ke,et=e=>Object.prototype.toString.call(e).slice(8,-1).toLowerCase(),ee=et,tt=e=>ee(e)==="array",M=tt,rt=e=>ee(e)==="object",A=rt,nt=e=>e?.$$typeof&&typeof e.$$typeof=="symbol"&&e.$$typeof.description?.indexOf("react.")===0,ie=nt,st=e=>e?.__v_isVNode,ot=st,ct=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),Ce=ct,Se=e=>{if(!M(e)&&!A(e))return e;const t=M(e)?[]:{};for(const n in e)if(Ce(e,n)){const s=e[n];t[n]=ie(s)||ot(s)||typeof s!="object"?s:s!==e?Se(s):"cyclic"}else Object.setPrototypeOf(t,{[n]:e[n]});return t},Y=Se,at=e=>ee(e)==="function",le=at,ut=e=>ee(e)==="promise"||A(e)&&le(e.then),J=ut,it=(e,t=3e5,n="\u8BF7\u6C42\u8D85\u65F6\uFF01")=>{if(!J(e))return{};let s=null,r=null;return{promiseFn:new Promise((c,a)=>{s=(i="canceled")=>{clearTimeout(r),c({canceled:!0,errMsg:i})},t&&(t=typeof t!="number"?12e4:t,r=setTimeout(()=>s(n),t)),e.then(i=>{clearTimeout(r),c({result:i,errMsg:!1})}).catch(i=>{clearTimeout(r),a(i)})}),cancelFn:s}},Re=it,lt=e=>e?e.charAt(e.length-1)==="/"?e.slice(0,-1):e:"",Ae=lt;var C=b(85);const ft=(e,t)=>(0,C.jsx)("div",{dangerouslySetInnerHTML:{__html:e},...t}),pt=ft,dt=e=>{const{error:t={},info:n=""}=e||{},{message:s,stack:r,errMsg:o}=t;let c=o||r||t.toString();c=`${c} | ||
| ${n}`.replace(/\r|\n|\r\n/g,"<br/>"),c=c.replace(/\t/g," "),c=c.replace(/\s/g," ");const a=s?.slice(0,120).split(". ").slice(0,2).join(". ");return(0,C.jsxs)("div",{style:{padding:"15px 20px",backgroundColor:"#fff",wordWrap:"break-word"},children:[pt(c,{style:{color:"red"}}),a&&(0,C.jsxs)("a",{style:{display:"inline-block",padding:"15px",color:"#00b4cf"},href:`https://stackoverflow.com/search?q=${a}`,target:"_blank",children:[" ","--> \u53BB\u7F51\u4E0A\u67E5\u627E\u9519\u8BEF\u539F\u56E0\uFF1F"]})]})},te=dt,_t=e=>/^https?:\/\/[^\s/?.#]+\.[^\s]+/.test(e),V=_t,mt=()=>{const e={};return{on:(r,o)=>{e[r]||(e[r]=[]),e[r].indexOf(o)===-1&&e[r].push(o)},emit:(r,o)=>{e[r]&&e[r].map(c=>c(o))},off:(r,o=null)=>{if(e[r]){if(typeof o!="function")return delete e[r];const c=e[r].indexOf(o);c>-1&&(e[r].splice(c,1),e[r].length||delete e[r])}}}},X=mt,Pe=e=>{const t={};for(let n in e)Ce(e,n)||(t[n]=e[n]);return t},ht=(e,t)=>{if(!A(e))return t;if(!A(t))return e;const n={...Pe(e),...Pe(t)},s={...e,...t};return Object.keys(n).map(r=>{Object.setPrototypeOf(s,{[r]:n[r]})}),s},gt=ht,vt=(e=X())=>{const{on:t,emit:n,off:s}=e,r={};return{getState:l=>Y(r[l]),setState:(l,u=!1)=>{if(typeof l=="function"&&(l=l(Y(r))),!A(l))throw TypeError("\u5FC5\u987B\u4F20\u5165object\u5BF9\u8C61\uFF01");const p=Y(l);Object.keys(p).map(h=>{const f=r[h],d=p[h],g=A(d)&&A(f)?gt(f,d):d;!u&&n(h,g),r[h]=g})},subscribe:(l,u)=>(t(l,u),()=>s(l,u)),unsubscribe:s,clean:l=>{typeof l=="string"?r[l]=void 0:Array.isArray(l)?l.map(u=>r[u]=void 0):Object.keys(r).map(u=>r[u]=void 0)}}},re=vt,yt=e=>(t,n)=>{const[s,r]=(0,v.useState)(()=>{const i=e?.getState(t);return i!==void 0?i:(n!==void 0&&e?.setState({[t]:n},!0),n)}),o=(0,v.useCallback)(i=>e?.setState({[t]:typeof i=="function"?i(e?.getState(t)):i}),[]),c=(0,v.useCallback)(i=>e?.subscribe(t,i),[]),a=(0,v.useCallback)((i=i)=>e?.clean(i),[]);return(0,v.useEffect)(()=>{e?.subscribe(t,i=>r(i))},[]),[s,o,c,a]},ke=yt,bt=re(),Fr=ke(bt),$r=X(),Ir=X(),Dr="push-emitter",Br="replace-emitter",Lr="useRoute-emitter",fe={delay:8e3,timeoutMsg:"\u8BF7\u6C42\u8D85\u65F6\uFF01",cancelMsg:"\u8BF7\u6C42\u5DF2\u53D6\u6D88\uFF01"},pe="/404",xt={getState:()=>history.state,go:e=>history.go(e),forward:()=>history.forward(),back:()=>history.back()},we=(e,t,n,s,r=[])=>{const o=i=>{for(let l=0,u=i.length;l<u;l++){const p=i[l],h=p[s].split("?")[0];if(new RegExp("^"+h.replace(/:[^/]+/g,"[^/]+")+"$").test(t)&&!p.childSameRouteLevel)return p;if(M(p[n])){const d=o(p[n]);if(d)return d}}},c=o(e);if(!c)return pe;const{redirect:a}=c;return a?V(a)?a:r.includes(a)?r:(r.push(a),we(e,a.split("?")[0],n,s,r)):r[r.length-1]},Et=(e,t,n,s,r)=>{if(!M(e))return null;const o=u=>{const p=u.split("/"),h=t.split("/"),f={};return p.map((d,g)=>d.indexOf(":")===0&&(f[d.slice(1)]=h[g])),f},c=(u,p)=>{const h=[],f=p.split("/:")[0];for(let d=0,g=u.length;d<g;d++){const _=u[d];if(_[r]===f){_.active=!0;const{name:m,title:y,icon:E,params:x}=_;h.push({name:m,title:y,icon:E,params:x,[r]:f})}else if(p.indexOf(`${_[r]}/`)===0){_.active=!0;const m=o(_[r]),y=Object.keys(m).map(O=>m[O]).join("/"),{name:E,title:x,icon:S}=_,R=y?`${f}/${y}`:_[r];h.push({name:E,title:x,icon:S,[r]:R,params:{..._.params,...m}})}else if(_[r]===p){_.active=!0;const m=o(_[r]),{[s]:y,...E}=_;h.push({...E,[r]:t,params:{...E.params,...n,...m}})}}return h},a=(u,p)=>{for(let h=0,f=u.length;h<f;h++){const d=u[h];if(p.indexOf(`${d[r]}/`)===0){d.active=!0;return}}},i=u=>{for(let p=0,h=u.length;p<h;p++){const f=u[p],d=(f[r]||"").split("?")[0];if(d===t){if(f.childSameRouteLevel){f.active=!0,f.open=!0;const{[s]:y,...E}=f;return[E,...i(f[s])]}f.hideMenu&&a(u,f.parentPath||d),f.active=!0;const{[s]:_,...m}=f;return[{...m,params:{...m.params,...n}}]}if(new RegExp("^"+d.replace(/:[^/]+/g,"[^/]+")+"$").test(t))return c(u,d);if(M(f[s])){const _=i(f[s]);if(_){f.active=!0,f.open=!0;const{[s]:m,...y}=f;return[y,..._]}}}},l=i(e)||[];return{result:e,current:l}},Me=(e,t,n)=>e.filter(s=>s.hideMenu||s[n].indexOf("/:")>-1?!1:(M(s[t])&&(s[t]=Me(s[t],t,n)),!0)),Ct=(e,t,n,s="children",r="path")=>{const o=we(e,t,s,r);if(o)return{redirect:o};const{result:c,current:a}=Et(e,t,n,s,r),i=Me(c,s,r);return{current:a,menu:i}},St=Ct,Rt=e=>M(e)&&!!e.length,Oe=Rt,de=(e,t)=>{const n=["#/","/"],s=n[!!t-0];if(!e||n.includes(e))return s;const r=e.charAt(e.length-1)==="/"?e.slice(0,-1):e;return t||r.indexOf("#/")>-1?r:`#${r}`},q=(e,t,n,s=!1)=>{const r=de(t,n);return s?r:n?e&&r==="/"?e:`${e}${r}`:e?`${e}/${r}`:r},At=(e,t,n,s,r,o)=>{if(!Oe(e))return e;const c=(a,i="",l=0)=>a.filter(u=>!u.denied).map(u=>{if(!o&&!u.exact&&!V(u[s])){(!u[s]||u[s]==="javascript:;")&&(u[s]="");const p=u[s].charAt(0)==="/"&&i.charAt(i.length-1)==="/"?u[s].slice(1):u[s].charAt(0)!=="/"&&i.charAt(i.length-1)!=="/"?`/${u[s]}`:u[s];u[s]=i?i+p:q(r,p,t)}if(u.redirect&&!V(u.redirect)&&(u.redirect=q(r,u.redirect,t)),Oe(u[n])&&(u[n]=c(u[n],u[s],l+1),!u.redirect)){const p=u[n].findIndex(h=>h[s]===u[s]);p&&(u.redirect=u[n][0][s]),p>-1&&(u.childSameRouteLevel=l+1)}return u});return c(e)},Pt=e=>{if(!A(e))return"";const t=[];return Object.keys(e).map((n,s)=>{const r=s>0?"&":"?";t.push(`${r}${n}=${e[n]}`)}),t.join("")},Te=Pt,kt=(e="")=>{const[t,n]=e.split("?");if(n){const s={};return n.split("&").map(o=>{const[c,a]=o.split("=");s[c]=a}),{path:t,params:s}}return{path:t}},_e=kt,wt=()=>{document.documentElement.scrollTop?document.documentElement.scrollTop=0:document.body.scrollTop&&(document.body.scrollTop=0)},Mt=(e,t,n={})=>{const s=n.description??"";for(let r=e.length-1,o;o=e[r--];){const{title:c,name:a}=o;if(typeof c=="string"&&c.length)return document.title=c,document.getElementsByTagName("meta").description.content=`${s??""}${c}`,c;if((c==null||c===!0)&&a){const i=t?`${a}-${t}`:a;return document.title=i,document.getElementsByTagName("meta").description.content=`${s??""}${i}`,i}if(t)return document.title=t,document.getElementsByTagName("meta").description.content=`${s??""}${t}`,t}},Ot=e=>{const{pathname:t,search:n,hash:s}=location;if(e){const i=de(t,e),l=decodeURIComponent(`${i}${n}`),{params:u}=_e(l);return{path:l,params:u}}const r=decodeURIComponent(de(s,e)),{params:o}=_e(r),c=Ae(t);return{path:c?`${c}/${r}`:r,params:o}},me=(e,t,n)=>{typeof e=="function"&&e({...t,stay:new Date-n})},Fe=(e,t,n,s)=>{let r=typeof e=="string"?e:e.path??"";const o=Te(e.query);V(r)||(r=q(n,r,s,e.exact)),window?.open(`${r}${o}`,t)},Tt=(e,t,n,s)=>{if(e.target||V(e.path)){Fe(e,e.target,t,n);return}let r,o,c;if(typeof e=="string")r=e;else if(A(e))r=e.path,o=e.params,c=e.query;else return;!r||r==="."||r==="./"?r=s:r.indexOf("./")===0?r=`${s.split("?")[0]}${r.replace("./","/")}`:r.indexOf("../")===0&&(r=`${s.split("?")[0].split("/").slice(0,-1).join("/")}${r.replace("../","/")}`),r=q(t,r,n,e?.exact);const a=_e(r);r=a.path;const i={...a.params,...c},l=Te(i);return r=`${r}${l}`,o={...o,...i},r===s?!1:{path:r,params:o}},$e=(e,t)=>{const n=e.split(t);return n.length>1?["","/"].includes(n[1].slice(0,1)):!1},Ft=X(),$t=e=>{const{on:t,emit:n,off:s}=Ft;return{on:r=>t(e,r),emit:r=>n(e,r),off:r=>s(e,r)}},Ie=$t,It=(e=re())=>(t,n)=>{const{getState:s,setState:r,subscribe:o,unsubscribe:c,clean:a}=e;return n!==void 0&&r({[t]:n},!0),{getState:()=>s(t),setState:(i,l)=>r({[t]:i},l),subscribe:i=>o(t,i),unsubscribe:()=>c(t),clean:()=>a(t)}},De=It,Dt=re(),Bt=De(Dt),Lt=Bt,he=Ie("push-emitter"),Be=Ie("replace-emitter"),B=Lt("route-store"),Le=X(),je=re(Le),ge=De(je),jt=ke(je),Nt=()=>![typeof window,typeof document].includes("undefined"),Ut=Nt,Wt=e=>{if(!Ut())return;const t=document.createElement("div");return t.innerHTML=e,t.children[0]},Ht=Wt;class Yt extends v.default.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){const{errorReport:s}=this.props;typeof s=="function"&&s({error:t,info:n.componentStack})}componentDidUpdate(t,n){n.error&&this.setState({error:null})}render(){const{error:t}=this.state,{fallback:n,children:s}=this.props;return t?n?.(t)??t:s}}const Jt=({children:e,report:t})=>(0,C.jsx)(Yt,{fallback:(n,s)=>te({error:n,info:s}),errorReport:t,children:e}),Vt=Jt;var Xt=b(591),Ne=b.n(Xt),qt=b(740),Ue=b.n(qt),zt=b(128),We=b.n(zt),Gt=b(855),He=b.n(Gt),Qt=b(51),Ye=b.n(Qt),Zt=b(656),Je=b.n(Zt),ne=b(670),L={};L.styleTagTransform=Je(),L.setAttributes=He(),L.insert=We().bind(null,"head"),L.domAPI=Ue(),L.insertStyleElement=Ye();var jr=Ne()(ne.A,L);const Nr=ne.A&&ne.A.locals?ne.A.locals:void 0,Kt=({global:e,absolute:t})=>(0,C.jsx)("div",{className:`spinner${e?" global":""}${t?" absolute":""}`,children:(0,C.jsx)("figure",{className:"spinning"})}),er=Kt,tr=()=>{const e=(0,v.useRef)([]);return(0,v.useEffect)(()=>()=>{e.current.map(t=>t.cancelFn()),e.current=[]},[]),(0,v.useCallback)((t,n=!0)=>{const s=Re(t,n);return e.current.indexOf(s)===-1&&e.current.push(s),s.promiseFn},[])},rr=tr,nr=(e={})=>{const t=rr(),[n,s]=(0,v.useState)(e),r=(0,v.useRef)({}),o=(0,v.useRef)({}),c=(0,v.useCallback)((i=null)=>{Array.isArray(i)&&i.length?i.map(l=>r.current[l]=e[l]):r.current=e},[]),a=(0,v.useCallback)((i,l,u=!1)=>{const p=Object.keys(i),h=JSON.stringify(p.sort());if(!o.current[h]){o.current[h]=!0,u&&c(Array.isArray(u)?u:p),p.map(f=>{r.current[f]||(r.current[f]={}),r.current[f].pending=!0}),s({...r.current});for(let f=0,d=p.length;f<d;f++){const g=p[f];t(i[g]).then(_=>{let{result:m,errMsg:y}=_;f===d-1&&(o.current[h]=!1),typeof l=="function"&&(m=l(m)||m),r.current[g]={...m,pending:!1},y===!1&&s({...r.current})}).catch(_=>{throw f===d-1&&(o.current[h]=!1),r.current[g]={error:_,pending:!1},s({...r.current}),_})}}},[]);return[n,a,c]},Ve=nr,se=e=>Object.keys(e).length,sr=e=>{const{Comp:t,restResolve:n,loadPromise:s,params:r,children:o}=e,[c,a]=Ve(),[i,l]=Ve();return(0,v.useEffect)(()=>{se(n)&&a(n),se(s)&&l(s)},[n,s]),(0,v.useEffect)(()=>{const u=se(c);u&&u===se(n)&&ge.setState(c)},[c]),(0,C.jsx)(t,{...r,...c,...i,children:o})},or=sr,cr=e=>e===!1?null:ie(e)?e:le(e)?(0,C.jsx)(e,{}):(0,C.jsx)(er,{}),ar=({Loading:e,ErrorBoundary:t,loadedComp:n})=>{const s=(0,C.jsx)(v.Suspense,{fallback:cr(e),children:n});return t===!1?s:le(t)?(0,C.jsx)(t,{children:s}):(0,C.jsx)(Vt,{children:s})},ur=({Comp:e,routerProps:t,children:n})=>{const{params:s,...r}=t,{loading:o,errorBoundary:c,...a}=s,i=(0,C.jsx)(or,{Comp:e,...r,params:a,children:n});return ar({Loading:o,ErrorBoundary:c,loadedComp:i})},Xe=ur,ve={},ye=(e,t,n,s)=>J(n)?n.then(r=>Xe({Comp:e,routerProps:t,children:r.default??r})):Xe({Comp:e,routerProps:t,children:n}),ir=(e,t)=>{const n={},s={};return A(e)?(Object.keys(e).map(r=>{const o=ge.getState(r);o==null?s[r]=e[r](t):n[r]=o}),{cachedResolve:n,restResolve:s}):{cachedResolve:n,restResolve:s}},lr=(e,t)=>{if(!A(e))return{};const n={};return Object.keys(e).map(s=>n[s]=e[s](t)),n},fr=e=>{const{current:t,menu:n,...s}=e,r=t.map(a=>{const{component:i,resolve:l,loadData:u,loading:p,errorBoundary:h,icon:f,...d}=a;return d}),o=[...t].filter(a=>a.component),c=(a=0)=>{if(!o.length)return null;const i=o.shift(),{component:l,resolve:u,loadData:p,icon:h,key:f,...d}=i;if(typeof l=="function"||J(l)){const g=`${d.path}${d.childSameRouteLevel??""}`;let _=ve[g];const{cachedResolve:m,restResolve:y}=ir(u,d),x={loadPromise:lr(p,d),restResolve:y,params:{current:r,...s,...d,...m}},S=c(a+1);if(_)return ye(_,x,S,g);try{_=l(),_=ie(_)?l:_}catch{_=l}return J(_)?_.then(R=>(_=R.default??R,ve[g]=_,ye(_,x,S,g))):(ve[g]=_,ye(_,x,S,g))}return typeof l=="string"?Ht(l):l};return c()},pr=fr,dr=e=>{const[t,n]=(0,v.useState)(e),[s,r]=(0,v.useState)(),[o,c]=(0,v.useState)(),a=K()(),i=K()(),l=K()(),u=K()(),p=()=>{typeof a.current=="function"&&(a.current({cancel:fe.cancelMsg}),a.current=null)},h=(0,v.useCallback)(m=>{typeof m=="function"?n(y=>({...y,...m(y)})):A(m)&&n(y=>({...y,...m}))},[]),f=(m,y="pushState")=>{const{basepath:E,browserRouter:x}=u.current,S=l.current,R=Tt(m,E,x,S);if(!R)return;const{path:O,params:I}=R;_({inputPath:O,inputParams:I},()=>history[y](m?.state,"",O))},d=(0,v.useCallback)(m=>f(m),[]),g=(0,v.useCallback)(m=>f(m,"replaceState"),[]),_=(0,v.useCallback)(({inputPath:m="",inputParams:y={}},E)=>{const x=+new Date,{browserRouter:S,childKey:R,idKey:O,title:I,metas:z,routers:G,beforeRender:N,afterRender:U,basepath:W,allowedNotFound:k,...qe}=u.current;if(!m){const{path:P,params:T}=Ot(S);m=P,y={...y,...T}}const oe=l.current;new Promise((P,T)=>{G?.length||T("\u8DEF\u7531\u4E3A\u7A7A\uFF01"),m!==l.current&&typeof N=="function"?N({path:m,params:y,prevPath:oe},P,T):P()}).then(P=>{if(P===!1)return;const T=P?.path;if(T&&q(W,T,S)!==m){g(P);return}i.current=i.current??m;const{redirect:F,current:H,menu:ze}=St(Y(G),m.split("?")[0],y,R,O);if(F){if(k&&F===pe&&(typeof k=="boolean"||typeof k=="string"&&$e(i.current,k)||M(k)&&k.find(ae=>$e(i.current,ae))))return;if(M(F)){console.error(`\u522B\u95F9\uFF0C[${[m,...F].join(" -> ")}] \u91CD\u5B9A\u5411\u6B7B\u5FAA\u73AF\uFF01\uFF01\uFF01`);return}return F===pe?g({path:F}):d({path:F,exact:!0})}E?.(),m?.split("?")[0]!==l.current?.split("?")[0]&&wt(),Mt(H,I,z);const be={...qe,updateRouter:h,router:{push:d,replace:g},current:H,menu:ze,inputPath:i.current,prevPath:oe,browserRouter:S,basepath:W,title:I,history:{...xt,goBack:Q=>d({...Q,path:oe})}};B.setState(be);const ce=pr(be);if(l.current=m,i.current=null,p(),J(ce)){const{promiseFn:Q,cancelFn:ae}=Re(ce,{delay:fe.delay,msg:{timeout:fe.timeoutMsg}});return a.current=ae,c(!0),Q.then(Z=>{a.current=null;const{result:Ge,errMsg:ue}=Z,xe=ue===!1?Ge:ue?.timeout?te({error:{errMsg:`${m} ${ue.timeout}`}}):null;xe&&(c(!1),me(U,H.slice(-1)[0],x),r(xe))}).catch(Z=>{throw a.current=null,c(!1),me(U,H.slice(-1)[0],x),r(te({error:Z})),Z})}me(U,H.slice(-1)[0],x),r(ce)}).catch(P=>{throw r(te({error:P})),P})},[]);return(0,v.useEffect)(()=>{const m={description:document.getElementsByTagName("meta").description.content??""},{childKey:y="children",idKey:E="path",browserRouter:x=!1,routers:S=[],basepath:R="",exact:O=!1,inputPath:I="",inputParams:z={},...G}=t,N=Ae(R),U=At(Y(S),x,y,E,N,O);u.current={...G,childKey:y,idKey:E,browserRouter:x,routers:U,basepath:N,metas:m};const W=x?"popstate":"hashchange",k=()=>_({});return _({inputPath:I,inputParams:z}),he.on(d),Be.on(g),window.addEventListener(W,k,!1),()=>{p(),he.off(d),Be.off(g),window.removeEventListener(W,k,!1)}},[t]),{updateRouter:h,output:s,loading:o}},_r=dr,mr=e=>{const{to:t,onClick:n,preventDefault:s,stopPropagation:r=!0,exact:o=!0,target:c,...a}=e,i=()=>{const u=typeof t=="string"?{exact:o,path:t}:{exact:o,...t};he.emit(u)};return u=>{if(u.preventDefault(),r&&u.stopPropagation(),!a?.disabled){if(!s){if(c){const{browserRouter:p,basepath:h}=B.getState();Fe(t,c,h,p);return}i()}typeof n=="function"&&n()}}},hr=mr;var $=b(845),j={};j.styleTagTransform=Je(),j.setAttributes=He(),j.insert=We().bind(null,"head"),j.domAPI=Ue(),j.insertStyleElement=Ye();var Ur=Ne()($.Ay,j);const Wr=$.Ay&&$.Ay.locals?$.Ay.locals:void 0,gr=e=>{if(!e)return $.nf;const t=e.trim().split(" ").filter(Boolean),s=t.find(r=>r==="active")?[$.vu]:[];return[$.nf,...s,...t].join(" ")},vr=e=>{const{to:t,onClick:n,preventDefault:s,stopPropagation:r,exact:o,target:c,className:a,...i}=e;return(0,C.jsx)("span",{onClick:hr(e),className:gr(a),...i})},yr=vr,br=()=>{const[e,t]=(0,v.useState)(B.getState());return(0,v.useEffect)(()=>B.subscribe(n=>t(n)),[]),e},xr=br,Er=B.getState,Cr=B.subscribe;var Sr=w.N_,Rr=w.vY,Ar=w.aM,Pr=w.RY,kr=w.oe,wr=w.jd,Mr=w.lq,Or=w.rd;export{Sr as Link,Rr as emitRoute,Ar as getRoute,Pr as huxyBus,kr as huxyStore,wr as useHuxyStore,Mr as useRoute,Or as useRouter}; |
+1
-1
| { | ||
| "name": "@huxy/router", | ||
| "version": "2.1.11", | ||
| "version": "2.1.12", | ||
| "title": "useRouter", | ||
@@ -5,0 +5,0 @@ "feature": "0.0.1", |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
1
Infinity%