@zohodesk/react-cli 1.1.19-exp.1 → 1.1.19-exp.11
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/cli.js +4 -0
- package/lib/babel/cmjs-plugins-presets.js +11 -6
- package/lib/babel/es-plugins-presets.js +12 -6
- package/lib/configs/jest.config.js +3 -3
- package/lib/configs/webpack.dev.config.js +4 -0
- package/lib/configs/webpack.prod.config.js +5 -1
- package/lib/jest/preProcessors/jsPreprocessor.js +1 -1
- package/lib/loaderUtils/getDevJsLoaders.js +1 -1
- package/lib/loaders/workerLoader.js +24 -39
- package/lib/schemas/index.js +3 -0
- package/npm-shrinkwrap.json +445 -19077
- package/package.json +6 -1
- package/packages/client_build_tool/lib/allCommandsConfigs.js +0 -23
- package/packages/client_build_tool/lib/buildToolLoggers.js +0 -32
- package/packages/client_build_tool/lib/commands/build/commandExecutor.js +0 -21
- package/packages/client_build_tool/lib/commands/build/config.js +0 -12
- package/packages/client_build_tool/lib/commands/build/errorHander.js +0 -10
- package/packages/client_build_tool/lib/commands/build/index.js +0 -35
- package/packages/client_build_tool/lib/commands/build/optionsProcesser.js +0 -40
- package/packages/client_build_tool/lib/commands/buildEs/commandExecutor.js +0 -17
- package/packages/client_build_tool/lib/commands/buildEs/config.js +0 -12
- package/packages/client_build_tool/lib/commands/buildLib/commandExecutor.js +0 -17
- package/packages/client_build_tool/lib/commands/buildLib/config.js +0 -12
- package/packages/client_build_tool/lib/commands/start/commandExecutor.js +0 -13
- package/packages/client_build_tool/lib/commands/start/config.js +0 -12
- package/packages/client_build_tool/lib/commands/start/deprecationHandler.js +0 -10
- package/packages/client_build_tool/lib/commands/start/errorHander.js +0 -10
- package/packages/client_build_tool/lib/commands/start/optionsProcesser.js +0 -36
- package/packages/client_build_tool/lib/commands/start/postProcesser.js +0 -10
- package/packages/client_build_tool/lib/commands/start/preProcesser.js +0 -10
- package/packages/client_build_tool/lib/commandsRouter.js +0 -71
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/decidePublicPath.js +0 -44
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/libAlias.js +0 -31
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/nameTemplates.js +0 -51
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +0 -21
- package/packages/client_build_tool/lib/shared/bundler/webpack/cssLoaders.js +0 -16
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin.js +0 -111
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/EFCPlugin.js +0 -1
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +0 -11
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +0 -136
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +0 -95
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +0 -25
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +0 -29
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +0 -24
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nDependency.js +0 -99
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +0 -81
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nModule.js +0 -201
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +0 -401
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +0 -67
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +0 -23
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +0 -29
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +0 -49
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +0 -77
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +0 -63
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +0 -19
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +0 -31
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -127
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +0 -1
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +0 -63
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +0 -89
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +0 -34
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +0 -15
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +0 -155
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin.js +0 -49
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/ExcludePlugin.js +0 -58
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/RTLSplitPlugin.js +0 -139
- package/packages/client_build_tool/lib/shared/bundler/webpack/devServerConfig.js +0 -34
- package/packages/client_build_tool/lib/shared/bundler/webpack/getCSSLoaders.js +0 -30
- package/packages/client_build_tool/lib/shared/bundler/webpack/jsLoaders.js +0 -17
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +0 -14
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +0 -24
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +0 -18
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +0 -21
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +0 -138
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +0 -83
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +0 -23
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaders/workerLoader.js +0 -133
- package/packages/client_build_tool/lib/shared/bundler/webpack/optimizationConfig.js +0 -39
- package/packages/client_build_tool/lib/shared/bundler/webpack/outputConfig.js +0 -28
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +0 -18
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCopyThirdpartyFile.js +0 -38
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +0 -24
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +0 -28
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +0 -35
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +0 -16
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +0 -23
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +0 -19
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +0 -27
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +0 -18
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configUglifyCSSPlugin.js +0 -15
- package/packages/client_build_tool/lib/shared/bundler/webpack/plugins.js +0 -39
- package/packages/client_build_tool/lib/shared/bundler/webpack/postcssPlugins.js +0 -36
- package/packages/client_build_tool/lib/shared/bundler/webpack/resolvers.js +0 -42
- package/packages/client_build_tool/lib/shared/bundler/webpack/splitChunksConfig.js +0 -12
- package/packages/client_build_tool/lib/shared/bundler/webpack/webpack.dev.config.js +0 -17
- package/packages/client_build_tool/lib/shared/bundler/webpack/webpackBuild.js +0 -24
- package/packages/client_build_tool/lib/shared/bundler/webpack/webpackConfig.js +0 -50
- package/packages/client_build_tool/lib/shared/commands-utlis/doBasicRequiermentCheck.js +0 -16
- package/packages/client_build_tool/lib/shared/commands-utlis/getCliPath.js +0 -38
- package/packages/client_build_tool/lib/shared/commands-utlis/index.js +0 -29
- package/packages/client_build_tool/lib/shared/commands-utlis/log.js +0 -13
- package/packages/client_build_tool/lib/shared/commands-utlis/readArgsFormCommandLine.js +0 -11
- package/packages/client_build_tool/lib/shared/commands-utlis/readOptionFormCommandLine.js +0 -11
- package/packages/client_build_tool/lib/shared/commands-utlis/spanSync.js +0 -35
- package/packages/client_build_tool/lib/shared/constants.js +0 -33
- package/packages/client_build_tool/lib/shared/schemas/applyValuesToShema.js +0 -37
- package/packages/client_build_tool/lib/shared/schemas/cliArgsToObject.js +0 -37
- package/packages/client_build_tool/lib/shared/schemas/defaultConfigValues.js +0 -119
- package/packages/client_build_tool/lib/shared/schemas/deprecatedOptionsHandler.js +0 -65
- package/packages/client_build_tool/lib/shared/schemas/getCWD.js +0 -23
- package/packages/client_build_tool/lib/shared/schemas/getNpmVersion.js +0 -21
- package/packages/client_build_tool/lib/shared/schemas/npmConfigToObject.js +0 -32
- package/packages/client_build_tool/lib/shared/schemas/oldDefaultConfigValues.js +0 -480
- package/packages/client_build_tool/lib/shared/schemas/readOptions.js +0 -55
- package/packages/client_build_tool/lib/shared/schemas/readOptionsForPackageJson.js +0 -26
- package/packages/client_build_tool/lib/shared/schemas/readOptionsOld.js +0 -152
- package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.crt +0 -37
- package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.key +0 -27
- package/packages/client_build_tool/lib/shared/server/configWebpackDevMiddleware.js +0 -40
- package/packages/client_build_tool/lib/shared/server/corsHandleing.js +0 -28
- package/packages/client_build_tool/lib/shared/server/getIp.js +0 -30
- package/packages/client_build_tool/lib/shared/server/getServerURL.js +0 -29
- package/packages/client_build_tool/lib/shared/server/httpsOptions.js +0 -53
- package/packages/client_build_tool/lib/shared/server/initExpressApp.js +0 -19
- package/packages/client_build_tool/lib/shared/server/initialHTMLHandling.js +0 -66
- package/packages/client_build_tool/lib/shared/server/serveContextFiles.js +0 -24
- package/packages/client_build_tool/lib/shared/server/serverBywebpackDevMiddleware.js +0 -40
- package/packages/client_build_tool/lib/shared/server/startHttpServer.js +0 -26
- package/packages/client_build_tool/lib/shared/server/startHttpsServer.js +0 -34
- package/packages/client_build_tool/lib/shared/server/unwanted/addHttp2Server.js +0 -41
- package/packages/client_build_tool/lib/shared/server/unwanted/configWebpackDevMiddleware.js +0 -44
- package/packages/client_build_tool/lib/shared/server/unwanted/devServerUtlis.js +0 -1
- package/packages/client_build_tool/lib/shared/server/unwanted/mockApiSupport.js +0 -19
- package/packages/client_build_tool/lib/shared/server/unwanted/webpackConfig.js +0 -32
- package/packages/client_build_tool/lib/shared/server/unwanted/websocketMockSetup.js +0 -48
- package/packages/client_build_tool/lib/shared/server/urlConcat.js +0 -25
- package/packages/client_build_tool/lib/shared/utils/utils.js +0 -1
- package/packages/client_build_tool/node_modules/history/CHANGES.md +0 -395
- package/packages/client_build_tool/node_modules/history/DOMUtils.js +0 -3
- package/packages/client_build_tool/node_modules/history/ExecutionEnvironment.js +0 -3
- package/packages/client_build_tool/node_modules/history/LICENSE +0 -21
- package/packages/client_build_tool/node_modules/history/LocationUtils.js +0 -3
- package/packages/client_build_tool/node_modules/history/PathUtils.js +0 -3
- package/packages/client_build_tool/node_modules/history/README.md +0 -282
- package/packages/client_build_tool/node_modules/history/cjs/history.js +0 -933
- package/packages/client_build_tool/node_modules/history/cjs/history.min.js +0 -1
- package/packages/client_build_tool/node_modules/history/createBrowserHistory.js +0 -3
- package/packages/client_build_tool/node_modules/history/createHashHistory.js +0 -3
- package/packages/client_build_tool/node_modules/history/createMemoryHistory.js +0 -3
- package/packages/client_build_tool/node_modules/history/createTransitionManager.js +0 -3
- package/packages/client_build_tool/node_modules/history/es/DOMUtils.js +0 -7
- package/packages/client_build_tool/node_modules/history/es/ExecutionEnvironment.js +0 -7
- package/packages/client_build_tool/node_modules/history/es/LocationUtils.js +0 -7
- package/packages/client_build_tool/node_modules/history/es/PathUtils.js +0 -7
- package/packages/client_build_tool/node_modules/history/es/createBrowserHistory.js +0 -7
- package/packages/client_build_tool/node_modules/history/es/createHashHistory.js +0 -7
- package/packages/client_build_tool/node_modules/history/es/createMemoryHistory.js +0 -7
- package/packages/client_build_tool/node_modules/history/es/createTransitionManager.js +0 -7
- package/packages/client_build_tool/node_modules/history/es/warnAboutDeprecatedESMImport.js +0 -35
- package/packages/client_build_tool/node_modules/history/esm/history.js +0 -904
- package/packages/client_build_tool/node_modules/history/index.js +0 -7
- package/packages/client_build_tool/node_modules/history/package.json +0 -117
- package/packages/client_build_tool/node_modules/history/umd/history.js +0 -1059
- package/packages/client_build_tool/node_modules/history/umd/history.min.js +0 -1
- package/packages/client_build_tool/node_modules/history/warnAboutDeprecatedCJSRequire.js +0 -35
@@ -1,1059 +0,0 @@
|
|
1
|
-
(function (global, factory) {
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
4
|
-
(factory((global.History = {})));
|
5
|
-
}(this, (function (exports) { 'use strict';
|
6
|
-
|
7
|
-
function _extends() {
|
8
|
-
_extends = Object.assign || function (target) {
|
9
|
-
for (var i = 1; i < arguments.length; i++) {
|
10
|
-
var source = arguments[i];
|
11
|
-
|
12
|
-
for (var key in source) {
|
13
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
14
|
-
target[key] = source[key];
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
return target;
|
20
|
-
};
|
21
|
-
|
22
|
-
return _extends.apply(this, arguments);
|
23
|
-
}
|
24
|
-
|
25
|
-
function warning(condition, message) {
|
26
|
-
{
|
27
|
-
if (condition) {
|
28
|
-
return;
|
29
|
-
}
|
30
|
-
|
31
|
-
console.warn(message);
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
var prefix = 'Invariant failed';
|
36
|
-
function invariant(condition, message) {
|
37
|
-
if (condition) {
|
38
|
-
return;
|
39
|
-
}
|
40
|
-
|
41
|
-
{
|
42
|
-
throw new Error(prefix + ": " + (message || ''));
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
function isAbsolute(pathname) {
|
47
|
-
return pathname.charAt(0) === '/';
|
48
|
-
}
|
49
|
-
|
50
|
-
// About 1.5x faster than the two-arg version of Array#splice()
|
51
|
-
function spliceOne(list, index) {
|
52
|
-
for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
|
53
|
-
list[i] = list[k];
|
54
|
-
}
|
55
|
-
|
56
|
-
list.pop();
|
57
|
-
}
|
58
|
-
|
59
|
-
// This implementation is based heavily on node's url.parse
|
60
|
-
function resolvePathname(to) {
|
61
|
-
var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
62
|
-
|
63
|
-
var toParts = to && to.split('/') || [];
|
64
|
-
var fromParts = from && from.split('/') || [];
|
65
|
-
|
66
|
-
var isToAbs = to && isAbsolute(to);
|
67
|
-
var isFromAbs = from && isAbsolute(from);
|
68
|
-
var mustEndAbs = isToAbs || isFromAbs;
|
69
|
-
|
70
|
-
if (to && isAbsolute(to)) {
|
71
|
-
// to is absolute
|
72
|
-
fromParts = toParts;
|
73
|
-
} else if (toParts.length) {
|
74
|
-
// to is relative, drop the filename
|
75
|
-
fromParts.pop();
|
76
|
-
fromParts = fromParts.concat(toParts);
|
77
|
-
}
|
78
|
-
|
79
|
-
if (!fromParts.length) return '/';
|
80
|
-
|
81
|
-
var hasTrailingSlash = void 0;
|
82
|
-
if (fromParts.length) {
|
83
|
-
var last = fromParts[fromParts.length - 1];
|
84
|
-
hasTrailingSlash = last === '.' || last === '..' || last === '';
|
85
|
-
} else {
|
86
|
-
hasTrailingSlash = false;
|
87
|
-
}
|
88
|
-
|
89
|
-
var up = 0;
|
90
|
-
for (var i = fromParts.length; i >= 0; i--) {
|
91
|
-
var part = fromParts[i];
|
92
|
-
|
93
|
-
if (part === '.') {
|
94
|
-
spliceOne(fromParts, i);
|
95
|
-
} else if (part === '..') {
|
96
|
-
spliceOne(fromParts, i);
|
97
|
-
up++;
|
98
|
-
} else if (up) {
|
99
|
-
spliceOne(fromParts, i);
|
100
|
-
up--;
|
101
|
-
}
|
102
|
-
}
|
103
|
-
|
104
|
-
if (!mustEndAbs) for (; up--; up) {
|
105
|
-
fromParts.unshift('..');
|
106
|
-
}if (mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute(fromParts[0]))) fromParts.unshift('');
|
107
|
-
|
108
|
-
var result = fromParts.join('/');
|
109
|
-
|
110
|
-
if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
|
111
|
-
|
112
|
-
return result;
|
113
|
-
}
|
114
|
-
|
115
|
-
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; };
|
116
|
-
|
117
|
-
function valueEqual(a, b) {
|
118
|
-
if (a === b) return true;
|
119
|
-
|
120
|
-
if (a == null || b == null) return false;
|
121
|
-
|
122
|
-
if (Array.isArray(a)) {
|
123
|
-
return Array.isArray(b) && a.length === b.length && a.every(function (item, index) {
|
124
|
-
return valueEqual(item, b[index]);
|
125
|
-
});
|
126
|
-
}
|
127
|
-
|
128
|
-
var aType = typeof a === 'undefined' ? 'undefined' : _typeof(a);
|
129
|
-
var bType = typeof b === 'undefined' ? 'undefined' : _typeof(b);
|
130
|
-
|
131
|
-
if (aType !== bType) return false;
|
132
|
-
|
133
|
-
if (aType === 'object') {
|
134
|
-
var aValue = a.valueOf();
|
135
|
-
var bValue = b.valueOf();
|
136
|
-
|
137
|
-
if (aValue !== a || bValue !== b) return valueEqual(aValue, bValue);
|
138
|
-
|
139
|
-
var aKeys = Object.keys(a);
|
140
|
-
var bKeys = Object.keys(b);
|
141
|
-
|
142
|
-
if (aKeys.length !== bKeys.length) return false;
|
143
|
-
|
144
|
-
return aKeys.every(function (key) {
|
145
|
-
return valueEqual(a[key], b[key]);
|
146
|
-
});
|
147
|
-
}
|
148
|
-
|
149
|
-
return false;
|
150
|
-
}
|
151
|
-
|
152
|
-
function addLeadingSlash(path) {
|
153
|
-
return path.charAt(0) === '/' ? path : '/' + path;
|
154
|
-
}
|
155
|
-
function stripLeadingSlash(path) {
|
156
|
-
return path.charAt(0) === '/' ? path.substr(1) : path;
|
157
|
-
}
|
158
|
-
function hasBasename(path, prefix) {
|
159
|
-
return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
|
160
|
-
}
|
161
|
-
function stripBasename(path, prefix) {
|
162
|
-
return hasBasename(path, prefix) ? path.substr(prefix.length) : path;
|
163
|
-
}
|
164
|
-
function stripTrailingSlash(path) {
|
165
|
-
return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
|
166
|
-
}
|
167
|
-
function parsePath(path) {
|
168
|
-
var pathname = path || '/';
|
169
|
-
var search = '';
|
170
|
-
var hash = '';
|
171
|
-
var hashIndex = pathname.indexOf('#');
|
172
|
-
|
173
|
-
if (hashIndex !== -1) {
|
174
|
-
hash = pathname.substr(hashIndex);
|
175
|
-
pathname = pathname.substr(0, hashIndex);
|
176
|
-
}
|
177
|
-
|
178
|
-
var searchIndex = pathname.indexOf('?');
|
179
|
-
|
180
|
-
if (searchIndex !== -1) {
|
181
|
-
search = pathname.substr(searchIndex);
|
182
|
-
pathname = pathname.substr(0, searchIndex);
|
183
|
-
}
|
184
|
-
|
185
|
-
return {
|
186
|
-
pathname: pathname,
|
187
|
-
search: search === '?' ? '' : search,
|
188
|
-
hash: hash === '#' ? '' : hash
|
189
|
-
};
|
190
|
-
}
|
191
|
-
function createPath(location) {
|
192
|
-
var pathname = location.pathname,
|
193
|
-
search = location.search,
|
194
|
-
hash = location.hash;
|
195
|
-
var path = pathname || '/';
|
196
|
-
if (search && search !== '?') path += search.charAt(0) === '?' ? search : "?" + search;
|
197
|
-
if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : "#" + hash;
|
198
|
-
return path;
|
199
|
-
}
|
200
|
-
|
201
|
-
function createLocation(path, state, key, currentLocation) {
|
202
|
-
var location;
|
203
|
-
|
204
|
-
if (typeof path === 'string') {
|
205
|
-
// Two-arg form: push(path, state)
|
206
|
-
location = parsePath(path);
|
207
|
-
location.state = state;
|
208
|
-
} else {
|
209
|
-
// One-arg form: push(location)
|
210
|
-
location = _extends({}, path);
|
211
|
-
if (location.pathname === undefined) location.pathname = '';
|
212
|
-
|
213
|
-
if (location.search) {
|
214
|
-
if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
|
215
|
-
} else {
|
216
|
-
location.search = '';
|
217
|
-
}
|
218
|
-
|
219
|
-
if (location.hash) {
|
220
|
-
if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
|
221
|
-
} else {
|
222
|
-
location.hash = '';
|
223
|
-
}
|
224
|
-
|
225
|
-
if (state !== undefined && location.state === undefined) location.state = state;
|
226
|
-
}
|
227
|
-
|
228
|
-
try {
|
229
|
-
location.pathname = decodeURI(location.pathname);
|
230
|
-
} catch (e) {
|
231
|
-
if (e instanceof URIError) {
|
232
|
-
throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
|
233
|
-
} else {
|
234
|
-
throw e;
|
235
|
-
}
|
236
|
-
}
|
237
|
-
|
238
|
-
if (key) location.key = key;
|
239
|
-
|
240
|
-
if (currentLocation) {
|
241
|
-
// Resolve incomplete/relative pathname relative to current location.
|
242
|
-
if (!location.pathname) {
|
243
|
-
location.pathname = currentLocation.pathname;
|
244
|
-
} else if (location.pathname.charAt(0) !== '/') {
|
245
|
-
location.pathname = resolvePathname(location.pathname, currentLocation.pathname);
|
246
|
-
}
|
247
|
-
} else {
|
248
|
-
// When there is no prior location and pathname is empty, set it to /
|
249
|
-
if (!location.pathname) {
|
250
|
-
location.pathname = '/';
|
251
|
-
}
|
252
|
-
}
|
253
|
-
|
254
|
-
return location;
|
255
|
-
}
|
256
|
-
function locationsAreEqual(a, b) {
|
257
|
-
return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && valueEqual(a.state, b.state);
|
258
|
-
}
|
259
|
-
|
260
|
-
function createTransitionManager() {
|
261
|
-
var prompt = null;
|
262
|
-
|
263
|
-
function setPrompt(nextPrompt) {
|
264
|
-
warning(prompt == null, 'A history supports only one prompt at a time');
|
265
|
-
prompt = nextPrompt;
|
266
|
-
return function () {
|
267
|
-
if (prompt === nextPrompt) prompt = null;
|
268
|
-
};
|
269
|
-
}
|
270
|
-
|
271
|
-
function confirmTransitionTo(location, action, getUserConfirmation, callback) {
|
272
|
-
// TODO: If another transition starts while we're still confirming
|
273
|
-
// the previous one, we may end up in a weird state. Figure out the
|
274
|
-
// best way to handle this.
|
275
|
-
if (prompt != null) {
|
276
|
-
var result = typeof prompt === 'function' ? prompt(location, action) : prompt;
|
277
|
-
|
278
|
-
if (typeof result === 'string') {
|
279
|
-
if (typeof getUserConfirmation === 'function') {
|
280
|
-
getUserConfirmation(result, callback);
|
281
|
-
} else {
|
282
|
-
warning(false, 'A history needs a getUserConfirmation function in order to use a prompt message');
|
283
|
-
callback(true);
|
284
|
-
}
|
285
|
-
} else {
|
286
|
-
// Return false from a transition hook to cancel the transition.
|
287
|
-
callback(result !== false);
|
288
|
-
}
|
289
|
-
} else {
|
290
|
-
callback(true);
|
291
|
-
}
|
292
|
-
}
|
293
|
-
|
294
|
-
var listeners = [];
|
295
|
-
|
296
|
-
function appendListener(fn) {
|
297
|
-
var isActive = true;
|
298
|
-
|
299
|
-
function listener() {
|
300
|
-
if (isActive) fn.apply(void 0, arguments);
|
301
|
-
}
|
302
|
-
|
303
|
-
listeners.push(listener);
|
304
|
-
return function () {
|
305
|
-
isActive = false;
|
306
|
-
listeners = listeners.filter(function (item) {
|
307
|
-
return item !== listener;
|
308
|
-
});
|
309
|
-
};
|
310
|
-
}
|
311
|
-
|
312
|
-
function notifyListeners() {
|
313
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
314
|
-
args[_key] = arguments[_key];
|
315
|
-
}
|
316
|
-
|
317
|
-
listeners.forEach(function (listener) {
|
318
|
-
return listener.apply(void 0, args);
|
319
|
-
});
|
320
|
-
}
|
321
|
-
|
322
|
-
return {
|
323
|
-
setPrompt: setPrompt,
|
324
|
-
confirmTransitionTo: confirmTransitionTo,
|
325
|
-
appendListener: appendListener,
|
326
|
-
notifyListeners: notifyListeners
|
327
|
-
};
|
328
|
-
}
|
329
|
-
|
330
|
-
var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
331
|
-
function getConfirmation(message, callback) {
|
332
|
-
callback(window.confirm(message)); // eslint-disable-line no-alert
|
333
|
-
}
|
334
|
-
/**
|
335
|
-
* Returns true if the HTML5 history API is supported. Taken from Modernizr.
|
336
|
-
*
|
337
|
-
* https://github.com/Modernizr/Modernizr/blob/master/LICENSE
|
338
|
-
* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
|
339
|
-
* changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586
|
340
|
-
*/
|
341
|
-
|
342
|
-
function supportsHistory() {
|
343
|
-
var ua = window.navigator.userAgent;
|
344
|
-
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;
|
345
|
-
return window.history && 'pushState' in window.history;
|
346
|
-
}
|
347
|
-
/**
|
348
|
-
* Returns true if browser fires popstate on hash change.
|
349
|
-
* IE10 and IE11 do not.
|
350
|
-
*/
|
351
|
-
|
352
|
-
function supportsPopStateOnHashChange() {
|
353
|
-
return window.navigator.userAgent.indexOf('Trident') === -1;
|
354
|
-
}
|
355
|
-
/**
|
356
|
-
* Returns false if using go(n) with hash history causes a full page reload.
|
357
|
-
*/
|
358
|
-
|
359
|
-
function supportsGoWithoutReloadUsingHash() {
|
360
|
-
return window.navigator.userAgent.indexOf('Firefox') === -1;
|
361
|
-
}
|
362
|
-
/**
|
363
|
-
* Returns true if a given popstate event is an extraneous WebKit event.
|
364
|
-
* Accounts for the fact that Chrome on iOS fires real popstate events
|
365
|
-
* containing undefined state when pressing the back button.
|
366
|
-
*/
|
367
|
-
|
368
|
-
function isExtraneousPopstateEvent(event) {
|
369
|
-
event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1;
|
370
|
-
}
|
371
|
-
|
372
|
-
var PopStateEvent = 'popstate';
|
373
|
-
var HashChangeEvent = 'hashchange';
|
374
|
-
|
375
|
-
function getHistoryState() {
|
376
|
-
try {
|
377
|
-
return window.history.state || {};
|
378
|
-
} catch (e) {
|
379
|
-
// IE 11 sometimes throws when accessing window.history.state
|
380
|
-
// See https://github.com/ReactTraining/history/pull/289
|
381
|
-
return {};
|
382
|
-
}
|
383
|
-
}
|
384
|
-
/**
|
385
|
-
* Creates a history object that uses the HTML5 history API including
|
386
|
-
* pushState, replaceState, and the popstate event.
|
387
|
-
*/
|
388
|
-
|
389
|
-
|
390
|
-
function createBrowserHistory(props) {
|
391
|
-
if (props === void 0) {
|
392
|
-
props = {};
|
393
|
-
}
|
394
|
-
|
395
|
-
!canUseDOM ? invariant(false, 'Browser history needs a DOM') : void 0;
|
396
|
-
var globalHistory = window.history;
|
397
|
-
var canUseHistory = supportsHistory();
|
398
|
-
var needsHashChangeListener = !supportsPopStateOnHashChange();
|
399
|
-
var _props = props,
|
400
|
-
_props$forceRefresh = _props.forceRefresh,
|
401
|
-
forceRefresh = _props$forceRefresh === void 0 ? false : _props$forceRefresh,
|
402
|
-
_props$getUserConfirm = _props.getUserConfirmation,
|
403
|
-
getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,
|
404
|
-
_props$keyLength = _props.keyLength,
|
405
|
-
keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
|
406
|
-
var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
|
407
|
-
|
408
|
-
function getDOMLocation(historyState) {
|
409
|
-
var _ref = historyState || {},
|
410
|
-
key = _ref.key,
|
411
|
-
state = _ref.state;
|
412
|
-
|
413
|
-
var _window$location = window.location,
|
414
|
-
pathname = _window$location.pathname,
|
415
|
-
search = _window$location.search,
|
416
|
-
hash = _window$location.hash;
|
417
|
-
var path = pathname + search + hash;
|
418
|
-
warning(!basename || 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 + '".');
|
419
|
-
if (basename) path = stripBasename(path, basename);
|
420
|
-
return createLocation(path, state, key);
|
421
|
-
}
|
422
|
-
|
423
|
-
function createKey() {
|
424
|
-
return Math.random().toString(36).substr(2, keyLength);
|
425
|
-
}
|
426
|
-
|
427
|
-
var transitionManager = createTransitionManager();
|
428
|
-
|
429
|
-
function setState(nextState) {
|
430
|
-
_extends(history, nextState);
|
431
|
-
|
432
|
-
history.length = globalHistory.length;
|
433
|
-
transitionManager.notifyListeners(history.location, history.action);
|
434
|
-
}
|
435
|
-
|
436
|
-
function handlePopState(event) {
|
437
|
-
// Ignore extraneous popstate events in WebKit.
|
438
|
-
if (isExtraneousPopstateEvent(event)) return;
|
439
|
-
handlePop(getDOMLocation(event.state));
|
440
|
-
}
|
441
|
-
|
442
|
-
function handleHashChange() {
|
443
|
-
handlePop(getDOMLocation(getHistoryState()));
|
444
|
-
}
|
445
|
-
|
446
|
-
var forceNextPop = false;
|
447
|
-
|
448
|
-
function handlePop(location) {
|
449
|
-
if (forceNextPop) {
|
450
|
-
forceNextPop = false;
|
451
|
-
setState();
|
452
|
-
} else {
|
453
|
-
var action = 'POP';
|
454
|
-
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
455
|
-
if (ok) {
|
456
|
-
setState({
|
457
|
-
action: action,
|
458
|
-
location: location
|
459
|
-
});
|
460
|
-
} else {
|
461
|
-
revertPop(location);
|
462
|
-
}
|
463
|
-
});
|
464
|
-
}
|
465
|
-
}
|
466
|
-
|
467
|
-
function revertPop(fromLocation) {
|
468
|
-
var toLocation = history.location; // TODO: We could probably make this more reliable by
|
469
|
-
// keeping a list of keys we've seen in sessionStorage.
|
470
|
-
// Instead, we just default to 0 for keys we don't know.
|
471
|
-
|
472
|
-
var toIndex = allKeys.indexOf(toLocation.key);
|
473
|
-
if (toIndex === -1) toIndex = 0;
|
474
|
-
var fromIndex = allKeys.indexOf(fromLocation.key);
|
475
|
-
if (fromIndex === -1) fromIndex = 0;
|
476
|
-
var delta = toIndex - fromIndex;
|
477
|
-
|
478
|
-
if (delta) {
|
479
|
-
forceNextPop = true;
|
480
|
-
go(delta);
|
481
|
-
}
|
482
|
-
}
|
483
|
-
|
484
|
-
var initialLocation = getDOMLocation(getHistoryState());
|
485
|
-
var allKeys = [initialLocation.key]; // Public interface
|
486
|
-
|
487
|
-
function createHref(location) {
|
488
|
-
return basename + createPath(location);
|
489
|
-
}
|
490
|
-
|
491
|
-
function push(path, state) {
|
492
|
-
warning(!(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');
|
493
|
-
var action = 'PUSH';
|
494
|
-
var location = createLocation(path, state, createKey(), history.location);
|
495
|
-
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
496
|
-
if (!ok) return;
|
497
|
-
var href = createHref(location);
|
498
|
-
var key = location.key,
|
499
|
-
state = location.state;
|
500
|
-
|
501
|
-
if (canUseHistory) {
|
502
|
-
globalHistory.pushState({
|
503
|
-
key: key,
|
504
|
-
state: state
|
505
|
-
}, null, href);
|
506
|
-
|
507
|
-
if (forceRefresh) {
|
508
|
-
window.location.href = href;
|
509
|
-
} else {
|
510
|
-
var prevIndex = allKeys.indexOf(history.location.key);
|
511
|
-
var nextKeys = allKeys.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);
|
512
|
-
nextKeys.push(location.key);
|
513
|
-
allKeys = nextKeys;
|
514
|
-
setState({
|
515
|
-
action: action,
|
516
|
-
location: location
|
517
|
-
});
|
518
|
-
}
|
519
|
-
} else {
|
520
|
-
warning(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history');
|
521
|
-
window.location.href = href;
|
522
|
-
}
|
523
|
-
});
|
524
|
-
}
|
525
|
-
|
526
|
-
function replace(path, state) {
|
527
|
-
warning(!(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');
|
528
|
-
var action = 'REPLACE';
|
529
|
-
var location = createLocation(path, state, createKey(), history.location);
|
530
|
-
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
531
|
-
if (!ok) return;
|
532
|
-
var href = createHref(location);
|
533
|
-
var key = location.key,
|
534
|
-
state = location.state;
|
535
|
-
|
536
|
-
if (canUseHistory) {
|
537
|
-
globalHistory.replaceState({
|
538
|
-
key: key,
|
539
|
-
state: state
|
540
|
-
}, null, href);
|
541
|
-
|
542
|
-
if (forceRefresh) {
|
543
|
-
window.location.replace(href);
|
544
|
-
} else {
|
545
|
-
var prevIndex = allKeys.indexOf(history.location.key);
|
546
|
-
if (prevIndex !== -1) allKeys[prevIndex] = location.key;
|
547
|
-
setState({
|
548
|
-
action: action,
|
549
|
-
location: location
|
550
|
-
});
|
551
|
-
}
|
552
|
-
} else {
|
553
|
-
warning(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history');
|
554
|
-
window.location.replace(href);
|
555
|
-
}
|
556
|
-
});
|
557
|
-
}
|
558
|
-
|
559
|
-
function go(n) {
|
560
|
-
globalHistory.go(n);
|
561
|
-
}
|
562
|
-
|
563
|
-
function goBack() {
|
564
|
-
go(-1);
|
565
|
-
}
|
566
|
-
|
567
|
-
function goForward() {
|
568
|
-
go(1);
|
569
|
-
}
|
570
|
-
|
571
|
-
var listenerCount = 0;
|
572
|
-
|
573
|
-
function checkDOMListeners(delta) {
|
574
|
-
listenerCount += delta;
|
575
|
-
|
576
|
-
if (listenerCount === 1 && delta === 1) {
|
577
|
-
window.addEventListener(PopStateEvent, handlePopState);
|
578
|
-
if (needsHashChangeListener) window.addEventListener(HashChangeEvent, handleHashChange);
|
579
|
-
} else if (listenerCount === 0) {
|
580
|
-
window.removeEventListener(PopStateEvent, handlePopState);
|
581
|
-
if (needsHashChangeListener) window.removeEventListener(HashChangeEvent, handleHashChange);
|
582
|
-
}
|
583
|
-
}
|
584
|
-
|
585
|
-
var isBlocked = false;
|
586
|
-
|
587
|
-
function block(prompt) {
|
588
|
-
if (prompt === void 0) {
|
589
|
-
prompt = false;
|
590
|
-
}
|
591
|
-
|
592
|
-
var unblock = transitionManager.setPrompt(prompt);
|
593
|
-
|
594
|
-
if (!isBlocked) {
|
595
|
-
checkDOMListeners(1);
|
596
|
-
isBlocked = true;
|
597
|
-
}
|
598
|
-
|
599
|
-
return function () {
|
600
|
-
if (isBlocked) {
|
601
|
-
isBlocked = false;
|
602
|
-
checkDOMListeners(-1);
|
603
|
-
}
|
604
|
-
|
605
|
-
return unblock();
|
606
|
-
};
|
607
|
-
}
|
608
|
-
|
609
|
-
function listen(listener) {
|
610
|
-
var unlisten = transitionManager.appendListener(listener);
|
611
|
-
checkDOMListeners(1);
|
612
|
-
return function () {
|
613
|
-
checkDOMListeners(-1);
|
614
|
-
unlisten();
|
615
|
-
};
|
616
|
-
}
|
617
|
-
|
618
|
-
var history = {
|
619
|
-
length: globalHistory.length,
|
620
|
-
action: 'POP',
|
621
|
-
location: initialLocation,
|
622
|
-
createHref: createHref,
|
623
|
-
push: push,
|
624
|
-
replace: replace,
|
625
|
-
go: go,
|
626
|
-
goBack: goBack,
|
627
|
-
goForward: goForward,
|
628
|
-
block: block,
|
629
|
-
listen: listen
|
630
|
-
};
|
631
|
-
return history;
|
632
|
-
}
|
633
|
-
|
634
|
-
var HashChangeEvent$1 = 'hashchange';
|
635
|
-
var HashPathCoders = {
|
636
|
-
hashbang: {
|
637
|
-
encodePath: function encodePath(path) {
|
638
|
-
return path.charAt(0) === '!' ? path : '!/' + stripLeadingSlash(path);
|
639
|
-
},
|
640
|
-
decodePath: function decodePath(path) {
|
641
|
-
return path.charAt(0) === '!' ? path.substr(1) : path;
|
642
|
-
}
|
643
|
-
},
|
644
|
-
noslash: {
|
645
|
-
encodePath: stripLeadingSlash,
|
646
|
-
decodePath: addLeadingSlash
|
647
|
-
},
|
648
|
-
slash: {
|
649
|
-
encodePath: addLeadingSlash,
|
650
|
-
decodePath: addLeadingSlash
|
651
|
-
}
|
652
|
-
};
|
653
|
-
|
654
|
-
function getHashPath() {
|
655
|
-
// We can't use window.location.hash here because it's not
|
656
|
-
// consistent across browsers - Firefox will pre-decode it!
|
657
|
-
var href = window.location.href;
|
658
|
-
var hashIndex = href.indexOf('#');
|
659
|
-
return hashIndex === -1 ? '' : href.substring(hashIndex + 1);
|
660
|
-
}
|
661
|
-
|
662
|
-
function pushHashPath(path) {
|
663
|
-
window.location.hash = path;
|
664
|
-
}
|
665
|
-
|
666
|
-
function replaceHashPath(path) {
|
667
|
-
var hashIndex = window.location.href.indexOf('#');
|
668
|
-
window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + '#' + path);
|
669
|
-
}
|
670
|
-
|
671
|
-
function createHashHistory(props) {
|
672
|
-
if (props === void 0) {
|
673
|
-
props = {};
|
674
|
-
}
|
675
|
-
|
676
|
-
!canUseDOM ? invariant(false, 'Hash history needs a DOM') : void 0;
|
677
|
-
var globalHistory = window.history;
|
678
|
-
var canGoWithoutReload = supportsGoWithoutReloadUsingHash();
|
679
|
-
var _props = props,
|
680
|
-
_props$getUserConfirm = _props.getUserConfirmation,
|
681
|
-
getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,
|
682
|
-
_props$hashType = _props.hashType,
|
683
|
-
hashType = _props$hashType === void 0 ? 'slash' : _props$hashType;
|
684
|
-
var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
|
685
|
-
var _HashPathCoders$hashT = HashPathCoders[hashType],
|
686
|
-
encodePath = _HashPathCoders$hashT.encodePath,
|
687
|
-
decodePath = _HashPathCoders$hashT.decodePath;
|
688
|
-
|
689
|
-
function getDOMLocation() {
|
690
|
-
var path = decodePath(getHashPath());
|
691
|
-
warning(!basename || 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 + '".');
|
692
|
-
if (basename) path = stripBasename(path, basename);
|
693
|
-
return createLocation(path);
|
694
|
-
}
|
695
|
-
|
696
|
-
var transitionManager = createTransitionManager();
|
697
|
-
|
698
|
-
function setState(nextState) {
|
699
|
-
_extends(history, nextState);
|
700
|
-
|
701
|
-
history.length = globalHistory.length;
|
702
|
-
transitionManager.notifyListeners(history.location, history.action);
|
703
|
-
}
|
704
|
-
|
705
|
-
var forceNextPop = false;
|
706
|
-
var ignorePath = null;
|
707
|
-
|
708
|
-
function handleHashChange() {
|
709
|
-
var path = getHashPath();
|
710
|
-
var encodedPath = encodePath(path);
|
711
|
-
|
712
|
-
if (path !== encodedPath) {
|
713
|
-
// Ensure we always have a properly-encoded hash.
|
714
|
-
replaceHashPath(encodedPath);
|
715
|
-
} else {
|
716
|
-
var location = getDOMLocation();
|
717
|
-
var prevLocation = history.location;
|
718
|
-
if (!forceNextPop && locationsAreEqual(prevLocation, location)) return; // A hashchange doesn't always == location change.
|
719
|
-
|
720
|
-
if (ignorePath === createPath(location)) return; // Ignore this change; we already setState in push/replace.
|
721
|
-
|
722
|
-
ignorePath = null;
|
723
|
-
handlePop(location);
|
724
|
-
}
|
725
|
-
}
|
726
|
-
|
727
|
-
function handlePop(location) {
|
728
|
-
if (forceNextPop) {
|
729
|
-
forceNextPop = false;
|
730
|
-
setState();
|
731
|
-
} else {
|
732
|
-
var action = 'POP';
|
733
|
-
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
734
|
-
if (ok) {
|
735
|
-
setState({
|
736
|
-
action: action,
|
737
|
-
location: location
|
738
|
-
});
|
739
|
-
} else {
|
740
|
-
revertPop(location);
|
741
|
-
}
|
742
|
-
});
|
743
|
-
}
|
744
|
-
}
|
745
|
-
|
746
|
-
function revertPop(fromLocation) {
|
747
|
-
var toLocation = history.location; // TODO: We could probably make this more reliable by
|
748
|
-
// keeping a list of paths we've seen in sessionStorage.
|
749
|
-
// Instead, we just default to 0 for paths we don't know.
|
750
|
-
|
751
|
-
var toIndex = allPaths.lastIndexOf(createPath(toLocation));
|
752
|
-
if (toIndex === -1) toIndex = 0;
|
753
|
-
var fromIndex = allPaths.lastIndexOf(createPath(fromLocation));
|
754
|
-
if (fromIndex === -1) fromIndex = 0;
|
755
|
-
var delta = toIndex - fromIndex;
|
756
|
-
|
757
|
-
if (delta) {
|
758
|
-
forceNextPop = true;
|
759
|
-
go(delta);
|
760
|
-
}
|
761
|
-
} // Ensure the hash is encoded properly before doing anything else.
|
762
|
-
|
763
|
-
|
764
|
-
var path = getHashPath();
|
765
|
-
var encodedPath = encodePath(path);
|
766
|
-
if (path !== encodedPath) replaceHashPath(encodedPath);
|
767
|
-
var initialLocation = getDOMLocation();
|
768
|
-
var allPaths = [createPath(initialLocation)]; // Public interface
|
769
|
-
|
770
|
-
function createHref(location) {
|
771
|
-
return '#' + encodePath(basename + createPath(location));
|
772
|
-
}
|
773
|
-
|
774
|
-
function push(path, state) {
|
775
|
-
warning(state === undefined, 'Hash history cannot push state; it is ignored');
|
776
|
-
var action = 'PUSH';
|
777
|
-
var location = createLocation(path, undefined, undefined, history.location);
|
778
|
-
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
779
|
-
if (!ok) return;
|
780
|
-
var path = createPath(location);
|
781
|
-
var encodedPath = encodePath(basename + path);
|
782
|
-
var hashChanged = getHashPath() !== encodedPath;
|
783
|
-
|
784
|
-
if (hashChanged) {
|
785
|
-
// We cannot tell if a hashchange was caused by a PUSH, so we'd
|
786
|
-
// rather setState here and ignore the hashchange. The caveat here
|
787
|
-
// is that other hash histories in the page will consider it a POP.
|
788
|
-
ignorePath = path;
|
789
|
-
pushHashPath(encodedPath);
|
790
|
-
var prevIndex = allPaths.lastIndexOf(createPath(history.location));
|
791
|
-
var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);
|
792
|
-
nextPaths.push(path);
|
793
|
-
allPaths = nextPaths;
|
794
|
-
setState({
|
795
|
-
action: action,
|
796
|
-
location: location
|
797
|
-
});
|
798
|
-
} else {
|
799
|
-
warning(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack');
|
800
|
-
setState();
|
801
|
-
}
|
802
|
-
});
|
803
|
-
}
|
804
|
-
|
805
|
-
function replace(path, state) {
|
806
|
-
warning(state === undefined, 'Hash history cannot replace state; it is ignored');
|
807
|
-
var action = 'REPLACE';
|
808
|
-
var location = createLocation(path, undefined, undefined, history.location);
|
809
|
-
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
810
|
-
if (!ok) return;
|
811
|
-
var path = createPath(location);
|
812
|
-
var encodedPath = encodePath(basename + path);
|
813
|
-
var hashChanged = getHashPath() !== encodedPath;
|
814
|
-
|
815
|
-
if (hashChanged) {
|
816
|
-
// We cannot tell if a hashchange was caused by a REPLACE, so we'd
|
817
|
-
// rather setState here and ignore the hashchange. The caveat here
|
818
|
-
// is that other hash histories in the page will consider it a POP.
|
819
|
-
ignorePath = path;
|
820
|
-
replaceHashPath(encodedPath);
|
821
|
-
}
|
822
|
-
|
823
|
-
var prevIndex = allPaths.indexOf(createPath(history.location));
|
824
|
-
if (prevIndex !== -1) allPaths[prevIndex] = path;
|
825
|
-
setState({
|
826
|
-
action: action,
|
827
|
-
location: location
|
828
|
-
});
|
829
|
-
});
|
830
|
-
}
|
831
|
-
|
832
|
-
function go(n) {
|
833
|
-
warning(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser');
|
834
|
-
globalHistory.go(n);
|
835
|
-
}
|
836
|
-
|
837
|
-
function goBack() {
|
838
|
-
go(-1);
|
839
|
-
}
|
840
|
-
|
841
|
-
function goForward() {
|
842
|
-
go(1);
|
843
|
-
}
|
844
|
-
|
845
|
-
var listenerCount = 0;
|
846
|
-
|
847
|
-
function checkDOMListeners(delta) {
|
848
|
-
listenerCount += delta;
|
849
|
-
|
850
|
-
if (listenerCount === 1 && delta === 1) {
|
851
|
-
window.addEventListener(HashChangeEvent$1, handleHashChange);
|
852
|
-
} else if (listenerCount === 0) {
|
853
|
-
window.removeEventListener(HashChangeEvent$1, handleHashChange);
|
854
|
-
}
|
855
|
-
}
|
856
|
-
|
857
|
-
var isBlocked = false;
|
858
|
-
|
859
|
-
function block(prompt) {
|
860
|
-
if (prompt === void 0) {
|
861
|
-
prompt = false;
|
862
|
-
}
|
863
|
-
|
864
|
-
var unblock = transitionManager.setPrompt(prompt);
|
865
|
-
|
866
|
-
if (!isBlocked) {
|
867
|
-
checkDOMListeners(1);
|
868
|
-
isBlocked = true;
|
869
|
-
}
|
870
|
-
|
871
|
-
return function () {
|
872
|
-
if (isBlocked) {
|
873
|
-
isBlocked = false;
|
874
|
-
checkDOMListeners(-1);
|
875
|
-
}
|
876
|
-
|
877
|
-
return unblock();
|
878
|
-
};
|
879
|
-
}
|
880
|
-
|
881
|
-
function listen(listener) {
|
882
|
-
var unlisten = transitionManager.appendListener(listener);
|
883
|
-
checkDOMListeners(1);
|
884
|
-
return function () {
|
885
|
-
checkDOMListeners(-1);
|
886
|
-
unlisten();
|
887
|
-
};
|
888
|
-
}
|
889
|
-
|
890
|
-
var history = {
|
891
|
-
length: globalHistory.length,
|
892
|
-
action: 'POP',
|
893
|
-
location: initialLocation,
|
894
|
-
createHref: createHref,
|
895
|
-
push: push,
|
896
|
-
replace: replace,
|
897
|
-
go: go,
|
898
|
-
goBack: goBack,
|
899
|
-
goForward: goForward,
|
900
|
-
block: block,
|
901
|
-
listen: listen
|
902
|
-
};
|
903
|
-
return history;
|
904
|
-
}
|
905
|
-
|
906
|
-
function clamp(n, lowerBound, upperBound) {
|
907
|
-
return Math.min(Math.max(n, lowerBound), upperBound);
|
908
|
-
}
|
909
|
-
/**
|
910
|
-
* Creates a history object that stores locations in memory.
|
911
|
-
*/
|
912
|
-
|
913
|
-
|
914
|
-
function createMemoryHistory(props) {
|
915
|
-
if (props === void 0) {
|
916
|
-
props = {};
|
917
|
-
}
|
918
|
-
|
919
|
-
var _props = props,
|
920
|
-
getUserConfirmation = _props.getUserConfirmation,
|
921
|
-
_props$initialEntries = _props.initialEntries,
|
922
|
-
initialEntries = _props$initialEntries === void 0 ? ['/'] : _props$initialEntries,
|
923
|
-
_props$initialIndex = _props.initialIndex,
|
924
|
-
initialIndex = _props$initialIndex === void 0 ? 0 : _props$initialIndex,
|
925
|
-
_props$keyLength = _props.keyLength,
|
926
|
-
keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
|
927
|
-
var transitionManager = createTransitionManager();
|
928
|
-
|
929
|
-
function setState(nextState) {
|
930
|
-
_extends(history, nextState);
|
931
|
-
|
932
|
-
history.length = history.entries.length;
|
933
|
-
transitionManager.notifyListeners(history.location, history.action);
|
934
|
-
}
|
935
|
-
|
936
|
-
function createKey() {
|
937
|
-
return Math.random().toString(36).substr(2, keyLength);
|
938
|
-
}
|
939
|
-
|
940
|
-
var index = clamp(initialIndex, 0, initialEntries.length - 1);
|
941
|
-
var entries = initialEntries.map(function (entry) {
|
942
|
-
return typeof entry === 'string' ? createLocation(entry, undefined, createKey()) : createLocation(entry, undefined, entry.key || createKey());
|
943
|
-
}); // Public interface
|
944
|
-
|
945
|
-
var createHref = createPath;
|
946
|
-
|
947
|
-
function push(path, state) {
|
948
|
-
warning(!(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');
|
949
|
-
var action = 'PUSH';
|
950
|
-
var location = createLocation(path, state, createKey(), history.location);
|
951
|
-
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
952
|
-
if (!ok) return;
|
953
|
-
var prevIndex = history.index;
|
954
|
-
var nextIndex = prevIndex + 1;
|
955
|
-
var nextEntries = history.entries.slice(0);
|
956
|
-
|
957
|
-
if (nextEntries.length > nextIndex) {
|
958
|
-
nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location);
|
959
|
-
} else {
|
960
|
-
nextEntries.push(location);
|
961
|
-
}
|
962
|
-
|
963
|
-
setState({
|
964
|
-
action: action,
|
965
|
-
location: location,
|
966
|
-
index: nextIndex,
|
967
|
-
entries: nextEntries
|
968
|
-
});
|
969
|
-
});
|
970
|
-
}
|
971
|
-
|
972
|
-
function replace(path, state) {
|
973
|
-
warning(!(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');
|
974
|
-
var action = 'REPLACE';
|
975
|
-
var location = createLocation(path, state, createKey(), history.location);
|
976
|
-
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
977
|
-
if (!ok) return;
|
978
|
-
history.entries[history.index] = location;
|
979
|
-
setState({
|
980
|
-
action: action,
|
981
|
-
location: location
|
982
|
-
});
|
983
|
-
});
|
984
|
-
}
|
985
|
-
|
986
|
-
function go(n) {
|
987
|
-
var nextIndex = clamp(history.index + n, 0, history.entries.length - 1);
|
988
|
-
var action = 'POP';
|
989
|
-
var location = history.entries[nextIndex];
|
990
|
-
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
991
|
-
if (ok) {
|
992
|
-
setState({
|
993
|
-
action: action,
|
994
|
-
location: location,
|
995
|
-
index: nextIndex
|
996
|
-
});
|
997
|
-
} else {
|
998
|
-
// Mimic the behavior of DOM histories by
|
999
|
-
// causing a render after a cancelled POP.
|
1000
|
-
setState();
|
1001
|
-
}
|
1002
|
-
});
|
1003
|
-
}
|
1004
|
-
|
1005
|
-
function goBack() {
|
1006
|
-
go(-1);
|
1007
|
-
}
|
1008
|
-
|
1009
|
-
function goForward() {
|
1010
|
-
go(1);
|
1011
|
-
}
|
1012
|
-
|
1013
|
-
function canGo(n) {
|
1014
|
-
var nextIndex = history.index + n;
|
1015
|
-
return nextIndex >= 0 && nextIndex < history.entries.length;
|
1016
|
-
}
|
1017
|
-
|
1018
|
-
function block(prompt) {
|
1019
|
-
if (prompt === void 0) {
|
1020
|
-
prompt = false;
|
1021
|
-
}
|
1022
|
-
|
1023
|
-
return transitionManager.setPrompt(prompt);
|
1024
|
-
}
|
1025
|
-
|
1026
|
-
function listen(listener) {
|
1027
|
-
return transitionManager.appendListener(listener);
|
1028
|
-
}
|
1029
|
-
|
1030
|
-
var history = {
|
1031
|
-
length: entries.length,
|
1032
|
-
action: 'POP',
|
1033
|
-
location: entries[index],
|
1034
|
-
index: index,
|
1035
|
-
entries: entries,
|
1036
|
-
createHref: createHref,
|
1037
|
-
push: push,
|
1038
|
-
replace: replace,
|
1039
|
-
go: go,
|
1040
|
-
goBack: goBack,
|
1041
|
-
goForward: goForward,
|
1042
|
-
canGo: canGo,
|
1043
|
-
block: block,
|
1044
|
-
listen: listen
|
1045
|
-
};
|
1046
|
-
return history;
|
1047
|
-
}
|
1048
|
-
|
1049
|
-
exports.createBrowserHistory = createBrowserHistory;
|
1050
|
-
exports.createHashHistory = createHashHistory;
|
1051
|
-
exports.createMemoryHistory = createMemoryHistory;
|
1052
|
-
exports.createLocation = createLocation;
|
1053
|
-
exports.locationsAreEqual = locationsAreEqual;
|
1054
|
-
exports.parsePath = parsePath;
|
1055
|
-
exports.createPath = createPath;
|
1056
|
-
|
1057
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
1058
|
-
|
1059
|
-
})));
|