Socket
Socket
Sign inDemoInstall

redux-first-routing

Package Overview
Dependencies
12
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.1 to 0.2.2

2

dist/redux-first-routing.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.ReduxFirstRouting = global.ReduxFirstRouting || {})));
(factory((global.ReduxFirstRouting = {})));
}(this, (function (exports) { 'use strict';

@@ -6,0 +6,0 @@

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.ReduxFirstRouting=t.ReduxFirstRouting||{})}(this,function(t){"use strict";function e(t,e){return e={exports:{}},t(e,e.exports),e.exports}function n(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function r(t){var e;switch(t.arrayFormat){case"index":return function(t,n,r){e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),e?(void 0===r[t]&&(r[t]={}),r[t][e[1]]=n):r[t]=n};case"bracket":return function(t,n,r){e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),e?void 0!==r[t]?r[t]=[].concat(r[t],n):r[t]=[n]:r[t]=n};default:return function(t,e,n){void 0!==n[t]?n[t]=[].concat(n[t],e):n[t]=e}}}function o(t){return Array.isArray(t)?t.sort():"object"==typeof t?o(Object.keys(t)).sort(function(t,e){return Number(t)-Number(e)}).map(function(e){return t[e]}):t}function a(t,e){e.dispatch(S({pathname:t.location.pathname,search:t.location.search,hash:t.location.hash})),t.listen(function(t){e.dispatch(S({pathname:t.pathname,search:t.search,hash:t.hash}))})}var i=function(){},u=function(t,e,n,r,o,a,i,u){if(!t){var s;if(void 0===e)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,o,a,i,u],f=0;(s=new Error(e.replace(/%s/g,function(){return c[f++]}))).name="Invariant Violation"}throw s.framesToPop=1,s}},s=function(t){return"/"===t.charAt(0)},c=function(t,e){for(var n=e,r=n+1,o=t.length;r<o;n+=1,r+=1)t[n]=t[r];t.pop()},f=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=t&&t.split("/")||[],r=e&&e.split("/")||[],o=t&&s(t),a=e&&s(e),i=o||a;if(t&&s(t)?r=n:n.length&&(r.pop(),r=r.concat(n)),!r.length)return"/";var u=void 0;if(r.length){var f=r[r.length-1];u="."===f||".."===f||""===f}else u=!1;for(var d=0,h=r.length;h>=0;h--){var l=r[h];"."===l?c(r,h):".."===l?(c(r,h),d++):d&&(c(r,h),d--)}if(!i)for(;d--;d)r.unshift("..");!i||""===r[0]||r[0]&&s(r[0])||r.unshift("");var p=r.join("/");return u&&"/"!==p.substr(-1)&&(p+="/"),p},d=e(function(t,e){e.__esModule=!0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=function t(e,r){if(e===r)return!0;if(null==e||null==r)return!1;if(Array.isArray(e))return Array.isArray(r)&&e.length===r.length&&e.every(function(e,n){return t(e,r[n])});var o=void 0===e?"undefined":n(e);if(o!==(void 0===r?"undefined":n(r)))return!1;if("object"===o){var a=e.valueOf(),i=r.valueOf();if(a!==e||i!==r)return t(a,i);var u=Object.keys(e),s=Object.keys(r);return u.length===s.length&&u.every(function(n){return t(e[n],r[n])})}return!1};e.default=r}),h=e(function(t,e){e.__esModule=!0;e.addLeadingSlash=function(t){return"/"===t.charAt(0)?t:"/"+t},e.stripLeadingSlash=function(t){return"/"===t.charAt(0)?t.substr(1):t};var n=e.hasBasename=function(t,e){return new RegExp("^"+e+"(\\/|\\?|#|$)","i").test(t)};e.stripBasename=function(t,e){return n(t,e)?t.substr(e.length):t},e.stripTrailingSlash=function(t){return"/"===t.charAt(t.length-1)?t.slice(0,-1):t},e.parsePath=function(t){var e=t||"/",n="",r="",o=e.indexOf("#");-1!==o&&(r=e.substr(o),e=e.substr(0,o));var a=e.indexOf("?");return-1!==a&&(n=e.substr(a),e=e.substr(0,a)),{pathname:e,search:"?"===n?"":n,hash:"#"===r?"":r}},e.createPath=function(t){var e=t.pathname,n=t.search,r=t.hash,o=e||"/";return n&&"?"!==n&&(o+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(o+="#"===r.charAt(0)?r:"#"+r),o}}),l=e(function(t,e){function n(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0,e.locationsAreEqual=e.createLocation=void 0;var r=Object.assign||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},o=n(f),a=n(d);e.createLocation=function(t,e,n,a){var i=void 0;"string"==typeof t?(i=(0,h.parsePath)(t)).state=e:(void 0===(i=r({},t)).pathname&&(i.pathname=""),i.search?"?"!==i.search.charAt(0)&&(i.search="?"+i.search):i.search="",i.hash?"#"!==i.hash.charAt(0)&&(i.hash="#"+i.hash):i.hash="",void 0!==e&&void 0===i.state&&(i.state=e));try{i.pathname=decodeURI(i.pathname)}catch(t){throw t instanceof URIError?new URIError('Pathname "'+i.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):t}return n&&(i.key=n),a?i.pathname?"/"!==i.pathname.charAt(0)&&(i.pathname=(0,o.default)(i.pathname,a.pathname)):i.pathname=a.pathname:i.pathname||(i.pathname="/"),i},e.locationsAreEqual=function(t,e){return t.pathname===e.pathname&&t.search===e.search&&t.hash===e.hash&&t.key===e.key&&(0,a.default)(t.state,e.state)}}),p=e(function(t,e){e.__esModule=!0;var n=function(t){return t&&t.__esModule?t:{default:t}}(i),r=function(){var t=null,e=[];return{setPrompt:function(e){return(0,n.default)(null==t,"A history supports only one prompt at a time"),t=e,function(){t===e&&(t=null)}},confirmTransitionTo:function(e,r,o,a){if(null!=t){var i="function"==typeof t?t(e,r):t;"string"==typeof i?"function"==typeof o?o(i,a):((0,n.default)(!1,"A history needs a getUserConfirmation function in order to use a prompt message"),a(!0)):a(!1!==i)}else a(!0)},appendListener:function(t){var n=!0,r=function(){n&&t.apply(void 0,arguments)};return e.push(r),function(){n=!1,e=e.filter(function(t){return t!==r})}},notifyListeners:function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];e.forEach(function(t){return t.apply(void 0,n)})}}};e.default=r}),v=e(function(t,e){e.__esModule=!0;e.canUseDOM=!("undefined"==typeof window||!window.document||!window.document.createElement),e.addEventListener=function(t,e,n){return t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent("on"+e,n)},e.removeEventListener=function(t,e,n){return t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent("on"+e,n)},e.getConfirmation=function(t,e){return e(window.confirm(t))},e.supportsHistory=function(){var t=window.navigator.userAgent;return(-1===t.indexOf("Android 2.")&&-1===t.indexOf("Android 4.0")||-1===t.indexOf("Mobile Safari")||-1!==t.indexOf("Chrome")||-1!==t.indexOf("Windows Phone"))&&(window.history&&"pushState"in window.history)},e.supportsPopStateOnHashChange=function(){return-1===window.navigator.userAgent.indexOf("Trident")},e.supportsGoWithoutReloadUsingHash=function(){return-1===window.navigator.userAgent.indexOf("Firefox")},e.isExtraneousPopstateEvent=function(t){return void 0===t.state&&-1===navigator.userAgent.indexOf("CriOS")}}),y=function(t){return t&&t.__esModule?t.default:t}(e(function(t,e){function n(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=Object.assign||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},a=n(i),s=n(u),c=n(p),f=function(){try{return window.history.state||{}}catch(t){return{}}},d=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,s.default)(v.canUseDOM,"Browser history needs a DOM");var e=window.history,n=(0,v.supportsHistory)(),i=!(0,v.supportsPopStateOnHashChange)(),u=t.forceRefresh,d=void 0!==u&&u,p=t.getUserConfirmation,y=void 0===p?v.getConfirmation:p,m=t.keyLength,g=void 0===m?6:m,O=t.basename?(0,h.stripTrailingSlash)((0,h.addLeadingSlash)(t.basename)):"",b=function(t){var e=t||{},n=e.key,r=e.state,o=window.location,i=o.pathname+o.search+o.hash;return(0,a.default)(!O||(0,h.hasBasename)(i,O),'You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "'+i+'" to begin with "'+O+'".'),O&&(i=(0,h.stripBasename)(i,O)),(0,l.createLocation)(i,r,n)},w=function(){return Math.random().toString(36).substr(2,g)},E=(0,c.default)(),A=function(t){o(D,t),D.length=e.length,E.notifyListeners(D.location,D.action)},R=function(t){(0,v.isExtraneousPopstateEvent)(t)||L(b(t.state))},j=function(){L(b(f()))},k=!1,L=function(t){if(k)k=!1,A();else{E.confirmTransitionTo(t,"POP",y,function(e){e?A({action:"POP",location:t}):P(t)})}},P=function(t){var e=D.location,n=x.indexOf(e.key);-1===n&&(n=0);var r=x.indexOf(t.key);-1===r&&(r=0);var o=n-r;o&&(k=!0,U(o))},_=b(f()),x=[_.key],S=function(t){return O+(0,h.createPath)(t)},T=function(t,o){(0,a.default)(!("object"===(void 0===t?"undefined":r(t))&&void 0!==t.state&&void 0!==o),"You should avoid providing a 2nd state argument to push when the 1st argument is a location-like object that already has state; it is ignored");var i=(0,l.createLocation)(t,o,w(),D.location);E.confirmTransitionTo(i,"PUSH",y,function(t){if(t){var r=S(i),o=i.key,u=i.state;if(n)if(e.pushState({key:o,state:u},null,r),d)window.location.href=r;else{var s=x.indexOf(D.location.key),c=x.slice(0,-1===s?0:s+1);c.push(i.key),x=c,A({action:"PUSH",location:i})}else(0,a.default)(void 0===u,"Browser history cannot push state in browsers that do not support HTML5 history"),window.location.href=r}})},C=function(t,o){(0,a.default)(!("object"===(void 0===t?"undefined":r(t))&&void 0!==t.state&&void 0!==o),"You should avoid providing a 2nd state argument to replace when the 1st argument is a location-like object that already has state; it is ignored");var i=(0,l.createLocation)(t,o,w(),D.location);E.confirmTransitionTo(i,"REPLACE",y,function(t){if(t){var r=S(i),o=i.key,u=i.state;if(n)if(e.replaceState({key:o,state:u},null,r),d)window.location.replace(r);else{var s=x.indexOf(D.location.key);-1!==s&&(x[s]=i.key),A({action:"REPLACE",location:i})}else(0,a.default)(void 0===u,"Browser history cannot replace state in browsers that do not support HTML5 history"),window.location.replace(r)}})},U=function(t){e.go(t)},M=function(){return U(-1)},H=function(){return U(1)},B=0,G=function(t){1===(B+=t)?((0,v.addEventListener)(window,"popstate",R),i&&(0,v.addEventListener)(window,"hashchange",j)):0===B&&((0,v.removeEventListener)(window,"popstate",R),i&&(0,v.removeEventListener)(window,"hashchange",j))},F=!1,N=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=E.setPrompt(t);return F||(G(1),F=!0),function(){return F&&(F=!1,G(-1)),e()}},I=function(t){var e=E.appendListener(t);return G(1),function(){G(-1),e()}},D={length:e.length,action:"POP",location:_,createHref:S,push:T,replace:C,go:U,goBack:M,goForward:H,block:N,listen:I};return D};e.default=d})),m=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,b=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(t){r[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,o,a=n(t),i=1;i<arguments.length;i++){r=Object(arguments[i]);for(var u in r)g.call(r,u)&&(a[u]=r[u]);if(m){o=m(r);for(var s=0;s<o.length;s++)O.call(r,o[s])&&(a[o[s]]=r[o[s]])}}return a},w=function(t,e){var n=r(e=b({arrayFormat:"none"},e)),a=Object.create(null);return"string"!=typeof t?a:(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach(function(t){var e=t.replace(/\+/g," ").split("="),r=e.shift(),o=e.length>0?e.join("="):void 0;o=void 0===o?null:decodeURIComponent(o),n(decodeURIComponent(r),o,a)}),Object.keys(a).sort().reduce(function(t,e){var n=a[e];return Boolean(n)&&"object"==typeof n&&!Array.isArray(n)?t[e]=o(n):t[e]=n,t},Object.create(null))):a},E="ROUTER/PUSH",A="ROUTER/REPLACE",R="ROUTER/GO",j="ROUTER/GO_BACK",k=function(t){return{type:E,payload:t}},L=function(t){return{type:A,payload:t}},P=function(t){return{type:R,payload:t}},_=function(){return{type:j}},x=function(){return{type:"ROUTER/GO_FORWARD"}},S=function(t){var e=t.pathname,n=t.search,r=t.hash;return{type:"ROUTER/LOCATION_CHANGE",payload:{pathname:e,search:n,queries:w(n),hash:r}}},T=function(t){return function(){return function(e){return function(n){switch(n.type){case E:t.push(n.payload);break;case A:t.replace(n.payload);break;case R:t.go(n.payload);break;case j:t.goBack();break;case"ROUTER/GO_FORWARD":t.goForward();break;default:return e(n)}}}}},C=Object.assign||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},U={pathname:"/",search:"",queries:{},hash:""},M=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:U,e=arguments[1];switch(e.type){case"ROUTER/LOCATION_CHANGE":return C({},t,e.payload);default:return t}};t.createBrowserHistory=y,t.startListener=a,t.PUSH=E,t.REPLACE=A,t.GO=R,t.GO_BACK=j,t.GO_FORWARD="ROUTER/GO_FORWARD",t.LOCATION_CHANGE="ROUTER/LOCATION_CHANGE",t.push=k,t.replace=L,t.go=P,t.goBack=_,t.goForward=x,t.locationChange=S,t.routerMiddleware=T,t.routerReducer=M,Object.defineProperty(t,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.ReduxFirstRouting={})}(this,function(e){"use strict";function t(e,t){return t={exports:{}},e(t,t.exports),t.exports}function n(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function r(e){var t;switch(e.arrayFormat){case"index":return function(e,n,r){t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===r[e]&&(r[e]={}),r[e][t[1]]=n):r[e]=n};case"bracket":return function(e,n,r){t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==r[e]?r[e]=[].concat(r[e],n):r[e]=[n]:r[e]=n};default:return function(e,t,n){void 0!==n[e]?n[e]=[].concat(n[e],t):n[e]=t}}}function o(e){return Array.isArray(e)?e.sort():"object"==typeof e?o(Object.keys(e)).sort(function(e,t){return Number(e)-Number(t)}).map(function(t){return e[t]}):e}function a(e,t){t.dispatch(S({pathname:e.location.pathname,search:e.location.search,hash:e.location.hash})),e.listen(function(e){t.dispatch(S({pathname:e.pathname,search:e.search,hash:e.hash}))})}var i=function(){},u=function(e,t,n,r,o,a,i,u){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,o,a,i,u],f=0;(s=new Error(t.replace(/%s/g,function(){return c[f++]}))).name="Invariant Violation"}throw s.framesToPop=1,s}},s=function(e){return"/"===e.charAt(0)},c=function(e,t){for(var n=t,r=n+1,o=e.length;r<o;n+=1,r+=1)e[n]=e[r];e.pop()},f=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=e&&e.split("/")||[],r=t&&t.split("/")||[],o=e&&s(e),a=t&&s(t),i=o||a;if(e&&s(e)?r=n:n.length&&(r.pop(),r=r.concat(n)),!r.length)return"/";var u=void 0;if(r.length){var f=r[r.length-1];u="."===f||".."===f||""===f}else u=!1;for(var h=0,l=r.length;l>=0;l--){var d=r[l];"."===d?c(r,l):".."===d?(c(r,l),h++):h&&(c(r,l),h--)}if(!i)for(;h--;h)r.unshift("..");!i||""===r[0]||r[0]&&s(r[0])||r.unshift("");var p=r.join("/");return u&&"/"!==p.substr(-1)&&(p+="/"),p},h=t(function(e,t){t.__esModule=!0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=function e(t,r){if(t===r)return!0;if(null==t||null==r)return!1;if(Array.isArray(t))return Array.isArray(r)&&t.length===r.length&&t.every(function(t,n){return e(t,r[n])});var o=void 0===t?"undefined":n(t);if(o!==(void 0===r?"undefined":n(r)))return!1;if("object"===o){var a=t.valueOf(),i=r.valueOf();if(a!==t||i!==r)return e(a,i);var u=Object.keys(t),s=Object.keys(r);return u.length===s.length&&u.every(function(n){return e(t[n],r[n])})}return!1};t.default=r}),l=t(function(e,t){t.__esModule=!0;t.addLeadingSlash=function(e){return"/"===e.charAt(0)?e:"/"+e},t.stripLeadingSlash=function(e){return"/"===e.charAt(0)?e.substr(1):e};var n=t.hasBasename=function(e,t){return new RegExp("^"+t+"(\\/|\\?|#|$)","i").test(e)};t.stripBasename=function(e,t){return n(e,t)?e.substr(t.length):e},t.stripTrailingSlash=function(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e},t.parsePath=function(e){var t=e||"/",n="",r="",o=t.indexOf("#");-1!==o&&(r=t.substr(o),t=t.substr(0,o));var a=t.indexOf("?");return-1!==a&&(n=t.substr(a),t=t.substr(0,a)),{pathname:t,search:"?"===n?"":n,hash:"#"===r?"":r}},t.createPath=function(e){var t=e.pathname,n=e.search,r=e.hash,o=t||"/";return n&&"?"!==n&&(o+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(o+="#"===r.charAt(0)?r:"#"+r),o}}),d=t(function(e,t){function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.locationsAreEqual=t.createLocation=void 0;var r=Object.assign||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},o=n(f),a=n(h);t.createLocation=function(e,t,n,a){var i=void 0;"string"==typeof e?(i=(0,l.parsePath)(e)).state=t:(void 0===(i=r({},e)).pathname&&(i.pathname=""),i.search?"?"!==i.search.charAt(0)&&(i.search="?"+i.search):i.search="",i.hash?"#"!==i.hash.charAt(0)&&(i.hash="#"+i.hash):i.hash="",void 0!==t&&void 0===i.state&&(i.state=t));try{i.pathname=decodeURI(i.pathname)}catch(e){throw e instanceof URIError?new URIError('Pathname "'+i.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):e}return n&&(i.key=n),a?i.pathname?"/"!==i.pathname.charAt(0)&&(i.pathname=(0,o.default)(i.pathname,a.pathname)):i.pathname=a.pathname:i.pathname||(i.pathname="/"),i},t.locationsAreEqual=function(e,t){return e.pathname===t.pathname&&e.search===t.search&&e.hash===t.hash&&e.key===t.key&&(0,a.default)(e.state,t.state)}}),p=t(function(e,t){t.__esModule=!0;var n=function(e){return e&&e.__esModule?e:{default:e}}(i),r=function(){var e=null,t=[];return{setPrompt:function(t){return(0,n.default)(null==e,"A history supports only one prompt at a time"),e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,r,o,a){if(null!=e){var i="function"==typeof e?e(t,r):e;"string"==typeof i?"function"==typeof o?o(i,a):((0,n.default)(!1,"A history needs a getUserConfirmation function in order to use a prompt message"),a(!0)):a(!1!==i)}else a(!0)},appendListener:function(e){var n=!0,r=function(){n&&e.apply(void 0,arguments)};return t.push(r),function(){n=!1,t=t.filter(function(e){return e!==r})}},notifyListeners:function(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];t.forEach(function(e){return e.apply(void 0,n)})}}};t.default=r}),v=t(function(e,t){t.__esModule=!0;t.canUseDOM=!("undefined"==typeof window||!window.document||!window.document.createElement),t.addEventListener=function(e,t,n){return e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent("on"+t,n)},t.removeEventListener=function(e,t,n){return e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent("on"+t,n)},t.getConfirmation=function(e,t){return t(window.confirm(e))},t.supportsHistory=function(){var e=window.navigator.userAgent;return(-1===e.indexOf("Android 2.")&&-1===e.indexOf("Android 4.0")||-1===e.indexOf("Mobile Safari")||-1!==e.indexOf("Chrome")||-1!==e.indexOf("Windows Phone"))&&(window.history&&"pushState"in window.history)},t.supportsPopStateOnHashChange=function(){return-1===window.navigator.userAgent.indexOf("Trident")},t.supportsGoWithoutReloadUsingHash=function(){return-1===window.navigator.userAgent.indexOf("Firefox")},t.isExtraneousPopstateEvent=function(e){return void 0===e.state&&-1===navigator.userAgent.indexOf("CriOS")}}),y=function(e){return e&&e.__esModule?e.default:e}(t(function(e,t){function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=Object.assign||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},a=n(i),s=n(u),c=n(p),f=function(){try{return window.history.state||{}}catch(e){return{}}},h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,s.default)(v.canUseDOM,"Browser history needs a DOM");var t=window.history,n=(0,v.supportsHistory)(),i=!(0,v.supportsPopStateOnHashChange)(),u=e.forceRefresh,h=void 0!==u&&u,p=e.getUserConfirmation,y=void 0===p?v.getConfirmation:p,m=e.keyLength,g=void 0===m?6:m,O=e.basename?(0,l.stripTrailingSlash)((0,l.addLeadingSlash)(e.basename)):"",b=function(e){var t=e||{},n=t.key,r=t.state,o=window.location,i=o.pathname+o.search+o.hash;return(0,a.default)(!O||(0,l.hasBasename)(i,O),'You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "'+i+'" to begin with "'+O+'".'),O&&(i=(0,l.stripBasename)(i,O)),(0,d.createLocation)(i,r,n)},w=function(){return Math.random().toString(36).substr(2,g)},E=(0,c.default)(),A=function(e){o(D,e),D.length=t.length,E.notifyListeners(D.location,D.action)},R=function(e){(0,v.isExtraneousPopstateEvent)(e)||L(b(e.state))},j=function(){L(b(f()))},k=!1,L=function(e){if(k)k=!1,A();else{E.confirmTransitionTo(e,"POP",y,function(t){t?A({action:"POP",location:e}):P(e)})}},P=function(e){var t=D.location,n=x.indexOf(t.key);-1===n&&(n=0);var r=x.indexOf(e.key);-1===r&&(r=0);var o=n-r;o&&(k=!0,U(o))},_=b(f()),x=[_.key],S=function(e){return O+(0,l.createPath)(e)},T=function(e,o){(0,a.default)(!("object"===(void 0===e?"undefined":r(e))&&void 0!==e.state&&void 0!==o),"You should avoid providing a 2nd state argument to push when the 1st argument is a location-like object that already has state; it is ignored");var i=(0,d.createLocation)(e,o,w(),D.location);E.confirmTransitionTo(i,"PUSH",y,function(e){if(e){var r=S(i),o=i.key,u=i.state;if(n)if(t.pushState({key:o,state:u},null,r),h)window.location.href=r;else{var s=x.indexOf(D.location.key),c=x.slice(0,-1===s?0:s+1);c.push(i.key),x=c,A({action:"PUSH",location:i})}else(0,a.default)(void 0===u,"Browser history cannot push state in browsers that do not support HTML5 history"),window.location.href=r}})},C=function(e,o){(0,a.default)(!("object"===(void 0===e?"undefined":r(e))&&void 0!==e.state&&void 0!==o),"You should avoid providing a 2nd state argument to replace when the 1st argument is a location-like object that already has state; it is ignored");var i=(0,d.createLocation)(e,o,w(),D.location);E.confirmTransitionTo(i,"REPLACE",y,function(e){if(e){var r=S(i),o=i.key,u=i.state;if(n)if(t.replaceState({key:o,state:u},null,r),h)window.location.replace(r);else{var s=x.indexOf(D.location.key);-1!==s&&(x[s]=i.key),A({action:"REPLACE",location:i})}else(0,a.default)(void 0===u,"Browser history cannot replace state in browsers that do not support HTML5 history"),window.location.replace(r)}})},U=function(e){t.go(e)},M=function(){return U(-1)},H=function(){return U(1)},B=0,G=function(e){1===(B+=e)?((0,v.addEventListener)(window,"popstate",R),i&&(0,v.addEventListener)(window,"hashchange",j)):0===B&&((0,v.removeEventListener)(window,"popstate",R),i&&(0,v.removeEventListener)(window,"hashchange",j))},N=!1,F=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=E.setPrompt(e);return N||(G(1),N=!0),function(){return N&&(N=!1,G(-1)),t()}},I=function(e){var t=E.appendListener(e);return G(1),function(){G(-1),t()}},D={length:t.length,action:"POP",location:_,createHref:S,push:T,replace:C,go:U,goBack:M,goForward:H,block:F,listen:I};return D};t.default=h})),m=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,b=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,o,a=n(e),i=1;i<arguments.length;i++){r=Object(arguments[i]);for(var u in r)g.call(r,u)&&(a[u]=r[u]);if(m){o=m(r);for(var s=0;s<o.length;s++)O.call(r,o[s])&&(a[o[s]]=r[o[s]])}}return a},w=function(e,t){var n=r(t=b({arrayFormat:"none"},t)),a=Object.create(null);return"string"!=typeof e?a:(e=e.trim().replace(/^(\?|#|&)/,""))?(e.split("&").forEach(function(e){var t=e.replace(/\+/g," ").split("="),r=t.shift(),o=t.length>0?t.join("="):void 0;o=void 0===o?null:decodeURIComponent(o),n(decodeURIComponent(r),o,a)}),Object.keys(a).sort().reduce(function(e,t){var n=a[t];return Boolean(n)&&"object"==typeof n&&!Array.isArray(n)?e[t]=o(n):e[t]=n,e},Object.create(null))):a},E="ROUTER/PUSH",A="ROUTER/REPLACE",R="ROUTER/GO",j="ROUTER/GO_BACK",k=function(e){return{type:E,payload:e}},L=function(e){return{type:A,payload:e}},P=function(e){return{type:R,payload:e}},_=function(){return{type:j}},x=function(){return{type:"ROUTER/GO_FORWARD"}},S=function(e){var t=e.pathname,n=e.search,r=e.hash;return{type:"ROUTER/LOCATION_CHANGE",payload:{pathname:t,search:n,queries:w(n),hash:r}}},T=function(e){return function(){return function(t){return function(n){switch(n.type){case E:e.push(n.payload);break;case A:e.replace(n.payload);break;case R:e.go(n.payload);break;case j:e.goBack();break;case"ROUTER/GO_FORWARD":e.goForward();break;default:return t(n)}}}}},C=Object.assign||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},U={pathname:"/",search:"",queries:{},hash:""},M=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:U,t=arguments[1];switch(t.type){case"ROUTER/LOCATION_CHANGE":return C({},e,t.payload);default:return e}};e.createBrowserHistory=y,e.startListener=a,e.PUSH=E,e.REPLACE=A,e.GO=R,e.GO_BACK=j,e.GO_FORWARD="ROUTER/GO_FORWARD",e.LOCATION_CHANGE="ROUTER/LOCATION_CHANGE",e.push=k,e.replace=L,e.go=P,e.goBack=_,e.goForward=x,e.locationChange=S,e.routerMiddleware=T,e.routerReducer=M,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "redux-first-routing",
"version": "0.2.1",
"version": "0.2.2",
"description": "Redux-first routing",

@@ -35,3 +35,3 @@ "main": "lib/index.js",

"dependencies": {
"history": "^4.6.2",
"history": "^4.6.3",
"query-string": "^4.3.4"

@@ -46,10 +46,10 @@ },

"babel-register": "^6.24.1",
"chai": "^4.0.2",
"chai": "^4.1.0",
"cross-env": "^5.0.1",
"eslint": "^4.0.0",
"eslint": "^3.19.0",
"eslint-config-airbnb-base": "^11.2.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-import": "^2.7.0",
"mocha": "^3.4.1",
"rimraf": "^2.6.1",
"rollup": "^0.43.0",
"rollup": "^0.45.2",
"rollup-plugin-babel": "^2.7.1",

@@ -60,3 +60,3 @@ "rollup-plugin-commonjs": "^8.0.2",

"rollup-plugin-uglify": "^2.0.1",
"sinon": "^2.3.4"
"sinon": "^2.3.7"
},

@@ -63,0 +63,0 @@ "scripts": {

@@ -9,2 +9,4 @@ # Redux-First Routing [![npm version](https://img.shields.io/npm/v/redux-first-routing.svg?style=flat)](https://www.npmjs.org/package/redux-first-routing) [![build status](https://api.travis-ci.org/mksarge/redux-first-routing.svg?branch=master)](https://travis-ci.org/mksarge/redux-first-routing/)

> **Learn more: [An Introduction to the Redux-First Routing Model](https://medium.com/@mksarge/an-introduction-to-the-redux-first-routing-model-98926ebf53cb)**
![Redux-first routing](https://camo.githubusercontent.com/b08b1b78a08e0444ab451f692618d59da977e6a1/687474703a2f2f692e696d6775722e636f6d2f734169566c6b4d2e6a7067)

@@ -91,18 +93,17 @@

hash: '#and-hash'
}
},
... // other redux state
}
```
> If the current design doesn't fit your needs, feel free to open an issue or fork the project.
The [`query-string`](https://github.com/sindresorhus/query-string) package is used internally to parse the `search` string into the `queries` object.
#### Compatible Routers
For a routing library to work seamlessly with `redux-first-routing`, **it must not be heavily coupled with the browser history**. For example, React Router [wraps its own instance of `history`](https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/modules/BrowserRouter.js#L18-L21), so a more integrated solution like `react-router-redux` is necessary.
For a router to work seamlessly with `redux-first-routing`, it must not be tightly coupled to the browser history/navigation code. The following libraries meet that criteria by providing router components that focus solely on the *routing* and/or *rendering* part:
The following libraries provide router components that just focus on the *routing* and/or *rendering* part, making them great matches for `redux-first-routing`:
- [Universal Router](https://github.com/kriasoft/universal-router) (framework-agnostic)
- [Redux JSON Router](https://github.com/mksarge/redux-json-router) (React)
> For full examples of usage, see [Recipies](#documentation). To add to this list, feel free to send a pull request.
> For examples of usage, see [Recipies](#documentation). To add to this list, feel free to send a pull request.

@@ -114,3 +115,17 @@ ## Documentation

- [Usage with Universal Router](/docs/recipes/usage-with-universal-router.md)
- [Usage with Redux JSON Router](/docs/recipes/usage-with-redux-json-router.md)
- [Building your own connected component](/docs/recipes/building-your-own-connected-component.md)
## Credits
The concept of "Redux-first routing" isn't particularly new — everything in this library has existed in one form or another across various other Redux routing libraries and packages. You may find a long list of similar projects (some of which may be classified as Redux-first routing libraries) here:
- https://github.com/markerikson/redux-ecosystem-links/blob/master/routing.md
Notable influences:
- [`react-router-redux`](https://github.com/reactjs/react-router-redux)
- [`redux-little-router`](https://github.com/FormidableLabs/redux-little-router)
- [`universal-redux-router`](https://github.com/colinmeinke/universal-redux-router)
## Contributing

@@ -117,0 +132,0 @@

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