Socket
Socket
Sign inDemoInstall

react-easy-router

Package Overview
Dependencies
8
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.4 to 2.0.5

7

CHANGELOGS.md

@@ -17,2 +17,9 @@ # CHANGELOG

## v2.0.5
#### Bug Fixes
- Remove BrowserRouter usage
- Added react-router-dom as a peer-dependency
## v2.0.4

@@ -19,0 +26,0 @@

2

dist/index.modern.js

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

import{useState as t,createContext as e,useContext as n,useEffect as r}from"react";import{Navigate as i,Route as o,BrowserRouter as a,Routes as c}from"react-router-dom";import{jsx as l}from"react/jsx-runtime";function h(){return h=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},h.apply(this,arguments)}const u=/*#__PURE__*/e(),d=/*#__PURE__*/e();function s(){return n(d)}function f({isAuthenticated:e,showLoader:n=!0,loader:r,children:i}){const[o,a]=t(null),[c]=t({isAuthenticated:e,showLoader:n,loader:r});/*#__PURE__*/return l(u.Provider,{value:{auth:o,setAuth:a},children:/*#__PURE__*/l(d.Provider,{value:{config:c},children:i})})}function p(){const{config:t}=s();/*#__PURE__*/return l("div",{className:"loader",style:{height:"100vh",width:"100%",backgroundColor:"white",position:"absolute",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"center"},children:/*#__PURE__*/l("img",{src:t.loader||"https://i.imgur.com/FhvNntt.gif",alt:"loader"})})}function m({failureRedirect:t="/",children:e}){const{auth:o,setAuth:a}=n(u),{config:{isAuthenticated:c,showLoader:h}}=s();return r(()=>{c?c().then(t=>{a(t)}).catch(()=>a(!1)):a(!1)},[c,a]),null===o?h&&/*#__PURE__*/l(p,{}):o?e:/*#__PURE__*/l(i,{to:t})}function g(t){/*#__PURE__*/return l(o,t.navigate?{path:t.path,element:/*#__PURE__*/l(i,{to:t.navigate})}:t.protected?{path:t.path,element:/*#__PURE__*/l(m,{failureRedirect:t.failureRedirect,children:t.element})}:{path:t.path,element:t.element},t.path)}function v(t,e=""){const n=t.map(t=>{t.path=function(t,e){const n=t.split("/"),r=e.split("/"),i=[...new Set([...n,...r])].join("/");return"/"===i[0]?i:`/${i}`}(e,t.path);let n=[];return t.children&&(n=v(t.children,t.path)),[...n,g(t)]});return n.flat()}function w(t){/*#__PURE__*/return l(a,{children:/*#__PURE__*/l(f,h({},t,{children:/*#__PURE__*/l(c,{children:v(t.routes)})}))})}export{w as default};
import{useState as t,createContext as e,useContext as n,useEffect as r}from"react";import{Navigate as i,Route as o,Routes as a}from"react-router-dom";import{jsx as c}from"react/jsx-runtime";function l(){return l=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},l.apply(this,arguments)}const u=/*#__PURE__*/e(),h=/*#__PURE__*/e();function d(){return n(h)}function s({isAuthenticated:e,showLoader:n=!0,loader:r,children:i}){const[o,a]=t(null),[l]=t({isAuthenticated:e,showLoader:n,loader:r});/*#__PURE__*/return c(u.Provider,{value:{auth:o,setAuth:a},children:/*#__PURE__*/c(h.Provider,{value:{config:l},children:i})})}function f(){const{config:t}=d();/*#__PURE__*/return c("div",{className:"loader",style:{height:"100vh",width:"100%",backgroundColor:"white",position:"absolute",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"center"},children:/*#__PURE__*/c("img",{src:t.loader||"https://i.imgur.com/FhvNntt.gif",alt:"loader"})})}function p({failureRedirect:t="/",children:e}){const{auth:o,setAuth:a}=n(u),{config:{isAuthenticated:l,showLoader:h}}=d();return r(()=>{l?l().then(t=>{a(t)}).catch(()=>a(!1)):a(!1)},[l,a]),null===o?h&&/*#__PURE__*/c(f,{}):o?e:/*#__PURE__*/c(i,{to:t})}function m(t){/*#__PURE__*/return c(o,t.navigate?{path:t.path,element:/*#__PURE__*/c(i,{to:t.navigate})}:t.protected?{path:t.path,element:/*#__PURE__*/c(p,{failureRedirect:t.failureRedirect,children:t.element})}:{path:t.path,element:t.element},t.path)}function g(t,e=""){const n=t.map(t=>{t.path=function(t,e){const n=t.split("/"),r=e.split("/"),i=[...new Set([...n,...r])].join("/");return"/"===i[0]?i:`/${i}`}(e,t.path);let n=[];return t.children&&(n=g(t.children,t.path)),[...n,m(t)]});return n.flat()}function v(t){/*#__PURE__*/return c(s,l({},t,{children:/*#__PURE__*/c(a,{children:g(t.routes)})}))}export{v as default};
//# sourceMappingURL=index.modern.js.map

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

