amis-rpc-design/node_modules/react-router/dist/react-router.production.min.js

13 lines
14 KiB
JavaScript
Raw Normal View History

2023-10-07 19:42:30 +08:00
/**
* React Router v6.16.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
import*as e from"react";import{UNSAFE_invariant as t,joinPaths as r,matchPath as n,UNSAFE_getPathContributingMatches as a,resolveTo as o,parsePath as i,matchRoutes as l,Action as u,UNSAFE_convertRouteMatchToUiMatch as s,stripBasename as c,IDLE_BLOCKER as p,isRouteErrorResponse as d,createMemoryHistory as m,AbortedDeferredError as h,createRouter as f}from"@remix-run/router";export{AbortedDeferredError,Action as NavigationType,createPath,defer,generatePath,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,redirectDocument,resolvePath}from"@remix-run/router";const v=e.createContext(null),E=e.createContext(null),g=e.createContext(null),x=e.createContext(null),C=e.createContext(null),y=e.createContext({outlet:null,matches:[],isDataRoute:!1}),R=e.createContext(null);function b(n,{relative:a}={}){U()||t(!1);let{basename:o,navigator:i}=e.useContext(x),{hash:l,pathname:u,search:s}=A(n,{relative:a}),c=u;return"/"!==o&&(c="/"===u?o:r([o,u])),i.createHref({pathname:c,search:s,hash:l})}function U(){return null!=e.useContext(C)}function S(){return U()||t(!1),e.useContext(C).location}function P(){return e.useContext(C).navigationType}function B(r){U()||t(!1);let{pathname:a}=S();return e.useMemo((()=>n(r,a)),[a,r])}function D(t){e.useContext(x).static||e.useLayoutEffect(t)}function _(){let{isDataRoute:n}=e.useContext(y);return n?function(){let{router:t}=$(z.UseNavigateStable),r=W(H.UseNavigateStable),n=e.useRef(!1);return D((()=>{n.current=!0})),e.useCallback(((e,a={})=>{n.current&&("number"==typeof e?t.navigate(e):t.navigate(e,{fromRouteId:r,...a}))}),[t,r])}():function(){U()||t(!1);let n=e.useContext(v),{basename:i,navigator:l}=e.useContext(x),{matches:u}=e.useContext(y),{pathname:s}=S(),c=JSON.stringify(a(u).map((e=>e.pathnameBase))),p=e.useRef(!1);return D((()=>{p.current=!0})),e.useCallback(((e,t={})=>{if(!p.current)return;if("number"==typeof e)return void l.go(e);let a=o(e,JSON.parse(c),s,"path"===t.relative);null==n&&"/"!==i&&(a.pathname="/"===a.pathname?i:r([i,a.pathname])),(t.replace?l.replace:l.push)(a,t.state,t)}),[i,l,c,s,n])}()}const k=e.createContext(null);function N(){return e.useContext(k)}function L(t){let r=e.useContext(y).outlet;return r?e.createElement(k.Provider,{value:t},r):r}function O(){let{matches:t}=e.useContext(y),r=t[t.length-1];return r?r.params:{}}function A(t,{relative:r}={}){let{matches:n}=e.useContext(y),{pathname:i}=S(),l=JSON.stringify(a(n).map((e=>e.pathnameBase)));return e.useMemo((()=>o(t,JSON.parse(l),i,"path"===r)),[t,l,i,r])}function F(e,t){return j(e,t)}function j(n,a,o){U()||t(!1);let{navigator:s}=e.useContext(x),{matches:c}=e.useContext(y),p=c[c.length-1],d=p?p.params:{};!p||p.pathname;let m=p?p.pathnameBase:"/";p&&p.route;let h,f=S();if(a){let e="string"==typeof a?i(a):a;"/"===m||e.pathname?.startsWith(m)||t(!1),h=e}else h=f;let v=h.pathname||"/",E="/"===m?v:v.slice(m.length)||"/",g=l(n,{pathname:E}),R=J(g&&g.map((e=>Object.assign({},e,{params:Object.assign({},d,e.params),pathname:r([m,s.encodeLocation?s.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?m:r([m,s.encodeLocation?s.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])}))),c,o);return a&&R?e.createElement(C.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...h},navigationType:u.Pop}},R):R}function I(){let t=ee(),r=d(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return e.createElement(e.Fragment,null,e.createElement("h2",null,"Unexpected Application Error!"),e.createElement("h3",{style:{fontStyle:"italic"}},r),n?e.createElement("pre",{style:a},n):null,null)}const M=e.createElement(I,null);class T extends e.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,rev
//# sourceMappingURL=react-router.production.min.js.map