You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
12 KiB

3 years ago
/**
* React Router v6.6.1
*
* 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{invariant as e,joinPaths as t,matchPath as r,UNSAFE_getPathContributingMatches as n,resolveTo as a,parsePath as o,matchRoutes as i,Action as l,isRouteErrorResponse as s,createMemoryHistory as u,stripBasename as c,AbortedDeferredError as d,createRouter as p}from"@remix-run/router";export{AbortedDeferredError,Action as NavigationType,createPath,defer,generatePath,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,resolvePath}from"@remix-run/router";import*as h from"react";const m="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},{useState:f,useEffect:v,useLayoutEffect:E,useDebugValue:g}=h;function x(e){const t=e.getSnapshot,r=e.value;try{const e=t();return!m(r,e)}catch(n){return!0}}const y=!!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement)?function(e,t,r){return t()}:function(e,t,r){const n=t(),[{inst:a},o]=f({inst:{value:n,getSnapshot:t}});return E((()=>{a.value=n,a.getSnapshot=t,x(a)&&o({inst:a})}),[e,n,t]),v((()=>{x(a)&&o({inst:a});return e((()=>{x(a)&&o({inst:a})}))}),[e]),g(n),n},C="useSyncExternalStore"in h?h.useSyncExternalStore:y,b=h.createContext(null),R=h.createContext(null),S=h.createContext(null),P=h.createContext(null),D=h.createContext(null),U=h.createContext(null),_=h.createContext({outlet:null,matches:[]}),w=h.createContext(null);function O(r,{relative:n}={}){L()||e(!1);let{basename:a,navigator:o}=h.useContext(D),{hash:i,pathname:l,search:s}=I(r,{relative:n}),u=l;return"/"!==a&&(u="/"===l?a:t([a,l])),o.createHref({pathname:u,search:s,hash:i})}function L(){return null!=h.useContext(U)}function N(){return L()||e(!1),h.useContext(U).location}function j(){return h.useContext(U).navigationType}function A(t){L()||e(!1);let{pathname:n}=N();return h.useMemo((()=>r(t,n)),[n,t])}function F(){L()||e(!1);let{basename:r,navigator:o}=h.useContext(D),{matches:i}=h.useContext(_),{pathname:l}=N(),s=JSON.stringify(n(i).map((e=>e.pathnameBase))),u=h.useRef(!1);return h.useEffect((()=>{u.current=!0})),h.useCallback(((e,n={})=>{if(!u.current)return;if("number"==typeof e)return void o.go(e);let i=a(e,JSON.parse(s),l,"path"===n.relative);"/"!==r&&(i.pathname="/"===i.pathname?r:t([r,i.pathname])),(n.replace?o.replace:o.push)(i,n.state,n)}),[r,o,s,l])}const k=h.createContext(null);function B(){return h.useContext(k)}function M(e){let t=h.useContext(_).outlet;return t?h.createElement(k.Provider,{value:e},t):t}function T(){let{matches:e}=h.useContext(_),t=e[e.length-1];return t?t.params:{}}function I(e,{relative:t}={}){let{matches:r}=h.useContext(_),{pathname:o}=N(),i=JSON.stringify(n(r).map((e=>e.pathnameBase)));return h.useMemo((()=>a(e,JSON.parse(i),o,"path"===t)),[e,i,o,t])}function J(r,n){L()||e(!1);let{navigator:a}=h.useContext(D),s=h.useContext(S),{matches:u}=h.useContext(_),c=u[u.length-1],d=c?c.params:{};!c||c.pathname;let p=c?c.pathnameBase:"/";c&&c.route;let m,f=N();if(n){let t="string"==typeof n?o(n):n;"/"===p||t.pathname?.startsWith(p)||e(!1),m=t}else m=f;let v=m.pathname||"/",E="/"===p?v:v.slice(p.length)||"/",g=i(r,{pathname:E}),x=V(g&&g.map((e=>Object.assign({},e,{params:Object.assign({},d,e.params),pathname:t([p,a.encodeLocation?a.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?p:t([p,a.encodeLocation?a.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])}))),u,s||void 0);return n&&x?h.createElement(U.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:l.Pop}},x):x}function H(){let e=ne(),t=s(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:n},o={padding:"2px 4px",backgroundColor:n};return h.createElement(h.Fragment,null,h.createElement("h2",null,"Unhandled Thrown Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},t),r?h.createElement("pre",{style:a},r):null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this wh
//# sourceMappingURL=react-router.production.min.js.map