LocalCDN-Firefox-Chrome-Brave/resources/react-router/6.22.3/react-router.min.jsm

13 lines
17 KiB
JavaScript
Raw Normal View History

2024-02-29 18:51:32 +01:00
/**
2024-03-17 10:57:58 +01:00
* React Router v6.22.3
2024-02-29 18:51:32 +01:00
*
* 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
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@remix-run/router")):"function"==typeof define&&define.amd?define(["exports","react","@remix-run/router"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactRouter={},e.React,e.RemixRouter)}(this,(function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=n(t);function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},o.apply(this,arguments)}const i=a.createContext(null),u=a.createContext(null),l=a.createContext(null),s=a.createContext(null),c=a.createContext(null),d=a.createContext({outlet:null,matches:[],isDataRoute:!1}),p=a.createContext(null);function f(){return null!=a.useContext(c)}function m(){return f()||r.UNSAFE_invariant(!1),a.useContext(c).location}function v(e){a.useContext(s).static||a.useLayoutEffect(e)}function h(){let{isDataRoute:e}=a.useContext(d);return e?function(){let{router:e}=O(_.UseNavigateStable),t=j(N.UseNavigateStable),r=a.useRef(!1);return v((()=>{r.current=!0})),a.useCallback((function(n,a){void 0===a&&(a={}),r.current&&("number"==typeof n?e.navigate(n):e.navigate(n,o({fromRouteId:t},a)))}),[e,t])}():function(){f()||r.UNSAFE_invariant(!1);let e=a.useContext(i),{basename:t,future:n,navigator:o}=a.useContext(s),{matches:u}=a.useContext(d),{pathname:l}=m(),c=JSON.stringify(r.UNSAFE_getResolveToMatches(u,n.v7_relativeSplatPath)),p=a.useRef(!1);return v((()=>{p.current=!0})),a.useCallback((function(n,a){if(void 0===a&&(a={}),!p.current)return;if("number"==typeof n)return void o.go(n);let i=r.resolveTo(n,JSON.parse(c),l,"path"===a.relative);null==e&&"/"!==t&&(i.pathname="/"===i.pathname?t:r.joinPaths([t,i.pathname])),(a.replace?o.replace:o.push)(i,a.state,a)}),[t,o,c,l,e])}()}const E=a.createContext(null);function g(e){let t=a.useContext(d).outlet;return t?a.createElement(E.Provider,{value:e},t):t}function y(e,t){let{relative:n}=void 0===t?{}:t,{future:o}=a.useContext(s),{matches:i}=a.useContext(d),{pathname:u}=m(),l=JSON.stringify(r.UNSAFE_getResolveToMatches(i,o.v7_relativeSplatPath));return a.useMemo((()=>r.resolveTo(e,JSON.parse(l),u,"path"===n)),[e,l,u,n])}function b(e,t){return R(e,t)}function R(e,t,n,i){f()||r.UNSAFE_invariant(!1);let{navigator:u}=a.useContext(s),{matches:l}=a.useContext(d),p=l[l.length-1],v=p?p.params:{};!p||p.pathname;let h=p?p.pathnameBase:"/";p&&p.route;let E,g=m();if(t){var y;let e="string"==typeof t?r.parsePath(t):t;"/"===h||(null==(y=e.pathname)?void 0:y.startsWith(h))||r.UNSAFE_invariant(!1),E=e}else E=g;let b=E.pathname||"/",R=b;if("/"!==h){let e=h.replace(/^\//,"").split("/");R="/"+b.replace(/^\//,"").split("/").slice(e.length).join("/")}let P=r.matchRoutes(e,{pathname:R}),x=U(P&&P.map((e=>Object.assign({},e,{params:Object.assign({},v,e.params),pathname:r.joinPaths([h,u.encodeLocation?u.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?h:r.joinPaths([h,u.encodeLocation?u.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])}))),l,n,i);return t&&x?a.createElement(c.Provider,{value:{location:o({pathname:"/",search:"",hash:"",state:null,key:"default"},E),navigationType:r.Action.Pop}},x):x}function P(){let e=F(),t=r.isRouteErrorResponse(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,o={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return a.createElement(a.Fragment,null,a.createElement("h2",null,"Unexpected Application Error!"),a.createElement("h3",{style:{fontStyle:"italic"}},t),n?a.createElement("pre",{style:o},n):null,null)}const x=a.createElement(P,null);class C extends a.Component{constructor(e){super(e),this.state={location:e.location,reva
//# sourceMappingURL=react-router.production.min.js.map