Socket
Socket
Sign inDemoInstall

@gatsbyjs/reach-router

Package Overview
Dependencies
Maintainers
21
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gatsbyjs/reach-router - npm Package Compare versions

Comparing version 1.3.10-no-navigate.3 to 1.3.10-no-navigate.4

2

dist/index.js

@@ -1,2 +0,2 @@

var e=require("react"),t=require("prop-types"),r=require("invariant");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function o(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,t}var a=/*#__PURE__*/o(e),i=/*#__PURE__*/n(t),u=/*#__PURE__*/n(r);function c(){return c=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},c.apply(this,arguments)}function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}function p(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t.indexOf(r=a[n])>=0||(o[r]=e[r]);return o}var l=function(e){var t=e.location,r=t.search,n=t.hash,o=t.href,a=t.origin,i=t.protocol,u=t.host,c=t.hostname,s=t.port,p=e.location.pathname;return!p&&o&&d&&(p=new URL(o).pathname),{pathname:encodeURI(decodeURI(p)),search:r,hash:n,href:o,origin:a,protocol:i,host:u,hostname:c,port:s,state:e.history.state,key:e.history.state&&e.history.state.key||"initial"}},f=function(e,t){var r=[],n=l(e),o=!1,a=function(){};return{get location(){return n},get transitioning(){return o},_onTransitionComplete:function(){o=!1,a()},listen:function(t){r.push(t);var o=function(){n=l(e),t({location:n,action:"POP"})};return e.addEventListener("popstate",o),function(){e.removeEventListener("popstate",o),r=r.filter(function(e){return e!==t})}},navigate:function(t,i){var u=void 0===i?{}:i,s=u.state,p=u.replace,f=void 0!==p&&p;if("number"==typeof t)e.history.go(t);else{s=c({},s,{key:Date.now()+""});try{o||f?e.history.replaceState(s,null,t):e.history.pushState(s,null,t)}catch(r){e.location[f?"replace":"assign"](t)}}n=l(e),o=!0;var h=new Promise(function(e){return a=e});return r.forEach(function(e){return e({location:n,action:"PUSH"})}),h}}},h=function(e){void 0===e&&(e="/");var t=e.indexOf("?"),r={pathname:t>-1?e.substr(0,t):e,search:t>-1?e.substr(t):""},n=0,o=[r],a=[null];return{get location(){return o[n]},addEventListener:function(e,t){},removeEventListener:function(e,t){},history:{get entries(){return o},get index(){return n},get state(){return a[n]},pushState:function(e,t,r){var i=r.split("?"),u=i[1],c=void 0===u?"":u;n++,o.push({pathname:i[0],search:c.length?"?"+c:c}),a.push(e)},replaceState:function(e,t,r){var i=r.split("?"),u=i[1];o[n]={pathname:i[0],search:void 0===u?"":u},a[n]=e},go:function(e){var t=n+e;t<0||t>a.length-1||(n=t)}}}},d=!("undefined"==typeof window||!window.document||!window.document.createElement),v=f(d?window:h()),m=v.navigate,y=new Map,x=function(e,t){return void 0===t&&(t=null),function(e,t){void 0===t&&(t=null);var r=y.get(e);return r||(r=a.createServerContext(e,t),y.set(e,r),r)}(e,t)},g=x("Base",{baseuri:"/",basepath:"/"}),b=x("Focus"),E=x("Location"),w=function(){return a.useContext(g)},C=function(){return a.useContext(b)},R=function(){return a.useContext(E)};function P(e){this.uri=e}var k=function(e){return e instanceof P},O=function(e){throw new P(e)};function j(e){var t=e.to,r=e.replace,n=void 0===r||r,o=e.state,i=e.noThrow,u=e.baseuri;a.useEffect(function(){Promise.resolve().then(function(){var r=N(t,u);m(U(r,e),{replace:n,state:o})})},[]);var c=N(t,u);return i||O(U(c,e)),null}var L=function(e){var t=R(),r=w();/*#__PURE__*/return a.createElement(j,c({},t,{baseuri:r.baseuri},e))};L.propTypes={from:i.default.string,to:i.default.string.isRequired};var M=function(e,t){return e.substr(0,t.length)===t},q=function(e,t){for(var r,n,o=t.split("?"),a=K(o[0]),i=""===a[0],c=T(e),s=0,p=c.length;s<p;s++){var l=!1,f=c[s].route;if(f.default)n={route:f,params:{},uri:t};else{for(var h=K(f.path),d={},v=Math.max(a.length,h.length),m=0;m<v;m++){var y=h[m],x=a[m];if(B(y)){d[y.slice(1)||"*"]=a.slice(m).map(decodeURIComponent).join("/");break}if(void 0===x){l=!0;break}var g=D.exec(y);if(g&&!i){var b=-1===H.indexOf(g[1]);u.default(b,'<Router> dynamic segment "'+g[1]+'" is a reserved name. Please use a different name in path "'+f.path+'".');var E=decodeURIComponent(x);d[g[1]]=E}else if(y!==x){l=!0;break}}if(!l){r={route:f,params:d,uri:"/"+a.slice(0,m).join("/")};break}}}return r||n||null},S=function(e,t){return q([{path:e}],t)},N=function(e,t){if(M(e,"/"))return e;var r=e.split("?"),n=r[0],o=r[1],a=t.split("?")[0],i=K(n),u=K(a);if(""===i[0])return A(a,o);if(!M(i[0],".")){var c=u.concat(i).join("/");return A(("/"===a?"":"/")+c,o)}for(var s=u.concat(i),p=[],l=0,f=s.length;l<f;l++){var h=s[l];".."===h?p.pop():"."!==h&&p.push(h)}return A("/"+p.join("/"),o)},U=function(e,t){var r=e.split("?"),n=r[1],o=void 0===n?"":n,a="/"+K(r[0]).map(function(e){var r=D.exec(e);return r?t[r[1]]:e}).join("/"),i=t.location,u=(i=void 0===i?{}:i).search,c=(void 0===u?"":u).split("?")[1]||"";return A(a,o,c)},_=function(e,t){var r=function(e){return F(e)};return K(e).filter(r).sort().join("/")===K(t).filter(r).sort().join("/")},D=/^:(.+)/,F=function(e){return D.test(e)},B=function(e){return e&&"*"===e[0]},I=function(e,t){return{route:e,score:e.default?0:K(e.path).reduce(function(e,t){return e+=4,function(e){return""===e}(t)?e+=1:F(t)?e+=2:B(t)?e-=5:e+=3,e},0),index:t}},T=function(e){return e.map(I).sort(function(e,t){return e.score<t.score?1:e.score>t.score?-1:e.index-t.index})},K=function(e){return e.replace(/(^\/+|\/+$)/g,"").split("/")},A=function(e){var t=[].slice.call(arguments,1);return e+((t=t.filter(function(e){return e&&e.length>0}))&&t.length>0?"?"+t.join("&"):"")},H=["uri","path"],W=function(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(function(r){return t.hasOwnProperty(r)&&e[r]===t[r]})},$=function(e){return e.replace(/(^\/+|\/+$)/g,"")},V=function e(t){return function(r){if(!r)return null;if(r.type===a.Fragment&&r.props.children)return a.Children.map(r.props.children,e(t));if(u.default(r.props.path||r.props.default||r.type===L,"<Router>: Children of <Router> must have a `path` or `default` prop, or be a `<Redirect>`. None found on element type `"+r.type+"`"),u.default(!!(r.type!==L||r.props.from&&r.props.to),'<Redirect from="'+r.props.from+'" to="'+r.props.to+'"/> requires both "from" and "to" props when inside a <Router>.'),u.default(!(r.type===L&&!_(r.props.from,r.props.to)),'<Redirect from="'+r.props.from+' to="'+r.props.to+'"/> has mismatched dynamic segments, ensure both paths have the exact same dynamic segments.'),r.props.default)return{value:r,default:!0};var n=r.type===L?r.props.from:r.props.path,o="/"===n?t:$(t)+"/"+$(n);return{value:r,default:r.props.default,path:r.props.children?$(o)+"/*":o}}},z=["innerRef"],G=["to","state","replace","getProps"],J=["key"],Q=a.forwardRef;void 0===Q&&(Q=function(e){return e});var X=function(){},Y=Q(function(e,t){var r=e.innerRef,n=p(e,z),o=w().baseuri,i=R().location,u=n.to,s=n.state,l=n.replace,f=n.getProps,h=void 0===f?X:f,d=p(n,G),v=N(u,o),y=encodeURI(v),x=i.pathname===y,g=M(i.pathname,y);/*#__PURE__*/return a.createElement("a",c({ref:t||r,"aria-current":x?"page":void 0},d,h({isCurrent:x,isPartiallyCurrent:g,href:v,location:i}),{href:v,onClick:function(e){if(d.onClick&&d.onClick(e),function(e){return!e.defaultPrevented&&0===e.button&&!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)){e.preventDefault();var t=l;if("boolean"!=typeof l&&x){var r=p(c({},i.state),J);t=W(c({},s),r)}m(v,{state:s,replace:t})}}}))});Y.displayName="Link",Y.propTypes={to:i.default.string.isRequired};var Z=/*#__PURE__*/function(e){var t,r;function n(){for(var t,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return(t=e.call.apply(e,[this].concat(n))||this).displayName="ReactUseErrorBoundary",t}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,s(t,r);var o=n.prototype;return o.componentDidCatch=function(){var e;this.setState({}),(e=this.props).onError.apply(e,[].slice.call(arguments))},o.render=function(){return this.props.children},n}(a.Component),ee=a.createContext({componentDidCatch:{current:void 0},error:void 0,setError:function(){return!1}});function te(e){var t=e.children,r=a.useState(),n=r[0],o=r[1],i=a.useRef(),u=a.useMemo(function(){return{componentDidCatch:i,error:n,setError:o}},[n]);/*#__PURE__*/return a.createElement(ee.Provider,{value:u},/*#__PURE__*/a.createElement(Z,{error:n,onError:function(e,t){o(e),null==i.current||i.current(e,t)}},t))}te.displayName="ReactUseErrorBoundaryContext";var re=function(e){var t,r;function n(t){/*#__PURE__*/return a.createElement(te,null,/*#__PURE__*/a.createElement(e,c({key:"WrappedComponent"},t)))}return n.displayName="WithErrorBoundary("+(null!=(t=null!=(r=e.displayName)?r:e.name)?t:"Component")+")",n}(function(e){var t=e.history,r=void 0===t?v:t,n=e.children,o=a.useState({location:r.location}),i=o[0],u=o[1],c=function(e){var t=a.useContext(ee);t.componentDidCatch.current=void 0;var r=a.useCallback(function(){t.setError(void 0)},[]);return[t.error,r]}()[0];if(a.useEffect(function(){r._onTransitionComplete()},[i.location]),a.useEffect(function(){var e=!1,t=r.listen(function(t){var r=t.location;Promise.resolve().then(function(){requestAnimationFrame(function(){e||u({location:r})})})});return function(){e=!0,t()}},[]),c){if(!k(c))throw c;m(c.uri,{replace:!0})}/*#__PURE__*/return a.createElement(E.Provider,{value:i},"function"==typeof n?n(i):n||null)}),ne=["uri","location","component"],oe=["children","style","requestFocus","component","uri","location"],ae=function(e){var t=e.uri,r=e.location,n=e.component,o=p(e,ne),i=C();/*#__PURE__*/return a.createElement(ue,c({},o,{component:n,requestFocus:i,uri:t,location:r}))},ie=0,ue=function(e){var t=e.children,r=e.style,n=e.requestFocus,o=e.component,i=void 0===o?"div":o,u=e.uri,s=e.location,l=p(e,oe),f=a.useRef(),h=a.useRef(!0),d=a.useRef(u),v=a.useRef(s.pathname),m=a.useRef(!0);a.useEffect(function(){return ie++,y(),function(){0==--ie&&(h.current=!0)}},[]),a.useEffect(function(){var e=!1,t=!1;u!==d.current&&(d.current=u,e=!0),s.pathname!==v.current&&(v.current=s.pathname,t=!0),m.current=e||t&&s.pathname===u,m.current&&y()},[u,s]);var y=a.useCallback(function(){"test"!==process.env.NODE_ENV&&(n?n(f.current):h.current?h.current=!1:f&&(f.current.contains(document.activeElement)||f.current.focus()))},[]);/*#__PURE__*/return a.createElement(i,c({style:c({outline:"none"},r),tabIndex:"-1",ref:function(e){return f=e}},l),/*#__PURE__*/a.createElement(b.Provider,{value:function(e){!m.current&&e&&e.current.focus()}},t))},ce=["location","primary","children","basepath","baseuri","component"],se=function(e){var t=w(),r=R();/*#__PURE__*/return a.createElement(pe,c({},t,r,e))};function pe(e){var t=e.location,r=e.primary,n=void 0===r||r,o=e.children,i=e.basepath,u=e.component,s=void 0===u?"div":u,l=p(e,ce),f=a.Children.toArray(o).reduce(function(e,t){var r=V(i)(t);return e.concat(r)},[]),h=q(f,t.pathname);if(h){var d=h.params,v=h.uri,m=h.route,y=h.route.value,x=m.default?i:m.path.replace(/\*$/,""),b=c({},d,{uri:v,location:t}),E=a.cloneElement(y,b,y.props.children?/*#__PURE__*/a.createElement(se,{location:t,primary:n},y.props.children):void 0),w=n?ae:s,C=n?c({uri:v,location:t,component:s},l):l;/*#__PURE__*/return a.createElement(g.Provider,{value:{baseuri:v,basepath:x}},/*#__PURE__*/a.createElement(w,C,E))}return null}var le=function(){var e=R();if(!e)throw new Error("useLocation hook was used but a LocationContext.Provider was not found in the parent tree. Make sure this is used in a component that is a child of Router");return e.location};exports.BaseContext=g,exports.FocusContext=b,exports.Link=Y,exports.Location=function(e){var t=e.children,r=R();return r?t(r):/*#__PURE__*/a.createElement(re,null,t)},exports.LocationContext=E,exports.LocationProvider=re,exports.Match=function(e){var t=e.path,r=e.children,n=w().baseuri,o=R().location,a=N(t,n),i=S(a,o.pathname);return r({location:o,match:i?c({},i.params,{uri:i.uri,path:t}):null})},exports.Redirect=L,exports.Router=se,exports.ServerLocation=function(e){var t,r=e.url,n=e.children,o=r.indexOf("?"),i="";return o>-1?(t=r.substring(0,o),i=r.substring(o)):t=r,/*#__PURE__*/a.createElement(E.Provider,{value:{location:{pathname:t,search:i,hash:""}}},n)},exports.createHistory=f,exports.createMemorySource=h,exports.globalHistory=v,exports.insertParams=U,exports.isRedirect=k,exports.matchPath=S,exports.navigate=m,exports.pick=q,exports.redirectTo=O,exports.resolve=N,exports.shallowCompare=W,exports.startsWith=M,exports.useBaseContext=w,exports.useFocusContext=C,exports.useLocation=le,exports.useLocationContext=R,exports.useMatch=function(e){if(!e)throw new Error("useMatch(path: string) requires an argument of a string to match against");var t=w();if(!t)throw new Error("useMatch hook was used but a LocationContext.Provider was not found in the parent tree. Make sure this is used in a component that is a child of Router");var r=le(),n=N(e,t.baseuri),o=S(n,r.pathname);return o?c({},o.params,{uri:o.uri,path:e}):null},exports.useNavigate=function(){throw new Error("useNavigate is removed. Use import { navigate } from 'gatsby' instead")},exports.useParams=function(){var e=w();if(!e)throw new Error("useParams hook was used but a LocationContext.Provider was not found in the parent tree. Make sure this is used in a component that is a child of Router");var t=le(),r=S(e.basepath,t.pathname);return r?r.params:null},exports.validateRedirect=_;
var e=require("react"),t=require("prop-types"),r=require("invariant");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function o(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,t}var a=/*#__PURE__*/o(e),i=/*#__PURE__*/n(t),u=/*#__PURE__*/n(r);function c(){return c=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},c.apply(this,arguments)}function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}function p(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t.indexOf(r=a[n])>=0||(o[r]=e[r]);return o}var l=function(e){var t=e.location,r=t.search,n=t.hash,o=t.href,a=t.origin,i=t.protocol,u=t.host,c=t.hostname,s=t.port,p=e.location.pathname;return!p&&o&&d&&(p=new URL(o).pathname),{pathname:encodeURI(decodeURI(p)),search:r,hash:n,href:o,origin:a,protocol:i,host:u,hostname:c,port:s,state:e.history.state,key:e.history.state&&e.history.state.key||"initial"}},f=function(e,t){var r=[],n=l(e),o=!1,a=function(){};return{get location(){return n},get transitioning(){return o},_onTransitionComplete:function(){o=!1,a()},listen:function(t){r.push(t);var o=function(){n=l(e),t({location:n,action:"POP"})};return e.addEventListener("popstate",o),function(){e.removeEventListener("popstate",o),r=r.filter(function(e){return e!==t})}},navigate:function(t,i){var u=void 0===i?{}:i,s=u.state,p=u.replace,f=void 0!==p&&p;if("number"==typeof t)e.history.go(t);else{s=c({},s,{key:Date.now()+""});try{o||f?e.history.replaceState(s,null,t):e.history.pushState(s,null,t)}catch(r){e.location[f?"replace":"assign"](t)}}n=l(e),o=!0;var h=new Promise(function(e){return a=e});return r.forEach(function(e){return e({location:n,action:"PUSH"})}),h}}},h=function(e){void 0===e&&(e="/");var t=e.indexOf("?"),r={pathname:t>-1?e.substr(0,t):e,search:t>-1?e.substr(t):""},n=0,o=[r],a=[null];return{get location(){return o[n]},addEventListener:function(e,t){},removeEventListener:function(e,t){},history:{get entries(){return o},get index(){return n},get state(){return a[n]},pushState:function(e,t,r){var i=r.split("?"),u=i[1],c=void 0===u?"":u;n++,o.push({pathname:i[0],search:c.length?"?"+c:c}),a.push(e)},replaceState:function(e,t,r){var i=r.split("?"),u=i[1];o[n]={pathname:i[0],search:void 0===u?"":u},a[n]=e},go:function(e){var t=n+e;t<0||t>a.length-1||(n=t)}}}},d=!("undefined"==typeof window||!window.document||!window.document.createElement),v=f(d?window:h()),m=v.navigate,y=function(t,r){return void 0===r&&(r=null),global.__SERVER_CONTEXT||(global.__SERVER_CONTEXT={}),global.__SERVER_CONTEXT[t]||(global.__SERVER_CONTEXT[t]=e.createServerContext(t,r)),global.__SERVER_CONTEXT[t]},g=y("Base",{baseuri:"/",basepath:"/"}),E=y("Focus"),b=y("Location"),x=function(){return a.useContext(g)},C=function(){return a.useContext(E)},R=function(){return a.useContext(b)};function w(e){this.uri=e}var P=function(e){return e instanceof w},O=function(e){throw new w(e)};function k(e){var t=e.to,r=e.replace,n=void 0===r||r,o=e.state,i=e.noThrow,u=e.baseuri;a.useEffect(function(){Promise.resolve().then(function(){var r=T(t,u);m(N(r,e),{replace:n,state:o})})},[]);var c=T(t,u);return i||O(N(c,e)),null}var _=function(e){var t=R(),r=x();/*#__PURE__*/return a.createElement(k,c({},t,{baseuri:r.baseuri},e))};_.propTypes={from:i.default.string,to:i.default.string.isRequired};var j=function(e,t){return e.substr(0,t.length)===t},L=function(e,t){for(var r,n,o=t.split("?"),a=I(o[0]),i=""===a[0],c=B(e),s=0,p=c.length;s<p;s++){var l=!1,f=c[s].route;if(f.default)n={route:f,params:{},uri:t};else{for(var h=I(f.path),d={},v=Math.max(a.length,h.length),m=0;m<v;m++){var y=h[m],g=a[m];if(D(y)){d[y.slice(1)||"*"]=a.slice(m).map(decodeURIComponent).join("/");break}if(void 0===g){l=!0;break}var E=M.exec(y);if(E&&!i){var b=-1===X.indexOf(E[1]);u.default(b,'<Router> dynamic segment "'+E[1]+'" is a reserved name. Please use a different name in path "'+f.path+'".');var x=decodeURIComponent(g);d[E[1]]=x}else if(y!==g){l=!0;break}}if(!l){r={route:f,params:d,uri:"/"+a.slice(0,m).join("/")};break}}}return r||n||null},S=function(e,t){return L([{path:e}],t)},T=function(e,t){if(j(e,"/"))return e;var r=e.split("?"),n=r[0],o=r[1],a=t.split("?")[0],i=I(n),u=I(a);if(""===i[0])return V(a,o);if(!j(i[0],".")){var c=u.concat(i).join("/");return V(("/"===a?"":"/")+c,o)}for(var s=u.concat(i),p=[],l=0,f=s.length;l<f;l++){var h=s[l];".."===h?p.pop():"."!==h&&p.push(h)}return V("/"+p.join("/"),o)},N=function(e,t){var r=e.split("?"),n=r[1],o=void 0===n?"":n,a="/"+I(r[0]).map(function(e){var r=M.exec(e);return r?t[r[1]]:e}).join("/"),i=t.location,u=(i=void 0===i?{}:i).search,c=(void 0===u?"":u).split("?")[1]||"";return V(a,o,c)},q=function(e,t){var r=function(e){return U(e)};return I(e).filter(r).sort().join("/")===I(t).filter(r).sort().join("/")},M=/^:(.+)/,U=function(e){return M.test(e)},D=function(e){return e&&"*"===e[0]},F=function(e,t){return{route:e,score:e.default?0:I(e.path).reduce(function(e,t){return e+=4,function(e){return""===e}(t)?e+=1:U(t)?e+=2:D(t)?e-=5:e+=3,e},0),index:t}},B=function(e){return e.map(F).sort(function(e,t){return e.score<t.score?1:e.score>t.score?-1:e.index-t.index})},I=function(e){return e.replace(/(^\/+|\/+$)/g,"").split("/")},V=function(e){var t=[].slice.call(arguments,1);return e+((t=t.filter(function(e){return e&&e.length>0}))&&t.length>0?"?"+t.join("&"):"")},X=["uri","path"],K=function(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(function(r){return t.hasOwnProperty(r)&&e[r]===t[r]})},A=function(e){return e.replace(/(^\/+|\/+$)/g,"")},H=function e(t){return function(r){if(!r)return null;if(r.type===a.Fragment&&r.props.children)return a.Children.map(r.props.children,e(t));if(u.default(r.props.path||r.props.default||r.type===_,"<Router>: Children of <Router> must have a `path` or `default` prop, or be a `<Redirect>`. None found on element type `"+r.type+"`"),u.default(!!(r.type!==_||r.props.from&&r.props.to),'<Redirect from="'+r.props.from+'" to="'+r.props.to+'"/> requires both "from" and "to" props when inside a <Router>.'),u.default(!(r.type===_&&!q(r.props.from,r.props.to)),'<Redirect from="'+r.props.from+' to="'+r.props.to+'"/> has mismatched dynamic segments, ensure both paths have the exact same dynamic segments.'),r.props.default)return{value:r,default:!0};var n=r.type===_?r.props.from:r.props.path,o="/"===n?t:A(t)+"/"+A(n);return{value:r,default:r.props.default,path:r.props.children?A(o)+"/*":o}}},W=["innerRef"],$=["to","state","replace","getProps"],z=["key"],G=a.forwardRef;void 0===G&&(G=function(e){return e});var J=function(){},Q=G(function(e,t){var r=e.innerRef,n=p(e,W),o=x().baseuri,i=R().location,u=n.to,s=n.state,l=n.replace,f=n.getProps,h=void 0===f?J:f,d=p(n,$),v=T(u,o),y=encodeURI(v),g=i.pathname===y,E=j(i.pathname,y);/*#__PURE__*/return a.createElement("a",c({ref:t||r,"aria-current":g?"page":void 0},d,h({isCurrent:g,isPartiallyCurrent:E,href:v,location:i}),{href:v,onClick:function(e){if(d.onClick&&d.onClick(e),function(e){return!e.defaultPrevented&&0===e.button&&!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)){e.preventDefault();var t=l;if("boolean"!=typeof l&&g){var r=p(c({},i.state),z);t=K(c({},s),r)}m(v,{state:s,replace:t})}}}))});Q.displayName="Link",Q.propTypes={to:i.default.string.isRequired};var Y=/*#__PURE__*/function(e){var t,r;function n(){for(var t,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return(t=e.call.apply(e,[this].concat(n))||this).displayName="ReactUseErrorBoundary",t}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,s(t,r);var o=n.prototype;return o.componentDidCatch=function(){var e;this.setState({}),(e=this.props).onError.apply(e,[].slice.call(arguments))},o.render=function(){return this.props.children},n}(a.Component),Z=a.createContext({componentDidCatch:{current:void 0},error:void 0,setError:function(){return!1}});function ee(e){var t=e.children,r=a.useState(),n=r[0],o=r[1],i=a.useRef(),u=a.useMemo(function(){return{componentDidCatch:i,error:n,setError:o}},[n]);/*#__PURE__*/return a.createElement(Z.Provider,{value:u},/*#__PURE__*/a.createElement(Y,{error:n,onError:function(e,t){o(e),null==i.current||i.current(e,t)}},t))}ee.displayName="ReactUseErrorBoundaryContext";var te=function(e){var t,r;function n(t){/*#__PURE__*/return a.createElement(ee,null,/*#__PURE__*/a.createElement(e,c({key:"WrappedComponent"},t)))}return n.displayName="WithErrorBoundary("+(null!=(t=null!=(r=e.displayName)?r:e.name)?t:"Component")+")",n}(function(e){var t=e.history,r=void 0===t?v:t,n=e.children,o=a.useState({location:r.location}),i=o[0],u=o[1],c=function(e){var t=a.useContext(Z);t.componentDidCatch.current=void 0;var r=a.useCallback(function(){t.setError(void 0)},[]);return[t.error,r]}()[0];if(a.useEffect(function(){r._onTransitionComplete()},[i.location]),a.useEffect(function(){var e=!1,t=r.listen(function(t){var r=t.location;Promise.resolve().then(function(){requestAnimationFrame(function(){e||u({location:r})})})});return function(){e=!0,t()}},[]),c){if(!P(c))throw c;m(c.uri,{replace:!0})}/*#__PURE__*/return a.createElement(b.Provider,{value:i},"function"==typeof n?n(i):n||null)}),re=["uri","location","component"],ne=["children","style","requestFocus","component","uri","location"],oe=function(e){var t=e.uri,r=e.location,n=e.component,o=p(e,re),i=C();/*#__PURE__*/return a.createElement(ie,c({},o,{component:n,requestFocus:i,uri:t,location:r}))},ae=0,ie=function(e){var t=e.children,r=e.style,n=e.requestFocus,o=e.component,i=void 0===o?"div":o,u=e.uri,s=e.location,l=p(e,ne),f=a.useRef(),h=a.useRef(!0),d=a.useRef(u),v=a.useRef(s.pathname),m=a.useRef(!0);a.useEffect(function(){return ae++,y(),function(){0==--ae&&(h.current=!0)}},[]),a.useEffect(function(){var e=!1,t=!1;u!==d.current&&(d.current=u,e=!0),s.pathname!==v.current&&(v.current=s.pathname,t=!0),m.current=e||t&&s.pathname===u,m.current&&y()},[u,s]);var y=a.useCallback(function(){"test"!==process.env.NODE_ENV&&(n?n(f.current):h.current?h.current=!1:f&&(f.current.contains(document.activeElement)||f.current.focus()))},[]);/*#__PURE__*/return a.createElement(i,c({style:c({outline:"none"},r),tabIndex:"-1",ref:function(e){return f=e}},l),/*#__PURE__*/a.createElement(E.Provider,{value:function(e){!m.current&&e&&e.current.focus()}},t))},ue=["location","primary","children","basepath","baseuri","component"],ce=function(e){var t=x(),r=R();/*#__PURE__*/return a.createElement(se,c({},t,r,e))};function se(e){var t=e.location,r=e.primary,n=void 0===r||r,o=e.children,i=e.basepath,u=e.component,s=void 0===u?"div":u,l=p(e,ue),f=a.Children.toArray(o).reduce(function(e,t){var r=H(i)(t);return e.concat(r)},[]),h=L(f,t.pathname);if(h){var d=h.params,v=h.uri,m=h.route,y=h.route.value,E=m.default?i:m.path.replace(/\*$/,""),b=c({},d,{uri:v,location:t}),x=a.cloneElement(y,b,y.props.children?/*#__PURE__*/a.createElement(ce,{location:t,primary:n},y.props.children):void 0),C=n?oe:s,R=n?c({uri:v,location:t,component:s},l):l;/*#__PURE__*/return a.createElement(g.Provider,{value:{baseuri:v,basepath:E}},/*#__PURE__*/a.createElement(C,R,x))}return null}var pe=function(){var e=R();if(!e)throw new Error("useLocation hook was used but a LocationContext.Provider was not found in the parent tree. Make sure this is used in a component that is a child of Router");return e.location};exports.BaseContext=g,exports.FocusContext=E,exports.Link=Q,exports.Location=function(e){var t=e.children,r=R();return r?t(r):/*#__PURE__*/a.createElement(te,null,t)},exports.LocationContext=b,exports.LocationProvider=te,exports.Match=function(e){var t=e.path,r=e.children,n=x().baseuri,o=R().location,a=T(t,n),i=S(a,o.pathname);return r({location:o,match:i?c({},i.params,{uri:i.uri,path:t}):null})},exports.Redirect=_,exports.Router=ce,exports.ServerLocation=function(e){var t,r=e.url,n=e.children,o=r.indexOf("?"),i="";return o>-1?(t=r.substring(0,o),i=r.substring(o)):t=r,/*#__PURE__*/a.createElement(b.Provider,{value:{location:{pathname:t,search:i,hash:""}}},n)},exports.createHistory=f,exports.createMemorySource=h,exports.globalHistory=v,exports.insertParams=N,exports.isRedirect=P,exports.matchPath=S,exports.navigate=m,exports.pick=L,exports.redirectTo=O,exports.resolve=T,exports.shallowCompare=K,exports.startsWith=j,exports.useBaseContext=x,exports.useFocusContext=C,exports.useLocation=pe,exports.useLocationContext=R,exports.useMatch=function(e){if(!e)throw new Error("useMatch(path: string) requires an argument of a string to match against");var t=x();if(!t)throw new Error("useMatch hook was used but a LocationContext.Provider was not found in the parent tree. Make sure this is used in a component that is a child of Router");var r=pe(),n=T(e,t.baseuri),o=S(n,r.pathname);return o?c({},o.params,{uri:o.uri,path:e}):null},exports.useNavigate=function(){throw new Error("useNavigate is removed. Use import { navigate } from 'gatsby' instead")},exports.useParams=function(){var e=x();if(!e)throw new Error("useParams hook was used but a LocationContext.Provider was not found in the parent tree. Make sure this is used in a component that is a child of Router");var t=pe(),r=S(e.basepath,t.pathname);return r?r.params:null},exports.validateRedirect=q;
//# sourceMappingURL=index.js.map
{
"name": "@gatsbyjs/reach-router",
"version": "1.3.10-no-navigate.3",
"version": "1.3.10-no-navigate.4",
"description": "Gatsby's fork to modernize reach-router",

@@ -5,0 +5,0 @@ "source": "src/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc