Socket
Socket
Sign inDemoInstall

react-router-magic

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-router-magic - npm Package Compare versions

Comparing version 0.6.3 to 0.6.4

2

lib/index.js

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

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],e):"object"==typeof exports?exports.ReactRouterMagic=e(require("react"),require("prop-types")):t.ReactRouterMagic=e(t.React,t.PropTypes)}(this,function(t,e){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var r={};return e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,o){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var r=t&&t.__esModule?function(){return t["default"]}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=16)}([function(e,r){e.exports=t},function(t,e,r){"use strict";function o(t,e,r){return h(t)?t(e,r):t}function n(t,e,r){return!1===e["switch"]&&t.switchIndex!==undefined&&console.warn("You should not set switchIndex props yourself"),e["switch"]&&t.switchIndex===undefined&&console.warn("Error: Switch children are supposed to have switchIndex passed from parent"),(!e["switch"]||!1!==e["switch"].matchIndex)&&((!e["switch"]||t.switchIndex===undefined||e["switch"].matchIndex===t.switchIndex)&&r)}function i(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function c(t,e,r,n,i,c){void 0===n&&(n=!1);var p=i?o(i,r,c):null,h=a(t,p,r,c),f=e.createHref(h),l=function(){return s(h,e,n)};return{href:f,navigate:l,match:p,location:r,handleAnchorClick:u(l)}}function u(t){return function(e,r){e.defaultPrevented||0!==e.button||r||i(e)||(e.preventDefault(),t())}}function s(t,e,r){void 0===r&&(r=!1),r?e.replace(t):e.push(t)}function a(t,e,r,o){var n=h(t)?t(e,r,o):t;return f(n)?{pathname:n}:n}function p(t,e,r){if("string"!=typeof e)for(var o=Object.getOwnPropertyNames(e),n=0;o.length>n;++n)if(!(l[o[n]]||d[o[n]]||r&&r[o[n]]))try{t[o[n]]=e[o[n]]}catch(i){console.warn(i)}return t}Object.defineProperty(e,"__esModule",{value:!0});var h=r(8),f=r(15);e.execValOrFunc=o,e.checkSwitchState=n,e.isModifiedEvent=i,e.createNavParams=c,e.createHandleAnchorClick=u,e.navigate=s,e.execTo=a;var l={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},d={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0};e.hoistNonReactStatics=p},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Store=function(){function t(t){this.listeners=[],this.state=t,this.subscribe=this.subscribe.bind(this)}return t.prototype.setState=function(t){return this.state=t,this.broadcast(this.state),this},t.prototype.broadcast=function(t){this.listeners.forEach(function(e){return e(t)})},t.prototype.getState=function(){return this.state},t.prototype.subscribe=function(t){var e=this;return this.listeners.push(t),function(){var r=e.listeners.indexOf(t);r>-1&&e.listeners.splice(r,1)}},t}()},function(t,r){t.exports=e},function(t,e,r){function o(t){return null===t||t===undefined}function n(t){return!(!t||"object"!=typeof t||"number"!=typeof t.length)&&("function"==typeof t.copy&&"function"==typeof t.slice&&(0>=t.length||"number"==typeof t[0]))}function i(t,e,r){var i,p;if(o(t)||o(e))return!1;if(t.prototype!==e.prototype)return!1;if(s(t))return!!s(e)&&(t=c.call(t),e=c.call(e),a(t,e,r));if(n(t)){if(!n(e))return!1;if(t.length!==e.length)return!1;for(i=0;t.length>i;i++)if(t[i]!==e[i])return!1;return!0}try{var h=u(t),f=u(e)}catch(l){return!1}if(h.length!=f.length)return!1;for(h.sort(),f.sort(),i=h.length-1;i>=0;i--)if(h[i]!=f[i])return!1;for(i=h.length-1;i>=0;i--)if(p=h[i],!a(t[p],e[p],r))return!1;return typeof t==typeof e}var c=Array.prototype.slice,u=r(14),s=r(13),a=t.exports=function(t,e,r){return r||(r={}),t===e||(t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():!t||!e||"object"!=typeof t&&"object"!=typeof e?r.strict?t===e:t==e:i(t,e,r))}},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(2),c=r(3),u=r(1),s=function(t){function e(e,r){var o=t.call(this,e,r)||this;if(!(r.routerStore&&r.routerStore.getState()&&r.router&&r.router.history))throw Error("InjectMatch need a RouterProvider as ancestor");return o}return o(e,t),e.prototype.componentDidMount=function(){var t=this;!0!==this.props.noSubscribe&&(this.unsubscribe=this.context.routerStore.subscribe(function(){t.forceUpdate()}))},e.prototype.componentWillReceiveProps=function(t){var e=this;this.props.noSubscribe!==t.noSubscribe&&(t.noSubscribe&&this.unsubscribe?this.unsubscribe():this.unsubscribe=this.context.routerStore.subscribe(function(){e.forceUpdate()}))},e.prototype.render=function(){var t=this.props,e=t.renderChild,r=t.to,o=t.replace,n=t.match,i=this.context.routerStore.getState();return e(u.createNavParams(r,this.context.router.history,i.location,o,n,i.match))},e}(n.Component);s.displayName="NavProvider",s.contextTypes={routerStore:c.instanceOf(i.Store),router:c.any},e.NavProvider=s},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(3),c=r(2),u=r(1),s=function(t){function e(e,r){var o=t.call(this,e,r)||this;return o.unsubscribe=r.routerStore.subscribe(function(){o.update(o.props)}),o}return o(e,t),e.prototype.componentDidMount=function(){var t=this;!0!==this.props.noSubscribe&&(this.unsubscribe=this.context.routerStore.subscribe(function(){t.update(t.props)})),this.update(this.props)},e.prototype.componentWillReceiveProps=function(t){this.update(t)},e.prototype.render=function(){return null},e.prototype.componentWillUnmount=function(){this.unsubscribe&&this.unsubscribe()},e.prototype.update=function(t){var e=this.context.routerStore.getState(),r=u.checkSwitchState(t,e,u.execValOrFunc(this.props.match,e.location,e.match)),o=!0===this.props.push;if(!1!==r){var n=u.execTo(this.props.to,r,e.location,e.match);u.navigate(n,this.context.router.history,!o)}},e}(n.Component);s.displayName="Redirect",s.contextTypes={routerStore:i.instanceOf(c.Store),router:i.any},e.Redirect=s},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(3),c=r(8),u=r(4),s=r(0),a=r(2),p=r(1),h=function(t){function e(e,r){var o=t.call(this,e,r)||this;if(o.matchResult=null,!r.routerStore||!r.routerStore.getState())throw Error("Route need a RouterProvider as ancestor");var n=r.routerStore.getState();return o.matchResult=p.execValOrFunc(e.match,n.location,n.match),!0!==e.passif&&(o.unsubscribe=r.routerStore.subscribe(function(){o.update(o.props)})),o.update(o.props,!1),o}return o(e,t),e.prototype.getChildContext=function(){return{routerStore:this.routerStore}},e.prototype.componentWillReceiveProps=function(t){this.update(t,!1)},e.prototype.componentWillUnmount=function(){this.unsubscribe&&this.unsubscribe()},e.prototype.render=function(){var t=this.props,e=t.component,r=t.render,o=t.children,i={match:this.matchResult,location:this.context.routerStore.getState().location};return e?!1!==this.matchResult?n.createElement(e,i):null:r?!1!==this.matchResult?r(i):null:c(o)?o(i):o?n.Children.only(o):null},e.prototype.update=function(t,e){void 0===e&&(e=!0);var r=this.context.routerStore.getState();this.matchResult=p.execValOrFunc(t.match,r.location,r.match),this.matchResult=p.checkSwitchState(t,r,this.matchResult);var o={location:r.location,match:this.matchResult,"switch":!1};this.routerStore?u(this.routerStore.getState(),o)||(this.routerStore.setState(o),e&&this.forceUpdate()):(this.routerStore=new a.Store(o),e&&this.forceUpdate())},e}(s.Component);h.displayName="Route",h.childContextTypes={routerStore:i.instanceOf(a.Store)},h.contextTypes={routerStore:i.instanceOf(a.Store)},e.Route=h},function(t,e){function r(t){var e=o(t)?u.call(t):"";return e==n||e==i}function o(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}var n="[object Function]",i="[object GeneratorFunction]",c=Object.prototype,u=c.toString;t.exports=r},function(t,e,r){"use strict";function o(t){return void 0===t&&(t={}),function(e){var r=t.match,o=void 0===r||r,h=t.location,f=void 0===h||h,l=t.history,d=void 0===l||l;if(!o&&!f&&!d)return console.warn("All inject are off, just returning the component"),e;var y=!o&&!f&&d,v=function(t){function r(e,r){var o=t.call(this,e,r)||this;if(!(r.routerStore&&r.routerStore.getState()&&r.router&&r.router.history))throw Error("InjectMatch need a RouterProvider as ancestor");return y&&(o.unsubscribe=r.routerStore.subscribe(function(){o.forceUpdate()})),o}return n(r,t),r.prototype.componentWillUnmount=function(){this.unsubscribe&&this.unsubscribe()},r.prototype.render=function(){var t={};return o&&(t.match=this.context.routerStore.getState().match),d&&(t.history=this.context.router.history),f&&(t.location=this.context.routerStore.getState().location),c.createElement(e,i({},t,this.props))},r}(u.Component);return v.displayName="MagicRouterProvider",v.contextTypes={routerStore:s.instanceOf(a.Store),router:s.any},p.hoistNonReactStatics(v,e)}}var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),i=this&&this.__assign||Object.assign||function(t){for(var e,r=1,o=arguments.length;o>r;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t};Object.defineProperty(e,"__esModule",{value:!0});var c=r(0),u=r(0),s=r(3),a=r(2),p=r(1);e.InjectMagicRouter=o},function(t,e,r){"use strict";var o=this&&this.__assign||Object.assign||function(t){for(var e,r=1,o=arguments.length;o>r;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},n=this&&this.__rest||function(t,e){var r={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(r[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,o=Object.getOwnPropertySymbols(t);o.length>n;n++)0>e.indexOf(o[n])&&(r[o[n]]=t[o[n]]);return r};Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),c=r(5);e.Link=function(t){var e=t.to,r=t.match,u=t.noSubscribe,s=t.replace,a=t.activeClassName,p=void 0===a?"":a,h=t.className,f=n(t,["to","match","noSubscribe","replace","activeClassName","className"]);return i.createElement(c.NavProvider,o({},{to:e,match:r,noSubscribe:u,replace:s},{renderChild:function(t){return i.createElement("a",o({},f,{href:t.href,className:[!1===r?p:"",h].join(" "),onClick:function(e){return f.onClick&&f.onClick(e),t.handleAnchorClick(e)}}))}}))}},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(3),c=r(4),u=r(0),s=r(2),a=function(t){function e(e){var r=t.call(this,e)||this;return r.routerStore=new s.Store({location:e.location,match:null,"switch":!1}),r}return o(e,t),e.prototype.componentWillReceiveProps=function(t){c(t.location,this.props.location)||this.routerStore.setState({location:t.location,match:null,"switch":!1})},e.prototype.getChildContext=function(){return{router:{history:this.props.history},routerStore:this.routerStore}},e.prototype.render=function(){return n.Children.only(this.props.children)},e}(u.Component);a.displayName="RouterProvider",a.childContextTypes={routerStore:i.instanceOf(s.Store),router:i.any},e.RouterProvider=a},function(t,e,r){"use strict";function o(t,e){return t.type===e}var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),c=r(0),u=r(3),s=r(2),a=r(7),p=r(6),h=r(1),f=r(4),l=function(t){function e(e,r){var o=t.call(this,e,r)||this;if(o.validChildren=[],!r.routerStore||!r.routerStore.getState())throw Error("Switch need a RouterProvider as ancestor");return o.unsubscribe=r.routerStore.subscribe(function(){o.update(o.props)}),o.update(e,!1),o}return n(e,t),e.prototype.getChildContext=function(){return{routerStore:this.routerStore}},e.prototype.componentWillReceiveProps=function(t){this.update(t,!1)},e.prototype.componentWillUnmount=function(){this.unsubscribe&&this.unsubscribe()},e.prototype.render=function(){var t=this.props.renderContainer;return(void 0===t?this.defaultRenderContainer:t)(this.validChildren.map(function(t,e){return i.cloneElement(t,{switchIndex:e})}))},e.prototype.defaultRenderContainer=function(t){return i.createElement("div",null,i.Children.toArray(t))},e.prototype.updateValidChildren=function(t){var e=this;this.validChildren=[],i.Children.forEach(t.children,function(t){i.isValidElement(t)&&(o(t,a.Route)||o(t,p.Redirect)?e.validChildren.push(t):console.warn("Switch only accept Route or Redirect components as children"))})},e.prototype.update=function(t,e){void 0===e&&(e=!0),this.updateValidChildren(t);var r=this.context.routerStore.getState(),o=null,n=!1;this.validChildren.forEach(function(t,e){if(!1===n){var i=h.execValOrFunc(t.props.match,r.location,r.match);!1!==i&&(o=i,n=e)}});var i={location:r.location,match:r.match,"switch":{match:o,matchIndex:n}};this.routerStore?f(this.routerStore.getState(),i)||(this.routerStore.setState(i),e&&this.forceUpdate()):(this.routerStore=new s.Store(i),e&&this.forceUpdate())},e}(c.Component);l.displayName="Switch",l.childContextTypes={routerStore:u.instanceOf(s.Store)},l.contextTypes={routerStore:u.instanceOf(s.Store)},e.Switch=l},function(t,e){function r(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function o(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Object.prototype.hasOwnProperty.call(t,"callee")&&!Object.prototype.propertyIsEnumerable.call(t,"callee")||!1}e=t.exports="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}()?r:o,e.supported=r,e.unsupported=o},function(t,e){function r(t){var e=[];for(var r in t)e.push(r);return e}e=t.exports="function"==typeof Object.keys?Object.keys:r,e.shim=r},function(t,e){function r(t){return!!t&&"object"==typeof t}function o(t){return"string"==typeof t||!u(t)&&r(t)&&c.call(t)==n}var n="[object String]",i=Object.prototype,c=i.toString,u=Array.isArray;t.exports=o},function(t,e,r){"use strict";function o(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),o(r(7)),o(r(12)),o(r(5)),o(r(11)),o(r(6)),o(r(10)),o(r(9));var n=r(1);e.createNavParams=n.createNavParams,e.createHandleAnchorClick=n.createHandleAnchorClick,e.navigate=n.navigate}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],e):"object"==typeof exports?exports.ReactRouterMagic=e(require("react"),require("prop-types")):t.ReactRouterMagic=e(t.React,t.PropTypes)}(this,function(t,e){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var r={};return e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,o){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var r=t&&t.__esModule?function(){return t["default"]}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=16)}([function(e,r){e.exports=t},function(t,e,r){"use strict";function o(t,e,r){return h(t)?t(e,r):t}function n(t,e,r){return!1===e["switch"]&&t.switchIndex!==undefined&&console.warn("You should not set switchIndex props yourself"),e["switch"]&&t.switchIndex===undefined&&console.warn("Error: Switch children are supposed to have switchIndex passed from parent"),(!e["switch"]||!1!==e["switch"].matchIndex)&&((!e["switch"]||t.switchIndex===undefined||e["switch"].matchIndex===t.switchIndex)&&r)}function i(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function c(t,e,r,n,i,c){void 0===n&&(n=!1);var p=i?o(i,r,c):null,h=a(t,p,r,c),f=e.createHref(h),l=function(){return s(h,e,n)};return{href:f,navigate:l,match:p,location:r,handleAnchorClick:u(l)}}function u(t){return function(e,r){e.defaultPrevented||0!==e.button||r||i(e)||(e.preventDefault(),t())}}function s(t,e,r){void 0===r&&(r=!1),r?e.replace(t):e.push(t)}function a(t,e,r,o){var n=h(t)?t(e,r,o):t;return f(n)?{pathname:n}:n}function p(t,e,r){if("string"!=typeof e)for(var o=Object.getOwnPropertyNames(e),n=0;o.length>n;++n)if(!(l[o[n]]||d[o[n]]||r&&r[o[n]]))try{t[o[n]]=e[o[n]]}catch(i){console.warn(i)}return t}Object.defineProperty(e,"__esModule",{value:!0});var h=r(8),f=r(15);e.execValOrFunc=o,e.checkSwitchState=n,e.isModifiedEvent=i,e.createNavParams=c,e.createHandleAnchorClick=u,e.navigate=s,e.execTo=a;var l={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},d={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0};e.hoistNonReactStatics=p},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Store=function(){function t(t){this.listeners=[],this.state=t,this.subscribe=this.subscribe.bind(this)}return t.prototype.setState=function(t){return this.state=t,this.broadcast(this.state),this},t.prototype.broadcast=function(t){this.listeners.forEach(function(e){return e(t)})},t.prototype.getState=function(){return this.state},t.prototype.subscribe=function(t){var e=this;return this.listeners.push(t),function(){var r=e.listeners.indexOf(t);r>-1&&e.listeners.splice(r,1)}},t}()},function(t,r){t.exports=e},function(t,e,r){function o(t){return null===t||t===undefined}function n(t){return!(!t||"object"!=typeof t||"number"!=typeof t.length)&&("function"==typeof t.copy&&"function"==typeof t.slice&&(0>=t.length||"number"==typeof t[0]))}function i(t,e,r){var i,p;if(o(t)||o(e))return!1;if(t.prototype!==e.prototype)return!1;if(s(t))return!!s(e)&&(t=c.call(t),e=c.call(e),a(t,e,r));if(n(t)){if(!n(e))return!1;if(t.length!==e.length)return!1;for(i=0;t.length>i;i++)if(t[i]!==e[i])return!1;return!0}try{var h=u(t),f=u(e)}catch(l){return!1}if(h.length!=f.length)return!1;for(h.sort(),f.sort(),i=h.length-1;i>=0;i--)if(h[i]!=f[i])return!1;for(i=h.length-1;i>=0;i--)if(p=h[i],!a(t[p],e[p],r))return!1;return typeof t==typeof e}var c=Array.prototype.slice,u=r(14),s=r(13),a=t.exports=function(t,e,r){return r||(r={}),t===e||(t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():!t||!e||"object"!=typeof t&&"object"!=typeof e?r.strict?t===e:t==e:i(t,e,r))}},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(2),c=r(3),u=r(1),s=function(t){function e(e,r){var o=t.call(this,e,r)||this;if(!(r.routerStore&&r.routerStore.getState()&&r.router&&r.router.history))throw Error("InjectMatch need a RouterProvider as ancestor");return o}return o(e,t),e.prototype.componentDidMount=function(){var t=this;!0!==this.props.noSubscribe&&(this.unsubscribe=this.context.routerStore.subscribe(function(){t.forceUpdate()}))},e.prototype.componentWillReceiveProps=function(t){var e=this;this.props.noSubscribe!==t.noSubscribe&&(t.noSubscribe&&this.unsubscribe?this.unsubscribe():this.unsubscribe=this.context.routerStore.subscribe(function(){e.forceUpdate()}))},e.prototype.render=function(){var t=this.props,e=t.renderChild,r=t.to,o=t.replace,n=t.match,i=this.context.routerStore.getState();return e(u.createNavParams(r,this.context.router.history,i.location,o,n,i.match))},e}(n.Component);s.displayName="NavProvider",s.contextTypes={routerStore:c.instanceOf(i.Store),router:c.any},e.NavProvider=s},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(3),c=r(2),u=r(1),s=function(t){function e(e,r){var o=t.call(this,e,r)||this;return o.unsubscribe=r.routerStore.subscribe(function(){o.update(o.props)}),o}return o(e,t),e.prototype.componentDidMount=function(){var t=this;!0!==this.props.noSubscribe&&(this.unsubscribe=this.context.routerStore.subscribe(function(){t.update(t.props)})),this.update(this.props)},e.prototype.componentWillReceiveProps=function(t){this.update(t)},e.prototype.render=function(){return null},e.prototype.componentWillUnmount=function(){this.unsubscribe&&this.unsubscribe()},e.prototype.update=function(t){var e=this.context.routerStore.getState(),r=u.checkSwitchState(t,e,u.execValOrFunc(this.props.match,e.location,e.match)),o=!0===this.props.push;if(!1!==r){var n=u.execTo(this.props.to,r,e.location,e.match);u.navigate(n,this.context.router.history,!o)}},e}(n.Component);s.displayName="Redirect",s.contextTypes={routerStore:i.instanceOf(c.Store),router:i.any},e.Redirect=s},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(3),c=r(8),u=r(4),s=r(0),a=r(2),p=r(1),h=function(t){function e(e,r){var o=t.call(this,e,r)||this;if(o.matchResult=null,!r.routerStore||!r.routerStore.getState())throw Error("Route need a RouterProvider as ancestor");var n=r.routerStore.getState();return o.matchResult=p.execValOrFunc(e.match,n.location,n.match),!0!==e.passif&&(o.unsubscribe=r.routerStore.subscribe(function(){o.update(o.props)})),o.update(o.props,!1),o}return o(e,t),e.prototype.getChildContext=function(){return{routerStore:this.routerStore}},e.prototype.componentWillReceiveProps=function(t){this.update(t,!1)},e.prototype.componentWillUnmount=function(){this.unsubscribe&&this.unsubscribe()},e.prototype.render=function(){var t=this.props,e=t.component,r=t.render,o=t.children,i={match:this.matchResult,location:this.context.routerStore.getState().location};return e?!1!==this.matchResult?n.createElement(e,i):null:r?!1!==this.matchResult?r(i):null:c(o)?o(i):o?n.Children.only(o):null},e.prototype.update=function(t,e){void 0===e&&(e=!0);var r=this.context.routerStore.getState();this.matchResult=p.execValOrFunc(t.match,r.location,r.match),this.matchResult=p.checkSwitchState(t,r,this.matchResult);var o={location:r.location,match:this.matchResult,"switch":!1};this.routerStore?u(this.routerStore.getState(),o)||(this.routerStore.setState(o),e&&this.forceUpdate()):(this.routerStore=new a.Store(o),e&&this.forceUpdate())},e}(s.Component);h.displayName="Route",h.childContextTypes={routerStore:i.instanceOf(a.Store)},h.contextTypes={routerStore:i.instanceOf(a.Store)},e.Route=h},function(t,e){function r(t){var e=o(t)?u.call(t):"";return e==n||e==i}function o(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}var n="[object Function]",i="[object GeneratorFunction]",c=Object.prototype,u=c.toString;t.exports=r},function(t,e,r){"use strict";function o(t){return void 0===t&&(t={}),function(e){var r=t.match,o=void 0===r||r,h=t.location,f=void 0===h||h,l=t.history,d=void 0===l||l;if(!o&&!f&&!d)return console.warn("All inject are off, just returning the component"),e;var y=!o&&!f&&d,v=function(t){function r(e,r){var o=t.call(this,e,r)||this;if(!(r.routerStore&&r.routerStore.getState()&&r.router&&r.router.history))throw Error("InjectMatch need a RouterProvider as ancestor");return y&&(o.unsubscribe=r.routerStore.subscribe(function(){o.forceUpdate()})),o}return n(r,t),r.prototype.componentWillUnmount=function(){this.unsubscribe&&this.unsubscribe()},r.prototype.render=function(){var t={};return o&&(t.match=this.context.routerStore.getState().match),d&&(t.history=this.context.router.history),f&&(t.location=this.context.routerStore.getState().location),c.createElement(e,i({},t,this.props))},r}(u.Component);return v.displayName="MagicRouterProvider",v.contextTypes={routerStore:s.instanceOf(a.Store),router:s.any},p.hoistNonReactStatics(v,e)}}var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),i=this&&this.__assign||Object.assign||function(t){for(var e,r=1,o=arguments.length;o>r;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t};Object.defineProperty(e,"__esModule",{value:!0});var c=r(0),u=r(0),s=r(3),a=r(2),p=r(1);e.InjectMagicRouter=o},function(t,e,r){"use strict";var o=this&&this.__assign||Object.assign||function(t){for(var e,r=1,o=arguments.length;o>r;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},n=this&&this.__rest||function(t,e){var r={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(r[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,o=Object.getOwnPropertySymbols(t);o.length>n;n++)0>e.indexOf(o[n])&&(r[o[n]]=t[o[n]]);return r};Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),c=r(5);e.Link=function(t){var e=t.to,r=t.match,u=t.noSubscribe,s=t.replace,a=t.activeClassName,p=void 0===a?"":a,h=t.className,f=n(t,["to","match","noSubscribe","replace","activeClassName","className"]);return i.createElement(c.NavProvider,o({},{to:e,match:r,noSubscribe:u,replace:s},{renderChild:function(t){return i.createElement("a",o({},f,{href:t.href,className:[!1!==t.match?p:"",h].join(" "),onClick:function(e){return f.onClick&&f.onClick(e),t.handleAnchorClick(e)}}))}}))}},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(3),c=r(4),u=r(0),s=r(2),a=function(t){function e(e){var r=t.call(this,e)||this;return r.routerStore=new s.Store({location:e.location,match:null,"switch":!1}),r}return o(e,t),e.prototype.componentWillReceiveProps=function(t){c(t.location,this.props.location)||this.routerStore.setState({location:t.location,match:null,"switch":!1})},e.prototype.getChildContext=function(){return{router:{history:this.props.history},routerStore:this.routerStore}},e.prototype.render=function(){return n.Children.only(this.props.children)},e}(u.Component);a.displayName="RouterProvider",a.childContextTypes={routerStore:i.instanceOf(s.Store),router:i.any},e.RouterProvider=a},function(t,e,r){"use strict";function o(t,e){return t.type===e}var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),c=r(0),u=r(3),s=r(2),a=r(7),p=r(6),h=r(1),f=r(4),l=function(t){function e(e,r){var o=t.call(this,e,r)||this;if(o.validChildren=[],!r.routerStore||!r.routerStore.getState())throw Error("Switch need a RouterProvider as ancestor");return o.unsubscribe=r.routerStore.subscribe(function(){o.update(o.props)}),o.update(e,!1),o}return n(e,t),e.prototype.getChildContext=function(){return{routerStore:this.routerStore}},e.prototype.componentWillReceiveProps=function(t){this.update(t,!1)},e.prototype.componentWillUnmount=function(){this.unsubscribe&&this.unsubscribe()},e.prototype.render=function(){var t=this.props.renderContainer;return(void 0===t?this.defaultRenderContainer:t)(this.validChildren.map(function(t,e){return i.cloneElement(t,{switchIndex:e})}))},e.prototype.defaultRenderContainer=function(t){return i.createElement("div",null,i.Children.toArray(t))},e.prototype.updateValidChildren=function(t){var e=this;this.validChildren=[],i.Children.forEach(t.children,function(t){i.isValidElement(t)&&(o(t,a.Route)||o(t,p.Redirect)?e.validChildren.push(t):console.warn("Switch only accept Route or Redirect components as children"))})},e.prototype.update=function(t,e){void 0===e&&(e=!0),this.updateValidChildren(t);var r=this.context.routerStore.getState(),o=null,n=!1;this.validChildren.forEach(function(t,e){if(!1===n){var i=h.execValOrFunc(t.props.match,r.location,r.match);!1!==i&&(o=i,n=e)}});var i={location:r.location,match:r.match,"switch":{match:o,matchIndex:n}};this.routerStore?f(this.routerStore.getState(),i)||(this.routerStore.setState(i),e&&this.forceUpdate()):(this.routerStore=new s.Store(i),e&&this.forceUpdate())},e}(c.Component);l.displayName="Switch",l.childContextTypes={routerStore:u.instanceOf(s.Store)},l.contextTypes={routerStore:u.instanceOf(s.Store)},e.Switch=l},function(t,e){function r(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function o(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Object.prototype.hasOwnProperty.call(t,"callee")&&!Object.prototype.propertyIsEnumerable.call(t,"callee")||!1}e=t.exports="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}()?r:o,e.supported=r,e.unsupported=o},function(t,e){function r(t){var e=[];for(var r in t)e.push(r);return e}e=t.exports="function"==typeof Object.keys?Object.keys:r,e.shim=r},function(t,e){function r(t){return!!t&&"object"==typeof t}function o(t){return"string"==typeof t||!u(t)&&r(t)&&c.call(t)==n}var n="[object String]",i=Object.prototype,c=i.toString,u=Array.isArray;t.exports=o},function(t,e,r){"use strict";function o(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),o(r(7)),o(r(12)),o(r(5)),o(r(11)),o(r(6)),o(r(10)),o(r(9));var n=r(1);e.createNavParams=n.createNavParams,e.createHandleAnchorClick=n.createHandleAnchorClick,e.navigate=n.navigate}])});
//# sourceMappingURL=index.js.map
{
"name": "react-router-magic",
"version": "0.6.3",
"version": "0.6.4",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

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