Socket
Socket
Sign inDemoInstall

react-navi

Package Overview
Dependencies
15
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.14.1 to 0.14.2

2

dist/commonjs/Link.js

@@ -131,3 +131,3 @@ "use strict";

React.useEffect(function () {
if (prefetch === true) {
if (prefetch === 'mount') {
doPrefetch();

@@ -134,0 +134,0 @@ }

@@ -122,3 +122,3 @@ var __assign = (this && this.__assign) || function () {

React.useEffect(function () {
if (prefetch === true) {
if (prefetch === 'mount') {
doPrefetch();

@@ -125,0 +125,0 @@ }

@@ -183,3 +183,3 @@ (function (global, factory) {

React.useEffect(function () {
if (prefetch === true) {
if (prefetch === 'mount') {
doPrefetch();

@@ -186,0 +186,0 @@ }

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("navi")):"function"==typeof define&&define.amd?define(["exports","react","navi"],e):e((t=t||self).ReactNavi={},t.React,t.Navi)}(this,function(t,e,n){"use strict";var r=e.createContext("auto");function o(t){return t.behavior?e.createElement(r.Provider,{value:t.behavior},t.children):e.createElement(e.Fragment,null,t.children)}function i(t,e){try{window.scroll({top:e,left:t,behavior:"smooth"})}catch(n){window.scroll(t,e)}}var a={none:function(){},auto:function(t){if(t){var e=document.getElementById(t.slice(1));if(e){var n=e.getBoundingClientRect(),r=n.top,o=n.left;window.scroll(o+window.pageXOffset,r+window.pageYOffset)}}else window.scroll(0,0)},smooth:function(t){if(t){var e=document.getElementById(t.slice(1));if(e){var n=e.getBoundingClientRect(),r=n.top;i(n.left+window.pageXOffset,r+window.pageYOffset),e.focus()}}else i(0,0)}};function u(t,e){void 0===e&&(e="auto"),("string"==typeof e?a[e]:e)(t)}var s=e.createContext({}),c=(s.Consumer,s.Provider,function(){return(c=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)}),l=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};function f(t){return!t||"string"==typeof t&&(-1!==t.indexOf("://")||0===t.indexOf("mailto:"))}function h(t,e){if(!f(t))return e&&"string"==typeof t&&(t="/"===t[0]?t:n.joinPaths("/",e.pathname,t)),n.createURLDescriptor(t)}var p,v=function(t,r){var o=void 0===r?{}:r,i=o.exact,a=void 0===i||i,u=o.loading,c=void 0!==u&&u,l=e.useContext(s),f=c?l.busyRoute||l.steadyRoute:l.steadyRoute||l.busyRoute,p=f&&f.url,v=h(t,p);return!(!v||!p||(a?v.pathname!==p.pathname:0!==n.modifyTrailingSlash(p.pathname,"add").indexOf(v.pathname)))},d=function(t){var o,i,a=t.disabled,c=t.hashScrollBehavior,l=t.href,p=t.prefetch,v=t.state,d=t.onClick,y=t.onMouseEnter;p&&v&&(p=!1),!0===p&&(p="mount"),void 0===p&&(p="hover");var m=e.useContext(r),b=e.useContext(s),g=b.navigation;void 0===c&&(c=m);var w=b.steadyRoute||b.busyRoute,C=e.useMemo(function(){return w&&w.url},[null===(o=w)||void 0===o?void 0:o.url.href]),R=h(l,C);if(!f(l)){var x=l;C&&"string"==typeof l&&(x="/"===l[0]?l:n.joinPaths("/",C.pathname,l)),R=n.createURLDescriptor(x)}var O=e.useMemo(function(){return R},[null===(i=R)||void 0===i?void 0:i.href]),E=e.useMemo(function(){var t=!1;return function(){!t&&O&&O.pathname&&g&&(t=!0,g.prefetch(O).catch(function(t){console.warn('A <Link> tried to prefetch "'+O.pathname+'", but the router was unable to fetch this path.')}))}},[O,g]);e.useEffect(function(){!0===p&&E()},[p,E]);var P=e.useCallback(function(t){if("hover"===p){if(y&&y(t),a)return void t.preventDefault();t.defaultPrevented||E()}},[a,E,y,p]);return{onClick:e.useCallback(function(t){if(0===t.button&&!(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)){if(a)return void t.preventDefault();if(d&&d(t),!C)return;if(!t.defaultPrevented&&R){t.preventDefault();var e=n.modifyTrailingSlash(R.pathname,"remove")===n.modifyTrailingSlash(C.pathname,"remove");g.navigate(R,v?{state:v}:void 0),(e||""===R.pathname)&&R.hash===C.hash&&R.hash&&u(C.hash,c)}}},[a,d,R&&R.href,C&&C.href]),onMouseEnter:P,href:R?R.href:l}},y=e.forwardRef(function(t,n){var r=t.active,o=t.activeClassName,i=t.activeStyle,a=t.className,u=(t.disabled,t.exact),s=t.hashScrollBehavior,f=t.href,h=t.onClick,p=t.onMouseEnter,y=t.prefetch,m=t.state,b=t.style,g=l(t,["active","activeClassName","activeStyle","className","disabled","exact","hashScrollBehavior","href","onClick","onMouseEnter","prefetch","state","style"]),w=d({hashScrollBehavior:s,href:f,onClick:h,onMouseEnter:p,prefetch:y,state:m}),C=w.onClick,R=w.onMouseEnter,x=l(w,["onClick","onMouseEnter"]),O=v(x.href,{exact:!!u});return void 0===r&&(r=O),e.createElement("a",c({ref:n,className:(a||"")+" "+(r&&o||""),style:b&&i?Object.assign({},b,r?i:{}):void 0},g,x,{onClick:t.target?h:C,onMouseEnter:t.target?p:R}))}),m=(p=function(t,e){return(p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}p(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),b=function(t){function n(e){var n=t.call(this,e)||this;return n.handleNavigationSnapshot=function(t){"busy"!==t.type?n.setState({steadyRoute:t,busyRoute:void 0}):n.setState({busyRoute:t})},n.handleError=function(t){throw t},n.state={},n}return m(n,t),n.getDerivedStateFromProps=function(t,e){if(e.navigation!==t.navigation){var n=t.navigation.getCurrentValue();return"busy"===n.type?{steadyRoute:e.steadyRoute,busyRoute:n,navigation:t.navigation}:{steadyRoute:n,busyRoute:void 0,navigation:t.navigation}}return null},n.prototype.render=function(){return e.createElement(o,{behavior:this.props.hashScrollBehavior},e.createElement(s.Provider,{value:this.state},this.props.children))},n.prototype.componentDidMount=function(){this.subscribe()},n.prototype.componentDidUpdate=function(t){t.navigation!==this.props.navigation&&(this.unsubscribe(),this.subscribe())},n.prototype.componentWillUnmount=function(){this.unsubscribe()},n.prototype.subscribe=function(){if(!this.props.navigation)throw new Error('A <NaviProvider> component must receive a "navigation" prop.');this.subscription=this.props.navigation.subscribe(this.handleNavigationSnapshot,this.handleError)},n.prototype.unsubscribe=function(){this.subscription&&(this.subscription.unsubscribe(),delete this.subscription)},n}(e.Component),g=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),w=function(){return(w=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},C=function(t){function e(e){var n=t.call(this,e)||this;return n.state={},n}return g(e,t),e.getDerivedStateFromProps=function(t,e){return e.error&&t.context.steadyRoute.url.pathname!==e.errorPathname?{error:void 0,errorPathname:void 0,errorInfo:void 0}:null},e.prototype.componentDidCatch=function(t,e){if(!(t instanceof n.NotFoundError))throw t;this.setState({error:t,errorInfo:e,errorPathname:this.props.context.steadyRoute.url.pathname})},e.prototype.componentDidUpdate=function(t,e){this.state.error&&e.error},e.prototype.render=function(){return this.state.error?this.props.render(this.state.error):this.props.children},e}(e.Component),R=e.createContext(null),x=function(){return(x=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function O(t){return"view"===t.type}function E(t){var n=void 0===t?{}:t,o=n.disableScrolling,i=void 0!==o&&o,a=n.hashScrollBehavior,c=n.renderHead,l=n.where,f=void 0===l?O:l,h=e.useContext(r),p=e.useContext(R),v=e.useContext(s);void 0===a&&(a=h),void 0===c&&p&&(c=p);var d=v.steadyRoute||v.busyRoute;if(!d)throw new Error("react-navi: A <View> component cannot be rendered outside of a <Router> or <NaviProvider> component.");var y=v.unconsumedSteadyRouteChunks||d.chunks,m=y.findIndex(f),b=-1!==m&&y[m].view,g=-1===m||!y.slice(m+1).find(f)&&"error"!==d.type,w=e.useMemo(function(){return g?y:y.slice(0,m+1)},[g,y,m]),C=w.find(function(t){return"error"===t.type});if(C)throw C.error||new Error("Unknown routing error");if(!b&&!v.steadyRoute)throw v.navigation.getRoute();var E=e.useMemo(function(){return x(x({},v),{unconsumedSteadyRouteChunks:g?[]:y.slice(m+1)})},[v,y,m]),P=e.useCallback(function(t){return e.createElement(s.Provider,{value:E},e.isValidElement(t)?e.cloneElement(t):t)},[E]),S=e.useMemo(function(){return"function"==typeof b?e.createElement(b,{route:v.steadyRoute}):b||null},[b,v.steadyRoute]),_=e.useMemo(function(){return c?c(w):null},[c,w]),j=e.useRef();e.useEffect(function(){var t=d,e=j.current;if(j.current=d,g&&d&&0!==y.length&&t&&"busy"!==t.type){if(e&&t.url.pathname===e.url.pathname&&t.url.search===e.url.search&&t.url.hash===e.url.hash)return;i||e&&e.url&&e.url.hash===t.url.hash&&e.url.pathname===t.url.pathname||u(t.url.hash,e&&e.url&&e.url.pathname===t.url.pathname?a:"auto")}},[d]);var k=e.useMemo(function(){return{chunks:w,connect:P,content:S,element:P(e.createElement(e.Fragment,null,_,S)),final:g,head:_}},[w,P,S,g,_]);return 0===y.length?null:k}var P=function(t){var e=E({disableScrolling:t.disableScrolling,hashScrollBehavior:t.hashScrollBehavior,renderHead:t.renderHead,where:t.where});if(!e)throw new Error("A Navi <View> was not able to find a view to render.");return e.element},S=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),_=function(t){function r(e){var r=t.call(this,e)||this;return r.navigation=e.navigation||n.createBrowserNavigation({basename:e.basename,context:e.context,history:e.history,routes:e.routes}),r}return S(r,t),r.prototype.render=function(){var t=this.props,n=t.children,r=t.hashScrollBehavior;return e.createElement(b,{navigation:this.navigation,hashScrollBehavior:r},n||e.createElement(P,null))},r.prototype.componentDidMount=function(){this.props.navigation&&this.props.context&&this.props.navigation.setContext(this.props.context)},r.prototype.componentDidUpdate=function(t){(function(t,e){for(var n in t)if(!(n in e))return!0;for(var n in e)if(t[n]!==e[n])return!0;return!1})(t.context||{},this.props.context||{})&&this.navigation.setContext(this.props.context||{})},r.prototype.componentWillUnmount=function(){this.props.navigation||this.navigation.dispose(),delete this.navigation},r.defaultProps={fallback:void 0},r}(e.Component);t.HashScroll=o,t.useLinkProps=d,t.useActive=v,t.Link=y,t.NaviProvider=b,t.NotFoundBoundary=function(t){return e.createElement(s.Consumer,null,function(n){return e.createElement(C,w({context:n},t))})},t.Router=_,t.useNavigation=function(){return e.useContext(s).navigation},t.useHistory=function(){return e.useContext(s).navigation._history},t.History=function(t){return e.useEffect(function(){},[]),e.createElement(s.Consumer,null,function(e){return t.children(e.navigation._history)})},t.useLoadingRoute=function(){return e.useContext(s).busyRoute},t.useCurrentRoute=function(){var t=e.useContext(s),n=t.steadyRoute,r=t.busyRoute;return n||r},t.View=P,t.useView=E,t.useViewElement=function(t){void 0===t&&(t={});var e=E(t);return e&&e.element},t.ViewHeadRendererContext=R,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("navi")):"function"==typeof define&&define.amd?define(["exports","react","navi"],e):e((t=t||self).ReactNavi={},t.React,t.Navi)}(this,function(t,e,n){"use strict";var r=e.createContext("auto");function o(t){return t.behavior?e.createElement(r.Provider,{value:t.behavior},t.children):e.createElement(e.Fragment,null,t.children)}function i(t,e){try{window.scroll({top:e,left:t,behavior:"smooth"})}catch(n){window.scroll(t,e)}}var a={none:function(){},auto:function(t){if(t){var e=document.getElementById(t.slice(1));if(e){var n=e.getBoundingClientRect(),r=n.top,o=n.left;window.scroll(o+window.pageXOffset,r+window.pageYOffset)}}else window.scroll(0,0)},smooth:function(t){if(t){var e=document.getElementById(t.slice(1));if(e){var n=e.getBoundingClientRect(),r=n.top;i(n.left+window.pageXOffset,r+window.pageYOffset),e.focus()}}else i(0,0)}};function u(t,e){void 0===e&&(e="auto"),("string"==typeof e?a[e]:e)(t)}var s=e.createContext({}),c=(s.Consumer,s.Provider,function(){return(c=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)}),l=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};function f(t){return!t||"string"==typeof t&&(-1!==t.indexOf("://")||0===t.indexOf("mailto:"))}function h(t,e){if(!f(t))return e&&"string"==typeof t&&(t="/"===t[0]?t:n.joinPaths("/",e.pathname,t)),n.createURLDescriptor(t)}var p,v=function(t,r){var o=void 0===r?{}:r,i=o.exact,a=void 0===i||i,u=o.loading,c=void 0!==u&&u,l=e.useContext(s),f=c?l.busyRoute||l.steadyRoute:l.steadyRoute||l.busyRoute,p=f&&f.url,v=h(t,p);return!(!v||!p||(a?v.pathname!==p.pathname:0!==n.modifyTrailingSlash(p.pathname,"add").indexOf(v.pathname)))},d=function(t){var o,i,a=t.disabled,c=t.hashScrollBehavior,l=t.href,p=t.prefetch,v=t.state,d=t.onClick,y=t.onMouseEnter;p&&v&&(p=!1),!0===p&&(p="mount"),void 0===p&&(p="hover");var m=e.useContext(r),b=e.useContext(s),g=b.navigation;void 0===c&&(c=m);var w=b.steadyRoute||b.busyRoute,C=e.useMemo(function(){return w&&w.url},[null===(o=w)||void 0===o?void 0:o.url.href]),R=h(l,C);if(!f(l)){var x=l;C&&"string"==typeof l&&(x="/"===l[0]?l:n.joinPaths("/",C.pathname,l)),R=n.createURLDescriptor(x)}var O=e.useMemo(function(){return R},[null===(i=R)||void 0===i?void 0:i.href]),E=e.useMemo(function(){var t=!1;return function(){!t&&O&&O.pathname&&g&&(t=!0,g.prefetch(O).catch(function(t){console.warn('A <Link> tried to prefetch "'+O.pathname+'", but the router was unable to fetch this path.')}))}},[O,g]);e.useEffect(function(){"mount"===p&&E()},[p,E]);var P=e.useCallback(function(t){if("hover"===p){if(y&&y(t),a)return void t.preventDefault();t.defaultPrevented||E()}},[a,E,y,p]);return{onClick:e.useCallback(function(t){if(0===t.button&&!(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)){if(a)return void t.preventDefault();if(d&&d(t),!C)return;if(!t.defaultPrevented&&R){t.preventDefault();var e=n.modifyTrailingSlash(R.pathname,"remove")===n.modifyTrailingSlash(C.pathname,"remove");g.navigate(R,v?{state:v}:void 0),(e||""===R.pathname)&&R.hash===C.hash&&R.hash&&u(C.hash,c)}}},[a,d,R&&R.href,C&&C.href]),onMouseEnter:P,href:R?R.href:l}},y=e.forwardRef(function(t,n){var r=t.active,o=t.activeClassName,i=t.activeStyle,a=t.className,u=(t.disabled,t.exact),s=t.hashScrollBehavior,f=t.href,h=t.onClick,p=t.onMouseEnter,y=t.prefetch,m=t.state,b=t.style,g=l(t,["active","activeClassName","activeStyle","className","disabled","exact","hashScrollBehavior","href","onClick","onMouseEnter","prefetch","state","style"]),w=d({hashScrollBehavior:s,href:f,onClick:h,onMouseEnter:p,prefetch:y,state:m}),C=w.onClick,R=w.onMouseEnter,x=l(w,["onClick","onMouseEnter"]),O=v(x.href,{exact:!!u});return void 0===r&&(r=O),e.createElement("a",c({ref:n,className:(a||"")+" "+(r&&o||""),style:b&&i?Object.assign({},b,r?i:{}):void 0},g,x,{onClick:t.target?h:C,onMouseEnter:t.target?p:R}))}),m=(p=function(t,e){return(p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}p(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),b=function(t){function n(e){var n=t.call(this,e)||this;return n.handleNavigationSnapshot=function(t){"busy"!==t.type?n.setState({steadyRoute:t,busyRoute:void 0}):n.setState({busyRoute:t})},n.handleError=function(t){throw t},n.state={},n}return m(n,t),n.getDerivedStateFromProps=function(t,e){if(e.navigation!==t.navigation){var n=t.navigation.getCurrentValue();return"busy"===n.type?{steadyRoute:e.steadyRoute,busyRoute:n,navigation:t.navigation}:{steadyRoute:n,busyRoute:void 0,navigation:t.navigation}}return null},n.prototype.render=function(){return e.createElement(o,{behavior:this.props.hashScrollBehavior},e.createElement(s.Provider,{value:this.state},this.props.children))},n.prototype.componentDidMount=function(){this.subscribe()},n.prototype.componentDidUpdate=function(t){t.navigation!==this.props.navigation&&(this.unsubscribe(),this.subscribe())},n.prototype.componentWillUnmount=function(){this.unsubscribe()},n.prototype.subscribe=function(){if(!this.props.navigation)throw new Error('A <NaviProvider> component must receive a "navigation" prop.');this.subscription=this.props.navigation.subscribe(this.handleNavigationSnapshot,this.handleError)},n.prototype.unsubscribe=function(){this.subscription&&(this.subscription.unsubscribe(),delete this.subscription)},n}(e.Component),g=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),w=function(){return(w=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},C=function(t){function e(e){var n=t.call(this,e)||this;return n.state={},n}return g(e,t),e.getDerivedStateFromProps=function(t,e){return e.error&&t.context.steadyRoute.url.pathname!==e.errorPathname?{error:void 0,errorPathname:void 0,errorInfo:void 0}:null},e.prototype.componentDidCatch=function(t,e){if(!(t instanceof n.NotFoundError))throw t;this.setState({error:t,errorInfo:e,errorPathname:this.props.context.steadyRoute.url.pathname})},e.prototype.componentDidUpdate=function(t,e){this.state.error&&e.error},e.prototype.render=function(){return this.state.error?this.props.render(this.state.error):this.props.children},e}(e.Component),R=e.createContext(null),x=function(){return(x=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function O(t){return"view"===t.type}function E(t){var n=void 0===t?{}:t,o=n.disableScrolling,i=void 0!==o&&o,a=n.hashScrollBehavior,c=n.renderHead,l=n.where,f=void 0===l?O:l,h=e.useContext(r),p=e.useContext(R),v=e.useContext(s);void 0===a&&(a=h),void 0===c&&p&&(c=p);var d=v.steadyRoute||v.busyRoute;if(!d)throw new Error("react-navi: A <View> component cannot be rendered outside of a <Router> or <NaviProvider> component.");var y=v.unconsumedSteadyRouteChunks||d.chunks,m=y.findIndex(f),b=-1!==m&&y[m].view,g=-1===m||!y.slice(m+1).find(f)&&"error"!==d.type,w=e.useMemo(function(){return g?y:y.slice(0,m+1)},[g,y,m]),C=w.find(function(t){return"error"===t.type});if(C)throw C.error||new Error("Unknown routing error");if(!b&&!v.steadyRoute)throw v.navigation.getRoute();var E=e.useMemo(function(){return x(x({},v),{unconsumedSteadyRouteChunks:g?[]:y.slice(m+1)})},[v,y,m]),P=e.useCallback(function(t){return e.createElement(s.Provider,{value:E},e.isValidElement(t)?e.cloneElement(t):t)},[E]),S=e.useMemo(function(){return"function"==typeof b?e.createElement(b,{route:v.steadyRoute}):b||null},[b,v.steadyRoute]),_=e.useMemo(function(){return c?c(w):null},[c,w]),j=e.useRef();e.useEffect(function(){var t=d,e=j.current;if(j.current=d,g&&d&&0!==y.length&&t&&"busy"!==t.type){if(e&&t.url.pathname===e.url.pathname&&t.url.search===e.url.search&&t.url.hash===e.url.hash)return;i||e&&e.url&&e.url.hash===t.url.hash&&e.url.pathname===t.url.pathname||u(t.url.hash,e&&e.url&&e.url.pathname===t.url.pathname?a:"auto")}},[d]);var k=e.useMemo(function(){return{chunks:w,connect:P,content:S,element:P(e.createElement(e.Fragment,null,_,S)),final:g,head:_}},[w,P,S,g,_]);return 0===y.length?null:k}var P=function(t){var e=E({disableScrolling:t.disableScrolling,hashScrollBehavior:t.hashScrollBehavior,renderHead:t.renderHead,where:t.where});if(!e)throw new Error("A Navi <View> was not able to find a view to render.");return e.element},S=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),_=function(t){function r(e){var r=t.call(this,e)||this;return r.navigation=e.navigation||n.createBrowserNavigation({basename:e.basename,context:e.context,history:e.history,routes:e.routes}),r}return S(r,t),r.prototype.render=function(){var t=this.props,n=t.children,r=t.hashScrollBehavior;return e.createElement(b,{navigation:this.navigation,hashScrollBehavior:r},n||e.createElement(P,null))},r.prototype.componentDidMount=function(){this.props.navigation&&this.props.context&&this.props.navigation.setContext(this.props.context)},r.prototype.componentDidUpdate=function(t){(function(t,e){for(var n in t)if(!(n in e))return!0;for(var n in e)if(t[n]!==e[n])return!0;return!1})(t.context||{},this.props.context||{})&&this.navigation.setContext(this.props.context||{})},r.prototype.componentWillUnmount=function(){this.props.navigation||this.navigation.dispose(),delete this.navigation},r.defaultProps={fallback:void 0},r}(e.Component);t.HashScroll=o,t.useLinkProps=d,t.useActive=v,t.Link=y,t.NaviProvider=b,t.NotFoundBoundary=function(t){return e.createElement(s.Consumer,null,function(n){return e.createElement(C,w({context:n},t))})},t.Router=_,t.useNavigation=function(){return e.useContext(s).navigation},t.useHistory=function(){return e.useContext(s).navigation._history},t.History=function(t){return e.useEffect(function(){},[]),e.createElement(s.Consumer,null,function(e){return t.children(e.navigation._history)})},t.useLoadingRoute=function(){return e.useContext(s).busyRoute},t.useCurrentRoute=function(){var t=e.useContext(s),n=t.steadyRoute,r=t.busyRoute;return n||r},t.View=P,t.useView=E,t.useViewElement=function(t){void 0===t&&(t={});var e=E(t);return e&&e.element},t.ViewHeadRendererContext=R,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "react-navi",
"version": "0.14.1",
"version": "0.14.2",
"description": "A batteries-included router for react.",

@@ -68,3 +68,3 @@ "author": "James K Nelson <james@jamesknelson.com>",

},
"gitHead": "137a81f41ced60e5b53d49540396e9f3ee87eeaf"
"gitHead": "01344cd22d0d5e8e3d6ad40c344ae8fc783c38a7"
}

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc