(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["History"] = factory(); else root["History"] = factory(); })(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; exports.createPath = exports.parsePath = exports.locationsAreEqual = exports.createLocation = exports.createMemoryHistory = exports.createHashHistory = exports.createBrowserHistory = undefined; var _LocationUtils = __webpack_require__(1); Object.defineProperty(exports, "createLocation", { enumerable: true, get: function get() { return _LocationUtils.createLocation; } }); Object.defineProperty(exports, "locationsAreEqual", { enumerable: true, get: function get() { return _LocationUtils.locationsAreEqual; } }); var _PathUtils = __webpack_require__(4); Object.defineProperty(exports, "parsePath", { enumerable: true, get: function get() { return _PathUtils.parsePath; } }); Object.defineProperty(exports, "createPath", { enumerable: true, get: function get() { return _PathUtils.createPath; } }); var _createBrowserHistory2 = __webpack_require__(9); var _createBrowserHistory3 = _interopRequireDefault(_createBrowserHistory2); var _createHashHistory2 = __webpack_require__(14); var _createHashHistory3 = _interopRequireDefault(_createHashHistory2); var _createMemoryHistory2 = __webpack_require__(15); var _createMemoryHistory3 = _interopRequireDefault(_createMemoryHistory2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.createBrowserHistory = _createBrowserHistory3.default; exports.createHashHistory = _createHashHistory3.default; exports.createMemoryHistory = _createMemoryHistory3.default; /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; exports.locationsAreEqual = exports.createLocation = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _resolvePathname = __webpack_require__(2); var _resolvePathname2 = _interopRequireDefault(_resolvePathname); var _valueEqual = __webpack_require__(3); var _valueEqual2 = _interopRequireDefault(_valueEqual); var _PathUtils = __webpack_require__(4); var _queryString = __webpack_require__(5); var _queryString2 = _interopRequireDefault(_queryString); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var createLocation = exports.createLocation = function createLocation(path, state, key, currentLocation) { var location = void 0; if (typeof path === "string") { // Two-arg form: push(path, state) location = (0, _PathUtils.parsePath)(path); location.query = location.search ? _queryString2.default.parse(location.search) : {}; location.state = state; } else { // One-arg form: push(location) location = _extends({}, path); if (location.pathname === undefined) location.pathname = ""; if (location.search) { if (location.search.charAt(0) !== "?") { location.search = "?" + location.search; } location.query = _queryString2.default.parse(location.search); } else { location.search = location.query ? _queryString2.default.stringify(location.query) : ""; location.query = location.query || {}; } if (location.hash) { if (location.hash.charAt(0) !== "#") location.hash = "#" + location.hash; } else { location.hash = ""; } if (state !== undefined && location.state === undefined) location.state = state; } try { location.pathname = decodeURI(location.pathname); } catch (e) { if (e instanceof URIError) { throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + "This is likely caused by an invalid percent-encoding."); } else { throw e; } } if (key) location.key = key; if (currentLocation) { // Resolve incomplete/relative pathname relative to current location. if (!location.pathname) { location.pathname = currentLocation.pathname; } else if (location.pathname.charAt(0) !== "/") { location.pathname = (0, _resolvePathname2.default)(location.pathname, currentLocation.pathname); } } else { // When there is no prior location and pathname is empty, set it to / if (!location.pathname) { location.pathname = "/"; } } return location; }; var locationsAreEqual = exports.locationsAreEqual = function locationsAreEqual(a, b) { return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && (0, _valueEqual2.default)(a.state, b.state); }; /***/ }), /* 2 */ /***/ (function(module, exports) { 'use strict'; exports.__esModule = true; function isAbsolute(pathname) { return pathname.charAt(0) === '/'; } // About 1.5x faster than the two-arg version of Array#splice() function spliceOne(list, index) { for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) { list[i] = list[k]; } list.pop(); } // This implementation is based heavily on node's url.parse function resolvePathname(to) { var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; var toParts = to && to.split('/') || []; var fromParts = from && from.split('/') || []; var isToAbs = to && isAbsolute(to); var isFromAbs = from && isAbsolute(from); var mustEndAbs = isToAbs || isFromAbs; if (to && isAbsolute(to)) { // to is absolute fromParts = toParts; } else if (toParts.length) { // to is relative, drop the filename fromParts.pop(); fromParts = fromParts.concat(toParts); } if (!fromParts.length) return '/'; var hasTrailingSlash = void 0; if (fromParts.length) { var last = fromParts[fromParts.length - 1]; hasTrailingSlash = last === '.' || last === '..' || last === ''; } else { hasTrailingSlash = false; } var up = 0; for (var i = fromParts.length; i >= 0; i--) { var part = fromParts[i]; if (part === '.') { spliceOne(fromParts, i); } else if (part === '..') { spliceOne(fromParts, i); up++; } else if (up) { spliceOne(fromParts, i); up--; } } if (!mustEndAbs) for (; up--; up) { fromParts.unshift('..'); }if (mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute(fromParts[0]))) fromParts.unshift(''); var result = fromParts.join('/'); if (hasTrailingSlash && result.substr(-1) !== '/') result += '/'; return result; } exports.default = resolvePathname; module.exports = exports['default']; /***/ }), /* 3 */ /***/ (function(module, exports) { 'use strict'; exports.__esModule = true; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; function valueEqual(a, b) { if (a === b) return true; if (a == null || b == null) return false; if (Array.isArray(a)) { return Array.isArray(b) && a.length === b.length && a.every(function (item, index) { return valueEqual(item, b[index]); }); } var aType = typeof a === 'undefined' ? 'undefined' : _typeof(a); var bType = typeof b === 'undefined' ? 'undefined' : _typeof(b); if (aType !== bType) return false; if (aType === 'object') { var aValue = a.valueOf(); var bValue = b.valueOf(); if (aValue !== a || bValue !== b) return valueEqual(aValue, bValue); var aKeys = Object.keys(a); var bKeys = Object.keys(b); if (aKeys.length !== bKeys.length) return false; return aKeys.every(function (key) { return valueEqual(a[key], b[key]); }); } return false; } exports.default = valueEqual; module.exports = exports['default']; /***/ }), /* 4 */ /***/ (function(module, exports) { "use strict"; exports.__esModule = true; var addLeadingSlash = exports.addLeadingSlash = function addLeadingSlash(path) { return path.charAt(0) === "/" ? path : "/" + path; }; var stripLeadingSlash = exports.stripLeadingSlash = function stripLeadingSlash(path) { return path.charAt(0) === "/" ? path.substr(1) : path; }; var hasBasename = exports.hasBasename = function hasBasename(path, prefix) { return new RegExp("^" + prefix + "(\\/|\\?|#|$)", "i").test(path); }; var stripBasename = exports.stripBasename = function stripBasename(path, prefix) { return hasBasename(path, prefix) ? path.substr(prefix.length) : path; }; var stripTrailingSlash = exports.stripTrailingSlash = function stripTrailingSlash(path) { return path.charAt(path.length - 1) === "/" ? path.slice(0, -1) : path; }; var parsePath = exports.parsePath = function parsePath(path) { var pathname = path || "/"; var search = ""; var hash = ""; var hashIndex = pathname.indexOf("#"); if (hashIndex !== -1) { hash = pathname.substr(hashIndex); pathname = pathname.substr(0, hashIndex); } var searchIndex = pathname.indexOf("?"); if (searchIndex !== -1) { search = pathname.substr(searchIndex); pathname = pathname.substr(0, searchIndex); } return { pathname: pathname, search: search === "?" ? "" : search, hash: hash === "#" ? "" : hash }; }; var createPath = exports.createPath = function createPath(location) { var pathname = location.pathname, search = location.search, hash = location.hash; var path = pathname || "/"; if (search && search !== "?") path += search.charAt(0) === "?" ? search : "?" + search; if (hash && hash !== "#") path += hash.charAt(0) === "#" ? hash : "#" + hash; return path; }; /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { 'use strict'; var strictUriEncode = __webpack_require__(6); var objectAssign = __webpack_require__(7); var decodeComponent = __webpack_require__(8); function encoderForArrayFormat(opts) { switch (opts.arrayFormat) { case 'index': return function (key, value, index) { return value === null ? [ encode(key, opts), '[', index, ']' ].join('') : [ encode(key, opts), '[', encode(index, opts), ']=', encode(value, opts) ].join(''); }; case 'bracket': return function (key, value) { return value === null ? encode(key, opts) : [ encode(key, opts), '[]=', encode(value, opts) ].join(''); }; default: return function (key, value) { return value === null ? encode(key, opts) : [ encode(key, opts), '=', encode(value, opts) ].join(''); }; } } function parserForArrayFormat(opts) { var result; switch (opts.arrayFormat) { case 'index': return function (key, value, accumulator) { result = /\[(\d*)\]$/.exec(key); key = key.replace(/\[\d*\]$/, ''); if (!result) { accumulator[key] = value; return; } if (accumulator[key] === undefined) { accumulator[key] = {}; } accumulator[key][result[1]] = value; }; case 'bracket': return function (key, value, accumulator) { result = /(\[\])$/.exec(key); key = key.replace(/\[\]$/, ''); if (!result) { accumulator[key] = value; return; } else if (accumulator[key] === undefined) { accumulator[key] = [value]; return; } accumulator[key] = [].concat(accumulator[key], value); }; default: return function (key, value, accumulator) { if (accumulator[key] === undefined) { accumulator[key] = value; return; } accumulator[key] = [].concat(accumulator[key], value); }; } } function encode(value, opts) { if (opts.encode) { return opts.strict ? strictUriEncode(value) : encodeURIComponent(value); } return value; } function keysSorter(input) { if (Array.isArray(input)) { return input.sort(); } else if (typeof input === 'object') { return keysSorter(Object.keys(input)).sort(function (a, b) { return Number(a) - Number(b); }).map(function (key) { return input[key]; }); } return input; } exports.extract = function (str) { var queryStart = str.indexOf('?'); if (queryStart === -1) { return ''; } return str.slice(queryStart + 1); }; exports.parse = function (str, opts) { opts = objectAssign({arrayFormat: 'none'}, opts); var formatter = parserForArrayFormat(opts); // Create an object with no prototype // https://github.com/sindresorhus/query-string/issues/47 var ret = Object.create(null); if (typeof str !== 'string') { return ret; } str = str.trim().replace(/^[?#&]/, ''); if (!str) { return ret; } str.split('&').forEach(function (param) { var parts = param.replace(/\+/g, ' ').split('='); // Firefox (pre 40) decodes `%3D` to `=` // https://github.com/sindresorhus/query-string/pull/37 var key = parts.shift(); var val = parts.length > 0 ? parts.join('=') : undefined; // missing `=` should be `null`: // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters val = val === undefined ? null : decodeComponent(val); formatter(decodeComponent(key), val, ret); }); return Object.keys(ret).sort().reduce(function (result, key) { var val = ret[key]; if (Boolean(val) && typeof val === 'object' && !Array.isArray(val)) { // Sort object keys, not values result[key] = keysSorter(val); } else { result[key] = val; } return result; }, Object.create(null)); }; exports.stringify = function (obj, opts) { var defaults = { encode: true, strict: true, arrayFormat: 'none' }; opts = objectAssign(defaults, opts); var formatter = encoderForArrayFormat(opts); return obj ? Object.keys(obj).sort().map(function (key) { var val = obj[key]; if (val === undefined) { return ''; } if (val === null) { return encode(key, opts); } if (Array.isArray(val)) { var result = []; val.slice().forEach(function (val2) { if (val2 === undefined) { return; } result.push(formatter(key, val2, result.length)); }); return result.join('&'); } return encode(key, opts) + '=' + encode(val, opts); }).filter(function (x) { return x.length > 0; }).join('&') : ''; }; /***/ }), /* 6 */ /***/ (function(module, exports) { 'use strict'; module.exports = function (str) { return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { return '%' + c.charCodeAt(0).toString(16).toUpperCase(); }); }; /***/ }), /* 7 */ /***/ (function(module, exports) { /* object-assign (c) Sindre Sorhus @license MIT */ 'use strict'; /* eslint-disable no-unused-vars */ var getOwnPropertySymbols = Object.getOwnPropertySymbols; var hasOwnProperty = Object.prototype.hasOwnProperty; var propIsEnumerable = Object.prototype.propertyIsEnumerable; function toObject(val) { if (val === null || val === undefined) { throw new TypeError('Object.assign cannot be called with null or undefined'); } return Object(val); } function shouldUseNative() { try { if (!Object.assign) { return false; } // Detect buggy property enumeration order in older V8 versions. // https://bugs.chromium.org/p/v8/issues/detail?id=4118 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers test1[5] = 'de'; if (Object.getOwnPropertyNames(test1)[0] === '5') { return false; } // https://bugs.chromium.org/p/v8/issues/detail?id=3056 var test2 = {}; for (var i = 0; i < 10; i++) { test2['_' + String.fromCharCode(i)] = i; } var order2 = Object.getOwnPropertyNames(test2).map(function (n) { return test2[n]; }); if (order2.join('') !== '0123456789') { return false; } // https://bugs.chromium.org/p/v8/issues/detail?id=3056 var test3 = {}; 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { test3[letter] = letter; }); if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') { return false; } return true; } catch (err) { // We don't expect any of the above to throw, but better to be safe. return false; } } module.exports = shouldUseNative() ? Object.assign : function (target, source) { var from; var to = toObject(target); var symbols; for (var s = 1; s < arguments.length; s++) { from = Object(arguments[s]); for (var key in from) { if (hasOwnProperty.call(from, key)) { to[key] = from[key]; } } if (getOwnPropertySymbols) { symbols = getOwnPropertySymbols(from); for (var i = 0; i < symbols.length; i++) { if (propIsEnumerable.call(from, symbols[i])) { to[symbols[i]] = from[symbols[i]]; } } } } return to; }; /***/ }), /* 8 */ /***/ (function(module, exports) { 'use strict'; var token = '%[a-f0-9]{2}'; var singleMatcher = new RegExp(token, 'gi'); var multiMatcher = new RegExp('(' + token + ')+', 'gi'); function decodeComponents(components, split) { try { // Try to decode the entire string first return decodeURIComponent(components.join('')); } catch (err) { // Do nothing } if (components.length === 1) { return components; } split = split || 1; // Split the array in 2 parts var left = components.slice(0, split); var right = components.slice(split); return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); } function decode(input) { try { return decodeURIComponent(input); } catch (err) { var tokens = input.match(singleMatcher); for (var i = 1; i < tokens.length; i++) { input = decodeComponents(tokens, i).join(''); tokens = input.match(singleMatcher); } return input; } } function customDecodeURIComponent(input) { // Keep track of all the replacements and prefill the map with the `BOM` var replaceMap = { '%FE%FF': '\uFFFD\uFFFD', '%FF%FE': '\uFFFD\uFFFD' }; var match = multiMatcher.exec(input); while (match) { try { // Decode as big chunks as possible replaceMap[match[0]] = decodeURIComponent(match[0]); } catch (err) { var result = decode(match[0]); if (result !== match[0]) { replaceMap[match[0]] = result; } } match = multiMatcher.exec(input); } // Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else replaceMap['%C2'] = '\uFFFD'; var entries = Object.keys(replaceMap); for (var i = 0; i < entries.length; i++) { // Replace all decoded components var key = entries[i]; input = input.replace(new RegExp(key, 'g'), replaceMap[key]); } return input; } module.exports = function (encodedURI) { if (typeof encodedURI !== 'string') { throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`'); } try { encodedURI = encodedURI.replace(/\+/g, ' '); // Try the built in decoder first return decodeURIComponent(encodedURI); } catch (err) { // Fallback to a more advanced decoder return customDecodeURIComponent(encodedURI); } }; /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _warning = __webpack_require__(10); var _warning2 = _interopRequireDefault(_warning); var _invariant = __webpack_require__(11); var _invariant2 = _interopRequireDefault(_invariant); var _LocationUtils = __webpack_require__(1); var _PathUtils = __webpack_require__(4); var _createTransitionManager = __webpack_require__(12); var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); var _DOMUtils = __webpack_require__(13); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var PopStateEvent = "popstate"; var HashChangeEvent = "hashchange"; var getHistoryState = function getHistoryState() { try { return window.history.state || {}; } catch (e) { // IE 11 sometimes throws when accessing window.history.state // See https://github.com/ReactTraining/history/pull/289 return {}; } }; /** * Creates a history object that uses the HTML5 history API including * pushState, replaceState, and the popstate event. */ var createBrowserHistory = function createBrowserHistory() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; !_DOMUtils.canUseDOM ? false ? (0, _invariant2.default)(false, "Browser history needs a DOM") : (0, _invariant2.default)(false) : void 0; var globalHistory = window.history; var canUseHistory = (0, _DOMUtils.supportsHistory)(); var needsHashChangeListener = !(0, _DOMUtils.supportsPopStateOnHashChange)(); var _props$forceRefresh = props.forceRefresh, forceRefresh = _props$forceRefresh === undefined ? false : _props$forceRefresh, _props$getUserConfirm = props.getUserConfirmation, getUserConfirmation = _props$getUserConfirm === undefined ? _DOMUtils.getConfirmation : _props$getUserConfirm, _props$keyLength = props.keyLength, keyLength = _props$keyLength === undefined ? 6 : _props$keyLength; var basename = props.basename ? (0, _PathUtils.stripTrailingSlash)((0, _PathUtils.addLeadingSlash)(props.basename)) : ""; var getDOMLocation = function getDOMLocation(historyState) { var _ref = historyState || {}, key = _ref.key, state = _ref.state; var _window$location = window.location, pathname = _window$location.pathname, search = _window$location.search, hash = _window$location.hash; var path = pathname + search + hash; false ? (0, _warning2.default)(!basename || (0, _PathUtils.hasBasename)(path, basename), "You are attempting to use a basename on a page whose URL path does not begin " + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".') : void 0; if (basename) path = (0, _PathUtils.stripBasename)(path, basename); return (0, _LocationUtils.createLocation)(path, state, key); }; var createKey = function createKey() { return Math.random().toString(36).substr(2, keyLength); }; var transitionManager = (0, _createTransitionManager2.default)(); var setState = function setState(nextState) { _extends(history, nextState); history.length = globalHistory.length; transitionManager.notifyListeners(history.location, history.action); }; var handlePopState = function handlePopState(event) { // Ignore extraneous popstate events in WebKit. if ((0, _DOMUtils.isExtraneousPopstateEvent)(event)) return; handlePop(getDOMLocation(event.state)); }; var handleHashChange = function handleHashChange() { handlePop(getDOMLocation(getHistoryState())); }; var forceNextPop = false; var handlePop = function handlePop(location) { if (forceNextPop) { forceNextPop = false; setState(); } else { var action = "POP"; transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (ok) { setState({ action: action, location: location }); } else { revertPop(location); } }); } }; var revertPop = function revertPop(fromLocation) { var toLocation = history.location; // TODO: We could probably make this more reliable by // keeping a list of keys we've seen in sessionStorage. // Instead, we just default to 0 for keys we don't know. var toIndex = allKeys.indexOf(toLocation.key); if (toIndex === -1) toIndex = 0; var fromIndex = allKeys.indexOf(fromLocation.key); if (fromIndex === -1) fromIndex = 0; var delta = toIndex - fromIndex; if (delta) { forceNextPop = true; go(delta); } }; var initialLocation = getDOMLocation(getHistoryState()); var allKeys = [initialLocation.key]; // Public interface var createHref = function createHref(location) { return basename + (0, _PathUtils.createPath)(location); }; var push = function push(path, state) { false ? (0, _warning2.default)(!((typeof path === "undefined" ? "undefined" : _typeof(path)) === "object" && path.state !== undefined && state !== undefined), "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") : void 0; var action = "PUSH"; var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var href = createHref(location); var key = location.key, state = location.state; if (canUseHistory) { globalHistory.pushState({ key: key, state: state }, null, href); if (forceRefresh) { window.location.href = href; } else { var prevIndex = allKeys.indexOf(history.location.key); var nextKeys = allKeys.slice(0, prevIndex === -1 ? 0 : prevIndex + 1); nextKeys.push(location.key); allKeys = nextKeys; setState({ action: action, location: location }); } } else { false ? (0, _warning2.default)(state === undefined, "Browser history cannot push state in browsers that do not support HTML5 history") : void 0; window.location.href = href; } }); }; var replace = function replace(path, state) { false ? (0, _warning2.default)(!((typeof path === "undefined" ? "undefined" : _typeof(path)) === "object" && path.state !== undefined && state !== undefined), "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") : void 0; var action = "REPLACE"; var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var href = createHref(location); var key = location.key, state = location.state; if (canUseHistory) { globalHistory.replaceState({ key: key, state: state }, null, href); if (forceRefresh) { window.location.replace(href); } else { var prevIndex = allKeys.indexOf(history.location.key); if (prevIndex !== -1) allKeys[prevIndex] = location.key; setState({ action: action, location: location }); } } else { false ? (0, _warning2.default)(state === undefined, "Browser history cannot replace state in browsers that do not support HTML5 history") : void 0; window.location.replace(href); } }); }; var go = function go(n) { globalHistory.go(n); }; var goBack = function goBack() { return go(-1); }; var goForward = function goForward() { return go(1); }; var listenerCount = 0; var checkDOMListeners = function checkDOMListeners(delta) { listenerCount += delta; if (listenerCount === 1) { window.addEventListener(PopStateEvent, handlePopState); if (needsHashChangeListener) window.addEventListener(HashChangeEvent, handleHashChange); } else if (listenerCount === 0) { window.removeEventListener(PopStateEvent, handlePopState); if (needsHashChangeListener) window.removeEventListener(HashChangeEvent, handleHashChange); } }; var isBlocked = false; var block = function block() { var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var unblock = transitionManager.setPrompt(prompt); if (!isBlocked) { checkDOMListeners(1); isBlocked = true; } return function () { if (isBlocked) { isBlocked = false; checkDOMListeners(-1); } return unblock(); }; }; var listen = function listen(listener) { var unlisten = transitionManager.appendListener(listener); checkDOMListeners(1); return function () { checkDOMListeners(-1); unlisten(); }; }; var history = { length: globalHistory.length, action: "POP", location: initialLocation, createHref: createHref, push: push, replace: replace, go: go, goBack: goBack, goForward: goForward, block: block, listen: listen }; return history; }; exports.default = createBrowserHistory; /***/ }), /* 10 */ /***/ (function(module, exports, __webpack_require__) { /** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ 'use strict'; /** * Similar to invariant but only logs a warning if the condition is not met. * This can be used to log issues in development environments in critical * paths. Removing the logging code for production environments will keep the * same logic and follow the same code paths. */ var warning = function() {}; if (false) { warning = function(condition, format, args) { var len = arguments.length; args = new Array(len > 2 ? len - 2 : 0); for (var key = 2; key < len; key++) { args[key - 2] = arguments[key]; } if (format === undefined) { throw new Error( '`warning(condition, format, ...args)` requires a warning ' + 'message argument' ); } if (format.length < 10 || (/^[s\W]*$/).test(format)) { throw new Error( 'The warning format should be able to uniquely identify this ' + 'warning. Please, use a more descriptive format than: ' + format ); } if (!condition) { var argIndex = 0; var message = 'Warning: ' + format.replace(/%s/g, function() { return args[argIndex++]; }); if (typeof console !== 'undefined') { console.error(message); } try { // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. throw new Error(message); } catch(x) {} } }; } module.exports = warning; /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ 'use strict'; /** * Use invariant() to assert state which your program assumes to be true. * * Provide sprintf-style format (only %s is supported) and arguments * to provide information about what broke and what you were * expecting. * * The invariant message will be stripped in production, but the invariant * will remain to ensure logic does not differ in production. */ var invariant = function(condition, format, a, b, c, d, e, f) { if (false) { if (format === undefined) { throw new Error('invariant requires an error message argument'); } } if (!condition) { var error; if (format === undefined) { error = new Error( 'Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.' ); } else { var args = [a, b, c, d, e, f]; var argIndex = 0; error = new Error( format.replace(/%s/g, function() { return args[argIndex++]; }) ); error.name = 'Invariant Violation'; } error.framesToPop = 1; // we don't care about invariant's own frame throw error; } }; module.exports = invariant; /***/ }), /* 12 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var _warning = __webpack_require__(10); var _warning2 = _interopRequireDefault(_warning); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var createTransitionManager = function createTransitionManager() { var prompt = null; var setPrompt = function setPrompt(nextPrompt) { false ? (0, _warning2.default)(prompt == null, "A history supports only one prompt at a time") : void 0; prompt = nextPrompt; return function () { if (prompt === nextPrompt) prompt = null; }; }; var confirmTransitionTo = function confirmTransitionTo(location, action, getUserConfirmation, callback) { // TODO: If another transition starts while we're still confirming // the previous one, we may end up in a weird state. Figure out the // best way to handle this. if (prompt != null) { var result = typeof prompt === "function" ? prompt(location, action) : prompt; if (typeof result === "string") { if (typeof getUserConfirmation === "function") { getUserConfirmation(result, callback); } else { false ? (0, _warning2.default)(false, "A history needs a getUserConfirmation function in order to use a prompt message") : void 0; callback(true); } } else { // Return false from a transition hook to cancel the transition. callback(result !== false); } } else { callback(true); } }; var listeners = []; var appendListener = function appendListener(fn) { var isActive = true; var listener = function listener() { if (isActive) fn.apply(undefined, arguments); }; listeners.push(listener); return function () { isActive = false; listeners = listeners.filter(function (item) { return item !== listener; }); }; }; var notifyListeners = function notifyListeners() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } listeners.forEach(function (listener) { return listener.apply(undefined, args); }); }; return { setPrompt: setPrompt, confirmTransitionTo: confirmTransitionTo, appendListener: appendListener, notifyListeners: notifyListeners }; }; exports.default = createTransitionManager; /***/ }), /* 13 */ /***/ (function(module, exports) { "use strict"; exports.__esModule = true; var canUseDOM = exports.canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement); var getConfirmation = exports.getConfirmation = function getConfirmation(message, callback) { return callback(window.confirm(message)); }; // eslint-disable-line no-alert /** * Returns true if the HTML5 history API is supported. Taken from Modernizr. * * https://github.com/Modernizr/Modernizr/blob/master/LICENSE * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js * changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586 */ var supportsHistory = exports.supportsHistory = function supportsHistory() { var ua = window.navigator.userAgent; if ((ua.indexOf("Android 2.") !== -1 || ua.indexOf("Android 4.0") !== -1) && ua.indexOf("Mobile Safari") !== -1 && ua.indexOf("Chrome") === -1 && ua.indexOf("Windows Phone") === -1) return false; return window.history && "pushState" in window.history; }; /** * Returns true if browser fires popstate on hash change. * IE10 and IE11 do not. */ var supportsPopStateOnHashChange = exports.supportsPopStateOnHashChange = function supportsPopStateOnHashChange() { return window.navigator.userAgent.indexOf("Trident") === -1; }; /** * Returns false if using go(n) with hash history causes a full page reload. */ var supportsGoWithoutReloadUsingHash = exports.supportsGoWithoutReloadUsingHash = function supportsGoWithoutReloadUsingHash() { return window.navigator.userAgent.indexOf("Firefox") === -1; }; /** * Returns true if a given popstate event is an extraneous WebKit event. * Accounts for the fact that Chrome on iOS fires real popstate events * containing undefined state when pressing the back button. */ var isExtraneousPopstateEvent = exports.isExtraneousPopstateEvent = function isExtraneousPopstateEvent(event) { return event.state === undefined && navigator.userAgent.indexOf("CriOS") === -1; }; /***/ }), /* 14 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _warning = __webpack_require__(10); var _warning2 = _interopRequireDefault(_warning); var _invariant = __webpack_require__(11); var _invariant2 = _interopRequireDefault(_invariant); var _LocationUtils = __webpack_require__(1); var _PathUtils = __webpack_require__(4); var _createTransitionManager = __webpack_require__(12); var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); var _DOMUtils = __webpack_require__(13); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var HashChangeEvent = "hashchange"; var HashPathCoders = { hashbang: { encodePath: function encodePath(path) { return path.charAt(0) === "!" ? path : "!/" + (0, _PathUtils.stripLeadingSlash)(path); }, decodePath: function decodePath(path) { return path.charAt(0) === "!" ? path.substr(1) : path; } }, noslash: { encodePath: _PathUtils.stripLeadingSlash, decodePath: _PathUtils.addLeadingSlash }, slash: { encodePath: _PathUtils.addLeadingSlash, decodePath: _PathUtils.addLeadingSlash } }; var getHashPath = function getHashPath() { // We can't use window.location.hash here because it's not // consistent across browsers - Firefox will pre-decode it! var href = window.location.href; var hashIndex = href.indexOf("#"); return hashIndex === -1 ? "" : href.substring(hashIndex + 1); }; var pushHashPath = function pushHashPath(path) { return window.location.hash = path; }; var replaceHashPath = function replaceHashPath(path) { var hashIndex = window.location.href.indexOf("#"); window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + "#" + path); }; var createHashHistory = function createHashHistory() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; !_DOMUtils.canUseDOM ? false ? (0, _invariant2.default)(false, "Hash history needs a DOM") : (0, _invariant2.default)(false) : void 0; var globalHistory = window.history; var canGoWithoutReload = (0, _DOMUtils.supportsGoWithoutReloadUsingHash)(); var _props$getUserConfirm = props.getUserConfirmation, getUserConfirmation = _props$getUserConfirm === undefined ? _DOMUtils.getConfirmation : _props$getUserConfirm, _props$hashType = props.hashType, hashType = _props$hashType === undefined ? "slash" : _props$hashType; var basename = props.basename ? (0, _PathUtils.stripTrailingSlash)((0, _PathUtils.addLeadingSlash)(props.basename)) : ""; var _HashPathCoders$hashT = HashPathCoders[hashType], encodePath = _HashPathCoders$hashT.encodePath, decodePath = _HashPathCoders$hashT.decodePath; var getDOMLocation = function getDOMLocation() { var path = decodePath(getHashPath()); false ? (0, _warning2.default)(!basename || (0, _PathUtils.hasBasename)(path, basename), "You are attempting to use a basename on a page whose URL path does not begin " + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".') : void 0; if (basename) path = (0, _PathUtils.stripBasename)(path, basename); return (0, _LocationUtils.createLocation)(path); }; var transitionManager = (0, _createTransitionManager2.default)(); var setState = function setState(nextState) { _extends(history, nextState); history.length = globalHistory.length; transitionManager.notifyListeners(history.location, history.action); }; var forceNextPop = false; var ignorePath = null; var handleHashChange = function handleHashChange() { var path = getHashPath(); var encodedPath = encodePath(path); if (path !== encodedPath) { // Ensure we always have a properly-encoded hash. replaceHashPath(encodedPath); } else { var location = getDOMLocation(); var prevLocation = history.location; if (!forceNextPop && (0, _LocationUtils.locationsAreEqual)(prevLocation, location)) return; // A hashchange doesn't always == location change. if (ignorePath === (0, _PathUtils.createPath)(location)) return; // Ignore this change; we already setState in push/replace. ignorePath = null; handlePop(location); } }; var handlePop = function handlePop(location) { if (forceNextPop) { forceNextPop = false; setState(); } else { var action = "POP"; transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (ok) { setState({ action: action, location: location }); } else { revertPop(location); } }); } }; var revertPop = function revertPop(fromLocation) { var toLocation = history.location; // TODO: We could probably make this more reliable by // keeping a list of paths we've seen in sessionStorage. // Instead, we just default to 0 for paths we don't know. var toIndex = allPaths.lastIndexOf((0, _PathUtils.createPath)(toLocation)); if (toIndex === -1) toIndex = 0; var fromIndex = allPaths.lastIndexOf((0, _PathUtils.createPath)(fromLocation)); if (fromIndex === -1) fromIndex = 0; var delta = toIndex - fromIndex; if (delta) { forceNextPop = true; go(delta); } }; // Ensure the hash is encoded properly before doing anything else. var path = getHashPath(); var encodedPath = encodePath(path); if (path !== encodedPath) replaceHashPath(encodedPath); var initialLocation = getDOMLocation(); var allPaths = [(0, _PathUtils.createPath)(initialLocation)]; // Public interface var createHref = function createHref(location) { return "#" + encodePath(basename + (0, _PathUtils.createPath)(location)); }; var push = function push(path, state) { false ? (0, _warning2.default)(state === undefined, "Hash history cannot push state; it is ignored") : void 0; var action = "PUSH"; var location = (0, _LocationUtils.createLocation)(path, undefined, undefined, history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var path = (0, _PathUtils.createPath)(location); var encodedPath = encodePath(basename + path); var hashChanged = getHashPath() !== encodedPath; if (hashChanged) { // We cannot tell if a hashchange was caused by a PUSH, so we'd // rather setState here and ignore the hashchange. The caveat here // is that other hash histories in the page will consider it a POP. ignorePath = path; pushHashPath(encodedPath); var prevIndex = allPaths.lastIndexOf((0, _PathUtils.createPath)(history.location)); var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1); nextPaths.push(path); allPaths = nextPaths; setState({ action: action, location: location }); } else { false ? (0, _warning2.default)(false, "Hash history cannot PUSH the same path; a new entry will not be added to the history stack") : void 0; setState(); } }); }; var replace = function replace(path, state) { false ? (0, _warning2.default)(state === undefined, "Hash history cannot replace state; it is ignored") : void 0; var action = "REPLACE"; var location = (0, _LocationUtils.createLocation)(path, undefined, undefined, history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var path = (0, _PathUtils.createPath)(location); var encodedPath = encodePath(basename + path); var hashChanged = getHashPath() !== encodedPath; if (hashChanged) { // We cannot tell if a hashchange was caused by a REPLACE, so we'd // rather setState here and ignore the hashchange. The caveat here // is that other hash histories in the page will consider it a POP. ignorePath = path; replaceHashPath(encodedPath); } var prevIndex = allPaths.indexOf((0, _PathUtils.createPath)(history.location)); if (prevIndex !== -1) allPaths[prevIndex] = path; setState({ action: action, location: location }); }); }; var go = function go(n) { false ? (0, _warning2.default)(canGoWithoutReload, "Hash history go(n) causes a full page reload in this browser") : void 0; globalHistory.go(n); }; var goBack = function goBack() { return go(-1); }; var goForward = function goForward() { return go(1); }; var listenerCount = 0; var checkDOMListeners = function checkDOMListeners(delta) { listenerCount += delta; if (listenerCount === 1) { window.addEventListener(HashChangeEvent, handleHashChange); } else if (listenerCount === 0) { window.removeEventListener(HashChangeEvent, handleHashChange); } }; var isBlocked = false; var block = function block() { var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var unblock = transitionManager.setPrompt(prompt); if (!isBlocked) { checkDOMListeners(1); isBlocked = true; } return function () { if (isBlocked) { isBlocked = false; checkDOMListeners(-1); } return unblock(); }; }; var listen = function listen(listener) { var unlisten = transitionManager.appendListener(listener); checkDOMListeners(1); return function () { checkDOMListeners(-1); unlisten(); }; }; var history = { length: globalHistory.length, action: "POP", location: initialLocation, createHref: createHref, push: push, replace: replace, go: go, goBack: goBack, goForward: goForward, block: block, listen: listen }; return history; }; exports.default = createHashHistory; /***/ }), /* 15 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _warning = __webpack_require__(10); var _warning2 = _interopRequireDefault(_warning); var _PathUtils = __webpack_require__(4); var _LocationUtils = __webpack_require__(1); var _createTransitionManager = __webpack_require__(12); var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var clamp = function clamp(n, lowerBound, upperBound) { return Math.min(Math.max(n, lowerBound), upperBound); }; /** * Creates a history object that stores locations in memory. */ var createMemoryHistory = function createMemoryHistory() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var getUserConfirmation = props.getUserConfirmation, _props$initialEntries = props.initialEntries, initialEntries = _props$initialEntries === undefined ? ["/"] : _props$initialEntries, _props$initialIndex = props.initialIndex, initialIndex = _props$initialIndex === undefined ? 0 : _props$initialIndex, _props$keyLength = props.keyLength, keyLength = _props$keyLength === undefined ? 6 : _props$keyLength; var transitionManager = (0, _createTransitionManager2.default)(); var setState = function setState(nextState) { _extends(history, nextState); history.length = history.entries.length; transitionManager.notifyListeners(history.location, history.action); }; var createKey = function createKey() { return Math.random().toString(36).substr(2, keyLength); }; var index = clamp(initialIndex, 0, initialEntries.length - 1); var entries = initialEntries.map(function (entry) { return typeof entry === "string" ? (0, _LocationUtils.createLocation)(entry, undefined, createKey()) : (0, _LocationUtils.createLocation)(entry, undefined, entry.key || createKey()); }); // Public interface var createHref = _PathUtils.createPath; var push = function push(path, state) { false ? (0, _warning2.default)(!((typeof path === "undefined" ? "undefined" : _typeof(path)) === "object" && path.state !== undefined && state !== undefined), "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") : void 0; var action = "PUSH"; var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; var prevIndex = history.index; var nextIndex = prevIndex + 1; var nextEntries = history.entries.slice(0); if (nextEntries.length > nextIndex) { nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location); } else { nextEntries.push(location); } setState({ action: action, location: location, index: nextIndex, entries: nextEntries }); }); }; var replace = function replace(path, state) { false ? (0, _warning2.default)(!((typeof path === "undefined" ? "undefined" : _typeof(path)) === "object" && path.state !== undefined && state !== undefined), "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") : void 0; var action = "REPLACE"; var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location); transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (!ok) return; history.entries[history.index] = location; setState({ action: action, location: location }); }); }; var go = function go(n) { var nextIndex = clamp(history.index + n, 0, history.entries.length - 1); var action = "POP"; var location = history.entries[nextIndex]; transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { if (ok) { setState({ action: action, location: location, index: nextIndex }); } else { // Mimic the behavior of DOM histories by // causing a render after a cancelled POP. setState(); } }); }; var goBack = function goBack() { return go(-1); }; var goForward = function goForward() { return go(1); }; var canGo = function canGo(n) { var nextIndex = history.index + n; return nextIndex >= 0 && nextIndex < history.entries.length; }; var block = function block() { var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; return transitionManager.setPrompt(prompt); }; var listen = function listen(listener) { return transitionManager.appendListener(listener); }; var history = { length: entries.length, action: "POP", location: entries[index], index: index, entries: entries, createHref: createHref, push: push, replace: replace, go: go, goBack: goBack, goForward: goForward, canGo: canGo, block: block, listen: listen }; return history; }; exports.default = createMemoryHistory; /***/ }) /******/ ]) }); ;