@zohodesk/react-cli 1.1.18 → 1.1.19-exp.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. package/README.md +6 -0
  2. package/lib/babel/babel-option-utils/babel-preset-react-option.js +22 -0
  3. package/lib/babel/cmjs-plugins-presets.js +7 -1
  4. package/lib/babel/es-plugins-presets.js +7 -1
  5. package/lib/configs/webpack.prod.config.js +9 -2
  6. package/lib/loaderUtils/getDevJsLoaders.js +7 -2
  7. package/lib/loaders/workerLoader.js +39 -24
  8. package/lib/pluginUtils/configHtmlWebpackPlugins.js +9 -2
  9. package/lib/pluginUtils/getDevPlugins.js +4 -2
  10. package/lib/pluginUtils/getProdPlugins.js +3 -1
  11. package/lib/schemas/index.js +2 -1
  12. package/npm-shrinkwrap.json +19077 -15
  13. package/package.json +1 -1
  14. package/packages/client_build_tool/lib/allCommandsConfigs.js +23 -0
  15. package/packages/client_build_tool/lib/buildToolLoggers.js +32 -0
  16. package/packages/client_build_tool/lib/commands/build/commandExecutor.js +21 -0
  17. package/packages/client_build_tool/lib/commands/build/config.js +12 -0
  18. package/packages/client_build_tool/lib/commands/build/errorHander.js +10 -0
  19. package/packages/client_build_tool/lib/commands/build/index.js +35 -0
  20. package/packages/client_build_tool/lib/commands/build/optionsProcesser.js +40 -0
  21. package/packages/client_build_tool/lib/commands/buildEs/commandExecutor.js +17 -0
  22. package/packages/client_build_tool/lib/commands/buildEs/config.js +12 -0
  23. package/packages/client_build_tool/lib/commands/buildLib/commandExecutor.js +17 -0
  24. package/packages/client_build_tool/lib/commands/buildLib/config.js +12 -0
  25. package/packages/client_build_tool/lib/commands/start/commandExecutor.js +13 -0
  26. package/packages/client_build_tool/lib/commands/start/config.js +12 -0
  27. package/packages/client_build_tool/lib/commands/start/deprecationHandler.js +10 -0
  28. package/packages/client_build_tool/lib/commands/start/errorHander.js +10 -0
  29. package/packages/client_build_tool/lib/commands/start/optionsProcesser.js +36 -0
  30. package/packages/client_build_tool/lib/commands/start/postProcesser.js +10 -0
  31. package/packages/client_build_tool/lib/commands/start/preProcesser.js +10 -0
  32. package/packages/client_build_tool/lib/commandsRouter.js +71 -0
  33. package/packages/client_build_tool/lib/shared/bundler/webpack/common/decidePublicPath.js +44 -0
  34. package/packages/client_build_tool/lib/shared/bundler/webpack/common/libAlias.js +31 -0
  35. package/packages/client_build_tool/lib/shared/bundler/webpack/common/nameTemplates.js +51 -0
  36. package/packages/client_build_tool/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +21 -0
  37. package/packages/client_build_tool/lib/shared/bundler/webpack/cssLoaders.js +16 -0
  38. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin.js +111 -0
  39. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/EFCPlugin.js +1 -0
  40. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +11 -0
  41. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +136 -0
  42. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +95 -0
  43. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +25 -0
  44. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +29 -0
  45. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +24 -0
  46. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nDependency.js +99 -0
  47. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +81 -0
  48. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nModule.js +201 -0
  49. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +401 -0
  50. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +67 -0
  51. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +23 -0
  52. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +29 -0
  53. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +49 -0
  54. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +77 -0
  55. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +63 -0
  56. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +19 -0
  57. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +31 -0
  58. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +127 -0
  59. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +1 -0
  60. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +63 -0
  61. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +89 -0
  62. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +34 -0
  63. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +15 -0
  64. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +155 -0
  65. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin.js +49 -0
  66. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/ExcludePlugin.js +58 -0
  67. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/RTLSplitPlugin.js +139 -0
  68. package/packages/client_build_tool/lib/shared/bundler/webpack/devServerConfig.js +34 -0
  69. package/packages/client_build_tool/lib/shared/bundler/webpack/getCSSLoaders.js +30 -0
  70. package/packages/client_build_tool/lib/shared/bundler/webpack/jsLoaders.js +17 -0
  71. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +14 -0
  72. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +24 -0
  73. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +18 -0
  74. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +21 -0
  75. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +138 -0
  76. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +83 -0
  77. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +23 -0
  78. package/packages/client_build_tool/lib/shared/bundler/webpack/loaders/workerLoader.js +133 -0
  79. package/packages/client_build_tool/lib/shared/bundler/webpack/optimizationConfig.js +39 -0
  80. package/packages/client_build_tool/lib/shared/bundler/webpack/outputConfig.js +28 -0
  81. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +18 -0
  82. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCopyThirdpartyFile.js +38 -0
  83. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +24 -0
  84. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +28 -0
  85. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +35 -0
  86. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +16 -0
  87. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +23 -0
  88. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +19 -0
  89. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +27 -0
  90. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +18 -0
  91. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configUglifyCSSPlugin.js +15 -0
  92. package/packages/client_build_tool/lib/shared/bundler/webpack/plugins.js +39 -0
  93. package/packages/client_build_tool/lib/shared/bundler/webpack/postcssPlugins.js +36 -0
  94. package/packages/client_build_tool/lib/shared/bundler/webpack/resolvers.js +42 -0
  95. package/packages/client_build_tool/lib/shared/bundler/webpack/splitChunksConfig.js +12 -0
  96. package/packages/client_build_tool/lib/shared/bundler/webpack/webpack.dev.config.js +17 -0
  97. package/packages/client_build_tool/lib/shared/bundler/webpack/webpackBuild.js +24 -0
  98. package/packages/client_build_tool/lib/shared/bundler/webpack/webpackConfig.js +50 -0
  99. package/packages/client_build_tool/lib/shared/commands-utlis/doBasicRequiermentCheck.js +16 -0
  100. package/packages/client_build_tool/lib/shared/commands-utlis/getCliPath.js +38 -0
  101. package/packages/client_build_tool/lib/shared/commands-utlis/index.js +29 -0
  102. package/packages/client_build_tool/lib/shared/commands-utlis/log.js +13 -0
  103. package/packages/client_build_tool/lib/shared/commands-utlis/readArgsFormCommandLine.js +11 -0
  104. package/packages/client_build_tool/lib/shared/commands-utlis/readOptionFormCommandLine.js +11 -0
  105. package/packages/client_build_tool/lib/shared/commands-utlis/spanSync.js +35 -0
  106. package/packages/client_build_tool/lib/shared/constants.js +33 -0
  107. package/packages/client_build_tool/lib/shared/schemas/applyValuesToShema.js +37 -0
  108. package/packages/client_build_tool/lib/shared/schemas/cliArgsToObject.js +37 -0
  109. package/packages/client_build_tool/lib/shared/schemas/defaultConfigValues.js +119 -0
  110. package/packages/client_build_tool/lib/shared/schemas/deprecatedOptionsHandler.js +65 -0
  111. package/packages/client_build_tool/lib/shared/schemas/getCWD.js +23 -0
  112. package/packages/client_build_tool/lib/shared/schemas/getNpmVersion.js +21 -0
  113. package/packages/client_build_tool/lib/shared/schemas/npmConfigToObject.js +32 -0
  114. package/packages/client_build_tool/lib/shared/schemas/oldDefaultConfigValues.js +480 -0
  115. package/packages/client_build_tool/lib/shared/schemas/readOptions.js +55 -0
  116. package/packages/client_build_tool/lib/shared/schemas/readOptionsForPackageJson.js +26 -0
  117. package/packages/client_build_tool/lib/shared/schemas/readOptionsOld.js +152 -0
  118. package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.crt +37 -0
  119. package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.key +27 -0
  120. package/packages/client_build_tool/lib/shared/server/configWebpackDevMiddleware.js +40 -0
  121. package/packages/client_build_tool/lib/shared/server/corsHandleing.js +28 -0
  122. package/packages/client_build_tool/lib/shared/server/getIp.js +30 -0
  123. package/packages/client_build_tool/lib/shared/server/getServerURL.js +29 -0
  124. package/packages/client_build_tool/lib/shared/server/httpsOptions.js +53 -0
  125. package/packages/client_build_tool/lib/shared/server/initExpressApp.js +19 -0
  126. package/packages/client_build_tool/lib/shared/server/initialHTMLHandling.js +66 -0
  127. package/packages/client_build_tool/lib/shared/server/serveContextFiles.js +24 -0
  128. package/packages/client_build_tool/lib/shared/server/serverBywebpackDevMiddleware.js +40 -0
  129. package/packages/client_build_tool/lib/shared/server/startHttpServer.js +26 -0
  130. package/packages/client_build_tool/lib/shared/server/startHttpsServer.js +34 -0
  131. package/packages/client_build_tool/lib/shared/server/unwanted/addHttp2Server.js +41 -0
  132. package/packages/client_build_tool/lib/shared/server/unwanted/configWebpackDevMiddleware.js +44 -0
  133. package/packages/client_build_tool/lib/shared/server/unwanted/devServerUtlis.js +1 -0
  134. package/packages/client_build_tool/lib/shared/server/unwanted/mockApiSupport.js +19 -0
  135. package/packages/client_build_tool/lib/shared/server/unwanted/webpackConfig.js +32 -0
  136. package/packages/client_build_tool/lib/shared/server/unwanted/websocketMockSetup.js +48 -0
  137. package/packages/client_build_tool/lib/shared/server/urlConcat.js +25 -0
  138. package/packages/client_build_tool/lib/shared/utils/utils.js +1 -0
  139. package/packages/client_build_tool/node_modules/history/CHANGES.md +395 -0
  140. package/packages/client_build_tool/node_modules/history/DOMUtils.js +3 -0
  141. package/packages/client_build_tool/node_modules/history/ExecutionEnvironment.js +3 -0
  142. package/packages/client_build_tool/node_modules/history/LICENSE +21 -0
  143. package/packages/client_build_tool/node_modules/history/LocationUtils.js +3 -0
  144. package/packages/client_build_tool/node_modules/history/PathUtils.js +3 -0
  145. package/packages/client_build_tool/node_modules/history/README.md +282 -0
  146. package/packages/client_build_tool/node_modules/history/cjs/history.js +933 -0
  147. package/packages/client_build_tool/node_modules/history/cjs/history.min.js +1 -0
  148. package/packages/client_build_tool/node_modules/history/createBrowserHistory.js +3 -0
  149. package/packages/client_build_tool/node_modules/history/createHashHistory.js +3 -0
  150. package/packages/client_build_tool/node_modules/history/createMemoryHistory.js +3 -0
  151. package/packages/client_build_tool/node_modules/history/createTransitionManager.js +3 -0
  152. package/packages/client_build_tool/node_modules/history/es/DOMUtils.js +7 -0
  153. package/packages/client_build_tool/node_modules/history/es/ExecutionEnvironment.js +7 -0
  154. package/packages/client_build_tool/node_modules/history/es/LocationUtils.js +7 -0
  155. package/packages/client_build_tool/node_modules/history/es/PathUtils.js +7 -0
  156. package/packages/client_build_tool/node_modules/history/es/createBrowserHistory.js +7 -0
  157. package/packages/client_build_tool/node_modules/history/es/createHashHistory.js +7 -0
  158. package/packages/client_build_tool/node_modules/history/es/createMemoryHistory.js +7 -0
  159. package/packages/client_build_tool/node_modules/history/es/createTransitionManager.js +7 -0
  160. package/packages/client_build_tool/node_modules/history/es/warnAboutDeprecatedESMImport.js +35 -0
  161. package/packages/client_build_tool/node_modules/history/esm/history.js +904 -0
  162. package/packages/client_build_tool/node_modules/history/index.js +7 -0
  163. package/packages/client_build_tool/node_modules/history/package.json +117 -0
  164. package/packages/client_build_tool/node_modules/history/umd/history.js +1059 -0
  165. package/packages/client_build_tool/node_modules/history/umd/history.min.js +1 -0
  166. package/packages/client_build_tool/node_modules/history/warnAboutDeprecatedCJSRequire.js +35 -0
