meetup-web-mocks
Version:
Meetup Web Mocks
1,605 lines (1,175 loc) • 63.6 kB
JavaScript
(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.locationsAreEqual = exports.Actions = exports.useQueries = exports.useBeforeUnload = exports.useBasename = exports.createMemoryHistory = exports.createHashHistory = exports.createHistory = undefined;
var _LocationUtils = __webpack_require__(1);
Object.defineProperty(exports, 'locationsAreEqual', {
enumerable: true,
get: function get() {
return _LocationUtils.locationsAreEqual;
}
});
var _createBrowserHistory = __webpack_require__(6);
var _createBrowserHistory2 = _interopRequireDefault(_createBrowserHistory);
var _createHashHistory2 = __webpack_require__(15);
var _createHashHistory3 = _interopRequireDefault(_createHashHistory2);
var _createMemoryHistory2 = __webpack_require__(17);
var _createMemoryHistory3 = _interopRequireDefault(_createMemoryHistory2);
var _useBasename2 = __webpack_require__(18);
var _useBasename3 = _interopRequireDefault(_useBasename2);
var _useBeforeUnload2 = __webpack_require__(19);
var _useBeforeUnload3 = _interopRequireDefault(_useBeforeUnload2);
var _useQueries2 = __webpack_require__(20);
var _useQueries3 = _interopRequireDefault(_useQueries2);
var _Actions2 = __webpack_require__(5);
var _Actions = _interopRequireWildcard(_Actions2);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.createHistory = _createBrowserHistory2.default;
exports.createHashHistory = _createHashHistory3.default;
exports.createMemoryHistory = _createMemoryHistory3.default;
exports.useBasename = _useBasename3.default;
exports.useBeforeUnload = _useBeforeUnload3.default;
exports.useQueries = _useQueries3.default;
exports.Actions = _Actions;
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.locationsAreEqual = exports.statesAreEqual = exports.createLocation = exports.createQuery = undefined;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "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 _invariant = __webpack_require__(2);
var _invariant2 = _interopRequireDefault(_invariant);
var _warning = __webpack_require__(3);
var _warning2 = _interopRequireDefault(_warning);
var _PathUtils = __webpack_require__(4);
var _Actions = __webpack_require__(5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var createQuery = exports.createQuery = function createQuery(props) {
return _extends(Object.create(null), props);
};
var createLocation = exports.createLocation = function createLocation() {
var input = arguments.length <= 0 || arguments[0] === undefined ? '/' : arguments[0];
var action = arguments.length <= 1 || arguments[1] === undefined ? _Actions.POP : arguments[1];
var key = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2];
var object = typeof input === 'string' ? (0, _PathUtils.parsePath)(input) : input;
false ? (0, _warning2.default)(!object.path, 'Location descriptor objects should have a `pathname`, not a `path`.') : void 0;
var pathname = object.pathname || '/';
var search = object.search || '';
var hash = object.hash || '';
var state = object.state;
return {
pathname: pathname,
search: search,
hash: hash,
state: state,
action: action,
key: key
};
};
var isDate = function isDate(object) {
return Object.prototype.toString.call(object) === '[object Date]';
};
var statesAreEqual = exports.statesAreEqual = function statesAreEqual(a, b) {
if (a === b) return true;
var typeofA = typeof a === 'undefined' ? 'undefined' : _typeof(a);
var typeofB = typeof b === 'undefined' ? 'undefined' : _typeof(b);
if (typeofA !== typeofB) return false;
!(typeofA !== 'function') ? false ? (0, _invariant2.default)(false, 'You must not store functions in location state') : (0, _invariant2.default)(false) : void 0;
// Not the same object, but same type.
if (typeofA === 'object') {
!!(isDate(a) && isDate(b)) ? false ? (0, _invariant2.default)(false, 'You must not store Date objects in location state') : (0, _invariant2.default)(false) : void 0;
if (!Array.isArray(a)) {
var keysofA = Object.keys(a);
var keysofB = Object.keys(b);
return keysofA.length === keysofB.length && keysofA.every(function (key) {
return statesAreEqual(a[key], b[key]);
});
}
return Array.isArray(b) && a.length === b.length && a.every(function (item, index) {
return statesAreEqual(item, b[index]);
});
}
// All other serializable types (string, number, boolean)
// should be strict equal.
return false;
};
var locationsAreEqual = exports.locationsAreEqual = function locationsAreEqual(a, b) {
return a.key === b.key &&
// a.action === b.action && // Different action !== location change.
a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && statesAreEqual(a.state, b.state);
};
/***/ },
/* 2 */
/***/ 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;
/***/ },
/* 3 */
/***/ 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;
/***/ },
/* 4 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.createPath = exports.parsePath = exports.getQueryStringValueFromPath = exports.stripQueryStringValueFromPath = exports.addQueryStringValueToPath = undefined;
var _warning = __webpack_require__(3);
var _warning2 = _interopRequireDefault(_warning);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var addQueryStringValueToPath = exports.addQueryStringValueToPath = function addQueryStringValueToPath(path, key, value) {
var _parsePath = parsePath(path);
var pathname = _parsePath.pathname;
var search = _parsePath.search;
var hash = _parsePath.hash;
return createPath({
pathname: pathname,
search: search + (search.indexOf('?') === -1 ? '?' : '&') + key + '=' + value,
hash: hash
});
};
var stripQueryStringValueFromPath = exports.stripQueryStringValueFromPath = function stripQueryStringValueFromPath(path, key) {
var _parsePath2 = parsePath(path);
var pathname = _parsePath2.pathname;
var search = _parsePath2.search;
var hash = _parsePath2.hash;
return createPath({
pathname: pathname,
search: search.replace(new RegExp('([?&])' + key + '=[a-zA-Z0-9]+(&?)'), function (match, prefix, suffix) {
return prefix === '?' ? prefix : suffix;
}),
hash: hash
});
};
var getQueryStringValueFromPath = exports.getQueryStringValueFromPath = function getQueryStringValueFromPath(path, key) {
var _parsePath3 = parsePath(path);
var search = _parsePath3.search;
var match = search.match(new RegExp('[?&]' + key + '=([a-zA-Z0-9]+)'));
return match && match[1];
};
var extractPath = function extractPath(string) {
var match = string.match(/^(https?:)?\/\/[^\/]*/);
return match == null ? string : string.substring(match[0].length);
};
var parsePath = exports.parsePath = function parsePath(path) {
var pathname = extractPath(path);
var search = '';
var hash = '';
false ? (0, _warning2.default)(path === pathname, 'A path must be pathname + search + hash only, not a full URL like "%s"', path) : void 0;
var hashIndex = pathname.indexOf('#');
if (hashIndex !== -1) {
hash = pathname.substring(hashIndex);
pathname = pathname.substring(0, hashIndex);
}
var searchIndex = pathname.indexOf('?');
if (searchIndex !== -1) {
search = pathname.substring(searchIndex);
pathname = pathname.substring(0, searchIndex);
}
if (pathname === '') pathname = '/';
return {
pathname: pathname,
search: search,
hash: hash
};
};
var createPath = exports.createPath = function createPath(location) {
if (location == null || typeof location === 'string') return location;
var basename = location.basename;
var pathname = location.pathname;
var search = location.search;
var hash = location.hash;
var path = (basename || '') + pathname;
if (search && search !== '?') path += search;
if (hash) path += hash;
return path;
};
/***/ },
/* 5 */
/***/ function(module, exports) {
'use strict';
exports.__esModule = true;
/**
* Indicates that navigation was caused by a call to history.push.
*/
var PUSH = exports.PUSH = 'PUSH';
/**
* Indicates that navigation was caused by a call to history.replace.
*/
var REPLACE = exports.REPLACE = 'REPLACE';
/**
* Indicates that navigation was caused by some other action such
* as using a browser's back/forward buttons and/or manually manipulating
* the URL in a browser's location bar. This is the default.
*
* See https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate
* for more information.
*/
var POP = exports.POP = 'POP';
/***/ },
/* 6 */
/***/ 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 _invariant = __webpack_require__(2);
var _invariant2 = _interopRequireDefault(_invariant);
var _ExecutionEnvironment = __webpack_require__(7);
var _BrowserProtocol = __webpack_require__(8);
var BrowserProtocol = _interopRequireWildcard(_BrowserProtocol);
var _RefreshProtocol = __webpack_require__(11);
var RefreshProtocol = _interopRequireWildcard(_RefreshProtocol);
var _DOMUtils = __webpack_require__(9);
var _createHistory = __webpack_require__(12);
var _createHistory2 = _interopRequireDefault(_createHistory);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Creates and returns a history object that uses HTML5's history API
* (pushState, replaceState, and the popstate event) to manage history.
* This is the recommended method of managing history in browsers because
* it provides the cleanest URLs.
*
* Note: In browsers that do not support the HTML5 history API full
* page reloads will be used to preserve clean URLs. You can force this
* behavior using { forceRefresh: true } in options.
*/
var createBrowserHistory = function createBrowserHistory() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
!_ExecutionEnvironment.canUseDOM ? false ? (0, _invariant2.default)(false, 'Browser history needs a DOM') : (0, _invariant2.default)(false) : void 0;
var useRefresh = options.forceRefresh || !(0, _DOMUtils.supportsHistory)();
var Protocol = useRefresh ? RefreshProtocol : BrowserProtocol;
var getUserConfirmation = Protocol.getUserConfirmation;
var getCurrentLocation = Protocol.getCurrentLocation;
var pushLocation = Protocol.pushLocation;
var replaceLocation = Protocol.replaceLocation;
var go = Protocol.go;
var history = (0, _createHistory2.default)(_extends({
getUserConfirmation: getUserConfirmation }, options, {
getCurrentLocation: getCurrentLocation,
pushLocation: pushLocation,
replaceLocation: replaceLocation,
go: go
}));
var listenerCount = 0,
stopListener = void 0;
var startListener = function startListener(listener, before) {
if (++listenerCount === 1) stopListener = BrowserProtocol.startListener(history.transitionTo);
var unlisten = before ? history.listenBefore(listener) : history.listen(listener);
return function () {
unlisten();
if (--listenerCount === 0) stopListener();
};
};
var listenBefore = function listenBefore(listener) {
return startListener(listener, true);
};
var listen = function listen(listener) {
return startListener(listener, false);
};
return _extends({}, history, {
listenBefore: listenBefore,
listen: listen
});
};
exports.default = createBrowserHistory;
/***/ },
/* 7 */
/***/ function(module, exports) {
'use strict';
exports.__esModule = true;
var canUseDOM = exports.canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.go = exports.replaceLocation = exports.pushLocation = exports.startListener = exports.getUserConfirmation = exports.getCurrentLocation = undefined;
var _LocationUtils = __webpack_require__(1);
var _DOMUtils = __webpack_require__(9);
var _DOMStateStorage = __webpack_require__(10);
var _PathUtils = __webpack_require__(4);
var _ExecutionEnvironment = __webpack_require__(7);
var PopStateEvent = 'popstate';
var HashChangeEvent = 'hashchange';
var needsHashchangeListener = _ExecutionEnvironment.canUseDOM && !(0, _DOMUtils.supportsPopstateOnHashchange)();
var _createLocation = function _createLocation(historyState) {
var key = historyState && historyState.key;
return (0, _LocationUtils.createLocation)({
pathname: window.location.pathname,
search: window.location.search,
hash: window.location.hash,
state: key ? (0, _DOMStateStorage.readState)(key) : undefined
}, undefined, key);
};
var getCurrentLocation = exports.getCurrentLocation = function getCurrentLocation() {
var historyState = void 0;
try {
historyState = window.history.state || {};
} catch (error) {
// IE 11 sometimes throws when accessing window.history.state
// See https://github.com/ReactTraining/history/pull/289
historyState = {};
}
return _createLocation(historyState);
};
var getUserConfirmation = exports.getUserConfirmation = function getUserConfirmation(message, callback) {
return callback(window.confirm(message));
}; // eslint-disable-line no-alert
var startListener = exports.startListener = function startListener(listener) {
var handlePopState = function handlePopState(event) {
if (event.state !== undefined) // Ignore extraneous popstate events in WebKit
listener(_createLocation(event.state));
};
(0, _DOMUtils.addEventListener)(window, PopStateEvent, handlePopState);
var handleUnpoppedHashChange = function handleUnpoppedHashChange() {
return listener(getCurrentLocation());
};
if (needsHashchangeListener) {
(0, _DOMUtils.addEventListener)(window, HashChangeEvent, handleUnpoppedHashChange);
}
return function () {
(0, _DOMUtils.removeEventListener)(window, PopStateEvent, handlePopState);
if (needsHashchangeListener) {
(0, _DOMUtils.removeEventListener)(window, HashChangeEvent, handleUnpoppedHashChange);
}
};
};
var updateLocation = function updateLocation(location, updateState) {
var state = location.state;
var key = location.key;
if (state !== undefined) (0, _DOMStateStorage.saveState)(key, state);
updateState({ key: key }, (0, _PathUtils.createPath)(location));
};
var pushLocation = exports.pushLocation = function pushLocation(location) {
return updateLocation(location, function (state, path) {
return window.history.pushState(state, null, path);
});
};
var replaceLocation = exports.replaceLocation = function replaceLocation(location) {
return updateLocation(location, function (state, path) {
return window.history.replaceState(state, null, path);
});
};
var go = exports.go = function go(n) {
if (n) window.history.go(n);
};
/***/ },
/* 9 */
/***/ function(module, exports) {
'use strict';
exports.__esModule = true;
var addEventListener = exports.addEventListener = function addEventListener(node, event, listener) {
return node.addEventListener ? node.addEventListener(event, listener, false) : node.attachEvent('on' + event, listener);
};
var removeEventListener = exports.removeEventListener = function removeEventListener(node, event, listener) {
return node.removeEventListener ? node.removeEventListener(event, listener, false) : node.detachEvent('on' + event, listener);
};
/**
* 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 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 browser fires popstate on hash change.
* IE10 and IE11 do not.
*/
var supportsPopstateOnHashchange = exports.supportsPopstateOnHashchange = function supportsPopstateOnHashchange() {
return window.navigator.userAgent.indexOf('Trident') === -1;
};
/***/ },
/* 10 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.readState = exports.saveState = undefined;
var _warning = __webpack_require__(3);
var _warning2 = _interopRequireDefault(_warning);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var QuotaExceededErrors = {
QuotaExceededError: true,
QUOTA_EXCEEDED_ERR: true
};
var SecurityErrors = {
SecurityError: true
};
var KeyPrefix = '@@History/';
var createKey = function createKey(key) {
return KeyPrefix + key;
};
var saveState = exports.saveState = function saveState(key, state) {
if (!window.sessionStorage) {
// Session storage is not available or hidden.
// sessionStorage is undefined in Internet Explorer when served via file protocol.
false ? (0, _warning2.default)(false, '[history] Unable to save state; sessionStorage is not available') : void 0;
return;
}
try {
if (state == null) {
window.sessionStorage.removeItem(createKey(key));
} else {
window.sessionStorage.setItem(createKey(key), JSON.stringify(state));
}
} catch (error) {
if (SecurityErrors[error.name]) {
// Blocking cookies in Chrome/Firefox/Safari throws SecurityError on any
// attempt to access window.sessionStorage.
false ? (0, _warning2.default)(false, '[history] Unable to save state; sessionStorage is not available due to security settings') : void 0;
return;
}
if (QuotaExceededErrors[error.name] && window.sessionStorage.length === 0) {
// Safari "private mode" throws QuotaExceededError.
false ? (0, _warning2.default)(false, '[history] Unable to save state; sessionStorage is not available in Safari private mode') : void 0;
return;
}
throw error;
}
};
var readState = exports.readState = function readState(key) {
var json = void 0;
try {
json = window.sessionStorage.getItem(createKey(key));
} catch (error) {
if (SecurityErrors[error.name]) {
// Blocking cookies in Chrome/Firefox/Safari throws SecurityError on any
// attempt to access window.sessionStorage.
false ? (0, _warning2.default)(false, '[history] Unable to read state; sessionStorage is not available due to security settings') : void 0;
return undefined;
}
}
if (json) {
try {
return JSON.parse(json);
} catch (error) {
// Ignore invalid JSON.
}
}
return undefined;
};
/***/ },
/* 11 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.replaceLocation = exports.pushLocation = exports.getCurrentLocation = exports.go = exports.getUserConfirmation = undefined;
var _BrowserProtocol = __webpack_require__(8);
Object.defineProperty(exports, 'getUserConfirmation', {
enumerable: true,
get: function get() {
return _BrowserProtocol.getUserConfirmation;
}
});
Object.defineProperty(exports, 'go', {
enumerable: true,
get: function get() {
return _BrowserProtocol.go;
}
});
var _LocationUtils = __webpack_require__(1);
var _PathUtils = __webpack_require__(4);
var getCurrentLocation = exports.getCurrentLocation = function getCurrentLocation() {
return (0, _LocationUtils.createLocation)(window.location);
};
var pushLocation = exports.pushLocation = function pushLocation(location) {
window.location.href = (0, _PathUtils.createPath)(location);
return false; // Don't update location
};
var replaceLocation = exports.replaceLocation = function replaceLocation(location) {
window.location.replace((0, _PathUtils.createPath)(location));
return false; // Don't update location
};
/***/ },
/* 12 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _AsyncUtils = __webpack_require__(13);
var _PathUtils = __webpack_require__(4);
var _runTransitionHook = __webpack_require__(14);
var _runTransitionHook2 = _interopRequireDefault(_runTransitionHook);
var _Actions = __webpack_require__(5);
var _LocationUtils = __webpack_require__(1);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var createHistory = function createHistory() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var getCurrentLocation = options.getCurrentLocation;
var getUserConfirmation = options.getUserConfirmation;
var pushLocation = options.pushLocation;
var replaceLocation = options.replaceLocation;
var go = options.go;
var keyLength = options.keyLength;
var currentLocation = void 0;
var pendingLocation = void 0;
var beforeListeners = [];
var listeners = [];
var allKeys = [];
var getCurrentIndex = function getCurrentIndex() {
if (pendingLocation && pendingLocation.action === _Actions.POP) return allKeys.indexOf(pendingLocation.key);
if (currentLocation) return allKeys.indexOf(currentLocation.key);
return -1;
};
var updateLocation = function updateLocation(nextLocation) {
var currentIndex = getCurrentIndex();
currentLocation = nextLocation;
if (currentLocation.action === _Actions.PUSH) {
allKeys = [].concat(allKeys.slice(0, currentIndex + 1), [currentLocation.key]);
} else if (currentLocation.action === _Actions.REPLACE) {
allKeys[currentIndex] = currentLocation.key;
}
listeners.forEach(function (listener) {
return listener(currentLocation);
});
};
var listenBefore = function listenBefore(listener) {
beforeListeners.push(listener);
return function () {
return beforeListeners = beforeListeners.filter(function (item) {
return item !== listener;
});
};
};
var listen = function listen(listener) {
listeners.push(listener);
return function () {
return listeners = listeners.filter(function (item) {
return item !== listener;
});
};
};
var confirmTransitionTo = function confirmTransitionTo(location, callback) {
(0, _AsyncUtils.loopAsync)(beforeListeners.length, function (index, next, done) {
(0, _runTransitionHook2.default)(beforeListeners[index], location, function (result) {
return result != null ? done(result) : next();
});
}, function (message) {
if (getUserConfirmation && typeof message === 'string') {
getUserConfirmation(message, function (ok) {
return callback(ok !== false);
});
} else {
callback(message !== false);
}
});
};
var transitionTo = function transitionTo(nextLocation) {
if (currentLocation && (0, _LocationUtils.locationsAreEqual)(currentLocation, nextLocation) || pendingLocation && (0, _LocationUtils.locationsAreEqual)(pendingLocation, nextLocation)) return; // Nothing to do
pendingLocation = nextLocation;
confirmTransitionTo(nextLocation, function (ok) {
if (pendingLocation !== nextLocation) return; // Transition was interrupted during confirmation
pendingLocation = null;
if (ok) {
// Treat PUSH to same path like REPLACE to be consistent with browsers
if (nextLocation.action === _Actions.PUSH) {
var prevPath = (0, _PathUtils.createPath)(currentLocation);
var nextPath = (0, _PathUtils.createPath)(nextLocation);
if (nextPath === prevPath && (0, _LocationUtils.statesAreEqual)(currentLocation.state, nextLocation.state)) nextLocation.action = _Actions.REPLACE;
}
if (nextLocation.action === _Actions.POP) {
updateLocation(nextLocation);
} else if (nextLocation.action === _Actions.PUSH) {
if (pushLocation(nextLocation) !== false) updateLocation(nextLocation);
} else if (nextLocation.action === _Actions.REPLACE) {
if (replaceLocation(nextLocation) !== false) updateLocation(nextLocation);
}
} else if (currentLocation && nextLocation.action === _Actions.POP) {
var prevIndex = allKeys.indexOf(currentLocation.key);
var nextIndex = allKeys.indexOf(nextLocation.key);
if (prevIndex !== -1 && nextIndex !== -1) go(prevIndex - nextIndex); // Restore the URL
}
});
};
var push = function push(input) {
return transitionTo(createLocation(input, _Actions.PUSH));
};
var replace = function replace(input) {
return transitionTo(createLocation(input, _Actions.REPLACE));
};
var goBack = function goBack() {
return go(-1);
};
var goForward = function goForward() {
return go(1);
};
var createKey = function createKey() {
return Math.random().toString(36).substr(2, keyLength || 6);
};
var createHref = function createHref(location) {
return (0, _PathUtils.createPath)(location);
};
var createLocation = function createLocation(location, action) {
var key = arguments.length <= 2 || arguments[2] === undefined ? createKey() : arguments[2];
return (0, _LocationUtils.createLocation)(location, action, key);
};
return {
getCurrentLocation: getCurrentLocation,
listenBefore: listenBefore,
listen: listen,
transitionTo: transitionTo,
push: push,
replace: replace,
go: go,
goBack: goBack,
goForward: goForward,
createKey: createKey,
createPath: _PathUtils.createPath,
createHref: createHref,
createLocation: createLocation
};
};
exports.default = createHistory;
/***/ },
/* 13 */
/***/ function(module, exports) {
"use strict";
exports.__esModule = true;
var loopAsync = exports.loopAsync = function loopAsync(turns, work, callback) {
var currentTurn = 0,
isDone = false;
var isSync = false,
hasNext = false,
doneArgs = void 0;
var done = function done() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
isDone = true;
if (isSync) {
// Iterate instead of recursing if possible.
doneArgs = args;
return;
}
callback.apply(undefined, args);
};
var next = function next() {
if (isDone) return;
hasNext = true;
if (isSync) return; // Iterate instead of recursing if possible.
isSync = true;
while (!isDone && currentTurn < turns && hasNext) {
hasNext = false;
work(currentTurn++, next, done);
}
isSync = false;
if (isDone) {
// This means the loop finished synchronously.
callback.apply(undefined, doneArgs);
return;
}
if (currentTurn >= turns && hasNext) {
isDone = true;
callback();
}
};
next();
};
/***/ },
/* 14 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _warning = __webpack_require__(3);
var _warning2 = _interopRequireDefault(_warning);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var runTransitionHook = function runTransitionHook(hook, location, callback) {
var result = hook(location, callback);
if (hook.length < 2) {
// Assume the hook runs synchronously and automatically
// call the callback with the return value.
callback(result);
} else {
false ? (0, _warning2.default)(result === undefined, 'You should not "return" in a transition hook with a callback argument; ' + 'call the callback instead') : void 0;
}
};
exports.default = runTransitionHook;
/***/ },
/* 15 */
/***/ 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__(3);
var _warning2 = _interopRequireDefault(_warning);
var _invariant = __webpack_require__(2);
var _invariant2 = _interopRequireDefault(_invariant);
var _ExecutionEnvironment = __webpack_require__(7);
var _DOMUtils = __webpack_require__(9);
var _HashProtocol = __webpack_require__(16);
var HashProtocol = _interopRequireWildcard(_HashProtocol);
var _createHistory = __webpack_require__(12);
var _createHistory2 = _interopRequireDefault(_createHistory);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var DefaultQueryKey = '_k';
var addLeadingSlash = function addLeadingSlash(path) {
return path.charAt(0) === '/' ? path : '/' + path;
};
var HashPathCoders = {
hashbang: {
encodePath: function encodePath(path) {
return path.charAt(0) === '!' ? path : '!' + path;
},
decodePath: function decodePath(path) {
return path.charAt(0) === '!' ? path.substring(1) : path;
}
},
noslash: {
encodePath: function encodePath(path) {
return path.charAt(0) === '/' ? path.substring(1) : path;
},
decodePath: addLeadingSlash
},
slash: {
encodePath: addLeadingSlash,
decodePath: addLeadingSlash
}
};
var createHashHistory = function createHashHistory() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
!_ExecutionEnvironment.canUseDOM ? false ? (0, _invariant2.default)(false, 'Hash history needs a DOM') : (0, _invariant2.default)(false) : void 0;
var queryKey = options.queryKey;
var hashType = options.hashType;
false ? (0, _warning2.default)(queryKey !== false, 'Using { queryKey: false } no longer works. Instead, just don\'t ' + 'use location state if you don\'t want a key in your URL query string') : void 0;
if (typeof queryKey !== 'string') queryKey = DefaultQueryKey;
if (hashType == null) hashType = 'slash';
if (!(hashType in HashPathCoders)) {
false ? (0, _warning2.default)(false, 'Invalid hash type: %s', hashType) : void 0;
hashType = 'slash';
}
var pathCoder = HashPathCoders[hashType];
var getUserConfirmation = HashProtocol.getUserConfirmation;
var getCurrentLocation = function getCurrentLocation() {
return HashProtocol.getCurrentLocation(pathCoder, queryKey);
};
var pushLocation = function pushLocation(location) {
return HashProtocol.pushLocation(location, pathCoder, queryKey);
};
var replaceLocation = function replaceLocation(location) {
return HashProtocol.replaceLocation(location, pathCoder, queryKey);
};
var history = (0, _createHistory2.default)(_extends({
getUserConfirmation: getUserConfirmation }, options, {
getCurrentLocation: getCurrentLocation,
pushLocation: pushLocation,
replaceLocation: replaceLocation,
go: HashProtocol.go
}));
var listenerCount = 0,
stopListener = void 0;
var startListener = function startListener(listener, before) {
if (++listenerCount === 1) stopListener = HashProtocol.startListener(history.transitionTo, pathCoder, queryKey);
var unlisten = before ? history.listenBefore(listener) : history.listen(listener);
return function () {
unlisten();
if (--listenerCount === 0) stopListener();
};
};
var listenBefore = function listenBefore(listener) {
return startListener(listener, true);
};
var listen = function listen(listener) {
return startListener(listener, false);
};
var goIsSupportedWithoutReload = (0, _DOMUtils.supportsGoWithoutReloadUsingHash)();
var go = function go(n) {
false ? (0, _warning2.default)(goIsSupportedWithoutReload, 'Hash history go(n) causes a full page reload in this browser') : void 0;
history.go(n);
};
var createHref = function createHref(path) {
return '#' + pathCoder.encodePath(history.createHref(path));
};
return _extends({}, history, {
listenBefore: listenBefore,
listen: listen,
go: go,
createHref: createHref
});
};
exports.default = createHashHistory;
/***/ },
/* 16 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.replaceLocation = exports.pushLocation = exports.startListener = exports.getCurrentLocation = exports.go = exports.getUserConfirmation = undefined;
var _BrowserProtocol = __webpack_require__(8);
Object.defineProperty(exports, 'getUserConfirmation', {
enumerable: true,
get: function get() {
return _BrowserProtocol.getUserConfirmation;
}
});
Object.defineProperty(exports, 'go', {
enumerable: true,
get: function get() {
return _BrowserProtocol.go;
}
});
var _warning = __webpack_require__(3);
var _warning2 = _interopRequireDefault(_warning);
var _LocationUtils = __webpack_require__(1);
var _DOMUtils = __webpack_require__(9);
var _DOMStateStorage = __webpack_require__(10);
var _PathUtils = __webpack_require__(4);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var HashChangeEvent = 'hashchange';
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 getCurrentLocation = exports.getCurrentLocation = function getCurrentLocation(pathCoder, queryKey) {
var path = pathCoder.decodePath(getHashPath());
var key = (0, _PathUtils.getQueryStringValueFromPath)(path, queryKey);
var state = void 0;
if (key) {
path = (0, _PathUtils.stripQueryStringValueFromPath)(path, queryKey);
state = (0, _DOMStateStorage.readState)(key);
}
var init = (0, _PathUtils.parsePath)(path);
init.state = state;
return (0, _LocationUtils.createLocation)(init, undefined, key);
};
var prevLocation = void 0;
var startListener = exports.startListener = function startListener(listener, pathCoder, queryKey) {
var handleHashChange = function handleHashChange() {
var path = getHashPath();
var encodedPath = pathCoder.encodePath(path);
if (path !== encodedPath) {
// Always be sure we have a properly-encoded hash.
replaceHashPath(encodedPath);
} else {
var currentLocation = getCurrentLocation(pathCoder, queryKey);
if (prevLocation && currentLocation.key && prevLocation.key === currentLocation.key) return; // Ignore extraneous hashchange events
prevLocation = currentLocation;
listener(currentLocation);
}
};
// Ensure the hash is encoded properly.
var path = getHashPath();
var encodedPath = pathCoder.encodePath(path);
if (path !== encodedPath) replaceHashPath(encodedPath);
(0, _DOMUtils.addEventListener)(window, HashChangeEvent, handleHashChange);
return function () {
return (0, _DOMUtils.removeEventListener)(window, HashChangeEvent, handleHashChange);
};
};
var updateLocation = function updateLocation(location, pathCoder, queryKey, updateHash) {
var state = location.state;
var key = location.key;
var path = pathCoder.encodePath((0, _PathUtils.createPath)(location));
if (state !== undefined) {
path = (0, _PathUtils.addQueryStringValueToPath)(path, queryKey, key);
(0, _DOMStateStorage.saveState)(key, state);
}
prevLocation = location;
updateHash(path);
};
var pushLocation = exports.pushLocation = function pushLocation(location, pathCoder, queryKey) {
return updateLocation(location, pathCoder, queryKey, function (path) {
if (getHashPath() !== path) {
pushHashPath(path);
} else {
false ? (0, _warning2.default)(false, 'You cannot PUSH the same path using hash history') : void 0;
}
});
};
var replaceLocation = exports.replaceLocation = function replaceLocation(location, pathCoder, queryKey) {
return updateLocation(location, pathCoder, queryKey, function (path) {
if (getHashPath() !== path) replaceHashPath(path);
});
};
/***/ },
/* 17 */
/***/ 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__(3);
var _warning2 = _interopRequireDefault(_warning);
var _invariant = __webpack_require__(2);
var _invariant2 = _interopRequireDefault(_invariant);
var _LocationUtils = __webpack_require__(1);
var _PathUtils = __webpack_require__(4);
var _createHistory = __webpack_require__(12);
var _createHistory2 = _interopRequireDefault(_createHistory);
var _Actions = __webpack_require__(5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var createStateStorage = function createStateStorage(entries) {
return entries.filter(function (entry) {
return entry.state;
}).reduce(function (memo, entry) {
memo[entry.key] = entry.state;
return memo;
}, {});
};
var createMemoryHistory = function createMemoryHistory() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
if (Array.isArray(options)) {
options = { entries: options };
} else if (typeof options === 'string') {
options = { entries: [options] };
}
var getCurrentLocation = function getCurrentLocation() {
var entry = entries[current];
var path = (0, _PathUtils.createPath)(entry);
var key = void 0,
state = void 0;
if (entry.key) {
key = entry.key;
state = readState(key);
}
var init = (0, _PathUtils.parsePath)(path);
return (0, _LocationUtils.createLocation)(_extends({}, init, { state: state }), undefined, key);
};
var canGo = function canGo(n) {
var index = current + n;
return index >= 0 && index < entries.length;
};
var go = function go(n) {
if (!n) return;
if (!canGo(n)) {
false ? (0, _warning2.default)(false, 'Cannot go(%s) there is not enough history', n) : void 0;
return;
}
current += n;
var currentLocation = getCurrentLocation();
// Change action to POP
history.transitionTo(_extends({}, currentLocation, { action: _Actions.POP }));
};
var pushLocation = function pushLocation(location) {
current += 1;
if (current < entries.length) entries.splice(current);
entries.push(location);
saveState(location.key, location.state);
};
var replaceLocation = function replaceLocation(location) {
entries[current] = location;
saveState(location.key, location.state);
};
var history = (0, _createHistory2.default)(_extends({}, options, {
getCurrentLocation: getCurrentLocation,
pushLocation: pushLocation,
replaceLocation: replaceLocation,
go: go
}));
var _options = options;
var entries = _options.entries;
var current = _options.current;
if (typeof entries === 'string') {
entries = [entries];
} else if (!Array.isArray(entries)) {
entries = ['/'];
}
entries = entries.map(function (entry) {
return (0, _LocationUtils.createLocation)(entry);
});
if (current == null) {
current = entries.length - 1;
} else {
!(current >= 0 && current < entries.length) ? false ? (0, _invariant2.default)(false, 'Current index must be >= 0 and < %s, was %s', entries.length, current) : (0, _invariant2.default)(false) : void 0;
}
var storage = createStateStorage(entries);
var saveState = function saveState(key, state) {
return storage[key] = state;
};
var readState = function readState(key) {
return storage[key];
};
return _extends({}, history, {
canGo: canGo
});
};
exports.default = createMemoryHistory;
/***/ },
/* 18 */
/***/ 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 _runTransitionHook = __webpack_require__(14);
var _runTransitionHook2 = _interopRequireDefault(_runTransitionHook);
var _PathUtils = __webpack_require__(4);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var useBasename = function useBasename(createHistory) {
return function () {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var history = createHistory(options);
var basename = options.basename;
var addBasename = function addBasename(location) {
if (!location) return location;
if (basename && location.basename == null) {
if (location.pathname.indexOf(basename) === 0) {
location.pathname = location.pathname.substring(basename.length);
location.basename = basename;
if (location.pathname === '') location.pathname = '/';
} else {
location.basename = '';
}
}
return location;
};
var prependBasename = function prependBasename(location) {
if (!basename) return location;
var object = typeof location === 'st