import{useState as t,createContext as e,useContext as r,useEffect as n}from"react";import{Navigate as i,Route as a,BrowserRouter as o,Routes as c}from"react-router-dom";import{jsx as u}from"react/jsx-runtime";function l(){return l=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},l.apply(this,arguments)}var h=/*#__PURE__*/e(),d=/*#__PURE__*/e();function f(){return r(d)}function s(e){var r=e.isAuthenticated,n=e.showLoader,i=void 0===n||n,a=e.loader,o=e.children,c=t(null),l=c[0],f=c[1],s=t({isAuthenticated:r,showLoader:i,loader:a});/*#__PURE__*/return u(h.Provider,{value:{auth:l,setAuth:f},children:/*#__PURE__*/u(d.Provider,{value:{config:s[0]},children:o})})}function p(){var t=f();/*#__PURE__*/return u("div",{className:"loader",style:{height:"100vh",width:"100%",backgroundColor:"white",position:"absolute",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"center"},children:/*#__PURE__*/u("img",{src:t.config.loader||"https://i.imgur.com/FhvNntt.gif",alt:"loader"})})}function v(t){var e=t.failureRedirect,a=void 0===e?"/":e,o=t.children,c=r(h),l=c.auth,d=c.setAuth,s=f().config,v=s.isAuthenticated,m=s.showLoader;return n(function(){v?v().then(function(t){d(t)}).catch(function(){return d(!1)}):d(!1)},[v,d]),null===l?m&&/*#__PURE__*/u(p,{}):l?o:/*#__PURE__*/u(i,{to:a})}function m(t){/*#__PURE__*/return u(a,t.navigate?{path:t.path,element:/*#__PURE__*/u(i,{to:t.navigate})}:t.protected?{path:t.path,element:/*#__PURE__*/u(v,{failureRedirect:t.failureRedirect,children:t.element})}:{path:t.path,element:t.element},t.path)}function g(t,e){void 0===e&&(e="");var r=t.map(function(t){t.path=function(t,e){var r=t.split("/"),n=e.split("/"),i=[].concat(new Set([].concat(r,n))).join("/");return"/"===i[0]?i:"/"+i}(e,t.path);var r=[];return t.children&&(r=g(t.children,t.path)),[].concat(r,[m(t)])});return r.flat()}function w(t){/*#__PURE__*/return u(o,{children:/*#__PURE__*/u(s,l({},t,{children:/*#__PURE__*/u(c,{children:g(t.routes)})}))})}export{w as default};
import{useState as t,createContext as e,useContext as r,useEffect as n}from"react";import{Navigate as i,Route as a,Routes as o}from"react-router-dom";import{jsx as c}from"react/jsx-runtime";function u(){return u=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},u.apply(this,arguments)}var l=/*#__PURE__*/e(),h=/*#__PURE__*/e();function d(){return r(h)}function f(e){var r=e.isAuthenticated,n=e.showLoader,i=void 0===n||n,a=e.loader,o=e.children,u=t(null),d=u[0],f=u[1],s=t({isAuthenticated:r,showLoader:i,loader:a});/*#__PURE__*/return c(l.Provider,{value:{auth:d,setAuth:f},children:/*#__PURE__*/c(h.Provider,{value:{config:s[0]},children:o})})}function s(){var t=d();/*#__PURE__*/return c("div",{className:"loader",style:{height:"100vh",width:"100%",backgroundColor:"white",position:"absolute",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"center"},children:/*#__PURE__*/c("img",{src:t.config.loader||"https://i.imgur.com/FhvNntt.gif",alt:"loader"})})}function p(t){var e=t.failureRedirect,a=void 0===e?"/":e,o=t.children,u=r(l),h=u.auth,f=u.setAuth,p=d().config,v=p.isAuthenticated,m=p.showLoader;return n(function(){v?v().then(function(t){f(t)}).catch(function(){return f(!1)}):f(!1)},[v,f]),null===h?m&&/*#__PURE__*/c(s,{}):h?o:/*#__PURE__*/c(i,{to:a})}function v(t){/*#__PURE__*/return c(a,t.navigate?{path:t.path,element:/*#__PURE__*/c(i,{to:t.navigate})}:t.protected?{path:t.path,element:/*#__PURE__*/c(p,{failureRedirect:t.failureRedirect,children:t.element})}:{path:t.path,element:t.element},t.path)}function m(t,e){void 0===e&&(e="");var r=t.map(function(t){t.path=function(t,e){var r=t.split("/"),n=e.split("/"),i=[].concat(new Set([].concat(r,n))).join("/");return"/"===i[0]?i:"/"+i}(e,t.path);var r=[];return t.children&&(r=m(t.children,t.path)),[].concat(r,[v(t)])});return r.flat()}function g(t){/*#__PURE__*/return c(f,u({},t,{children:/*#__PURE__*/c(o,{children:m(t.routes)})}))}export{g as default};
//# sourceMappingURL=index.module.js.map

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("react-router-dom"),require("react/jsx-runtime")):"function"==typeof define&&define.amd?define(["react","react-router-dom","react/jsx-runtime"],t):(e||self).reactEasyRouter=t(e.react,e.reactRouterDom,e.jsxRuntime)}(this,function(e,t,n){function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},r.apply(this,arguments)}var i=/*#__PURE__*/e.createContext(),o=/*#__PURE__*/e.createContext();function a(){return e.useContext(o)}function u(t){var r=t.isAuthenticated,a=t.showLoader,u=void 0===a||a,c=t.loader,s=t.children,l=e.useState(null),d=l[0],h=l[1],f=e.useState({isAuthenticated:r,showLoader:u,loader:c});/*#__PURE__*/return n.jsx(i.Provider,{value:{auth:d,setAuth:h},children:/*#__PURE__*/n.jsx(o.Provider,{value:{config:f[0]},children:s})})}function c(){var e=a();/*#__PURE__*/return n.jsx("div",{className:"loader",style:{height:"100vh",width:"100%",backgroundColor:"white",position:"absolute",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"center"},children:/*#__PURE__*/n.jsx("img",{src:e.config.loader||"https://i.imgur.com/FhvNntt.gif",alt:"loader"})})}function s(r){var o=r.failureRedirect,u=void 0===o?"/":o,s=r.children,l=e.useContext(i),d=l.auth,h=l.setAuth,f=a().config,p=f.isAuthenticated,v=f.showLoader;return e.useEffect(function(){p?p().then(function(e){h(e)}).catch(function(){return h(!1)}):h(!1)},[p,h]),null===d?v&&/*#__PURE__*/n.jsx(c,{}):d?s:/*#__PURE__*/n.jsx(t.Navigate,{to:u})}function l(e){/*#__PURE__*/return n.jsx(t.Route,e.navigate?{path:e.path,element:/*#__PURE__*/n.jsx(t.Navigate,{to:e.navigate})}:e.protected?{path:e.path,element:/*#__PURE__*/n.jsx(s,{failureRedirect:e.failureRedirect,children:e.element})}:{path:e.path,element:e.element},e.path)}function d(e,t){void 0===t&&(t="");var n=e.map(function(e){e.path=function(e,t){var n=e.split("/"),r=t.split("/"),i=[].concat(new Set([].concat(n,r))).join("/");return"/"===i[0]?i:"/"+i}(t,e.path);var n=[];return e.children&&(n=d(e.children,e.path)),[].concat(n,[l(e)])});return n.flat()}return function(e){/*#__PURE__*/return n.jsx(t.BrowserRouter,{children:/*#__PURE__*/n.jsx(u,r({},e,{children:/*#__PURE__*/n.jsx(t.Routes,{children:d(e.routes)})}))})}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("react-router-dom"),require("react/jsx-runtime")):"function"==typeof define&&define.amd?define(["react","react-router-dom","react/jsx-runtime"],t):(e||self).reactEasyRouter=t(e.react,e.reactRouterDom,e.jsxRuntime)}(this,function(e,t,n){function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},r.apply(this,arguments)}var i=/*#__PURE__*/e.createContext(),a=/*#__PURE__*/e.createContext();function o(){return e.useContext(a)}function u(t){var r=t.isAuthenticated,o=t.showLoader,u=void 0===o||o,c=t.loader,s=t.children,l=e.useState(null),d=l[0],h=l[1],f=e.useState({isAuthenticated:r,showLoader:u,loader:c});/*#__PURE__*/return n.jsx(i.Provider,{value:{auth:d,setAuth:h},children:/*#__PURE__*/n.jsx(a.Provider,{value:{config:f[0]},children:s})})}function c(){var e=o();/*#__PURE__*/return n.jsx("div",{className:"loader",style:{height:"100vh",width:"100%",backgroundColor:"white",position:"absolute",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"center"},children:/*#__PURE__*/n.jsx("img",{src:e.config.loader||"https://i.imgur.com/FhvNntt.gif",alt:"loader"})})}function s(r){var a=r.failureRedirect,u=void 0===a?"/":a,s=r.children,l=e.useContext(i),d=l.auth,h=l.setAuth,f=o().config,p=f.isAuthenticated,v=f.showLoader;return e.useEffect(function(){p?p().then(function(e){h(e)}).catch(function(){return h(!1)}):h(!1)},[p,h]),null===d?v&&/*#__PURE__*/n.jsx(c,{}):d?s:/*#__PURE__*/n.jsx(t.Navigate,{to:u})}function l(e){/*#__PURE__*/return n.jsx(t.Route,e.navigate?{path:e.path,element:/*#__PURE__*/n.jsx(t.Navigate,{to:e.navigate})}:e.protected?{path:e.path,element:/*#__PURE__*/n.jsx(s,{failureRedirect:e.failureRedirect,children:e.element})}:{path:e.path,element:e.element},e.path)}function d(e,t){void 0===t&&(t="");var n=e.map(function(e){e.path=function(e,t){var n=e.split("/"),r=t.split("/"),i=[].concat(new Set([].concat(n,r))).join("/");return"/"===i[0]?i:"/"+i}(t,e.path);var n=[];return e.children&&(n=d(e.children,e.path)),[].concat(n,[l(e)])});return n.flat()}return function(e){/*#__PURE__*/return n.jsx(u,r({},e,{children:/*#__PURE__*/n.jsx(t.Routes,{children:d(e.routes)})}))}});
//# sourceMappingURL=index.umd.js.map
{
"name": "react-easy-router",
"version": "2.0.4",
"version": "2.0.5",
"description": "The simplest way to add routing to your React app",

@@ -46,5 +46,2 @@ "type": "module",

"homepage": "https://github.com/yousufkalim/react-easy-router#readme",
"dependencies": {
"react-router-dom": "^6.4.0"
},
"devDependencies": {

@@ -65,3 +62,2 @@ "@commitlint/cli": "^17.1.2",

"react-dom": "^18.2.0",
"react-router-dom": "^6.6.1",
"react-scripts": "^5.0.1"

@@ -71,4 +67,5 @@ },

"react": ">=16.8",
"react-dom": ">=16.8"
"react-dom": ">=16.8",
"react-router-dom": ">=6.4.0"
}
}

@@ -6,3 +6,3 @@ /**

import React from 'react';
import { BrowserRouter, Routes } from 'react-router-dom';
import { Routes } from 'react-router-dom';
import { StoreProvider } from '../Store';

@@ -19,8 +19,6 @@ import getRoutes from '../utils/getRoutes';

return (
<BrowserRouter>
<StoreProvider {...props}>
<Routes>{getRoutes(props.routes)}</Routes>
</StoreProvider>
</BrowserRouter>
<StoreProvider {...props}>
<Routes>{getRoutes(props.routes)}</Routes>
</StoreProvider>
);
}

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

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