@@ -0,0 +1,282 @@
1
+ # history [![Travis][build-badge]][build] [![npm package][npm-badge]][npm]
2
+
3
+ [build-badge]: https://img.shields.io/travis/ReactTraining/history/master.svg?style=flat-square
4
+ [build]: https://travis-ci.org/ReactTraining/history
5
+ [npm-badge]: https://img.shields.io/npm/v/history.svg?style=flat-square
6
+ [npm]: https://www.npmjs.org/package/history
7
+
8
+ [`history`](https://www.npmjs.com/package/history) is a JavaScript library that lets you easily manage session history anywhere JavaScript runs. `history` abstracts away the differences in various environments and provides a minimal API that lets you manage the history stack, navigate, confirm navigation, and persist state between sessions.
9
+
10
+ ## Installation
11
+
12
+ Using [npm](https://www.npmjs.com/):
13
+
14
+ $ npm install --save history
15
+
16
+ Then with a module bundler like [webpack](https://webpack.github.io/), use as you would anything else:
17
+
18
+ ```js
19
+ // using ES6 modules
20
+ import { createBrowserHistory } from 'history';
21
+
22
+ // using CommonJS modules
23
+ var createBrowserHistory = require('history').createBrowserHistory;
24
+ ```
25
+
26
+ The UMD build is also available on [unpkg](https://unpkg.com):
27
+
28
+ ```html
29
+ <script src="https://unpkg.com/history"></script>
30
+ ```
31
+
32
+ You can find the library on `window.History`.
33
+
34
+ ## Usage
35
+
36
+ `history` provides 3 different methods for creating a `history` object, depending on your environment.
37
+
38
+ - `createBrowserHistory` is for use in modern web browsers that support the [HTML5 history API](http://diveintohtml5.info/history.html) (see [cross-browser compatibility](http://caniuse.com/#feat=history))
39
+ - `createMemoryHistory` is used as a reference implementation and may also be used in non-DOM environments, like [React Native](https://facebook.github.io/react-native/) or tests
40
+ - `createHashHistory` is for use in legacy web browsers
41
+
42
+ Depending on the method you want to use to keep track of history, you'll `import` (or `require`) one of these methods directly from the package root (i.e. `history/createBrowserHistory`). The remainder of this document uses the term `createHistory` to refer to any of these implementations.
43
+
44
+ Basic usage looks like this:
45
+
46
+ ```js
47
+ import { createBrowserHistory } from 'history';
48
+
49
+ const history = createBrowserHistory();
50
+
51
+ // Get the current location.
52
+ const location = history.location;
53
+
54
+ // Listen for changes to the current location.
55
+ const unlisten = history.listen((location, action) => {
56
+ // location is an object like window.location
57
+ console.log(action, location.pathname, location.state);
58
+ });
59
+
60
+ // Use push, replace, and go to navigate around.
61
+ history.push('/home', { some: 'state' });
62
+
63
+ // To stop listening, call the function returned from listen().
64
+ unlisten();
65
+ ```
66
+
67
+ The options that each `create` method takes, along with its default values, are:
68
+
69
+ ```js
70
+ createBrowserHistory({
71
+ basename: '', // The base URL of the app (see below)
72
+ forceRefresh: false, // Set true to force full page refreshes
73
+ keyLength: 6, // The length of location.key
74
+ // A function to use to confirm navigation with the user (see below)
75
+ getUserConfirmation: (message, callback) => callback(window.confirm(message))
76
+ });
77
+
78
+ createMemoryHistory({
79
+ initialEntries: ['/'], // The initial URLs in the history stack
80
+ initialIndex: 0, // The starting index in the history stack
81
+ keyLength: 6, // The length of location.key
82
+ // A function to use to confirm navigation with the user. Required
83
+ // if you return string prompts from transition hooks (see below)
84
+ getUserConfirmation: null
85
+ });
86
+
87
+ createHashHistory({
88
+ basename: '', // The base URL of the app (see below)
89
+ hashType: 'slash', // The hash type to use (see below)
90
+ // A function to use to confirm navigation with the user (see below)
91
+ getUserConfirmation: (message, callback) => callback(window.confirm(message))
92
+ });
93
+ ```
94
+
95
+ ### Properties
96
+
97
+ Each `history` object has the following properties:
98
+
99
+ - `history.length` - The number of entries in the history stack
100
+ - `history.location` - The current location (see below)
101
+ - `history.action` - The current navigation action (see below)
102
+
103
+ Additionally, `createMemoryHistory` provides `history.index` and `history.entries` properties that let you inspect the history stack.
104
+
105
+ ### Listening
106
+
107
+ You can listen for changes to the current location using `history.listen`:
108
+
109
+ ```js
110
+ history.listen((location, action) => {
111
+ console.log(
112
+ `The current URL is ${location.pathname}${location.search}${location.hash}`
113
+ );
114
+ console.log(`The last navigation action was ${action}`);
115
+ });
116
+ ```
117
+
118
+ The `location` object implements a subset of [the `window.location` interface](https://developer.mozilla.org/en-US/docs/Web/API/Location), including:
119
+
120
+ - `location.pathname` - The path of the URL
121
+ - `location.search` - The URL query string
122
+ - `location.hash` - The URL hash fragment
123
+
124
+ Locations may also have the following properties:
125
+
126
+ - `location.state` - Some extra state for this location that does not reside in the URL (supported in `createBrowserHistory` and `createMemoryHistory`)
127
+ - `location.key` - A unique string representing this location (supported in `createBrowserHistory` and `createMemoryHistory`)
128
+
129
+ The `action` is one of `PUSH`, `REPLACE`, or `POP` depending on how the user got to the current URL.
130
+
131
+ #### Cleaning up
132
+
133
+ When you attach a listener using `history.listen`, it returns a function that can be used to remove the listener, which can then be invoked in cleanup logic:
134
+
135
+ ```js
136
+ const unlisten = history.listen(myListener);
137
+ // ...
138
+ unlisten();
139
+ ```
140
+
141
+ ### Navigation
142
+
143
+ `history` objects may be used to programmatically change the current location using the following methods:
144
+
145
+ - `history.push(path, [state])`
146
+ - `history.replace(path, [state])`
147
+ - `history.go(n)`
148
+ - `history.goBack()`
149
+ - `history.goForward()`
150
+ - `history.canGo(n)` (only in `createMemoryHistory`)
151
+
152
+ When using `push` or `replace` you can either specify both the URL path and state as separate arguments or include everything in a single location-like object as the first argument.
153
+
154
+ 1. A URL path _or_
155
+ 2. A location-like object with `{ pathname, search, hash, state }`
156
+
157
+ ```js
158
+ // Push a new entry onto the history stack.
159
+ history.push('/home');
160
+
161
+ // Push a new entry onto the history stack with a query string
162
+ // and some state. Location state does not appear in the URL.
163
+ history.push('/home?the=query', { some: 'state' });
164
+
165
+ // If you prefer, use a single location-like object to specify both
166
+ // the URL and state. This is equivalent to the example above.
167
+ history.push({
168
+ pathname: '/home',
169
+ search: '?the=query',
170
+ state: { some: 'state' }
171
+ });
172
+
173
+ // Go back to the previous history entry. The following
174
+ // two lines are synonymous.
175
+ history.go(-1);
176
+ history.goBack();
177
+ ```
178
+
179
+ **Note:** Location state is only supported in `createBrowserHistory` and `createMemoryHistory`.
180
+
181
+ ### Blocking Transitions
182
+
183
+ `history` lets you register a prompt message that will be shown to the user before location listeners are notified. This allows you to make sure the user wants to leave the current page before they navigate away.
184
+
185
+ ```js
186
+ // Register a simple prompt message that will be shown the
187
+ // user before they navigate away from the current page.
188
+ const unblock = history.block('Are you sure you want to leave this page?');
189
+
190
+ // Or use a function that returns the message when it's needed.
191
+ history.block((location, action) => {
192
+ // The location and action arguments indicate the location
193
+ // we're transitioning to and how we're getting there.
194
+
195
+ // A common use case is to prevent the user from leaving the
196
+ // page if there's a form they haven't submitted yet.
197
+ if (input.value !== '') return 'Are you sure you want to leave this page?';
198
+ });
199
+
200
+ // To stop blocking transitions, call the function returned from block().
201
+ unblock();
202
+ ```
203
+
204
+ **Note:** You'll need to provide a `getUserConfirmation` function to use this feature with `createMemoryHistory` (see below).
205
+
206
+ ### Customizing the Confirm Dialog
207
+
208
+ By default, [`window.confirm`](https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm) is used to show prompt messages to the user. If you need to override this behavior (or if you're using `createMemoryHistory`, which doesn't assume a DOM environment), provide a `getUserConfirmation` function when you create your history object.
209
+
210
+ ```js
211
+ const history = createHistory({
212
+ getUserConfirmation(message, callback) {
213
+ // Show some custom dialog to the user and call
214
+ // callback(true) to continue the transiton, or
215
+ // callback(false) to abort it.
216
+ }
217
+ });
218
+ ```
219
+
220
+ ### Using a Base URL
221
+
222
+ If all the URLs in your app are relative to some other "base" URL, use the `basename` option. This option transparently adds the given string to the front of all URLs you use.
223
+
224
+ ```js
225
+ const history = createHistory({
226
+ basename: '/the/base'
227
+ });
228
+
229
+ history.listen(location => {
230
+ console.log(location.pathname); // /home
231
+ });
232
+
233
+ history.push('/home'); // URL is now /the/base/home
234
+ ```
235
+
236
+ **Note:** `basename` is not suppported in `createMemoryHistory`.
237
+
238
+ ### Forcing Full Page Refreshes in createBrowserHistory
239
+
240
+ By default `createBrowserHistory` uses HTML5 `pushState` and `replaceState` to prevent reloading the entire page from the server while navigating around. If instead you would like to reload as the URL changes, use the `forceRefresh` option.
241
+
242
+ ```js
243
+ const history = createBrowserHistory({
244
+ forceRefresh: true
245
+ });
246
+ ```
247
+
248
+ ### Modifying the Hash Type in createHashHistory
249
+
250
+ By default `createHashHistory` uses a leading slash in hash-based URLs. You can use the `hashType` option to use a different hash formatting.
251
+
252
+ ```js
253
+ const history = createHashHistory({
254
+ hashType: 'slash' // the default
255
+ });
256
+
257
+ history.push('/home'); // window.location.hash is #/home
258
+
259
+ const history = createHashHistory({
260
+ hashType: 'noslash' // Omit the leading slash
261
+ });
262
+
263
+ history.push('/home'); // window.location.hash is #home
264
+
265
+ const history = createHashHistory({
266
+ hashType: 'hashbang' // Google's legacy AJAX URL format
267
+ });
268
+
269
+ history.push('/home'); // window.location.hash is #!/home
270
+ ```
271
+
272
+ ## About
273
+
274
+ `history` is developed and maintained by [React Training](https://reacttraining.com). If
275
+ you're interested in learning more about what React can do for your company, please
276
+ [get in touch](mailto:hello@reacttraining.com)!
277
+
278
+ ## Thanks
279
+
280
+ A big thank-you to [BrowserStack](https://www.browserstack.com/) for providing the infrastructure that allows us to run our build in real browsers.
281
+
282
+ Also, thanks to [Dan Shaw](https://www.npmjs.com/~dshaw) for letting us use the `history` npm package name. Thanks Dan!