sequenceserver 1.1.0.beta → 1.1.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -7
- data/README.md +9 -11
- data/Rakefile +2 -15
- data/lib/sequenceserver/database.rb +7 -1
- data/lib/sequenceserver/routes.rb +5 -2
- data/lib/sequenceserver/version.rb +1 -1
- data/lib/sequenceserver.rb +3 -1
- data/package.json +2 -3
- data/public/config.js +0 -7
- data/public/css/sequenceserver.css +8 -17
- data/public/css/sequenceserver.min.css +2 -2
- data/public/js/report.js +62 -45
- data/public/js/search.js +24 -17
- data/public/js/sequenceserver.js +23 -60
- data/public/sequenceserver-report.min.js +17 -0
- data/public/sequenceserver-search.min.js +11 -0
- data/sequenceserver.gemspec +5 -5
- data/spec/capybara_spec.rb +3 -3
- data/spec/sequence_spec.rb +2 -2
- data/views/layout.erb +1 -13
- data/views/report.erb +13 -0
- data/views/search.erb +45 -0
- metadata +26 -92
- data/public/css/sequenceserver.min.css.gz +0 -0
- data/public/sequenceserver.min.js +0 -26
- data/public/sequenceserver.min.js.gz +0 -0
- data/public/vendor/npm/object-assign@2.1.1/.jspm-hash +0 -1
- data/public/vendor/npm/object-assign@2.1.1/.jspm.json +0 -72
- data/public/vendor/npm/object-assign@2.1.1/index.js +0 -27
- data/public/vendor/npm/object-assign@2.1.1/package.json +0 -38
- data/public/vendor/npm/object-assign@2.1.1.js +0 -1
- data/public/vendor/npm/qs@2.4.1/.jshintignore +0 -1
- data/public/vendor/npm/qs@2.4.1/.jshintrc +0 -10
- data/public/vendor/npm/qs@2.4.1/.jspm-hash +0 -1
- data/public/vendor/npm/qs@2.4.1/.jspm.json +0 -61
- data/public/vendor/npm/qs@2.4.1/.npmignore +0 -18
- data/public/vendor/npm/qs@2.4.1/.travis.yml +0 -6
- data/public/vendor/npm/qs@2.4.1/CHANGELOG.md +0 -68
- data/public/vendor/npm/qs@2.4.1/CONTRIBUTING.md +0 -1
- data/public/vendor/npm/qs@2.4.1/LICENSE +0 -28
- data/public/vendor/npm/qs@2.4.1/Makefile +0 -8
- data/public/vendor/npm/qs@2.4.1/README.md +0 -233
- data/public/vendor/npm/qs@2.4.1/index.js +0 -2
- data/public/vendor/npm/qs@2.4.1/lib/index.js +0 -8
- data/public/vendor/npm/qs@2.4.1/lib/parse.js +0 -100
- data/public/vendor/npm/qs@2.4.1/lib/stringify.js +0 -67
- data/public/vendor/npm/qs@2.4.1/lib/utils.js +0 -132
- data/public/vendor/npm/qs@2.4.1/lib.js +0 -2
- data/public/vendor/npm/qs@2.4.1/package.json +0 -29
- data/public/vendor/npm/qs@2.4.1/test/parse.js +0 -359
- data/public/vendor/npm/qs@2.4.1.js +0 -1
- data/public/vendor/npm/react-router@0.13.3/.jspm-hash +0 -1
- data/public/vendor/npm/react-router@0.13.3/.jspm.json +0 -70
- data/public/vendor/npm/react-router@0.13.3/README.md +0 -140
- data/public/vendor/npm/react-router@0.13.3/lib/Cancellation.js +0 -9
- data/public/vendor/npm/react-router@0.13.3/lib/History.js +0 -31
- data/public/vendor/npm/react-router@0.13.3/lib/Match.js +0 -80
- data/public/vendor/npm/react-router@0.13.3/lib/Navigation.js +0 -22
- data/public/vendor/npm/react-router@0.13.3/lib/PathUtils.js +0 -154
- data/public/vendor/npm/react-router@0.13.3/lib/PropTypes.js +0 -15
- data/public/vendor/npm/react-router@0.13.3/lib/Redirect.js +0 -12
- data/public/vendor/npm/react-router@0.13.3/lib/Route.js +0 -133
- data/public/vendor/npm/react-router@0.13.3/lib/ScrollHistory.js +0 -53
- data/public/vendor/npm/react-router@0.13.3/lib/State.js +0 -25
- data/public/vendor/npm/react-router@0.13.3/lib/TestUtils.js +0 -102
- data/public/vendor/npm/react-router@0.13.3/lib/Transition.js +0 -58
- data/public/vendor/npm/react-router@0.13.3/lib/actions/LocationActions.js +0 -25
- data/public/vendor/npm/react-router@0.13.3/lib/behaviors/ImitateBrowserBehavior.js +0 -19
- data/public/vendor/npm/react-router@0.13.3/lib/behaviors/ScrollToTopBehavior.js +0 -15
- data/public/vendor/npm/react-router@0.13.3/lib/components/ActiveHandler.js +0 -111
- data/public/vendor/npm/react-router@0.13.3/lib/components/ContextWrapper.js +0 -39
- data/public/vendor/npm/react-router@0.13.3/lib/components/DefaultRoute.js +0 -41
- data/public/vendor/npm/react-router@0.13.3/lib/components/Link.js +0 -119
- data/public/vendor/npm/react-router@0.13.3/lib/components/NotFoundRoute.js +0 -41
- data/public/vendor/npm/react-router@0.13.3/lib/components/Redirect.js +0 -40
- data/public/vendor/npm/react-router@0.13.3/lib/components/Route.js +0 -67
- data/public/vendor/npm/react-router@0.13.3/lib/components/RouteHandler.js +0 -111
- data/public/vendor/npm/react-router@0.13.3/lib/createRouter.js +0 -329
- data/public/vendor/npm/react-router@0.13.3/lib/createRoutesFromReactChildren.js +0 -59
- data/public/vendor/npm/react-router@0.13.3/lib/getWindowScrollPosition.js +0 -19
- data/public/vendor/npm/react-router@0.13.3/lib/index.js +0 -26
- data/public/vendor/npm/react-router@0.13.3/lib/isReactChildren.js +0 -14
- data/public/vendor/npm/react-router@0.13.3/lib/locations/HashLocation.js +0 -79
- data/public/vendor/npm/react-router@0.13.3/lib/locations/HistoryLocation.js +0 -64
- data/public/vendor/npm/react-router@0.13.3/lib/locations/RefreshLocation.js +0 -18
- data/public/vendor/npm/react-router@0.13.3/lib/locations/StaticLocation.js +0 -50
- data/public/vendor/npm/react-router@0.13.3/lib/locations/TestLocation.js +0 -104
- data/public/vendor/npm/react-router@0.13.3/lib/runRouter.js +0 -16
- data/public/vendor/npm/react-router@0.13.3/lib/supportsHistory.js +0 -17
- data/public/vendor/npm/react-router@0.13.3/lib.js +0 -2
- data/public/vendor/npm/react-router@0.13.3/package.json +0 -36
- data/public/vendor/npm/react-router@0.13.3/umd/ReactRouter.js +0 -3388
- data/public/vendor/npm/react-router@0.13.3/umd/ReactRouter.min.js +0 -8
@@ -1,3388 +0,0 @@
|
|
1
|
-
/* */
|
2
|
-
"format cjs";
|
3
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
4
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
5
|
-
module.exports = factory(require("react"));
|
6
|
-
else if(typeof define === 'function' && define.amd)
|
7
|
-
define(["react"], factory);
|
8
|
-
else if(typeof exports === 'object')
|
9
|
-
exports["ReactRouter"] = factory(require("react"));
|
10
|
-
else
|
11
|
-
root["ReactRouter"] = factory(root["React"]);
|
12
|
-
})(this, function(__WEBPACK_EXTERNAL_MODULE_21__) {
|
13
|
-
return /******/ (function(modules) { // webpackBootstrap
|
14
|
-
/******/ // The module cache
|
15
|
-
/******/ var installedModules = {};
|
16
|
-
/******/
|
17
|
-
/******/ // The require function
|
18
|
-
/******/ function __webpack_require__(moduleId) {
|
19
|
-
/******/
|
20
|
-
/******/ // Check if module is in cache
|
21
|
-
/******/ if(installedModules[moduleId])
|
22
|
-
/******/ return installedModules[moduleId].exports;
|
23
|
-
/******/
|
24
|
-
/******/ // Create a new module (and put it into the cache)
|
25
|
-
/******/ var module = installedModules[moduleId] = {
|
26
|
-
/******/ exports: {},
|
27
|
-
/******/ id: moduleId,
|
28
|
-
/******/ loaded: false
|
29
|
-
/******/ };
|
30
|
-
/******/
|
31
|
-
/******/ // Execute the module function
|
32
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
33
|
-
/******/
|
34
|
-
/******/ // Flag the module as loaded
|
35
|
-
/******/ module.loaded = true;
|
36
|
-
/******/
|
37
|
-
/******/ // Return the exports of the module
|
38
|
-
/******/ return module.exports;
|
39
|
-
/******/ }
|
40
|
-
/******/
|
41
|
-
/******/
|
42
|
-
/******/ // expose the modules object (__webpack_modules__)
|
43
|
-
/******/ __webpack_require__.m = modules;
|
44
|
-
/******/
|
45
|
-
/******/ // expose the module cache
|
46
|
-
/******/ __webpack_require__.c = installedModules;
|
47
|
-
/******/
|
48
|
-
/******/ // __webpack_public_path__
|
49
|
-
/******/ __webpack_require__.p = "";
|
50
|
-
/******/
|
51
|
-
/******/ // Load entry module and return exports
|
52
|
-
/******/ return __webpack_require__(0);
|
53
|
-
/******/ })
|
54
|
-
/************************************************************************/
|
55
|
-
/******/ ([
|
56
|
-
/* 0 */
|
57
|
-
/***/ function(module, exports, __webpack_require__) {
|
58
|
-
|
59
|
-
'use strict';
|
60
|
-
|
61
|
-
exports.DefaultRoute = __webpack_require__(1);
|
62
|
-
exports.Link = __webpack_require__(2);
|
63
|
-
exports.NotFoundRoute = __webpack_require__(3);
|
64
|
-
exports.Redirect = __webpack_require__(4);
|
65
|
-
exports.Route = __webpack_require__(5);
|
66
|
-
exports.ActiveHandler = __webpack_require__(6);
|
67
|
-
exports.RouteHandler = exports.ActiveHandler;
|
68
|
-
|
69
|
-
exports.HashLocation = __webpack_require__(7);
|
70
|
-
exports.HistoryLocation = __webpack_require__(8);
|
71
|
-
exports.RefreshLocation = __webpack_require__(9);
|
72
|
-
exports.StaticLocation = __webpack_require__(10);
|
73
|
-
exports.TestLocation = __webpack_require__(11);
|
74
|
-
|
75
|
-
exports.ImitateBrowserBehavior = __webpack_require__(12);
|
76
|
-
exports.ScrollToTopBehavior = __webpack_require__(13);
|
77
|
-
|
78
|
-
exports.History = __webpack_require__(14);
|
79
|
-
exports.Navigation = __webpack_require__(15);
|
80
|
-
exports.State = __webpack_require__(16);
|
81
|
-
|
82
|
-
exports.createRoute = __webpack_require__(17).createRoute;
|
83
|
-
exports.createDefaultRoute = __webpack_require__(17).createDefaultRoute;
|
84
|
-
exports.createNotFoundRoute = __webpack_require__(17).createNotFoundRoute;
|
85
|
-
exports.createRedirect = __webpack_require__(17).createRedirect;
|
86
|
-
exports.createRoutesFromReactChildren = __webpack_require__(18);
|
87
|
-
|
88
|
-
exports.create = __webpack_require__(19);
|
89
|
-
exports.run = __webpack_require__(20);
|
90
|
-
|
91
|
-
/***/ },
|
92
|
-
/* 1 */
|
93
|
-
/***/ function(module, exports, __webpack_require__) {
|
94
|
-
|
95
|
-
'use strict';
|
96
|
-
|
97
|
-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
98
|
-
|
99
|
-
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
100
|
-
|
101
|
-
var PropTypes = __webpack_require__(22);
|
102
|
-
var RouteHandler = __webpack_require__(6);
|
103
|
-
var Route = __webpack_require__(5);
|
104
|
-
|
105
|
-
/**
|
106
|
-
* A <DefaultRoute> component is a special kind of <Route> that
|
107
|
-
* renders when its parent matches but none of its siblings do.
|
108
|
-
* Only one such route may be used at any given level in the
|
109
|
-
* route hierarchy.
|
110
|
-
*/
|
111
|
-
|
112
|
-
var DefaultRoute = (function (_Route) {
|
113
|
-
function DefaultRoute() {
|
114
|
-
_classCallCheck(this, DefaultRoute);
|
115
|
-
|
116
|
-
if (_Route != null) {
|
117
|
-
_Route.apply(this, arguments);
|
118
|
-
}
|
119
|
-
}
|
120
|
-
|
121
|
-
_inherits(DefaultRoute, _Route);
|
122
|
-
|
123
|
-
return DefaultRoute;
|
124
|
-
})(Route);
|
125
|
-
|
126
|
-
// TODO: Include these in the above class definition
|
127
|
-
// once we can use ES7 property initializers.
|
128
|
-
// https://github.com/babel/babel/issues/619
|
129
|
-
|
130
|
-
DefaultRoute.propTypes = {
|
131
|
-
name: PropTypes.string,
|
132
|
-
path: PropTypes.falsy,
|
133
|
-
children: PropTypes.falsy,
|
134
|
-
handler: PropTypes.func.isRequired
|
135
|
-
};
|
136
|
-
|
137
|
-
DefaultRoute.defaultProps = {
|
138
|
-
handler: RouteHandler
|
139
|
-
};
|
140
|
-
|
141
|
-
module.exports = DefaultRoute;
|
142
|
-
|
143
|
-
/***/ },
|
144
|
-
/* 2 */
|
145
|
-
/***/ function(module, exports, __webpack_require__) {
|
146
|
-
|
147
|
-
'use strict';
|
148
|
-
|
149
|
-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
150
|
-
|
151
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
152
|
-
|
153
|
-
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
154
|
-
|
155
|
-
var React = __webpack_require__(21);
|
156
|
-
var assign = __webpack_require__(33);
|
157
|
-
var PropTypes = __webpack_require__(22);
|
158
|
-
|
159
|
-
function isLeftClickEvent(event) {
|
160
|
-
return event.button === 0;
|
161
|
-
}
|
162
|
-
|
163
|
-
function isModifiedEvent(event) {
|
164
|
-
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
165
|
-
}
|
166
|
-
|
167
|
-
/**
|
168
|
-
* <Link> components are used to create an <a> element that links to a route.
|
169
|
-
* When that route is active, the link gets an "active" class name (or the
|
170
|
-
* value of its `activeClassName` prop).
|
171
|
-
*
|
172
|
-
* For example, assuming you have the following route:
|
173
|
-
*
|
174
|
-
* <Route name="showPost" path="/posts/:postID" handler={Post}/>
|
175
|
-
*
|
176
|
-
* You could use the following component to link to that route:
|
177
|
-
*
|
178
|
-
* <Link to="showPost" params={{ postID: "123" }} />
|
179
|
-
*
|
180
|
-
* In addition to params, links may pass along query string parameters
|
181
|
-
* using the `query` prop.
|
182
|
-
*
|
183
|
-
* <Link to="showPost" params={{ postID: "123" }} query={{ show:true }}/>
|
184
|
-
*/
|
185
|
-
|
186
|
-
var Link = (function (_React$Component) {
|
187
|
-
function Link() {
|
188
|
-
_classCallCheck(this, Link);
|
189
|
-
|
190
|
-
if (_React$Component != null) {
|
191
|
-
_React$Component.apply(this, arguments);
|
192
|
-
}
|
193
|
-
}
|
194
|
-
|
195
|
-
_inherits(Link, _React$Component);
|
196
|
-
|
197
|
-
_createClass(Link, [{
|
198
|
-
key: 'handleClick',
|
199
|
-
value: function handleClick(event) {
|
200
|
-
var allowTransition = true;
|
201
|
-
var clickResult;
|
202
|
-
|
203
|
-
if (this.props.onClick) clickResult = this.props.onClick(event);
|
204
|
-
|
205
|
-
if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
|
206
|
-
return;
|
207
|
-
}if (clickResult === false || event.defaultPrevented === true) allowTransition = false;
|
208
|
-
|
209
|
-
event.preventDefault();
|
210
|
-
|
211
|
-
if (allowTransition) this.context.router.transitionTo(this.props.to, this.props.params, this.props.query);
|
212
|
-
}
|
213
|
-
}, {
|
214
|
-
key: 'getHref',
|
215
|
-
|
216
|
-
/**
|
217
|
-
* Returns the value of the "href" attribute to use on the DOM element.
|
218
|
-
*/
|
219
|
-
value: function getHref() {
|
220
|
-
return this.context.router.makeHref(this.props.to, this.props.params, this.props.query);
|
221
|
-
}
|
222
|
-
}, {
|
223
|
-
key: 'getClassName',
|
224
|
-
|
225
|
-
/**
|
226
|
-
* Returns the value of the "class" attribute to use on the DOM element, which contains
|
227
|
-
* the value of the activeClassName property when this <Link> is active.
|
228
|
-
*/
|
229
|
-
value: function getClassName() {
|
230
|
-
var className = this.props.className;
|
231
|
-
|
232
|
-
if (this.getActiveState()) className += ' ' + this.props.activeClassName;
|
233
|
-
|
234
|
-
return className;
|
235
|
-
}
|
236
|
-
}, {
|
237
|
-
key: 'getActiveState',
|
238
|
-
value: function getActiveState() {
|
239
|
-
return this.context.router.isActive(this.props.to, this.props.params, this.props.query);
|
240
|
-
}
|
241
|
-
}, {
|
242
|
-
key: 'render',
|
243
|
-
value: function render() {
|
244
|
-
var props = assign({}, this.props, {
|
245
|
-
href: this.getHref(),
|
246
|
-
className: this.getClassName(),
|
247
|
-
onClick: this.handleClick.bind(this)
|
248
|
-
});
|
249
|
-
|
250
|
-
if (props.activeStyle && this.getActiveState()) props.style = props.activeStyle;
|
251
|
-
|
252
|
-
return React.DOM.a(props, this.props.children);
|
253
|
-
}
|
254
|
-
}]);
|
255
|
-
|
256
|
-
return Link;
|
257
|
-
})(React.Component);
|
258
|
-
|
259
|
-
// TODO: Include these in the above class definition
|
260
|
-
// once we can use ES7 property initializers.
|
261
|
-
// https://github.com/babel/babel/issues/619
|
262
|
-
|
263
|
-
Link.contextTypes = {
|
264
|
-
router: PropTypes.router.isRequired
|
265
|
-
};
|
266
|
-
|
267
|
-
Link.propTypes = {
|
268
|
-
activeClassName: PropTypes.string.isRequired,
|
269
|
-
to: PropTypes.oneOfType([PropTypes.string, PropTypes.route]).isRequired,
|
270
|
-
params: PropTypes.object,
|
271
|
-
query: PropTypes.object,
|
272
|
-
activeStyle: PropTypes.object,
|
273
|
-
onClick: PropTypes.func
|
274
|
-
};
|
275
|
-
|
276
|
-
Link.defaultProps = {
|
277
|
-
activeClassName: 'active',
|
278
|
-
className: ''
|
279
|
-
};
|
280
|
-
|
281
|
-
module.exports = Link;
|
282
|
-
|
283
|
-
/***/ },
|
284
|
-
/* 3 */
|
285
|
-
/***/ function(module, exports, __webpack_require__) {
|
286
|
-
|
287
|
-
'use strict';
|
288
|
-
|
289
|
-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
290
|
-
|
291
|
-
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
292
|
-
|
293
|
-
var PropTypes = __webpack_require__(22);
|
294
|
-
var RouteHandler = __webpack_require__(6);
|
295
|
-
var Route = __webpack_require__(5);
|
296
|
-
|
297
|
-
/**
|
298
|
-
* A <NotFoundRoute> is a special kind of <Route> that
|
299
|
-
* renders when the beginning of its parent's path matches
|
300
|
-
* but none of its siblings do, including any <DefaultRoute>.
|
301
|
-
* Only one such route may be used at any given level in the
|
302
|
-
* route hierarchy.
|
303
|
-
*/
|
304
|
-
|
305
|
-
var NotFoundRoute = (function (_Route) {
|
306
|
-
function NotFoundRoute() {
|
307
|
-
_classCallCheck(this, NotFoundRoute);
|
308
|
-
|
309
|
-
if (_Route != null) {
|
310
|
-
_Route.apply(this, arguments);
|
311
|
-
}
|
312
|
-
}
|
313
|
-
|
314
|
-
_inherits(NotFoundRoute, _Route);
|
315
|
-
|
316
|
-
return NotFoundRoute;
|
317
|
-
})(Route);
|
318
|
-
|
319
|
-
// TODO: Include these in the above class definition
|
320
|
-
// once we can use ES7 property initializers.
|
321
|
-
// https://github.com/babel/babel/issues/619
|
322
|
-
|
323
|
-
NotFoundRoute.propTypes = {
|
324
|
-
name: PropTypes.string,
|
325
|
-
path: PropTypes.falsy,
|
326
|
-
children: PropTypes.falsy,
|
327
|
-
handler: PropTypes.func.isRequired
|
328
|
-
};
|
329
|
-
|
330
|
-
NotFoundRoute.defaultProps = {
|
331
|
-
handler: RouteHandler
|
332
|
-
};
|
333
|
-
|
334
|
-
module.exports = NotFoundRoute;
|
335
|
-
|
336
|
-
/***/ },
|
337
|
-
/* 4 */
|
338
|
-
/***/ function(module, exports, __webpack_require__) {
|
339
|
-
|
340
|
-
'use strict';
|
341
|
-
|
342
|
-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
343
|
-
|
344
|
-
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
345
|
-
|
346
|
-
var PropTypes = __webpack_require__(22);
|
347
|
-
var Route = __webpack_require__(5);
|
348
|
-
|
349
|
-
/**
|
350
|
-
* A <Redirect> component is a special kind of <Route> that always
|
351
|
-
* redirects to another route when it matches.
|
352
|
-
*/
|
353
|
-
|
354
|
-
var Redirect = (function (_Route) {
|
355
|
-
function Redirect() {
|
356
|
-
_classCallCheck(this, Redirect);
|
357
|
-
|
358
|
-
if (_Route != null) {
|
359
|
-
_Route.apply(this, arguments);
|
360
|
-
}
|
361
|
-
}
|
362
|
-
|
363
|
-
_inherits(Redirect, _Route);
|
364
|
-
|
365
|
-
return Redirect;
|
366
|
-
})(Route);
|
367
|
-
|
368
|
-
// TODO: Include these in the above class definition
|
369
|
-
// once we can use ES7 property initializers.
|
370
|
-
// https://github.com/babel/babel/issues/619
|
371
|
-
|
372
|
-
Redirect.propTypes = {
|
373
|
-
path: PropTypes.string,
|
374
|
-
from: PropTypes.string, // Alias for path.
|
375
|
-
to: PropTypes.string,
|
376
|
-
handler: PropTypes.falsy
|
377
|
-
};
|
378
|
-
|
379
|
-
// Redirects should not have a default handler
|
380
|
-
Redirect.defaultProps = {};
|
381
|
-
|
382
|
-
module.exports = Redirect;
|
383
|
-
|
384
|
-
/***/ },
|
385
|
-
/* 5 */
|
386
|
-
/***/ function(module, exports, __webpack_require__) {
|
387
|
-
|
388
|
-
'use strict';
|
389
|
-
|
390
|
-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
391
|
-
|
392
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
393
|
-
|
394
|
-
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
395
|
-
|
396
|
-
var React = __webpack_require__(21);
|
397
|
-
var invariant = __webpack_require__(34);
|
398
|
-
var PropTypes = __webpack_require__(22);
|
399
|
-
var RouteHandler = __webpack_require__(6);
|
400
|
-
|
401
|
-
/**
|
402
|
-
* <Route> components specify components that are rendered to the page when the
|
403
|
-
* URL matches a given pattern.
|
404
|
-
*
|
405
|
-
* Routes are arranged in a nested tree structure. When a new URL is requested,
|
406
|
-
* the tree is searched depth-first to find a route whose path matches the URL.
|
407
|
-
* When one is found, all routes in the tree that lead to it are considered
|
408
|
-
* "active" and their components are rendered into the DOM, nested in the same
|
409
|
-
* order as they are in the tree.
|
410
|
-
*
|
411
|
-
* The preferred way to configure a router is using JSX. The XML-like syntax is
|
412
|
-
* a great way to visualize how routes are laid out in an application.
|
413
|
-
*
|
414
|
-
* var routes = [
|
415
|
-
* <Route handler={App}>
|
416
|
-
* <Route name="login" handler={Login}/>
|
417
|
-
* <Route name="logout" handler={Logout}/>
|
418
|
-
* <Route name="about" handler={About}/>
|
419
|
-
* </Route>
|
420
|
-
* ];
|
421
|
-
*
|
422
|
-
* Router.run(routes, function (Handler) {
|
423
|
-
* React.render(<Handler/>, document.body);
|
424
|
-
* });
|
425
|
-
*
|
426
|
-
* Handlers for Route components that contain children can render their active
|
427
|
-
* child route using a <RouteHandler> element.
|
428
|
-
*
|
429
|
-
* var App = React.createClass({
|
430
|
-
* render: function () {
|
431
|
-
* return (
|
432
|
-
* <div class="application">
|
433
|
-
* <RouteHandler/>
|
434
|
-
* </div>
|
435
|
-
* );
|
436
|
-
* }
|
437
|
-
* });
|
438
|
-
*
|
439
|
-
* If no handler is provided for the route, it will render a matched child route.
|
440
|
-
*/
|
441
|
-
|
442
|
-
var Route = (function (_React$Component) {
|
443
|
-
function Route() {
|
444
|
-
_classCallCheck(this, Route);
|
445
|
-
|
446
|
-
if (_React$Component != null) {
|
447
|
-
_React$Component.apply(this, arguments);
|
448
|
-
}
|
449
|
-
}
|
450
|
-
|
451
|
-
_inherits(Route, _React$Component);
|
452
|
-
|
453
|
-
_createClass(Route, [{
|
454
|
-
key: 'render',
|
455
|
-
value: function render() {
|
456
|
-
invariant(false, '%s elements are for router configuration only and should not be rendered', this.constructor.name);
|
457
|
-
}
|
458
|
-
}]);
|
459
|
-
|
460
|
-
return Route;
|
461
|
-
})(React.Component);
|
462
|
-
|
463
|
-
// TODO: Include these in the above class definition
|
464
|
-
// once we can use ES7 property initializers.
|
465
|
-
// https://github.com/babel/babel/issues/619
|
466
|
-
|
467
|
-
Route.propTypes = {
|
468
|
-
name: PropTypes.string,
|
469
|
-
path: PropTypes.string,
|
470
|
-
handler: PropTypes.func,
|
471
|
-
ignoreScrollBehavior: PropTypes.bool
|
472
|
-
};
|
473
|
-
|
474
|
-
Route.defaultProps = {
|
475
|
-
handler: RouteHandler
|
476
|
-
};
|
477
|
-
|
478
|
-
module.exports = Route;
|
479
|
-
|
480
|
-
/***/ },
|
481
|
-
/* 6 */
|
482
|
-
/***/ function(module, exports, __webpack_require__) {
|
483
|
-
|
484
|
-
'use strict';
|
485
|
-
|
486
|
-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
487
|
-
|
488
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
489
|
-
|
490
|
-
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
491
|
-
|
492
|
-
var React = __webpack_require__(21);
|
493
|
-
var ContextWrapper = __webpack_require__(23);
|
494
|
-
var assign = __webpack_require__(33);
|
495
|
-
var PropTypes = __webpack_require__(22);
|
496
|
-
|
497
|
-
var REF_NAME = '__routeHandler__';
|
498
|
-
|
499
|
-
/**
|
500
|
-
* A <RouteHandler> component renders the active child route handler
|
501
|
-
* when routes are nested.
|
502
|
-
*/
|
503
|
-
|
504
|
-
var RouteHandler = (function (_React$Component) {
|
505
|
-
function RouteHandler() {
|
506
|
-
_classCallCheck(this, RouteHandler);
|
507
|
-
|
508
|
-
if (_React$Component != null) {
|
509
|
-
_React$Component.apply(this, arguments);
|
510
|
-
}
|
511
|
-
}
|
512
|
-
|
513
|
-
_inherits(RouteHandler, _React$Component);
|
514
|
-
|
515
|
-
_createClass(RouteHandler, [{
|
516
|
-
key: 'getChildContext',
|
517
|
-
value: function getChildContext() {
|
518
|
-
return {
|
519
|
-
routeDepth: this.context.routeDepth + 1
|
520
|
-
};
|
521
|
-
}
|
522
|
-
}, {
|
523
|
-
key: 'componentDidMount',
|
524
|
-
value: function componentDidMount() {
|
525
|
-
this._updateRouteComponent(this.refs[REF_NAME]);
|
526
|
-
}
|
527
|
-
}, {
|
528
|
-
key: 'componentDidUpdate',
|
529
|
-
value: function componentDidUpdate() {
|
530
|
-
this._updateRouteComponent(this.refs[REF_NAME]);
|
531
|
-
}
|
532
|
-
}, {
|
533
|
-
key: 'componentWillUnmount',
|
534
|
-
value: function componentWillUnmount() {
|
535
|
-
this._updateRouteComponent(null);
|
536
|
-
}
|
537
|
-
}, {
|
538
|
-
key: '_updateRouteComponent',
|
539
|
-
value: function _updateRouteComponent(component) {
|
540
|
-
this.context.router.setRouteComponentAtDepth(this.getRouteDepth(), component);
|
541
|
-
}
|
542
|
-
}, {
|
543
|
-
key: 'getRouteDepth',
|
544
|
-
value: function getRouteDepth() {
|
545
|
-
return this.context.routeDepth;
|
546
|
-
}
|
547
|
-
}, {
|
548
|
-
key: 'createChildRouteHandler',
|
549
|
-
value: function createChildRouteHandler(props) {
|
550
|
-
var route = this.context.router.getRouteAtDepth(this.getRouteDepth());
|
551
|
-
|
552
|
-
if (route == null) {
|
553
|
-
return null;
|
554
|
-
}var childProps = assign({}, props || this.props, {
|
555
|
-
ref: REF_NAME,
|
556
|
-
params: this.context.router.getCurrentParams(),
|
557
|
-
query: this.context.router.getCurrentQuery()
|
558
|
-
});
|
559
|
-
|
560
|
-
return React.createElement(route.handler, childProps);
|
561
|
-
}
|
562
|
-
}, {
|
563
|
-
key: 'render',
|
564
|
-
value: function render() {
|
565
|
-
var handler = this.createChildRouteHandler();
|
566
|
-
// <script/> for things like <CSSTransitionGroup/> that don't like null
|
567
|
-
return handler ? React.createElement(
|
568
|
-
ContextWrapper,
|
569
|
-
null,
|
570
|
-
handler
|
571
|
-
) : React.createElement('script', null);
|
572
|
-
}
|
573
|
-
}]);
|
574
|
-
|
575
|
-
return RouteHandler;
|
576
|
-
})(React.Component);
|
577
|
-
|
578
|
-
// TODO: Include these in the above class definition
|
579
|
-
// once we can use ES7 property initializers.
|
580
|
-
// https://github.com/babel/babel/issues/619
|
581
|
-
|
582
|
-
RouteHandler.contextTypes = {
|
583
|
-
routeDepth: PropTypes.number.isRequired,
|
584
|
-
router: PropTypes.router.isRequired
|
585
|
-
};
|
586
|
-
|
587
|
-
RouteHandler.childContextTypes = {
|
588
|
-
routeDepth: PropTypes.number.isRequired
|
589
|
-
};
|
590
|
-
|
591
|
-
module.exports = RouteHandler;
|
592
|
-
|
593
|
-
/***/ },
|
594
|
-
/* 7 */
|
595
|
-
/***/ function(module, exports, __webpack_require__) {
|
596
|
-
|
597
|
-
'use strict';
|
598
|
-
|
599
|
-
var LocationActions = __webpack_require__(24);
|
600
|
-
var History = __webpack_require__(14);
|
601
|
-
|
602
|
-
var _listeners = [];
|
603
|
-
var _isListening = false;
|
604
|
-
var _actionType;
|
605
|
-
|
606
|
-
function notifyChange(type) {
|
607
|
-
if (type === LocationActions.PUSH) History.length += 1;
|
608
|
-
|
609
|
-
var change = {
|
610
|
-
path: HashLocation.getCurrentPath(),
|
611
|
-
type: type
|
612
|
-
};
|
613
|
-
|
614
|
-
_listeners.forEach(function (listener) {
|
615
|
-
listener.call(HashLocation, change);
|
616
|
-
});
|
617
|
-
}
|
618
|
-
|
619
|
-
function ensureSlash() {
|
620
|
-
var path = HashLocation.getCurrentPath();
|
621
|
-
|
622
|
-
if (path.charAt(0) === '/') {
|
623
|
-
return true;
|
624
|
-
}HashLocation.replace('/' + path);
|
625
|
-
|
626
|
-
return false;
|
627
|
-
}
|
628
|
-
|
629
|
-
function onHashChange() {
|
630
|
-
if (ensureSlash()) {
|
631
|
-
// If we don't have an _actionType then all we know is the hash
|
632
|
-
// changed. It was probably caused by the user clicking the Back
|
633
|
-
// button, but may have also been the Forward button or manual
|
634
|
-
// manipulation. So just guess 'pop'.
|
635
|
-
var curActionType = _actionType;
|
636
|
-
_actionType = null;
|
637
|
-
notifyChange(curActionType || LocationActions.POP);
|
638
|
-
}
|
639
|
-
}
|
640
|
-
|
641
|
-
/**
|
642
|
-
* A Location that uses `window.location.hash`.
|
643
|
-
*/
|
644
|
-
var HashLocation = {
|
645
|
-
|
646
|
-
addChangeListener: function addChangeListener(listener) {
|
647
|
-
_listeners.push(listener);
|
648
|
-
|
649
|
-
// Do this BEFORE listening for hashchange.
|
650
|
-
ensureSlash();
|
651
|
-
|
652
|
-
if (!_isListening) {
|
653
|
-
if (window.addEventListener) {
|
654
|
-
window.addEventListener('hashchange', onHashChange, false);
|
655
|
-
} else {
|
656
|
-
window.attachEvent('onhashchange', onHashChange);
|
657
|
-
}
|
658
|
-
|
659
|
-
_isListening = true;
|
660
|
-
}
|
661
|
-
},
|
662
|
-
|
663
|
-
removeChangeListener: function removeChangeListener(listener) {
|
664
|
-
_listeners = _listeners.filter(function (l) {
|
665
|
-
return l !== listener;
|
666
|
-
});
|
667
|
-
|
668
|
-
if (_listeners.length === 0) {
|
669
|
-
if (window.removeEventListener) {
|
670
|
-
window.removeEventListener('hashchange', onHashChange, false);
|
671
|
-
} else {
|
672
|
-
window.removeEvent('onhashchange', onHashChange);
|
673
|
-
}
|
674
|
-
|
675
|
-
_isListening = false;
|
676
|
-
}
|
677
|
-
},
|
678
|
-
|
679
|
-
push: function push(path) {
|
680
|
-
_actionType = LocationActions.PUSH;
|
681
|
-
window.location.hash = path;
|
682
|
-
},
|
683
|
-
|
684
|
-
replace: function replace(path) {
|
685
|
-
_actionType = LocationActions.REPLACE;
|
686
|
-
window.location.replace(window.location.pathname + window.location.search + '#' + path);
|
687
|
-
},
|
688
|
-
|
689
|
-
pop: function pop() {
|
690
|
-
_actionType = LocationActions.POP;
|
691
|
-
History.back();
|
692
|
-
},
|
693
|
-
|
694
|
-
getCurrentPath: function getCurrentPath() {
|
695
|
-
return decodeURI(
|
696
|
-
// We can't use window.location.hash here because it's not
|
697
|
-
// consistent across browsers - Firefox will pre-decode it!
|
698
|
-
window.location.href.split('#')[1] || '');
|
699
|
-
},
|
700
|
-
|
701
|
-
toString: function toString() {
|
702
|
-
return '<HashLocation>';
|
703
|
-
}
|
704
|
-
|
705
|
-
};
|
706
|
-
|
707
|
-
module.exports = HashLocation;
|
708
|
-
|
709
|
-
/***/ },
|
710
|
-
/* 8 */
|
711
|
-
/***/ function(module, exports, __webpack_require__) {
|
712
|
-
|
713
|
-
'use strict';
|
714
|
-
|
715
|
-
var LocationActions = __webpack_require__(24);
|
716
|
-
var History = __webpack_require__(14);
|
717
|
-
|
718
|
-
var _listeners = [];
|
719
|
-
var _isListening = false;
|
720
|
-
|
721
|
-
function notifyChange(type) {
|
722
|
-
var change = {
|
723
|
-
path: HistoryLocation.getCurrentPath(),
|
724
|
-
type: type
|
725
|
-
};
|
726
|
-
|
727
|
-
_listeners.forEach(function (listener) {
|
728
|
-
listener.call(HistoryLocation, change);
|
729
|
-
});
|
730
|
-
}
|
731
|
-
|
732
|
-
function onPopState(event) {
|
733
|
-
if (event.state === undefined) {
|
734
|
-
return;
|
735
|
-
} // Ignore extraneous popstate events in WebKit.
|
736
|
-
|
737
|
-
notifyChange(LocationActions.POP);
|
738
|
-
}
|
739
|
-
|
740
|
-
/**
|
741
|
-
* A Location that uses HTML5 history.
|
742
|
-
*/
|
743
|
-
var HistoryLocation = {
|
744
|
-
|
745
|
-
addChangeListener: function addChangeListener(listener) {
|
746
|
-
_listeners.push(listener);
|
747
|
-
|
748
|
-
if (!_isListening) {
|
749
|
-
if (window.addEventListener) {
|
750
|
-
window.addEventListener('popstate', onPopState, false);
|
751
|
-
} else {
|
752
|
-
window.attachEvent('onpopstate', onPopState);
|
753
|
-
}
|
754
|
-
|
755
|
-
_isListening = true;
|
756
|
-
}
|
757
|
-
},
|
758
|
-
|
759
|
-
removeChangeListener: function removeChangeListener(listener) {
|
760
|
-
_listeners = _listeners.filter(function (l) {
|
761
|
-
return l !== listener;
|
762
|
-
});
|
763
|
-
|
764
|
-
if (_listeners.length === 0) {
|
765
|
-
if (window.addEventListener) {
|
766
|
-
window.removeEventListener('popstate', onPopState, false);
|
767
|
-
} else {
|
768
|
-
window.removeEvent('onpopstate', onPopState);
|
769
|
-
}
|
770
|
-
|
771
|
-
_isListening = false;
|
772
|
-
}
|
773
|
-
},
|
774
|
-
|
775
|
-
push: function push(path) {
|
776
|
-
window.history.pushState({ path: path }, '', path);
|
777
|
-
History.length += 1;
|
778
|
-
notifyChange(LocationActions.PUSH);
|
779
|
-
},
|
780
|
-
|
781
|
-
replace: function replace(path) {
|
782
|
-
window.history.replaceState({ path: path }, '', path);
|
783
|
-
notifyChange(LocationActions.REPLACE);
|
784
|
-
},
|
785
|
-
|
786
|
-
pop: History.back,
|
787
|
-
|
788
|
-
getCurrentPath: function getCurrentPath() {
|
789
|
-
return decodeURI(window.location.pathname + window.location.search);
|
790
|
-
},
|
791
|
-
|
792
|
-
toString: function toString() {
|
793
|
-
return '<HistoryLocation>';
|
794
|
-
}
|
795
|
-
|
796
|
-
};
|
797
|
-
|
798
|
-
module.exports = HistoryLocation;
|
799
|
-
|
800
|
-
/***/ },
|
801
|
-
/* 9 */
|
802
|
-
/***/ function(module, exports, __webpack_require__) {
|
803
|
-
|
804
|
-
'use strict';
|
805
|
-
|
806
|
-
var HistoryLocation = __webpack_require__(8);
|
807
|
-
var History = __webpack_require__(14);
|
808
|
-
|
809
|
-
/**
|
810
|
-
* A Location that uses full page refreshes. This is used as
|
811
|
-
* the fallback for HistoryLocation in browsers that do not
|
812
|
-
* support the HTML5 history API.
|
813
|
-
*/
|
814
|
-
var RefreshLocation = {
|
815
|
-
|
816
|
-
push: function push(path) {
|
817
|
-
window.location = path;
|
818
|
-
},
|
819
|
-
|
820
|
-
replace: function replace(path) {
|
821
|
-
window.location.replace(path);
|
822
|
-
},
|
823
|
-
|
824
|
-
pop: History.back,
|
825
|
-
|
826
|
-
getCurrentPath: HistoryLocation.getCurrentPath,
|
827
|
-
|
828
|
-
toString: function toString() {
|
829
|
-
return '<RefreshLocation>';
|
830
|
-
}
|
831
|
-
|
832
|
-
};
|
833
|
-
|
834
|
-
module.exports = RefreshLocation;
|
835
|
-
|
836
|
-
/***/ },
|
837
|
-
/* 10 */
|
838
|
-
/***/ function(module, exports, __webpack_require__) {
|
839
|
-
|
840
|
-
'use strict';
|
841
|
-
|
842
|
-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
843
|
-
|
844
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
845
|
-
|
846
|
-
var invariant = __webpack_require__(34);
|
847
|
-
|
848
|
-
function throwCannotModify() {
|
849
|
-
invariant(false, 'You cannot modify a static location');
|
850
|
-
}
|
851
|
-
|
852
|
-
/**
|
853
|
-
* A location that only ever contains a single path. Useful in
|
854
|
-
* stateless environments like servers where there is no path history,
|
855
|
-
* only the path that was used in the request.
|
856
|
-
*/
|
857
|
-
|
858
|
-
var StaticLocation = (function () {
|
859
|
-
function StaticLocation(path) {
|
860
|
-
_classCallCheck(this, StaticLocation);
|
861
|
-
|
862
|
-
this.path = path;
|
863
|
-
}
|
864
|
-
|
865
|
-
_createClass(StaticLocation, [{
|
866
|
-
key: 'getCurrentPath',
|
867
|
-
value: function getCurrentPath() {
|
868
|
-
return this.path;
|
869
|
-
}
|
870
|
-
}, {
|
871
|
-
key: 'toString',
|
872
|
-
value: function toString() {
|
873
|
-
return '<StaticLocation path="' + this.path + '">';
|
874
|
-
}
|
875
|
-
}]);
|
876
|
-
|
877
|
-
return StaticLocation;
|
878
|
-
})();
|
879
|
-
|
880
|
-
// TODO: Include these in the above class definition
|
881
|
-
// once we can use ES7 property initializers.
|
882
|
-
// https://github.com/babel/babel/issues/619
|
883
|
-
|
884
|
-
StaticLocation.prototype.push = throwCannotModify;
|
885
|
-
StaticLocation.prototype.replace = throwCannotModify;
|
886
|
-
StaticLocation.prototype.pop = throwCannotModify;
|
887
|
-
|
888
|
-
module.exports = StaticLocation;
|
889
|
-
|
890
|
-
/***/ },
|
891
|
-
/* 11 */
|
892
|
-
/***/ function(module, exports, __webpack_require__) {
|
893
|
-
|
894
|
-
'use strict';
|
895
|
-
|
896
|
-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
897
|
-
|
898
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
899
|
-
|
900
|
-
var invariant = __webpack_require__(34);
|
901
|
-
var LocationActions = __webpack_require__(24);
|
902
|
-
var History = __webpack_require__(14);
|
903
|
-
|
904
|
-
/**
|
905
|
-
* A location that is convenient for testing and does not require a DOM.
|
906
|
-
*/
|
907
|
-
|
908
|
-
var TestLocation = (function () {
|
909
|
-
function TestLocation(history) {
|
910
|
-
_classCallCheck(this, TestLocation);
|
911
|
-
|
912
|
-
this.history = history || [];
|
913
|
-
this.listeners = [];
|
914
|
-
this._updateHistoryLength();
|
915
|
-
}
|
916
|
-
|
917
|
-
_createClass(TestLocation, [{
|
918
|
-
key: 'needsDOM',
|
919
|
-
get: function () {
|
920
|
-
return false;
|
921
|
-
}
|
922
|
-
}, {
|
923
|
-
key: '_updateHistoryLength',
|
924
|
-
value: function _updateHistoryLength() {
|
925
|
-
History.length = this.history.length;
|
926
|
-
}
|
927
|
-
}, {
|
928
|
-
key: '_notifyChange',
|
929
|
-
value: function _notifyChange(type) {
|
930
|
-
var change = {
|
931
|
-
path: this.getCurrentPath(),
|
932
|
-
type: type
|
933
|
-
};
|
934
|
-
|
935
|
-
for (var i = 0, len = this.listeners.length; i < len; ++i) this.listeners[i].call(this, change);
|
936
|
-
}
|
937
|
-
}, {
|
938
|
-
key: 'addChangeListener',
|
939
|
-
value: function addChangeListener(listener) {
|
940
|
-
this.listeners.push(listener);
|
941
|
-
}
|
942
|
-
}, {
|
943
|
-
key: 'removeChangeListener',
|
944
|
-
value: function removeChangeListener(listener) {
|
945
|
-
this.listeners = this.listeners.filter(function (l) {
|
946
|
-
return l !== listener;
|
947
|
-
});
|
948
|
-
}
|
949
|
-
}, {
|
950
|
-
key: 'push',
|
951
|
-
value: function push(path) {
|
952
|
-
this.history.push(path);
|
953
|
-
this._updateHistoryLength();
|
954
|
-
this._notifyChange(LocationActions.PUSH);
|
955
|
-
}
|
956
|
-
}, {
|
957
|
-
key: 'replace',
|
958
|
-
value: function replace(path) {
|
959
|
-
invariant(this.history.length, 'You cannot replace the current path with no history');
|
960
|
-
|
961
|
-
this.history[this.history.length - 1] = path;
|
962
|
-
|
963
|
-
this._notifyChange(LocationActions.REPLACE);
|
964
|
-
}
|
965
|
-
}, {
|
966
|
-
key: 'pop',
|
967
|
-
value: function pop() {
|
968
|
-
this.history.pop();
|
969
|
-
this._updateHistoryLength();
|
970
|
-
this._notifyChange(LocationActions.POP);
|
971
|
-
}
|
972
|
-
}, {
|
973
|
-
key: 'getCurrentPath',
|
974
|
-
value: function getCurrentPath() {
|
975
|
-
return this.history[this.history.length - 1];
|
976
|
-
}
|
977
|
-
}, {
|
978
|
-
key: 'toString',
|
979
|
-
value: function toString() {
|
980
|
-
return '<TestLocation>';
|
981
|
-
}
|
982
|
-
}]);
|
983
|
-
|
984
|
-
return TestLocation;
|
985
|
-
})();
|
986
|
-
|
987
|
-
module.exports = TestLocation;
|
988
|
-
|
989
|
-
/***/ },
|
990
|
-
/* 12 */
|
991
|
-
/***/ function(module, exports, __webpack_require__) {
|
992
|
-
|
993
|
-
'use strict';
|
994
|
-
|
995
|
-
var LocationActions = __webpack_require__(24);
|
996
|
-
|
997
|
-
/**
|
998
|
-
* A scroll behavior that attempts to imitate the default behavior
|
999
|
-
* of modern browsers.
|
1000
|
-
*/
|
1001
|
-
var ImitateBrowserBehavior = {
|
1002
|
-
|
1003
|
-
updateScrollPosition: function updateScrollPosition(position, actionType) {
|
1004
|
-
switch (actionType) {
|
1005
|
-
case LocationActions.PUSH:
|
1006
|
-
case LocationActions.REPLACE:
|
1007
|
-
window.scrollTo(0, 0);
|
1008
|
-
break;
|
1009
|
-
case LocationActions.POP:
|
1010
|
-
if (position) {
|
1011
|
-
window.scrollTo(position.x, position.y);
|
1012
|
-
} else {
|
1013
|
-
window.scrollTo(0, 0);
|
1014
|
-
}
|
1015
|
-
break;
|
1016
|
-
}
|
1017
|
-
}
|
1018
|
-
|
1019
|
-
};
|
1020
|
-
|
1021
|
-
module.exports = ImitateBrowserBehavior;
|
1022
|
-
|
1023
|
-
/***/ },
|
1024
|
-
/* 13 */
|
1025
|
-
/***/ function(module, exports, __webpack_require__) {
|
1026
|
-
|
1027
|
-
/**
|
1028
|
-
* A scroll behavior that always scrolls to the top of the page
|
1029
|
-
* after a transition.
|
1030
|
-
*/
|
1031
|
-
"use strict";
|
1032
|
-
|
1033
|
-
var ScrollToTopBehavior = {
|
1034
|
-
|
1035
|
-
updateScrollPosition: function updateScrollPosition() {
|
1036
|
-
window.scrollTo(0, 0);
|
1037
|
-
}
|
1038
|
-
|
1039
|
-
};
|
1040
|
-
|
1041
|
-
module.exports = ScrollToTopBehavior;
|
1042
|
-
|
1043
|
-
/***/ },
|
1044
|
-
/* 14 */
|
1045
|
-
/***/ function(module, exports, __webpack_require__) {
|
1046
|
-
|
1047
|
-
'use strict';
|
1048
|
-
|
1049
|
-
var invariant = __webpack_require__(34);
|
1050
|
-
var canUseDOM = __webpack_require__(35).canUseDOM;
|
1051
|
-
|
1052
|
-
var History = {
|
1053
|
-
|
1054
|
-
/**
|
1055
|
-
* The current number of entries in the history.
|
1056
|
-
*
|
1057
|
-
* Note: This property is read-only.
|
1058
|
-
*/
|
1059
|
-
length: 1,
|
1060
|
-
|
1061
|
-
/**
|
1062
|
-
* Sends the browser back one entry in the history.
|
1063
|
-
*/
|
1064
|
-
back: function back() {
|
1065
|
-
invariant(canUseDOM, 'Cannot use History.back without a DOM');
|
1066
|
-
|
1067
|
-
// Do this first so that History.length will
|
1068
|
-
// be accurate in location change listeners.
|
1069
|
-
History.length -= 1;
|
1070
|
-
|
1071
|
-
window.history.back();
|
1072
|
-
}
|
1073
|
-
|
1074
|
-
};
|
1075
|
-
|
1076
|
-
module.exports = History;
|
1077
|
-
|
1078
|
-
/***/ },
|
1079
|
-
/* 15 */
|
1080
|
-
/***/ function(module, exports, __webpack_require__) {
|
1081
|
-
|
1082
|
-
'use strict';
|
1083
|
-
|
1084
|
-
var PropTypes = __webpack_require__(22);
|
1085
|
-
|
1086
|
-
/**
|
1087
|
-
* A mixin for components that modify the URL.
|
1088
|
-
*
|
1089
|
-
* Example:
|
1090
|
-
*
|
1091
|
-
* var MyLink = React.createClass({
|
1092
|
-
* mixins: [ Router.Navigation ],
|
1093
|
-
* handleClick(event) {
|
1094
|
-
* event.preventDefault();
|
1095
|
-
* this.transitionTo('aRoute', { the: 'params' }, { the: 'query' });
|
1096
|
-
* },
|
1097
|
-
* render() {
|
1098
|
-
* return (
|
1099
|
-
* <a onClick={this.handleClick}>Click me!</a>
|
1100
|
-
* );
|
1101
|
-
* }
|
1102
|
-
* });
|
1103
|
-
*/
|
1104
|
-
var Navigation = {
|
1105
|
-
|
1106
|
-
contextTypes: {
|
1107
|
-
router: PropTypes.router.isRequired
|
1108
|
-
},
|
1109
|
-
|
1110
|
-
/**
|
1111
|
-
* Returns an absolute URL path created from the given route
|
1112
|
-
* name, URL parameters, and query values.
|
1113
|
-
*/
|
1114
|
-
makePath: function makePath(to, params, query) {
|
1115
|
-
return this.context.router.makePath(to, params, query);
|
1116
|
-
},
|
1117
|
-
|
1118
|
-
/**
|
1119
|
-
* Returns a string that may safely be used as the href of a
|
1120
|
-
* link to the route with the given name.
|
1121
|
-
*/
|
1122
|
-
makeHref: function makeHref(to, params, query) {
|
1123
|
-
return this.context.router.makeHref(to, params, query);
|
1124
|
-
},
|
1125
|
-
|
1126
|
-
/**
|
1127
|
-
* Transitions to the URL specified in the arguments by pushing
|
1128
|
-
* a new URL onto the history stack.
|
1129
|
-
*/
|
1130
|
-
transitionTo: function transitionTo(to, params, query) {
|
1131
|
-
this.context.router.transitionTo(to, params, query);
|
1132
|
-
},
|
1133
|
-
|
1134
|
-
/**
|
1135
|
-
* Transitions to the URL specified in the arguments by replacing
|
1136
|
-
* the current URL in the history stack.
|
1137
|
-
*/
|
1138
|
-
replaceWith: function replaceWith(to, params, query) {
|
1139
|
-
this.context.router.replaceWith(to, params, query);
|
1140
|
-
},
|
1141
|
-
|
1142
|
-
/**
|
1143
|
-
* Transitions to the previous URL.
|
1144
|
-
*/
|
1145
|
-
goBack: function goBack() {
|
1146
|
-
return this.context.router.goBack();
|
1147
|
-
}
|
1148
|
-
|
1149
|
-
};
|
1150
|
-
|
1151
|
-
module.exports = Navigation;
|
1152
|
-
|
1153
|
-
/***/ },
|
1154
|
-
/* 16 */
|
1155
|
-
/***/ function(module, exports, __webpack_require__) {
|
1156
|
-
|
1157
|
-
'use strict';
|
1158
|
-
|
1159
|
-
var PropTypes = __webpack_require__(22);
|
1160
|
-
|
1161
|
-
/**
|
1162
|
-
* A mixin for components that need to know the path, routes, URL
|
1163
|
-
* params and query that are currently active.
|
1164
|
-
*
|
1165
|
-
* Example:
|
1166
|
-
*
|
1167
|
-
* var AboutLink = React.createClass({
|
1168
|
-
* mixins: [ Router.State ],
|
1169
|
-
* render() {
|
1170
|
-
* var className = this.props.className;
|
1171
|
-
*
|
1172
|
-
* if (this.isActive('about'))
|
1173
|
-
* className += ' is-active';
|
1174
|
-
*
|
1175
|
-
* return React.DOM.a({ className: className }, this.props.children);
|
1176
|
-
* }
|
1177
|
-
* });
|
1178
|
-
*/
|
1179
|
-
var State = {
|
1180
|
-
|
1181
|
-
contextTypes: {
|
1182
|
-
router: PropTypes.router.isRequired
|
1183
|
-
},
|
1184
|
-
|
1185
|
-
/**
|
1186
|
-
* Returns the current URL path.
|
1187
|
-
*/
|
1188
|
-
getPath: function getPath() {
|
1189
|
-
return this.context.router.getCurrentPath();
|
1190
|
-
},
|
1191
|
-
|
1192
|
-
/**
|
1193
|
-
* Returns the current URL path without the query string.
|
1194
|
-
*/
|
1195
|
-
getPathname: function getPathname() {
|
1196
|
-
return this.context.router.getCurrentPathname();
|
1197
|
-
},
|
1198
|
-
|
1199
|
-
/**
|
1200
|
-
* Returns an object of the URL params that are currently active.
|
1201
|
-
*/
|
1202
|
-
getParams: function getParams() {
|
1203
|
-
return this.context.router.getCurrentParams();
|
1204
|
-
},
|
1205
|
-
|
1206
|
-
/**
|
1207
|
-
* Returns an object of the query params that are currently active.
|
1208
|
-
*/
|
1209
|
-
getQuery: function getQuery() {
|
1210
|
-
return this.context.router.getCurrentQuery();
|
1211
|
-
},
|
1212
|
-
|
1213
|
-
/**
|
1214
|
-
* Returns an array of the routes that are currently active.
|
1215
|
-
*/
|
1216
|
-
getRoutes: function getRoutes() {
|
1217
|
-
return this.context.router.getCurrentRoutes();
|
1218
|
-
},
|
1219
|
-
|
1220
|
-
/**
|
1221
|
-
* A helper method to determine if a given route, params, and query
|
1222
|
-
* are active.
|
1223
|
-
*/
|
1224
|
-
isActive: function isActive(to, params, query) {
|
1225
|
-
return this.context.router.isActive(to, params, query);
|
1226
|
-
}
|
1227
|
-
|
1228
|
-
};
|
1229
|
-
|
1230
|
-
module.exports = State;
|
1231
|
-
|
1232
|
-
/***/ },
|
1233
|
-
/* 17 */
|
1234
|
-
/***/ function(module, exports, __webpack_require__) {
|
1235
|
-
|
1236
|
-
'use strict';
|
1237
|
-
|
1238
|
-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
1239
|
-
|
1240
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
1241
|
-
|
1242
|
-
var assign = __webpack_require__(33);
|
1243
|
-
var invariant = __webpack_require__(34);
|
1244
|
-
var warning = __webpack_require__(36);
|
1245
|
-
var PathUtils = __webpack_require__(25);
|
1246
|
-
|
1247
|
-
var _currentRoute;
|
1248
|
-
|
1249
|
-
var Route = (function () {
|
1250
|
-
function Route(name, path, ignoreScrollBehavior, isDefault, isNotFound, onEnter, onLeave, handler) {
|
1251
|
-
_classCallCheck(this, Route);
|
1252
|
-
|
1253
|
-
this.name = name;
|
1254
|
-
this.path = path;
|
1255
|
-
this.paramNames = PathUtils.extractParamNames(this.path);
|
1256
|
-
this.ignoreScrollBehavior = !!ignoreScrollBehavior;
|
1257
|
-
this.isDefault = !!isDefault;
|
1258
|
-
this.isNotFound = !!isNotFound;
|
1259
|
-
this.onEnter = onEnter;
|
1260
|
-
this.onLeave = onLeave;
|
1261
|
-
this.handler = handler;
|
1262
|
-
}
|
1263
|
-
|
1264
|
-
_createClass(Route, [{
|
1265
|
-
key: 'appendChild',
|
1266
|
-
|
1267
|
-
/**
|
1268
|
-
* Appends the given route to this route's child routes.
|
1269
|
-
*/
|
1270
|
-
value: function appendChild(route) {
|
1271
|
-
invariant(route instanceof Route, 'route.appendChild must use a valid Route');
|
1272
|
-
|
1273
|
-
if (!this.childRoutes) this.childRoutes = [];
|
1274
|
-
|
1275
|
-
this.childRoutes.push(route);
|
1276
|
-
}
|
1277
|
-
}, {
|
1278
|
-
key: 'toString',
|
1279
|
-
value: function toString() {
|
1280
|
-
var string = '<Route';
|
1281
|
-
|
1282
|
-
if (this.name) string += ' name="' + this.name + '"';
|
1283
|
-
|
1284
|
-
string += ' path="' + this.path + '">';
|
1285
|
-
|
1286
|
-
return string;
|
1287
|
-
}
|
1288
|
-
}], [{
|
1289
|
-
key: 'createRoute',
|
1290
|
-
|
1291
|
-
/**
|
1292
|
-
* Creates and returns a new route. Options may be a URL pathname string
|
1293
|
-
* with placeholders for named params or an object with any of the following
|
1294
|
-
* properties:
|
1295
|
-
*
|
1296
|
-
* - name The name of the route. This is used to lookup a
|
1297
|
-
* route relative to its parent route and should be
|
1298
|
-
* unique among all child routes of the same parent
|
1299
|
-
* - path A URL pathname string with optional placeholders
|
1300
|
-
* that specify the names of params to extract from
|
1301
|
-
* the URL when the path matches. Defaults to `/${name}`
|
1302
|
-
* when there is a name given, or the path of the parent
|
1303
|
-
* route, or /
|
1304
|
-
* - ignoreScrollBehavior True to make this route (and all descendants) ignore
|
1305
|
-
* the scroll behavior of the router
|
1306
|
-
* - isDefault True to make this route the default route among all
|
1307
|
-
* its siblings
|
1308
|
-
* - isNotFound True to make this route the "not found" route among
|
1309
|
-
* all its siblings
|
1310
|
-
* - onEnter A transition hook that will be called when the
|
1311
|
-
* router is going to enter this route
|
1312
|
-
* - onLeave A transition hook that will be called when the
|
1313
|
-
* router is going to leave this route
|
1314
|
-
* - handler A React component that will be rendered when
|
1315
|
-
* this route is active
|
1316
|
-
* - parentRoute The parent route to use for this route. This option
|
1317
|
-
* is automatically supplied when creating routes inside
|
1318
|
-
* the callback to another invocation of createRoute. You
|
1319
|
-
* only ever need to use this when declaring routes
|
1320
|
-
* independently of one another to manually piece together
|
1321
|
-
* the route hierarchy
|
1322
|
-
*
|
1323
|
-
* The callback may be used to structure your route hierarchy. Any call to
|
1324
|
-
* createRoute, createDefaultRoute, createNotFoundRoute, or createRedirect
|
1325
|
-
* inside the callback automatically uses this route as its parent.
|
1326
|
-
*/
|
1327
|
-
value: function createRoute(options, callback) {
|
1328
|
-
options = options || {};
|
1329
|
-
|
1330
|
-
if (typeof options === 'string') options = { path: options };
|
1331
|
-
|
1332
|
-
var parentRoute = _currentRoute;
|
1333
|
-
|
1334
|
-
if (parentRoute) {
|
1335
|
-
warning(options.parentRoute == null || options.parentRoute === parentRoute, 'You should not use parentRoute with createRoute inside another route\'s child callback; it is ignored');
|
1336
|
-
} else {
|
1337
|
-
parentRoute = options.parentRoute;
|
1338
|
-
}
|
1339
|
-
|
1340
|
-
var name = options.name;
|
1341
|
-
var path = options.path || name;
|
1342
|
-
|
1343
|
-
if (path && !(options.isDefault || options.isNotFound)) {
|
1344
|
-
if (PathUtils.isAbsolute(path)) {
|
1345
|
-
if (parentRoute) {
|
1346
|
-
invariant(path === parentRoute.path || parentRoute.paramNames.length === 0, 'You cannot nest path "%s" inside "%s"; the parent requires URL parameters', path, parentRoute.path);
|
1347
|
-
}
|
1348
|
-
} else if (parentRoute) {
|
1349
|
-
// Relative paths extend their parent.
|
1350
|
-
path = PathUtils.join(parentRoute.path, path);
|
1351
|
-
} else {
|
1352
|
-
path = '/' + path;
|
1353
|
-
}
|
1354
|
-
} else {
|
1355
|
-
path = parentRoute ? parentRoute.path : '/';
|
1356
|
-
}
|
1357
|
-
|
1358
|
-
if (options.isNotFound && !/\*$/.test(path)) path += '*'; // Auto-append * to the path of not found routes.
|
1359
|
-
|
1360
|
-
var route = new Route(name, path, options.ignoreScrollBehavior, options.isDefault, options.isNotFound, options.onEnter, options.onLeave, options.handler);
|
1361
|
-
|
1362
|
-
if (parentRoute) {
|
1363
|
-
if (route.isDefault) {
|
1364
|
-
invariant(parentRoute.defaultRoute == null, '%s may not have more than one default route', parentRoute);
|
1365
|
-
|
1366
|
-
parentRoute.defaultRoute = route;
|
1367
|
-
} else if (route.isNotFound) {
|
1368
|
-
invariant(parentRoute.notFoundRoute == null, '%s may not have more than one not found route', parentRoute);
|
1369
|
-
|
1370
|
-
parentRoute.notFoundRoute = route;
|
1371
|
-
}
|
1372
|
-
|
1373
|
-
parentRoute.appendChild(route);
|
1374
|
-
}
|
1375
|
-
|
1376
|
-
// Any routes created in the callback
|
1377
|
-
// use this route as their parent.
|
1378
|
-
if (typeof callback === 'function') {
|
1379
|
-
var currentRoute = _currentRoute;
|
1380
|
-
_currentRoute = route;
|
1381
|
-
callback.call(route, route);
|
1382
|
-
_currentRoute = currentRoute;
|
1383
|
-
}
|
1384
|
-
|
1385
|
-
return route;
|
1386
|
-
}
|
1387
|
-
}, {
|
1388
|
-
key: 'createDefaultRoute',
|
1389
|
-
|
1390
|
-
/**
|
1391
|
-
* Creates and returns a route that is rendered when its parent matches
|
1392
|
-
* the current URL.
|
1393
|
-
*/
|
1394
|
-
value: function createDefaultRoute(options) {
|
1395
|
-
return Route.createRoute(assign({}, options, { isDefault: true }));
|
1396
|
-
}
|
1397
|
-
}, {
|
1398
|
-
key: 'createNotFoundRoute',
|
1399
|
-
|
1400
|
-
/**
|
1401
|
-
* Creates and returns a route that is rendered when its parent matches
|
1402
|
-
* the current URL but none of its siblings do.
|
1403
|
-
*/
|
1404
|
-
value: function createNotFoundRoute(options) {
|
1405
|
-
return Route.createRoute(assign({}, options, { isNotFound: true }));
|
1406
|
-
}
|
1407
|
-
}, {
|
1408
|
-
key: 'createRedirect',
|
1409
|
-
|
1410
|
-
/**
|
1411
|
-
* Creates and returns a route that automatically redirects the transition
|
1412
|
-
* to another route. In addition to the normal options to createRoute, this
|
1413
|
-
* function accepts the following options:
|
1414
|
-
*
|
1415
|
-
* - from An alias for the `path` option. Defaults to *
|
1416
|
-
* - to The path/route/route name to redirect to
|
1417
|
-
* - params The params to use in the redirect URL. Defaults
|
1418
|
-
* to using the current params
|
1419
|
-
* - query The query to use in the redirect URL. Defaults
|
1420
|
-
* to using the current query
|
1421
|
-
*/
|
1422
|
-
value: function createRedirect(options) {
|
1423
|
-
return Route.createRoute(assign({}, options, {
|
1424
|
-
path: options.path || options.from || '*',
|
1425
|
-
onEnter: function onEnter(transition, params, query) {
|
1426
|
-
transition.redirect(options.to, options.params || params, options.query || query);
|
1427
|
-
}
|
1428
|
-
}));
|
1429
|
-
}
|
1430
|
-
}]);
|
1431
|
-
|
1432
|
-
return Route;
|
1433
|
-
})();
|
1434
|
-
|
1435
|
-
module.exports = Route;
|
1436
|
-
|
1437
|
-
/***/ },
|
1438
|
-
/* 18 */
|
1439
|
-
/***/ function(module, exports, __webpack_require__) {
|
1440
|
-
|
1441
|
-
/* jshint -W084 */
|
1442
|
-
'use strict';
|
1443
|
-
|
1444
|
-
var React = __webpack_require__(21);
|
1445
|
-
var assign = __webpack_require__(33);
|
1446
|
-
var warning = __webpack_require__(36);
|
1447
|
-
var DefaultRoute = __webpack_require__(1);
|
1448
|
-
var NotFoundRoute = __webpack_require__(3);
|
1449
|
-
var Redirect = __webpack_require__(4);
|
1450
|
-
var Route = __webpack_require__(17);
|
1451
|
-
|
1452
|
-
function checkPropTypes(componentName, propTypes, props) {
|
1453
|
-
componentName = componentName || 'UnknownComponent';
|
1454
|
-
|
1455
|
-
for (var propName in propTypes) {
|
1456
|
-
if (propTypes.hasOwnProperty(propName)) {
|
1457
|
-
var error = propTypes[propName](props, propName, componentName);
|
1458
|
-
|
1459
|
-
if (error instanceof Error) warning(false, error.message);
|
1460
|
-
}
|
1461
|
-
}
|
1462
|
-
}
|
1463
|
-
|
1464
|
-
function createRouteOptions(props) {
|
1465
|
-
var options = assign({}, props);
|
1466
|
-
var handler = options.handler;
|
1467
|
-
|
1468
|
-
if (handler) {
|
1469
|
-
options.onEnter = handler.willTransitionTo;
|
1470
|
-
options.onLeave = handler.willTransitionFrom;
|
1471
|
-
}
|
1472
|
-
|
1473
|
-
return options;
|
1474
|
-
}
|
1475
|
-
|
1476
|
-
function createRouteFromReactElement(element) {
|
1477
|
-
if (!React.isValidElement(element)) {
|
1478
|
-
return;
|
1479
|
-
}var type = element.type;
|
1480
|
-
var props = assign({}, type.defaultProps, element.props);
|
1481
|
-
|
1482
|
-
if (type.propTypes) checkPropTypes(type.displayName, type.propTypes, props);
|
1483
|
-
|
1484
|
-
if (type === DefaultRoute) {
|
1485
|
-
return Route.createDefaultRoute(createRouteOptions(props));
|
1486
|
-
}if (type === NotFoundRoute) {
|
1487
|
-
return Route.createNotFoundRoute(createRouteOptions(props));
|
1488
|
-
}if (type === Redirect) {
|
1489
|
-
return Route.createRedirect(createRouteOptions(props));
|
1490
|
-
}return Route.createRoute(createRouteOptions(props), function () {
|
1491
|
-
if (props.children) createRoutesFromReactChildren(props.children);
|
1492
|
-
});
|
1493
|
-
}
|
1494
|
-
|
1495
|
-
/**
|
1496
|
-
* Creates and returns an array of routes created from the given
|
1497
|
-
* ReactChildren, all of which should be one of <Route>, <DefaultRoute>,
|
1498
|
-
* <NotFoundRoute>, or <Redirect>, e.g.:
|
1499
|
-
*
|
1500
|
-
* var { createRoutesFromReactChildren, Route, Redirect } = require('react-router');
|
1501
|
-
*
|
1502
|
-
* var routes = createRoutesFromReactChildren(
|
1503
|
-
* <Route path="/" handler={App}>
|
1504
|
-
* <Route name="user" path="/user/:userId" handler={User}>
|
1505
|
-
* <Route name="task" path="tasks/:taskId" handler={Task}/>
|
1506
|
-
* <Redirect from="todos/:taskId" to="task"/>
|
1507
|
-
* </Route>
|
1508
|
-
* </Route>
|
1509
|
-
* );
|
1510
|
-
*/
|
1511
|
-
function createRoutesFromReactChildren(children) {
|
1512
|
-
var routes = [];
|
1513
|
-
|
1514
|
-
React.Children.forEach(children, function (child) {
|
1515
|
-
if (child = createRouteFromReactElement(child)) routes.push(child);
|
1516
|
-
});
|
1517
|
-
|
1518
|
-
return routes;
|
1519
|
-
}
|
1520
|
-
|
1521
|
-
module.exports = createRoutesFromReactChildren;
|
1522
|
-
|
1523
|
-
/***/ },
|
1524
|
-
/* 19 */
|
1525
|
-
/***/ function(module, exports, __webpack_require__) {
|
1526
|
-
|
1527
|
-
/* jshint -W058 */
|
1528
|
-
'use strict';
|
1529
|
-
|
1530
|
-
var React = __webpack_require__(21);
|
1531
|
-
var warning = __webpack_require__(36);
|
1532
|
-
var invariant = __webpack_require__(34);
|
1533
|
-
var canUseDOM = __webpack_require__(35).canUseDOM;
|
1534
|
-
var LocationActions = __webpack_require__(24);
|
1535
|
-
var ImitateBrowserBehavior = __webpack_require__(12);
|
1536
|
-
var HashLocation = __webpack_require__(7);
|
1537
|
-
var HistoryLocation = __webpack_require__(8);
|
1538
|
-
var RefreshLocation = __webpack_require__(9);
|
1539
|
-
var StaticLocation = __webpack_require__(10);
|
1540
|
-
var ScrollHistory = __webpack_require__(26);
|
1541
|
-
var createRoutesFromReactChildren = __webpack_require__(18);
|
1542
|
-
var isReactChildren = __webpack_require__(27);
|
1543
|
-
var Transition = __webpack_require__(28);
|
1544
|
-
var PropTypes = __webpack_require__(22);
|
1545
|
-
var Redirect = __webpack_require__(29);
|
1546
|
-
var History = __webpack_require__(14);
|
1547
|
-
var Cancellation = __webpack_require__(30);
|
1548
|
-
var Match = __webpack_require__(31);
|
1549
|
-
var Route = __webpack_require__(17);
|
1550
|
-
var supportsHistory = __webpack_require__(32);
|
1551
|
-
var PathUtils = __webpack_require__(25);
|
1552
|
-
|
1553
|
-
/**
|
1554
|
-
* The default location for new routers.
|
1555
|
-
*/
|
1556
|
-
var DEFAULT_LOCATION = canUseDOM ? HashLocation : '/';
|
1557
|
-
|
1558
|
-
/**
|
1559
|
-
* The default scroll behavior for new routers.
|
1560
|
-
*/
|
1561
|
-
var DEFAULT_SCROLL_BEHAVIOR = canUseDOM ? ImitateBrowserBehavior : null;
|
1562
|
-
|
1563
|
-
function hasProperties(object, properties) {
|
1564
|
-
for (var propertyName in properties) if (properties.hasOwnProperty(propertyName) && object[propertyName] !== properties[propertyName]) {
|
1565
|
-
return false;
|
1566
|
-
}return true;
|
1567
|
-
}
|
1568
|
-
|
1569
|
-
function hasMatch(routes, route, prevParams, nextParams, prevQuery, nextQuery) {
|
1570
|
-
return routes.some(function (r) {
|
1571
|
-
if (r !== route) return false;
|
1572
|
-
|
1573
|
-
var paramNames = route.paramNames;
|
1574
|
-
var paramName;
|
1575
|
-
|
1576
|
-
// Ensure that all params the route cares about did not change.
|
1577
|
-
for (var i = 0, len = paramNames.length; i < len; ++i) {
|
1578
|
-
paramName = paramNames[i];
|
1579
|
-
|
1580
|
-
if (nextParams[paramName] !== prevParams[paramName]) return false;
|
1581
|
-
}
|
1582
|
-
|
1583
|
-
// Ensure the query hasn't changed.
|
1584
|
-
return hasProperties(prevQuery, nextQuery) && hasProperties(nextQuery, prevQuery);
|
1585
|
-
});
|
1586
|
-
}
|
1587
|
-
|
1588
|
-
function addRoutesToNamedRoutes(routes, namedRoutes) {
|
1589
|
-
var route;
|
1590
|
-
for (var i = 0, len = routes.length; i < len; ++i) {
|
1591
|
-
route = routes[i];
|
1592
|
-
|
1593
|
-
if (route.name) {
|
1594
|
-
invariant(namedRoutes[route.name] == null, 'You may not have more than one route named "%s"', route.name);
|
1595
|
-
|
1596
|
-
namedRoutes[route.name] = route;
|
1597
|
-
}
|
1598
|
-
|
1599
|
-
if (route.childRoutes) addRoutesToNamedRoutes(route.childRoutes, namedRoutes);
|
1600
|
-
}
|
1601
|
-
}
|
1602
|
-
|
1603
|
-
function routeIsActive(activeRoutes, routeName) {
|
1604
|
-
return activeRoutes.some(function (route) {
|
1605
|
-
return route.name === routeName;
|
1606
|
-
});
|
1607
|
-
}
|
1608
|
-
|
1609
|
-
function paramsAreActive(activeParams, params) {
|
1610
|
-
for (var property in params) if (String(activeParams[property]) !== String(params[property])) {
|
1611
|
-
return false;
|
1612
|
-
}return true;
|
1613
|
-
}
|
1614
|
-
|
1615
|
-
function queryIsActive(activeQuery, query) {
|
1616
|
-
for (var property in query) if (String(activeQuery[property]) !== String(query[property])) {
|
1617
|
-
return false;
|
1618
|
-
}return true;
|
1619
|
-
}
|
1620
|
-
|
1621
|
-
/**
|
1622
|
-
* Creates and returns a new router using the given options. A router
|
1623
|
-
* is a ReactComponent class that knows how to react to changes in the
|
1624
|
-
* URL and keep the contents of the page in sync.
|
1625
|
-
*
|
1626
|
-
* Options may be any of the following:
|
1627
|
-
*
|
1628
|
-
* - routes (required) The route config
|
1629
|
-
* - location The location to use. Defaults to HashLocation when
|
1630
|
-
* the DOM is available, "/" otherwise
|
1631
|
-
* - scrollBehavior The scroll behavior to use. Defaults to ImitateBrowserBehavior
|
1632
|
-
* when the DOM is available, null otherwise
|
1633
|
-
* - onError A function that is used to handle errors
|
1634
|
-
* - onAbort A function that is used to handle aborted transitions
|
1635
|
-
*
|
1636
|
-
* When rendering in a server-side environment, the location should simply
|
1637
|
-
* be the URL path that was used in the request, including the query string.
|
1638
|
-
*/
|
1639
|
-
function createRouter(options) {
|
1640
|
-
options = options || {};
|
1641
|
-
|
1642
|
-
if (isReactChildren(options)) options = { routes: options };
|
1643
|
-
|
1644
|
-
var mountedComponents = [];
|
1645
|
-
var location = options.location || DEFAULT_LOCATION;
|
1646
|
-
var scrollBehavior = options.scrollBehavior || DEFAULT_SCROLL_BEHAVIOR;
|
1647
|
-
var state = {};
|
1648
|
-
var nextState = {};
|
1649
|
-
var pendingTransition = null;
|
1650
|
-
var dispatchHandler = null;
|
1651
|
-
|
1652
|
-
if (typeof location === 'string') location = new StaticLocation(location);
|
1653
|
-
|
1654
|
-
if (location instanceof StaticLocation) {
|
1655
|
-
warning(!canUseDOM || ("production") === 'test', 'You should not use a static location in a DOM environment because ' + 'the router will not be kept in sync with the current URL');
|
1656
|
-
} else {
|
1657
|
-
invariant(canUseDOM || location.needsDOM === false, 'You cannot use %s without a DOM', location);
|
1658
|
-
}
|
1659
|
-
|
1660
|
-
// Automatically fall back to full page refreshes in
|
1661
|
-
// browsers that don't support the HTML history API.
|
1662
|
-
if (location === HistoryLocation && !supportsHistory()) location = RefreshLocation;
|
1663
|
-
|
1664
|
-
var Router = React.createClass({
|
1665
|
-
|
1666
|
-
displayName: 'Router',
|
1667
|
-
|
1668
|
-
statics: {
|
1669
|
-
|
1670
|
-
isRunning: false,
|
1671
|
-
|
1672
|
-
cancelPendingTransition: function cancelPendingTransition() {
|
1673
|
-
if (pendingTransition) {
|
1674
|
-
pendingTransition.cancel();
|
1675
|
-
pendingTransition = null;
|
1676
|
-
}
|
1677
|
-
},
|
1678
|
-
|
1679
|
-
clearAllRoutes: function clearAllRoutes() {
|
1680
|
-
Router.cancelPendingTransition();
|
1681
|
-
Router.namedRoutes = {};
|
1682
|
-
Router.routes = [];
|
1683
|
-
},
|
1684
|
-
|
1685
|
-
/**
|
1686
|
-
* Adds routes to this router from the given children object (see ReactChildren).
|
1687
|
-
*/
|
1688
|
-
addRoutes: function addRoutes(routes) {
|
1689
|
-
if (isReactChildren(routes)) routes = createRoutesFromReactChildren(routes);
|
1690
|
-
|
1691
|
-
addRoutesToNamedRoutes(routes, Router.namedRoutes);
|
1692
|
-
|
1693
|
-
Router.routes.push.apply(Router.routes, routes);
|
1694
|
-
},
|
1695
|
-
|
1696
|
-
/**
|
1697
|
-
* Replaces routes of this router from the given children object (see ReactChildren).
|
1698
|
-
*/
|
1699
|
-
replaceRoutes: function replaceRoutes(routes) {
|
1700
|
-
Router.clearAllRoutes();
|
1701
|
-
Router.addRoutes(routes);
|
1702
|
-
Router.refresh();
|
1703
|
-
},
|
1704
|
-
|
1705
|
-
/**
|
1706
|
-
* Performs a match of the given path against this router and returns an object
|
1707
|
-
* with the { routes, params, pathname, query } that match. Returns null if no
|
1708
|
-
* match can be made.
|
1709
|
-
*/
|
1710
|
-
match: function match(path) {
|
1711
|
-
return Match.findMatch(Router.routes, path);
|
1712
|
-
},
|
1713
|
-
|
1714
|
-
/**
|
1715
|
-
* Returns an absolute URL path created from the given route
|
1716
|
-
* name, URL parameters, and query.
|
1717
|
-
*/
|
1718
|
-
makePath: function makePath(to, params, query) {
|
1719
|
-
var path;
|
1720
|
-
if (PathUtils.isAbsolute(to)) {
|
1721
|
-
path = to;
|
1722
|
-
} else {
|
1723
|
-
var route = to instanceof Route ? to : Router.namedRoutes[to];
|
1724
|
-
|
1725
|
-
invariant(route instanceof Route, 'Cannot find a route named "%s"', to);
|
1726
|
-
|
1727
|
-
path = route.path;
|
1728
|
-
}
|
1729
|
-
|
1730
|
-
return PathUtils.withQuery(PathUtils.injectParams(path, params), query);
|
1731
|
-
},
|
1732
|
-
|
1733
|
-
/**
|
1734
|
-
* Returns a string that may safely be used as the href of a link
|
1735
|
-
* to the route with the given name, URL parameters, and query.
|
1736
|
-
*/
|
1737
|
-
makeHref: function makeHref(to, params, query) {
|
1738
|
-
var path = Router.makePath(to, params, query);
|
1739
|
-
return location === HashLocation ? '#' + path : path;
|
1740
|
-
},
|
1741
|
-
|
1742
|
-
/**
|
1743
|
-
* Transitions to the URL specified in the arguments by pushing
|
1744
|
-
* a new URL onto the history stack.
|
1745
|
-
*/
|
1746
|
-
transitionTo: function transitionTo(to, params, query) {
|
1747
|
-
var path = Router.makePath(to, params, query);
|
1748
|
-
|
1749
|
-
if (pendingTransition) {
|
1750
|
-
// Replace so pending location does not stay in history.
|
1751
|
-
location.replace(path);
|
1752
|
-
} else {
|
1753
|
-
location.push(path);
|
1754
|
-
}
|
1755
|
-
},
|
1756
|
-
|
1757
|
-
/**
|
1758
|
-
* Transitions to the URL specified in the arguments by replacing
|
1759
|
-
* the current URL in the history stack.
|
1760
|
-
*/
|
1761
|
-
replaceWith: function replaceWith(to, params, query) {
|
1762
|
-
location.replace(Router.makePath(to, params, query));
|
1763
|
-
},
|
1764
|
-
|
1765
|
-
/**
|
1766
|
-
* Transitions to the previous URL if one is available. Returns true if the
|
1767
|
-
* router was able to go back, false otherwise.
|
1768
|
-
*
|
1769
|
-
* Note: The router only tracks history entries in your application, not the
|
1770
|
-
* current browser session, so you can safely call this function without guarding
|
1771
|
-
* against sending the user back to some other site. However, when using
|
1772
|
-
* RefreshLocation (which is the fallback for HistoryLocation in browsers that
|
1773
|
-
* don't support HTML5 history) this method will *always* send the client back
|
1774
|
-
* because we cannot reliably track history length.
|
1775
|
-
*/
|
1776
|
-
goBack: function goBack() {
|
1777
|
-
if (History.length > 1 || location === RefreshLocation) {
|
1778
|
-
location.pop();
|
1779
|
-
return true;
|
1780
|
-
}
|
1781
|
-
|
1782
|
-
warning(false, 'goBack() was ignored because there is no router history');
|
1783
|
-
|
1784
|
-
return false;
|
1785
|
-
},
|
1786
|
-
|
1787
|
-
handleAbort: options.onAbort || function (abortReason) {
|
1788
|
-
if (location instanceof StaticLocation) throw new Error('Unhandled aborted transition! Reason: ' + abortReason);
|
1789
|
-
|
1790
|
-
if (abortReason instanceof Cancellation) {
|
1791
|
-
return;
|
1792
|
-
} else if (abortReason instanceof Redirect) {
|
1793
|
-
location.replace(Router.makePath(abortReason.to, abortReason.params, abortReason.query));
|
1794
|
-
} else {
|
1795
|
-
location.pop();
|
1796
|
-
}
|
1797
|
-
},
|
1798
|
-
|
1799
|
-
handleError: options.onError || function (error) {
|
1800
|
-
// Throw so we don't silently swallow async errors.
|
1801
|
-
throw error; // This error probably originated in a transition hook.
|
1802
|
-
},
|
1803
|
-
|
1804
|
-
handleLocationChange: function handleLocationChange(change) {
|
1805
|
-
Router.dispatch(change.path, change.type);
|
1806
|
-
},
|
1807
|
-
|
1808
|
-
/**
|
1809
|
-
* Performs a transition to the given path and calls callback(error, abortReason)
|
1810
|
-
* when the transition is finished. If both arguments are null the router's state
|
1811
|
-
* was updated. Otherwise the transition did not complete.
|
1812
|
-
*
|
1813
|
-
* In a transition, a router first determines which routes are involved by beginning
|
1814
|
-
* with the current route, up the route tree to the first parent route that is shared
|
1815
|
-
* with the destination route, and back down the tree to the destination route. The
|
1816
|
-
* willTransitionFrom hook is invoked on all route handlers we're transitioning away
|
1817
|
-
* from, in reverse nesting order. Likewise, the willTransitionTo hook is invoked on
|
1818
|
-
* all route handlers we're transitioning to.
|
1819
|
-
*
|
1820
|
-
* Both willTransitionFrom and willTransitionTo hooks may either abort or redirect the
|
1821
|
-
* transition. To resolve asynchronously, they may use the callback argument. If no
|
1822
|
-
* hooks wait, the transition is fully synchronous.
|
1823
|
-
*/
|
1824
|
-
dispatch: function dispatch(path, action) {
|
1825
|
-
Router.cancelPendingTransition();
|
1826
|
-
|
1827
|
-
var prevPath = state.path;
|
1828
|
-
var isRefreshing = action == null;
|
1829
|
-
|
1830
|
-
if (prevPath === path && !isRefreshing) {
|
1831
|
-
return;
|
1832
|
-
} // Nothing to do!
|
1833
|
-
|
1834
|
-
// Record the scroll position as early as possible to
|
1835
|
-
// get it before browsers try update it automatically.
|
1836
|
-
if (prevPath && action === LocationActions.PUSH) Router.recordScrollPosition(prevPath);
|
1837
|
-
|
1838
|
-
var match = Router.match(path);
|
1839
|
-
|
1840
|
-
warning(match != null, 'No route matches path "%s". Make sure you have <Route path="%s"> somewhere in your routes', path, path);
|
1841
|
-
|
1842
|
-
if (match == null) match = {};
|
1843
|
-
|
1844
|
-
var prevRoutes = state.routes || [];
|
1845
|
-
var prevParams = state.params || {};
|
1846
|
-
var prevQuery = state.query || {};
|
1847
|
-
|
1848
|
-
var nextRoutes = match.routes || [];
|
1849
|
-
var nextParams = match.params || {};
|
1850
|
-
var nextQuery = match.query || {};
|
1851
|
-
|
1852
|
-
var fromRoutes, toRoutes;
|
1853
|
-
if (prevRoutes.length) {
|
1854
|
-
fromRoutes = prevRoutes.filter(function (route) {
|
1855
|
-
return !hasMatch(nextRoutes, route, prevParams, nextParams, prevQuery, nextQuery);
|
1856
|
-
});
|
1857
|
-
|
1858
|
-
toRoutes = nextRoutes.filter(function (route) {
|
1859
|
-
return !hasMatch(prevRoutes, route, prevParams, nextParams, prevQuery, nextQuery);
|
1860
|
-
});
|
1861
|
-
} else {
|
1862
|
-
fromRoutes = [];
|
1863
|
-
toRoutes = nextRoutes;
|
1864
|
-
}
|
1865
|
-
|
1866
|
-
var transition = new Transition(path, Router.replaceWith.bind(Router, path));
|
1867
|
-
pendingTransition = transition;
|
1868
|
-
|
1869
|
-
var fromComponents = mountedComponents.slice(prevRoutes.length - fromRoutes.length);
|
1870
|
-
|
1871
|
-
Transition.from(transition, fromRoutes, fromComponents, function (error) {
|
1872
|
-
if (error || transition.abortReason) return dispatchHandler.call(Router, error, transition); // No need to continue.
|
1873
|
-
|
1874
|
-
Transition.to(transition, toRoutes, nextParams, nextQuery, function (error) {
|
1875
|
-
dispatchHandler.call(Router, error, transition, {
|
1876
|
-
path: path,
|
1877
|
-
action: action,
|
1878
|
-
pathname: match.pathname,
|
1879
|
-
routes: nextRoutes,
|
1880
|
-
params: nextParams,
|
1881
|
-
query: nextQuery
|
1882
|
-
});
|
1883
|
-
});
|
1884
|
-
});
|
1885
|
-
},
|
1886
|
-
|
1887
|
-
/**
|
1888
|
-
* Starts this router and calls callback(router, state) when the route changes.
|
1889
|
-
*
|
1890
|
-
* If the router's location is static (i.e. a URL path in a server environment)
|
1891
|
-
* the callback is called only once. Otherwise, the location should be one of the
|
1892
|
-
* Router.*Location objects (e.g. Router.HashLocation or Router.HistoryLocation).
|
1893
|
-
*/
|
1894
|
-
run: function run(callback) {
|
1895
|
-
invariant(!Router.isRunning, 'Router is already running');
|
1896
|
-
|
1897
|
-
dispatchHandler = function (error, transition, newState) {
|
1898
|
-
if (error) Router.handleError(error);
|
1899
|
-
|
1900
|
-
if (pendingTransition !== transition) return;
|
1901
|
-
|
1902
|
-
pendingTransition = null;
|
1903
|
-
|
1904
|
-
if (transition.abortReason) {
|
1905
|
-
Router.handleAbort(transition.abortReason);
|
1906
|
-
} else {
|
1907
|
-
callback.call(Router, Router, nextState = newState);
|
1908
|
-
}
|
1909
|
-
};
|
1910
|
-
|
1911
|
-
if (!(location instanceof StaticLocation)) {
|
1912
|
-
if (location.addChangeListener) location.addChangeListener(Router.handleLocationChange);
|
1913
|
-
|
1914
|
-
Router.isRunning = true;
|
1915
|
-
}
|
1916
|
-
|
1917
|
-
// Bootstrap using the current path.
|
1918
|
-
Router.refresh();
|
1919
|
-
},
|
1920
|
-
|
1921
|
-
refresh: function refresh() {
|
1922
|
-
Router.dispatch(location.getCurrentPath(), null);
|
1923
|
-
},
|
1924
|
-
|
1925
|
-
stop: function stop() {
|
1926
|
-
Router.cancelPendingTransition();
|
1927
|
-
|
1928
|
-
if (location.removeChangeListener) location.removeChangeListener(Router.handleLocationChange);
|
1929
|
-
|
1930
|
-
Router.isRunning = false;
|
1931
|
-
},
|
1932
|
-
|
1933
|
-
getLocation: function getLocation() {
|
1934
|
-
return location;
|
1935
|
-
},
|
1936
|
-
|
1937
|
-
getScrollBehavior: function getScrollBehavior() {
|
1938
|
-
return scrollBehavior;
|
1939
|
-
},
|
1940
|
-
|
1941
|
-
getRouteAtDepth: function getRouteAtDepth(routeDepth) {
|
1942
|
-
var routes = state.routes;
|
1943
|
-
return routes && routes[routeDepth];
|
1944
|
-
},
|
1945
|
-
|
1946
|
-
setRouteComponentAtDepth: function setRouteComponentAtDepth(routeDepth, component) {
|
1947
|
-
mountedComponents[routeDepth] = component;
|
1948
|
-
},
|
1949
|
-
|
1950
|
-
/**
|
1951
|
-
* Returns the current URL path + query string.
|
1952
|
-
*/
|
1953
|
-
getCurrentPath: function getCurrentPath() {
|
1954
|
-
return state.path;
|
1955
|
-
},
|
1956
|
-
|
1957
|
-
/**
|
1958
|
-
* Returns the current URL path without the query string.
|
1959
|
-
*/
|
1960
|
-
getCurrentPathname: function getCurrentPathname() {
|
1961
|
-
return state.pathname;
|
1962
|
-
},
|
1963
|
-
|
1964
|
-
/**
|
1965
|
-
* Returns an object of the currently active URL parameters.
|
1966
|
-
*/
|
1967
|
-
getCurrentParams: function getCurrentParams() {
|
1968
|
-
return state.params;
|
1969
|
-
},
|
1970
|
-
|
1971
|
-
/**
|
1972
|
-
* Returns an object of the currently active query parameters.
|
1973
|
-
*/
|
1974
|
-
getCurrentQuery: function getCurrentQuery() {
|
1975
|
-
return state.query;
|
1976
|
-
},
|
1977
|
-
|
1978
|
-
/**
|
1979
|
-
* Returns an array of the currently active routes.
|
1980
|
-
*/
|
1981
|
-
getCurrentRoutes: function getCurrentRoutes() {
|
1982
|
-
return state.routes;
|
1983
|
-
},
|
1984
|
-
|
1985
|
-
/**
|
1986
|
-
* Returns true if the given route, params, and query are active.
|
1987
|
-
*/
|
1988
|
-
isActive: function isActive(to, params, query) {
|
1989
|
-
if (PathUtils.isAbsolute(to)) {
|
1990
|
-
return to === state.path;
|
1991
|
-
}return routeIsActive(state.routes, to) && paramsAreActive(state.params, params) && (query == null || queryIsActive(state.query, query));
|
1992
|
-
}
|
1993
|
-
|
1994
|
-
},
|
1995
|
-
|
1996
|
-
mixins: [ScrollHistory],
|
1997
|
-
|
1998
|
-
propTypes: {
|
1999
|
-
children: PropTypes.falsy
|
2000
|
-
},
|
2001
|
-
|
2002
|
-
childContextTypes: {
|
2003
|
-
routeDepth: PropTypes.number.isRequired,
|
2004
|
-
router: PropTypes.router.isRequired
|
2005
|
-
},
|
2006
|
-
|
2007
|
-
getChildContext: function getChildContext() {
|
2008
|
-
return {
|
2009
|
-
routeDepth: 1,
|
2010
|
-
router: Router
|
2011
|
-
};
|
2012
|
-
},
|
2013
|
-
|
2014
|
-
getInitialState: function getInitialState() {
|
2015
|
-
return state = nextState;
|
2016
|
-
},
|
2017
|
-
|
2018
|
-
componentWillReceiveProps: function componentWillReceiveProps() {
|
2019
|
-
this.setState(state = nextState);
|
2020
|
-
},
|
2021
|
-
|
2022
|
-
componentWillUnmount: function componentWillUnmount() {
|
2023
|
-
Router.stop();
|
2024
|
-
},
|
2025
|
-
|
2026
|
-
render: function render() {
|
2027
|
-
var route = Router.getRouteAtDepth(0);
|
2028
|
-
return route ? React.createElement(route.handler, this.props) : null;
|
2029
|
-
}
|
2030
|
-
|
2031
|
-
});
|
2032
|
-
|
2033
|
-
Router.clearAllRoutes();
|
2034
|
-
|
2035
|
-
if (options.routes) Router.addRoutes(options.routes);
|
2036
|
-
|
2037
|
-
return Router;
|
2038
|
-
}
|
2039
|
-
|
2040
|
-
module.exports = createRouter;
|
2041
|
-
|
2042
|
-
/***/ },
|
2043
|
-
/* 20 */
|
2044
|
-
/***/ function(module, exports, __webpack_require__) {
|
2045
|
-
|
2046
|
-
'use strict';
|
2047
|
-
|
2048
|
-
var createRouter = __webpack_require__(19);
|
2049
|
-
|
2050
|
-
/**
|
2051
|
-
* A high-level convenience method that creates, configures, and
|
2052
|
-
* runs a router in one shot. The method signature is:
|
2053
|
-
*
|
2054
|
-
* Router.run(routes[, location ], callback);
|
2055
|
-
*
|
2056
|
-
* Using `window.location.hash` to manage the URL, you could do:
|
2057
|
-
*
|
2058
|
-
* Router.run(routes, function (Handler) {
|
2059
|
-
* React.render(<Handler/>, document.body);
|
2060
|
-
* });
|
2061
|
-
*
|
2062
|
-
* Using HTML5 history and a custom "cursor" prop:
|
2063
|
-
*
|
2064
|
-
* Router.run(routes, Router.HistoryLocation, function (Handler) {
|
2065
|
-
* React.render(<Handler cursor={cursor}/>, document.body);
|
2066
|
-
* });
|
2067
|
-
*
|
2068
|
-
* Returns the newly created router.
|
2069
|
-
*
|
2070
|
-
* Note: If you need to specify further options for your router such
|
2071
|
-
* as error/abort handling or custom scroll behavior, use Router.create
|
2072
|
-
* instead.
|
2073
|
-
*
|
2074
|
-
* var router = Router.create(options);
|
2075
|
-
* router.run(function (Handler) {
|
2076
|
-
* // ...
|
2077
|
-
* });
|
2078
|
-
*/
|
2079
|
-
function runRouter(routes, location, callback) {
|
2080
|
-
if (typeof location === 'function') {
|
2081
|
-
callback = location;
|
2082
|
-
location = null;
|
2083
|
-
}
|
2084
|
-
|
2085
|
-
var router = createRouter({
|
2086
|
-
routes: routes,
|
2087
|
-
location: location
|
2088
|
-
});
|
2089
|
-
|
2090
|
-
router.run(callback);
|
2091
|
-
|
2092
|
-
return router;
|
2093
|
-
}
|
2094
|
-
|
2095
|
-
module.exports = runRouter;
|
2096
|
-
|
2097
|
-
/***/ },
|
2098
|
-
/* 21 */
|
2099
|
-
/***/ function(module, exports, __webpack_require__) {
|
2100
|
-
|
2101
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_21__;
|
2102
|
-
|
2103
|
-
/***/ },
|
2104
|
-
/* 22 */
|
2105
|
-
/***/ function(module, exports, __webpack_require__) {
|
2106
|
-
|
2107
|
-
'use strict';
|
2108
|
-
|
2109
|
-
var assign = __webpack_require__(33);
|
2110
|
-
var ReactPropTypes = __webpack_require__(21).PropTypes;
|
2111
|
-
var Route = __webpack_require__(17);
|
2112
|
-
|
2113
|
-
var PropTypes = assign({}, ReactPropTypes, {
|
2114
|
-
|
2115
|
-
/**
|
2116
|
-
* Indicates that a prop should be falsy.
|
2117
|
-
*/
|
2118
|
-
falsy: function falsy(props, propName, componentName) {
|
2119
|
-
if (props[propName]) {
|
2120
|
-
return new Error('<' + componentName + '> should not have a "' + propName + '" prop');
|
2121
|
-
}
|
2122
|
-
},
|
2123
|
-
|
2124
|
-
/**
|
2125
|
-
* Indicates that a prop should be a Route object.
|
2126
|
-
*/
|
2127
|
-
route: ReactPropTypes.instanceOf(Route),
|
2128
|
-
|
2129
|
-
/**
|
2130
|
-
* Indicates that a prop should be a Router object.
|
2131
|
-
*/
|
2132
|
-
//router: ReactPropTypes.instanceOf(Router) // TODO
|
2133
|
-
router: ReactPropTypes.func
|
2134
|
-
|
2135
|
-
});
|
2136
|
-
|
2137
|
-
module.exports = PropTypes;
|
2138
|
-
|
2139
|
-
/***/ },
|
2140
|
-
/* 23 */
|
2141
|
-
/***/ function(module, exports, __webpack_require__) {
|
2142
|
-
|
2143
|
-
'use strict';
|
2144
|
-
|
2145
|
-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
2146
|
-
|
2147
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
2148
|
-
|
2149
|
-
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
2150
|
-
|
2151
|
-
/**
|
2152
|
-
* This component is necessary to get around a context warning
|
2153
|
-
* present in React 0.13.0. It sovles this by providing a separation
|
2154
|
-
* between the "owner" and "parent" contexts.
|
2155
|
-
*/
|
2156
|
-
|
2157
|
-
var React = __webpack_require__(21);
|
2158
|
-
|
2159
|
-
var ContextWrapper = (function (_React$Component) {
|
2160
|
-
function ContextWrapper() {
|
2161
|
-
_classCallCheck(this, ContextWrapper);
|
2162
|
-
|
2163
|
-
if (_React$Component != null) {
|
2164
|
-
_React$Component.apply(this, arguments);
|
2165
|
-
}
|
2166
|
-
}
|
2167
|
-
|
2168
|
-
_inherits(ContextWrapper, _React$Component);
|
2169
|
-
|
2170
|
-
_createClass(ContextWrapper, [{
|
2171
|
-
key: 'render',
|
2172
|
-
value: function render() {
|
2173
|
-
return this.props.children;
|
2174
|
-
}
|
2175
|
-
}]);
|
2176
|
-
|
2177
|
-
return ContextWrapper;
|
2178
|
-
})(React.Component);
|
2179
|
-
|
2180
|
-
module.exports = ContextWrapper;
|
2181
|
-
|
2182
|
-
/***/ },
|
2183
|
-
/* 24 */
|
2184
|
-
/***/ function(module, exports, __webpack_require__) {
|
2185
|
-
|
2186
|
-
/**
|
2187
|
-
* Actions that modify the URL.
|
2188
|
-
*/
|
2189
|
-
'use strict';
|
2190
|
-
|
2191
|
-
var LocationActions = {
|
2192
|
-
|
2193
|
-
/**
|
2194
|
-
* Indicates a new location is being pushed to the history stack.
|
2195
|
-
*/
|
2196
|
-
PUSH: 'push',
|
2197
|
-
|
2198
|
-
/**
|
2199
|
-
* Indicates the current location should be replaced.
|
2200
|
-
*/
|
2201
|
-
REPLACE: 'replace',
|
2202
|
-
|
2203
|
-
/**
|
2204
|
-
* Indicates the most recent entry should be removed from the history stack.
|
2205
|
-
*/
|
2206
|
-
POP: 'pop'
|
2207
|
-
|
2208
|
-
};
|
2209
|
-
|
2210
|
-
module.exports = LocationActions;
|
2211
|
-
|
2212
|
-
/***/ },
|
2213
|
-
/* 25 */
|
2214
|
-
/***/ function(module, exports, __webpack_require__) {
|
2215
|
-
|
2216
|
-
'use strict';
|
2217
|
-
|
2218
|
-
var invariant = __webpack_require__(34);
|
2219
|
-
var assign = __webpack_require__(38);
|
2220
|
-
var qs = __webpack_require__(39);
|
2221
|
-
|
2222
|
-
var paramCompileMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|[*.()\[\]\\+|{}^$]/g;
|
2223
|
-
var paramInjectMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?]?)|[*]/g;
|
2224
|
-
var paramInjectTrailingSlashMatcher = /\/\/\?|\/\?\/|\/\?/g;
|
2225
|
-
var queryMatcher = /\?(.*)$/;
|
2226
|
-
|
2227
|
-
var _compiledPatterns = {};
|
2228
|
-
|
2229
|
-
function compilePattern(pattern) {
|
2230
|
-
if (!(pattern in _compiledPatterns)) {
|
2231
|
-
var paramNames = [];
|
2232
|
-
var source = pattern.replace(paramCompileMatcher, function (match, paramName) {
|
2233
|
-
if (paramName) {
|
2234
|
-
paramNames.push(paramName);
|
2235
|
-
return '([^/?#]+)';
|
2236
|
-
} else if (match === '*') {
|
2237
|
-
paramNames.push('splat');
|
2238
|
-
return '(.*?)';
|
2239
|
-
} else {
|
2240
|
-
return '\\' + match;
|
2241
|
-
}
|
2242
|
-
});
|
2243
|
-
|
2244
|
-
_compiledPatterns[pattern] = {
|
2245
|
-
matcher: new RegExp('^' + source + '$', 'i'),
|
2246
|
-
paramNames: paramNames
|
2247
|
-
};
|
2248
|
-
}
|
2249
|
-
|
2250
|
-
return _compiledPatterns[pattern];
|
2251
|
-
}
|
2252
|
-
|
2253
|
-
var PathUtils = {
|
2254
|
-
|
2255
|
-
/**
|
2256
|
-
* Returns true if the given path is absolute.
|
2257
|
-
*/
|
2258
|
-
isAbsolute: function isAbsolute(path) {
|
2259
|
-
return path.charAt(0) === '/';
|
2260
|
-
},
|
2261
|
-
|
2262
|
-
/**
|
2263
|
-
* Joins two URL paths together.
|
2264
|
-
*/
|
2265
|
-
join: function join(a, b) {
|
2266
|
-
return a.replace(/\/*$/, '/') + b;
|
2267
|
-
},
|
2268
|
-
|
2269
|
-
/**
|
2270
|
-
* Returns an array of the names of all parameters in the given pattern.
|
2271
|
-
*/
|
2272
|
-
extractParamNames: function extractParamNames(pattern) {
|
2273
|
-
return compilePattern(pattern).paramNames;
|
2274
|
-
},
|
2275
|
-
|
2276
|
-
/**
|
2277
|
-
* Extracts the portions of the given URL path that match the given pattern
|
2278
|
-
* and returns an object of param name => value pairs. Returns null if the
|
2279
|
-
* pattern does not match the given path.
|
2280
|
-
*/
|
2281
|
-
extractParams: function extractParams(pattern, path) {
|
2282
|
-
var _compilePattern = compilePattern(pattern);
|
2283
|
-
|
2284
|
-
var matcher = _compilePattern.matcher;
|
2285
|
-
var paramNames = _compilePattern.paramNames;
|
2286
|
-
|
2287
|
-
var match = path.match(matcher);
|
2288
|
-
|
2289
|
-
if (!match) {
|
2290
|
-
return null;
|
2291
|
-
}var params = {};
|
2292
|
-
|
2293
|
-
paramNames.forEach(function (paramName, index) {
|
2294
|
-
params[paramName] = match[index + 1];
|
2295
|
-
});
|
2296
|
-
|
2297
|
-
return params;
|
2298
|
-
},
|
2299
|
-
|
2300
|
-
/**
|
2301
|
-
* Returns a version of the given route path with params interpolated. Throws
|
2302
|
-
* if there is a dynamic segment of the route path for which there is no param.
|
2303
|
-
*/
|
2304
|
-
injectParams: function injectParams(pattern, params) {
|
2305
|
-
params = params || {};
|
2306
|
-
|
2307
|
-
var splatIndex = 0;
|
2308
|
-
|
2309
|
-
return pattern.replace(paramInjectMatcher, function (match, paramName) {
|
2310
|
-
paramName = paramName || 'splat';
|
2311
|
-
|
2312
|
-
// If param is optional don't check for existence
|
2313
|
-
if (paramName.slice(-1) === '?') {
|
2314
|
-
paramName = paramName.slice(0, -1);
|
2315
|
-
|
2316
|
-
if (params[paramName] == null) return '';
|
2317
|
-
} else {
|
2318
|
-
invariant(params[paramName] != null, 'Missing "%s" parameter for path "%s"', paramName, pattern);
|
2319
|
-
}
|
2320
|
-
|
2321
|
-
var segment;
|
2322
|
-
if (paramName === 'splat' && Array.isArray(params[paramName])) {
|
2323
|
-
segment = params[paramName][splatIndex++];
|
2324
|
-
|
2325
|
-
invariant(segment != null, 'Missing splat # %s for path "%s"', splatIndex, pattern);
|
2326
|
-
} else {
|
2327
|
-
segment = params[paramName];
|
2328
|
-
}
|
2329
|
-
|
2330
|
-
return segment;
|
2331
|
-
}).replace(paramInjectTrailingSlashMatcher, '/');
|
2332
|
-
},
|
2333
|
-
|
2334
|
-
/**
|
2335
|
-
* Returns an object that is the result of parsing any query string contained
|
2336
|
-
* in the given path, null if the path contains no query string.
|
2337
|
-
*/
|
2338
|
-
extractQuery: function extractQuery(path) {
|
2339
|
-
var match = path.match(queryMatcher);
|
2340
|
-
return match && qs.parse(match[1]);
|
2341
|
-
},
|
2342
|
-
|
2343
|
-
/**
|
2344
|
-
* Returns a version of the given path without the query string.
|
2345
|
-
*/
|
2346
|
-
withoutQuery: function withoutQuery(path) {
|
2347
|
-
return path.replace(queryMatcher, '');
|
2348
|
-
},
|
2349
|
-
|
2350
|
-
/**
|
2351
|
-
* Returns a version of the given path with the parameters in the given
|
2352
|
-
* query merged into the query string.
|
2353
|
-
*/
|
2354
|
-
withQuery: function withQuery(path, query) {
|
2355
|
-
var existingQuery = PathUtils.extractQuery(path);
|
2356
|
-
|
2357
|
-
if (existingQuery) query = query ? assign(existingQuery, query) : existingQuery;
|
2358
|
-
|
2359
|
-
var queryString = qs.stringify(query, { arrayFormat: 'brackets' });
|
2360
|
-
|
2361
|
-
if (queryString) {
|
2362
|
-
return PathUtils.withoutQuery(path) + '?' + queryString;
|
2363
|
-
}return PathUtils.withoutQuery(path);
|
2364
|
-
}
|
2365
|
-
|
2366
|
-
};
|
2367
|
-
|
2368
|
-
module.exports = PathUtils;
|
2369
|
-
|
2370
|
-
/***/ },
|
2371
|
-
/* 26 */
|
2372
|
-
/***/ function(module, exports, __webpack_require__) {
|
2373
|
-
|
2374
|
-
'use strict';
|
2375
|
-
|
2376
|
-
var invariant = __webpack_require__(34);
|
2377
|
-
var canUseDOM = __webpack_require__(35).canUseDOM;
|
2378
|
-
var getWindowScrollPosition = __webpack_require__(37);
|
2379
|
-
|
2380
|
-
function shouldUpdateScroll(state, prevState) {
|
2381
|
-
if (!prevState) {
|
2382
|
-
return true;
|
2383
|
-
} // Don't update scroll position when only the query has changed.
|
2384
|
-
if (state.pathname === prevState.pathname) {
|
2385
|
-
return false;
|
2386
|
-
}var routes = state.routes;
|
2387
|
-
var prevRoutes = prevState.routes;
|
2388
|
-
|
2389
|
-
var sharedAncestorRoutes = routes.filter(function (route) {
|
2390
|
-
return prevRoutes.indexOf(route) !== -1;
|
2391
|
-
});
|
2392
|
-
|
2393
|
-
return !sharedAncestorRoutes.some(function (route) {
|
2394
|
-
return route.ignoreScrollBehavior;
|
2395
|
-
});
|
2396
|
-
}
|
2397
|
-
|
2398
|
-
/**
|
2399
|
-
* Provides the router with the ability to manage window scroll position
|
2400
|
-
* according to its scroll behavior.
|
2401
|
-
*/
|
2402
|
-
var ScrollHistory = {
|
2403
|
-
|
2404
|
-
statics: {
|
2405
|
-
|
2406
|
-
/**
|
2407
|
-
* Records curent scroll position as the last known position for the given URL path.
|
2408
|
-
*/
|
2409
|
-
recordScrollPosition: function recordScrollPosition(path) {
|
2410
|
-
if (!this.scrollHistory) this.scrollHistory = {};
|
2411
|
-
|
2412
|
-
this.scrollHistory[path] = getWindowScrollPosition();
|
2413
|
-
},
|
2414
|
-
|
2415
|
-
/**
|
2416
|
-
* Returns the last known scroll position for the given URL path.
|
2417
|
-
*/
|
2418
|
-
getScrollPosition: function getScrollPosition(path) {
|
2419
|
-
if (!this.scrollHistory) this.scrollHistory = {};
|
2420
|
-
|
2421
|
-
return this.scrollHistory[path] || null;
|
2422
|
-
}
|
2423
|
-
|
2424
|
-
},
|
2425
|
-
|
2426
|
-
componentWillMount: function componentWillMount() {
|
2427
|
-
invariant(this.constructor.getScrollBehavior() == null || canUseDOM, 'Cannot use scroll behavior without a DOM');
|
2428
|
-
},
|
2429
|
-
|
2430
|
-
componentDidMount: function componentDidMount() {
|
2431
|
-
this._updateScroll();
|
2432
|
-
},
|
2433
|
-
|
2434
|
-
componentDidUpdate: function componentDidUpdate(prevProps, prevState) {
|
2435
|
-
this._updateScroll(prevState);
|
2436
|
-
},
|
2437
|
-
|
2438
|
-
_updateScroll: function _updateScroll(prevState) {
|
2439
|
-
if (!shouldUpdateScroll(this.state, prevState)) {
|
2440
|
-
return;
|
2441
|
-
}var scrollBehavior = this.constructor.getScrollBehavior();
|
2442
|
-
|
2443
|
-
if (scrollBehavior) scrollBehavior.updateScrollPosition(this.constructor.getScrollPosition(this.state.path), this.state.action);
|
2444
|
-
}
|
2445
|
-
|
2446
|
-
};
|
2447
|
-
|
2448
|
-
module.exports = ScrollHistory;
|
2449
|
-
|
2450
|
-
/***/ },
|
2451
|
-
/* 27 */
|
2452
|
-
/***/ function(module, exports, __webpack_require__) {
|
2453
|
-
|
2454
|
-
'use strict';
|
2455
|
-
|
2456
|
-
var React = __webpack_require__(21);
|
2457
|
-
|
2458
|
-
function isValidChild(object) {
|
2459
|
-
return object == null || React.isValidElement(object);
|
2460
|
-
}
|
2461
|
-
|
2462
|
-
function isReactChildren(object) {
|
2463
|
-
return isValidChild(object) || Array.isArray(object) && object.every(isValidChild);
|
2464
|
-
}
|
2465
|
-
|
2466
|
-
module.exports = isReactChildren;
|
2467
|
-
|
2468
|
-
/***/ },
|
2469
|
-
/* 28 */
|
2470
|
-
/***/ function(module, exports, __webpack_require__) {
|
2471
|
-
|
2472
|
-
/* jshint -W058 */
|
2473
|
-
|
2474
|
-
'use strict';
|
2475
|
-
|
2476
|
-
var Cancellation = __webpack_require__(30);
|
2477
|
-
var Redirect = __webpack_require__(29);
|
2478
|
-
|
2479
|
-
/**
|
2480
|
-
* Encapsulates a transition to a given path.
|
2481
|
-
*
|
2482
|
-
* The willTransitionTo and willTransitionFrom handlers receive
|
2483
|
-
* an instance of this class as their first argument.
|
2484
|
-
*/
|
2485
|
-
function Transition(path, retry) {
|
2486
|
-
this.path = path;
|
2487
|
-
this.abortReason = null;
|
2488
|
-
// TODO: Change this to router.retryTransition(transition)
|
2489
|
-
this.retry = retry.bind(this);
|
2490
|
-
}
|
2491
|
-
|
2492
|
-
Transition.prototype.abort = function (reason) {
|
2493
|
-
if (this.abortReason == null) this.abortReason = reason || 'ABORT';
|
2494
|
-
};
|
2495
|
-
|
2496
|
-
Transition.prototype.redirect = function (to, params, query) {
|
2497
|
-
this.abort(new Redirect(to, params, query));
|
2498
|
-
};
|
2499
|
-
|
2500
|
-
Transition.prototype.cancel = function () {
|
2501
|
-
this.abort(new Cancellation());
|
2502
|
-
};
|
2503
|
-
|
2504
|
-
Transition.from = function (transition, routes, components, callback) {
|
2505
|
-
routes.reduce(function (callback, route, index) {
|
2506
|
-
return function (error) {
|
2507
|
-
if (error || transition.abortReason) {
|
2508
|
-
callback(error);
|
2509
|
-
} else if (route.onLeave) {
|
2510
|
-
try {
|
2511
|
-
route.onLeave(transition, components[index], callback);
|
2512
|
-
|
2513
|
-
// If there is no callback in the argument list, call it automatically.
|
2514
|
-
if (route.onLeave.length < 3) callback();
|
2515
|
-
} catch (e) {
|
2516
|
-
callback(e);
|
2517
|
-
}
|
2518
|
-
} else {
|
2519
|
-
callback();
|
2520
|
-
}
|
2521
|
-
};
|
2522
|
-
}, callback)();
|
2523
|
-
};
|
2524
|
-
|
2525
|
-
Transition.to = function (transition, routes, params, query, callback) {
|
2526
|
-
routes.reduceRight(function (callback, route) {
|
2527
|
-
return function (error) {
|
2528
|
-
if (error || transition.abortReason) {
|
2529
|
-
callback(error);
|
2530
|
-
} else if (route.onEnter) {
|
2531
|
-
try {
|
2532
|
-
route.onEnter(transition, params, query, callback);
|
2533
|
-
|
2534
|
-
// If there is no callback in the argument list, call it automatically.
|
2535
|
-
if (route.onEnter.length < 4) callback();
|
2536
|
-
} catch (e) {
|
2537
|
-
callback(e);
|
2538
|
-
}
|
2539
|
-
} else {
|
2540
|
-
callback();
|
2541
|
-
}
|
2542
|
-
};
|
2543
|
-
}, callback)();
|
2544
|
-
};
|
2545
|
-
|
2546
|
-
module.exports = Transition;
|
2547
|
-
|
2548
|
-
/***/ },
|
2549
|
-
/* 29 */
|
2550
|
-
/***/ function(module, exports, __webpack_require__) {
|
2551
|
-
|
2552
|
-
/**
|
2553
|
-
* Encapsulates a redirect to the given route.
|
2554
|
-
*/
|
2555
|
-
"use strict";
|
2556
|
-
|
2557
|
-
function Redirect(to, params, query) {
|
2558
|
-
this.to = to;
|
2559
|
-
this.params = params;
|
2560
|
-
this.query = query;
|
2561
|
-
}
|
2562
|
-
|
2563
|
-
module.exports = Redirect;
|
2564
|
-
|
2565
|
-
/***/ },
|
2566
|
-
/* 30 */
|
2567
|
-
/***/ function(module, exports, __webpack_require__) {
|
2568
|
-
|
2569
|
-
/**
|
2570
|
-
* Represents a cancellation caused by navigating away
|
2571
|
-
* before the previous transition has fully resolved.
|
2572
|
-
*/
|
2573
|
-
"use strict";
|
2574
|
-
|
2575
|
-
function Cancellation() {}
|
2576
|
-
|
2577
|
-
module.exports = Cancellation;
|
2578
|
-
|
2579
|
-
/***/ },
|
2580
|
-
/* 31 */
|
2581
|
-
/***/ function(module, exports, __webpack_require__) {
|
2582
|
-
|
2583
|
-
'use strict';
|
2584
|
-
|
2585
|
-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
2586
|
-
|
2587
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
2588
|
-
|
2589
|
-
/* jshint -W084 */
|
2590
|
-
var PathUtils = __webpack_require__(25);
|
2591
|
-
|
2592
|
-
function deepSearch(route, pathname, query) {
|
2593
|
-
// Check the subtree first to find the most deeply-nested match.
|
2594
|
-
var childRoutes = route.childRoutes;
|
2595
|
-
if (childRoutes) {
|
2596
|
-
var match, childRoute;
|
2597
|
-
for (var i = 0, len = childRoutes.length; i < len; ++i) {
|
2598
|
-
childRoute = childRoutes[i];
|
2599
|
-
|
2600
|
-
if (childRoute.isDefault || childRoute.isNotFound) continue; // Check these in order later.
|
2601
|
-
|
2602
|
-
if (match = deepSearch(childRoute, pathname, query)) {
|
2603
|
-
// A route in the subtree matched! Add this route and we're done.
|
2604
|
-
match.routes.unshift(route);
|
2605
|
-
return match;
|
2606
|
-
}
|
2607
|
-
}
|
2608
|
-
}
|
2609
|
-
|
2610
|
-
// No child routes matched; try the default route.
|
2611
|
-
var defaultRoute = route.defaultRoute;
|
2612
|
-
if (defaultRoute && (params = PathUtils.extractParams(defaultRoute.path, pathname))) {
|
2613
|
-
return new Match(pathname, params, query, [route, defaultRoute]);
|
2614
|
-
} // Does the "not found" route match?
|
2615
|
-
var notFoundRoute = route.notFoundRoute;
|
2616
|
-
if (notFoundRoute && (params = PathUtils.extractParams(notFoundRoute.path, pathname))) {
|
2617
|
-
return new Match(pathname, params, query, [route, notFoundRoute]);
|
2618
|
-
} // Last attempt: check this route.
|
2619
|
-
var params = PathUtils.extractParams(route.path, pathname);
|
2620
|
-
if (params) {
|
2621
|
-
return new Match(pathname, params, query, [route]);
|
2622
|
-
}return null;
|
2623
|
-
}
|
2624
|
-
|
2625
|
-
var Match = (function () {
|
2626
|
-
function Match(pathname, params, query, routes) {
|
2627
|
-
_classCallCheck(this, Match);
|
2628
|
-
|
2629
|
-
this.pathname = pathname;
|
2630
|
-
this.params = params;
|
2631
|
-
this.query = query;
|
2632
|
-
this.routes = routes;
|
2633
|
-
}
|
2634
|
-
|
2635
|
-
_createClass(Match, null, [{
|
2636
|
-
key: 'findMatch',
|
2637
|
-
|
2638
|
-
/**
|
2639
|
-
* Attempts to match depth-first a route in the given route's
|
2640
|
-
* subtree against the given path and returns the match if it
|
2641
|
-
* succeeds, null if no match can be made.
|
2642
|
-
*/
|
2643
|
-
value: function findMatch(routes, path) {
|
2644
|
-
var pathname = PathUtils.withoutQuery(path);
|
2645
|
-
var query = PathUtils.extractQuery(path);
|
2646
|
-
var match = null;
|
2647
|
-
|
2648
|
-
for (var i = 0, len = routes.length; match == null && i < len; ++i) match = deepSearch(routes[i], pathname, query);
|
2649
|
-
|
2650
|
-
return match;
|
2651
|
-
}
|
2652
|
-
}]);
|
2653
|
-
|
2654
|
-
return Match;
|
2655
|
-
})();
|
2656
|
-
|
2657
|
-
module.exports = Match;
|
2658
|
-
|
2659
|
-
/***/ },
|
2660
|
-
/* 32 */
|
2661
|
-
/***/ function(module, exports, __webpack_require__) {
|
2662
|
-
|
2663
|
-
'use strict';
|
2664
|
-
|
2665
|
-
function supportsHistory() {
|
2666
|
-
/*! taken from modernizr
|
2667
|
-
* https://github.com/Modernizr/Modernizr/blob/master/LICENSE
|
2668
|
-
* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
|
2669
|
-
* changed to avoid false negatives for Windows Phones: https://github.com/rackt/react-router/issues/586
|
2670
|
-
*/
|
2671
|
-
var ua = navigator.userAgent;
|
2672
|
-
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) {
|
2673
|
-
return false;
|
2674
|
-
}
|
2675
|
-
return window.history && 'pushState' in window.history;
|
2676
|
-
}
|
2677
|
-
|
2678
|
-
module.exports = supportsHistory;
|
2679
|
-
|
2680
|
-
/***/ },
|
2681
|
-
/* 33 */
|
2682
|
-
/***/ function(module, exports, __webpack_require__) {
|
2683
|
-
|
2684
|
-
/**
|
2685
|
-
* Copyright 2014-2015, Facebook, Inc.
|
2686
|
-
* All rights reserved.
|
2687
|
-
*
|
2688
|
-
* This source code is licensed under the BSD-style license found in the
|
2689
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
2690
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
2691
|
-
*
|
2692
|
-
* @providesModule Object.assign
|
2693
|
-
*/
|
2694
|
-
|
2695
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
|
2696
|
-
|
2697
|
-
'use strict';
|
2698
|
-
|
2699
|
-
function assign(target, sources) {
|
2700
|
-
if (target == null) {
|
2701
|
-
throw new TypeError('Object.assign target cannot be null or undefined');
|
2702
|
-
}
|
2703
|
-
|
2704
|
-
var to = Object(target);
|
2705
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
2706
|
-
|
2707
|
-
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
|
2708
|
-
var nextSource = arguments[nextIndex];
|
2709
|
-
if (nextSource == null) {
|
2710
|
-
continue;
|
2711
|
-
}
|
2712
|
-
|
2713
|
-
var from = Object(nextSource);
|
2714
|
-
|
2715
|
-
// We don't currently support accessors nor proxies. Therefore this
|
2716
|
-
// copy cannot throw. If we ever supported this then we must handle
|
2717
|
-
// exceptions and side-effects. We don't support symbols so they won't
|
2718
|
-
// be transferred.
|
2719
|
-
|
2720
|
-
for (var key in from) {
|
2721
|
-
if (hasOwnProperty.call(from, key)) {
|
2722
|
-
to[key] = from[key];
|
2723
|
-
}
|
2724
|
-
}
|
2725
|
-
}
|
2726
|
-
|
2727
|
-
return to;
|
2728
|
-
}
|
2729
|
-
|
2730
|
-
module.exports = assign;
|
2731
|
-
|
2732
|
-
/***/ },
|
2733
|
-
/* 34 */
|
2734
|
-
/***/ function(module, exports, __webpack_require__) {
|
2735
|
-
|
2736
|
-
/**
|
2737
|
-
* Copyright 2013-2015, Facebook, Inc.
|
2738
|
-
* All rights reserved.
|
2739
|
-
*
|
2740
|
-
* This source code is licensed under the BSD-style license found in the
|
2741
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
2742
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
2743
|
-
*
|
2744
|
-
* @providesModule invariant
|
2745
|
-
*/
|
2746
|
-
|
2747
|
-
"use strict";
|
2748
|
-
|
2749
|
-
/**
|
2750
|
-
* Use invariant() to assert state which your program assumes to be true.
|
2751
|
-
*
|
2752
|
-
* Provide sprintf-style format (only %s is supported) and arguments
|
2753
|
-
* to provide information about what broke and what you were
|
2754
|
-
* expecting.
|
2755
|
-
*
|
2756
|
-
* The invariant message will be stripped in production, but the invariant
|
2757
|
-
* will remain to ensure logic does not differ in production.
|
2758
|
-
*/
|
2759
|
-
|
2760
|
-
var invariant = function invariant(condition, format, a, b, c, d, e, f) {
|
2761
|
-
if (false) {
|
2762
|
-
if (format === undefined) {
|
2763
|
-
throw new Error("invariant requires an error message argument");
|
2764
|
-
}
|
2765
|
-
}
|
2766
|
-
|
2767
|
-
if (!condition) {
|
2768
|
-
var error;
|
2769
|
-
if (format === undefined) {
|
2770
|
-
error = new Error("Minified exception occurred; use the non-minified dev environment " + "for the full error message and additional helpful warnings.");
|
2771
|
-
} else {
|
2772
|
-
var args = [a, b, c, d, e, f];
|
2773
|
-
var argIndex = 0;
|
2774
|
-
error = new Error("Invariant Violation: " + format.replace(/%s/g, function () {
|
2775
|
-
return args[argIndex++];
|
2776
|
-
}));
|
2777
|
-
}
|
2778
|
-
|
2779
|
-
error.framesToPop = 1; // we don't care about invariant's own frame
|
2780
|
-
throw error;
|
2781
|
-
}
|
2782
|
-
};
|
2783
|
-
|
2784
|
-
module.exports = invariant;
|
2785
|
-
|
2786
|
-
/***/ },
|
2787
|
-
/* 35 */
|
2788
|
-
/***/ function(module, exports, __webpack_require__) {
|
2789
|
-
|
2790
|
-
/**
|
2791
|
-
* Copyright 2013-2015, Facebook, Inc.
|
2792
|
-
* All rights reserved.
|
2793
|
-
*
|
2794
|
-
* This source code is licensed under the BSD-style license found in the
|
2795
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
2796
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
2797
|
-
*
|
2798
|
-
* @providesModule ExecutionEnvironment
|
2799
|
-
*/
|
2800
|
-
|
2801
|
-
/*jslint evil: true */
|
2802
|
-
|
2803
|
-
'use strict';
|
2804
|
-
|
2805
|
-
var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
2806
|
-
|
2807
|
-
/**
|
2808
|
-
* Simple, lightweight module assisting with the detection and context of
|
2809
|
-
* Worker. Helps avoid circular dependencies and allows code to reason about
|
2810
|
-
* whether or not they are in a Worker, even if they never include the main
|
2811
|
-
* `ReactWorker` dependency.
|
2812
|
-
*/
|
2813
|
-
var ExecutionEnvironment = {
|
2814
|
-
|
2815
|
-
canUseDOM: canUseDOM,
|
2816
|
-
|
2817
|
-
canUseWorkers: typeof Worker !== 'undefined',
|
2818
|
-
|
2819
|
-
canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent),
|
2820
|
-
|
2821
|
-
canUseViewport: canUseDOM && !!window.screen,
|
2822
|
-
|
2823
|
-
isInWorker: !canUseDOM // For now, this is true - might change in the future.
|
2824
|
-
|
2825
|
-
};
|
2826
|
-
|
2827
|
-
module.exports = ExecutionEnvironment;
|
2828
|
-
|
2829
|
-
/***/ },
|
2830
|
-
/* 36 */
|
2831
|
-
/***/ function(module, exports, __webpack_require__) {
|
2832
|
-
|
2833
|
-
/**
|
2834
|
-
* Copyright 2014-2015, Facebook, Inc.
|
2835
|
-
* All rights reserved.
|
2836
|
-
*
|
2837
|
-
* This source code is licensed under the BSD-style license found in the
|
2838
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
2839
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
2840
|
-
*
|
2841
|
-
* @providesModule warning
|
2842
|
-
*/
|
2843
|
-
|
2844
|
-
"use strict";
|
2845
|
-
|
2846
|
-
var emptyFunction = __webpack_require__(40);
|
2847
|
-
|
2848
|
-
/**
|
2849
|
-
* Similar to invariant but only logs a warning if the condition is not met.
|
2850
|
-
* This can be used to log issues in development environments in critical
|
2851
|
-
* paths. Removing the logging code for production environments will keep the
|
2852
|
-
* same logic and follow the same code paths.
|
2853
|
-
*/
|
2854
|
-
|
2855
|
-
var warning = emptyFunction;
|
2856
|
-
|
2857
|
-
if (false) {
|
2858
|
-
warning = function (condition, format) {
|
2859
|
-
for (var args = [], $__0 = 2, $__1 = arguments.length; $__0 < $__1; $__0++) args.push(arguments[$__0]);
|
2860
|
-
if (format === undefined) {
|
2861
|
-
throw new Error("`warning(condition, format, ...args)` requires a warning " + "message argument");
|
2862
|
-
}
|
2863
|
-
|
2864
|
-
if (format.length < 10 || /^[s\W]*$/.test(format)) {
|
2865
|
-
throw new Error("The warning format should be able to uniquely identify this " + "warning. Please, use a more descriptive format than: " + format);
|
2866
|
-
}
|
2867
|
-
|
2868
|
-
if (format.indexOf("Failed Composite propType: ") === 0) {
|
2869
|
-
return; // Ignore CompositeComponent proptype check.
|
2870
|
-
}
|
2871
|
-
|
2872
|
-
if (!condition) {
|
2873
|
-
var argIndex = 0;
|
2874
|
-
var message = "Warning: " + format.replace(/%s/g, function () {
|
2875
|
-
return args[argIndex++];
|
2876
|
-
});
|
2877
|
-
console.warn(message);
|
2878
|
-
try {
|
2879
|
-
// --- Welcome to debugging React ---
|
2880
|
-
// This error was thrown as a convenience so that you can use this stack
|
2881
|
-
// to find the callsite that caused this warning to fire.
|
2882
|
-
throw new Error(message);
|
2883
|
-
} catch (x) {}
|
2884
|
-
}
|
2885
|
-
};
|
2886
|
-
}
|
2887
|
-
|
2888
|
-
module.exports = warning;
|
2889
|
-
|
2890
|
-
/***/ },
|
2891
|
-
/* 37 */
|
2892
|
-
/***/ function(module, exports, __webpack_require__) {
|
2893
|
-
|
2894
|
-
'use strict';
|
2895
|
-
|
2896
|
-
var invariant = __webpack_require__(34);
|
2897
|
-
var canUseDOM = __webpack_require__(35).canUseDOM;
|
2898
|
-
|
2899
|
-
/**
|
2900
|
-
* Returns the current scroll position of the window as { x, y }.
|
2901
|
-
*/
|
2902
|
-
function getWindowScrollPosition() {
|
2903
|
-
invariant(canUseDOM, 'Cannot get current scroll position without a DOM');
|
2904
|
-
|
2905
|
-
return {
|
2906
|
-
x: window.pageXOffset || document.documentElement.scrollLeft,
|
2907
|
-
y: window.pageYOffset || document.documentElement.scrollTop
|
2908
|
-
};
|
2909
|
-
}
|
2910
|
-
|
2911
|
-
module.exports = getWindowScrollPosition;
|
2912
|
-
|
2913
|
-
/***/ },
|
2914
|
-
/* 38 */
|
2915
|
-
/***/ function(module, exports, __webpack_require__) {
|
2916
|
-
|
2917
|
-
'use strict';
|
2918
|
-
|
2919
|
-
function ToObject(val) {
|
2920
|
-
if (val == null) {
|
2921
|
-
throw new TypeError('Object.assign cannot be called with null or undefined');
|
2922
|
-
}
|
2923
|
-
|
2924
|
-
return Object(val);
|
2925
|
-
}
|
2926
|
-
|
2927
|
-
module.exports = Object.assign || function (target, source) {
|
2928
|
-
var from;
|
2929
|
-
var keys;
|
2930
|
-
var to = ToObject(target);
|
2931
|
-
|
2932
|
-
for (var s = 1; s < arguments.length; s++) {
|
2933
|
-
from = arguments[s];
|
2934
|
-
keys = Object.keys(Object(from));
|
2935
|
-
|
2936
|
-
for (var i = 0; i < keys.length; i++) {
|
2937
|
-
to[keys[i]] = from[keys[i]];
|
2938
|
-
}
|
2939
|
-
}
|
2940
|
-
|
2941
|
-
return to;
|
2942
|
-
};
|
2943
|
-
|
2944
|
-
/***/ },
|
2945
|
-
/* 39 */
|
2946
|
-
/***/ function(module, exports, __webpack_require__) {
|
2947
|
-
|
2948
|
-
'use strict';
|
2949
|
-
|
2950
|
-
module.exports = __webpack_require__(41);
|
2951
|
-
|
2952
|
-
/***/ },
|
2953
|
-
/* 40 */
|
2954
|
-
/***/ function(module, exports, __webpack_require__) {
|
2955
|
-
|
2956
|
-
/**
|
2957
|
-
* Copyright 2013-2015, Facebook, Inc.
|
2958
|
-
* All rights reserved.
|
2959
|
-
*
|
2960
|
-
* This source code is licensed under the BSD-style license found in the
|
2961
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
2962
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
2963
|
-
*
|
2964
|
-
* @providesModule emptyFunction
|
2965
|
-
*/
|
2966
|
-
|
2967
|
-
"use strict";
|
2968
|
-
|
2969
|
-
function makeEmptyFunction(arg) {
|
2970
|
-
return function () {
|
2971
|
-
return arg;
|
2972
|
-
};
|
2973
|
-
}
|
2974
|
-
|
2975
|
-
/**
|
2976
|
-
* This function accepts and discards inputs; it has no side effects. This is
|
2977
|
-
* primarily useful idiomatically for overridable function endpoints which
|
2978
|
-
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
|
2979
|
-
*/
|
2980
|
-
function emptyFunction() {}
|
2981
|
-
|
2982
|
-
emptyFunction.thatReturns = makeEmptyFunction;
|
2983
|
-
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
2984
|
-
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
2985
|
-
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
2986
|
-
emptyFunction.thatReturnsThis = function () {
|
2987
|
-
return this;
|
2988
|
-
};
|
2989
|
-
emptyFunction.thatReturnsArgument = function (arg) {
|
2990
|
-
return arg;
|
2991
|
-
};
|
2992
|
-
|
2993
|
-
module.exports = emptyFunction;
|
2994
|
-
|
2995
|
-
/***/ },
|
2996
|
-
/* 41 */
|
2997
|
-
/***/ function(module, exports, __webpack_require__) {
|
2998
|
-
|
2999
|
-
// Load modules
|
3000
|
-
|
3001
|
-
'use strict';
|
3002
|
-
|
3003
|
-
var Stringify = __webpack_require__(42);
|
3004
|
-
var Parse = __webpack_require__(43);
|
3005
|
-
|
3006
|
-
// Declare internals
|
3007
|
-
|
3008
|
-
var internals = {};
|
3009
|
-
|
3010
|
-
module.exports = {
|
3011
|
-
stringify: Stringify,
|
3012
|
-
parse: Parse
|
3013
|
-
};
|
3014
|
-
|
3015
|
-
/***/ },
|
3016
|
-
/* 42 */
|
3017
|
-
/***/ function(module, exports, __webpack_require__) {
|
3018
|
-
|
3019
|
-
// Load modules
|
3020
|
-
|
3021
|
-
'use strict';
|
3022
|
-
|
3023
|
-
var Utils = __webpack_require__(44);
|
3024
|
-
|
3025
|
-
// Declare internals
|
3026
|
-
|
3027
|
-
var internals = {
|
3028
|
-
delimiter: '&',
|
3029
|
-
arrayPrefixGenerators: {
|
3030
|
-
brackets: function brackets(prefix, key) {
|
3031
|
-
return prefix + '[]';
|
3032
|
-
},
|
3033
|
-
indices: function indices(prefix, key) {
|
3034
|
-
return prefix + '[' + key + ']';
|
3035
|
-
},
|
3036
|
-
repeat: function repeat(prefix, key) {
|
3037
|
-
return prefix;
|
3038
|
-
}
|
3039
|
-
}
|
3040
|
-
};
|
3041
|
-
|
3042
|
-
internals.stringify = function (obj, prefix, generateArrayPrefix) {
|
3043
|
-
|
3044
|
-
if (Utils.isBuffer(obj)) {
|
3045
|
-
obj = obj.toString();
|
3046
|
-
} else if (obj instanceof Date) {
|
3047
|
-
obj = obj.toISOString();
|
3048
|
-
} else if (obj === null) {
|
3049
|
-
obj = '';
|
3050
|
-
}
|
3051
|
-
|
3052
|
-
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean') {
|
3053
|
-
|
3054
|
-
return [encodeURIComponent(prefix) + '=' + encodeURIComponent(obj)];
|
3055
|
-
}
|
3056
|
-
|
3057
|
-
var values = [];
|
3058
|
-
|
3059
|
-
if (typeof obj === 'undefined') {
|
3060
|
-
return values;
|
3061
|
-
}
|
3062
|
-
|
3063
|
-
var objKeys = Object.keys(obj);
|
3064
|
-
for (var i = 0, il = objKeys.length; i < il; ++i) {
|
3065
|
-
var key = objKeys[i];
|
3066
|
-
if (Array.isArray(obj)) {
|
3067
|
-
values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix));
|
3068
|
-
} else {
|
3069
|
-
values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']', generateArrayPrefix));
|
3070
|
-
}
|
3071
|
-
}
|
3072
|
-
|
3073
|
-
return values;
|
3074
|
-
};
|
3075
|
-
|
3076
|
-
module.exports = function (obj, options) {
|
3077
|
-
|
3078
|
-
options = options || {};
|
3079
|
-
var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter;
|
3080
|
-
|
3081
|
-
var keys = [];
|
3082
|
-
|
3083
|
-
if (typeof obj !== 'object' || obj === null) {
|
3084
|
-
|
3085
|
-
return '';
|
3086
|
-
}
|
3087
|
-
|
3088
|
-
var arrayFormat;
|
3089
|
-
if (options.arrayFormat in internals.arrayPrefixGenerators) {
|
3090
|
-
arrayFormat = options.arrayFormat;
|
3091
|
-
} else if ('indices' in options) {
|
3092
|
-
arrayFormat = options.indices ? 'indices' : 'repeat';
|
3093
|
-
} else {
|
3094
|
-
arrayFormat = 'indices';
|
3095
|
-
}
|
3096
|
-
|
3097
|
-
var generateArrayPrefix = internals.arrayPrefixGenerators[arrayFormat];
|
3098
|
-
|
3099
|
-
var objKeys = Object.keys(obj);
|
3100
|
-
for (var i = 0, il = objKeys.length; i < il; ++i) {
|
3101
|
-
var key = objKeys[i];
|
3102
|
-
keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix));
|
3103
|
-
}
|
3104
|
-
|
3105
|
-
return keys.join(delimiter);
|
3106
|
-
};
|
3107
|
-
|
3108
|
-
/***/ },
|
3109
|
-
/* 43 */
|
3110
|
-
/***/ function(module, exports, __webpack_require__) {
|
3111
|
-
|
3112
|
-
// Load modules
|
3113
|
-
|
3114
|
-
'use strict';
|
3115
|
-
|
3116
|
-
var Utils = __webpack_require__(44);
|
3117
|
-
|
3118
|
-
// Declare internals
|
3119
|
-
|
3120
|
-
var internals = {
|
3121
|
-
delimiter: '&',
|
3122
|
-
depth: 5,
|
3123
|
-
arrayLimit: 20,
|
3124
|
-
parameterLimit: 1000
|
3125
|
-
};
|
3126
|
-
|
3127
|
-
internals.parseValues = function (str, options) {
|
3128
|
-
|
3129
|
-
var obj = {};
|
3130
|
-
var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
|
3131
|
-
|
3132
|
-
for (var i = 0, il = parts.length; i < il; ++i) {
|
3133
|
-
var part = parts[i];
|
3134
|
-
var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
|
3135
|
-
|
3136
|
-
if (pos === -1) {
|
3137
|
-
obj[Utils.decode(part)] = '';
|
3138
|
-
} else {
|
3139
|
-
var key = Utils.decode(part.slice(0, pos));
|
3140
|
-
var val = Utils.decode(part.slice(pos + 1));
|
3141
|
-
|
3142
|
-
if (Object.prototype.hasOwnProperty(key)) {
|
3143
|
-
continue;
|
3144
|
-
}
|
3145
|
-
|
3146
|
-
if (!obj.hasOwnProperty(key)) {
|
3147
|
-
obj[key] = val;
|
3148
|
-
} else {
|
3149
|
-
obj[key] = [].concat(obj[key]).concat(val);
|
3150
|
-
}
|
3151
|
-
}
|
3152
|
-
}
|
3153
|
-
|
3154
|
-
return obj;
|
3155
|
-
};
|
3156
|
-
|
3157
|
-
internals.parseObject = function (chain, val, options) {
|
3158
|
-
|
3159
|
-
if (!chain.length) {
|
3160
|
-
return val;
|
3161
|
-
}
|
3162
|
-
|
3163
|
-
var root = chain.shift();
|
3164
|
-
|
3165
|
-
var obj = {};
|
3166
|
-
if (root === '[]') {
|
3167
|
-
obj = [];
|
3168
|
-
obj = obj.concat(internals.parseObject(chain, val, options));
|
3169
|
-
} else {
|
3170
|
-
var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
|
3171
|
-
var index = parseInt(cleanRoot, 10);
|
3172
|
-
var indexString = '' + index;
|
3173
|
-
if (!isNaN(index) && root !== cleanRoot && indexString === cleanRoot && index >= 0 && index <= options.arrayLimit) {
|
3174
|
-
|
3175
|
-
obj = [];
|
3176
|
-
obj[index] = internals.parseObject(chain, val, options);
|
3177
|
-
} else {
|
3178
|
-
obj[cleanRoot] = internals.parseObject(chain, val, options);
|
3179
|
-
}
|
3180
|
-
}
|
3181
|
-
|
3182
|
-
return obj;
|
3183
|
-
};
|
3184
|
-
|
3185
|
-
internals.parseKeys = function (key, val, options) {
|
3186
|
-
|
3187
|
-
if (!key) {
|
3188
|
-
return;
|
3189
|
-
}
|
3190
|
-
|
3191
|
-
// The regex chunks
|
3192
|
-
|
3193
|
-
var parent = /^([^\[\]]*)/;
|
3194
|
-
var child = /(\[[^\[\]]*\])/g;
|
3195
|
-
|
3196
|
-
// Get the parent
|
3197
|
-
|
3198
|
-
var segment = parent.exec(key);
|
3199
|
-
|
3200
|
-
// Don't allow them to overwrite object prototype properties
|
3201
|
-
|
3202
|
-
if (Object.prototype.hasOwnProperty(segment[1])) {
|
3203
|
-
return;
|
3204
|
-
}
|
3205
|
-
|
3206
|
-
// Stash the parent if it exists
|
3207
|
-
|
3208
|
-
var keys = [];
|
3209
|
-
if (segment[1]) {
|
3210
|
-
keys.push(segment[1]);
|
3211
|
-
}
|
3212
|
-
|
3213
|
-
// Loop through children appending to the array until we hit depth
|
3214
|
-
|
3215
|
-
var i = 0;
|
3216
|
-
while ((segment = child.exec(key)) !== null && i < options.depth) {
|
3217
|
-
|
3218
|
-
++i;
|
3219
|
-
if (!Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) {
|
3220
|
-
keys.push(segment[1]);
|
3221
|
-
}
|
3222
|
-
}
|
3223
|
-
|
3224
|
-
// If there's a remainder, just add whatever is left
|
3225
|
-
|
3226
|
-
if (segment) {
|
3227
|
-
keys.push('[' + key.slice(segment.index) + ']');
|
3228
|
-
}
|
3229
|
-
|
3230
|
-
return internals.parseObject(keys, val, options);
|
3231
|
-
};
|
3232
|
-
|
3233
|
-
module.exports = function (str, options) {
|
3234
|
-
|
3235
|
-
if (str === '' || str === null || typeof str === 'undefined') {
|
3236
|
-
|
3237
|
-
return {};
|
3238
|
-
}
|
3239
|
-
|
3240
|
-
options = options || {};
|
3241
|
-
options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter;
|
3242
|
-
options.depth = typeof options.depth === 'number' ? options.depth : internals.depth;
|
3243
|
-
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit;
|
3244
|
-
options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit;
|
3245
|
-
|
3246
|
-
var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str;
|
3247
|
-
var obj = {};
|
3248
|
-
|
3249
|
-
// Iterate over the keys and setup the new object
|
3250
|
-
|
3251
|
-
var keys = Object.keys(tempObj);
|
3252
|
-
for (var i = 0, il = keys.length; i < il; ++i) {
|
3253
|
-
var key = keys[i];
|
3254
|
-
var newObj = internals.parseKeys(key, tempObj[key], options);
|
3255
|
-
obj = Utils.merge(obj, newObj);
|
3256
|
-
}
|
3257
|
-
|
3258
|
-
return Utils.compact(obj);
|
3259
|
-
};
|
3260
|
-
|
3261
|
-
/***/ },
|
3262
|
-
/* 44 */
|
3263
|
-
/***/ function(module, exports, __webpack_require__) {
|
3264
|
-
|
3265
|
-
// Load modules
|
3266
|
-
|
3267
|
-
// Declare internals
|
3268
|
-
|
3269
|
-
'use strict';
|
3270
|
-
|
3271
|
-
var internals = {};
|
3272
|
-
|
3273
|
-
exports.arrayToObject = function (source) {
|
3274
|
-
|
3275
|
-
var obj = {};
|
3276
|
-
for (var i = 0, il = source.length; i < il; ++i) {
|
3277
|
-
if (typeof source[i] !== 'undefined') {
|
3278
|
-
|
3279
|
-
obj[i] = source[i];
|
3280
|
-
}
|
3281
|
-
}
|
3282
|
-
|
3283
|
-
return obj;
|
3284
|
-
};
|
3285
|
-
|
3286
|
-
exports.merge = function (target, source) {
|
3287
|
-
|
3288
|
-
if (!source) {
|
3289
|
-
return target;
|
3290
|
-
}
|
3291
|
-
|
3292
|
-
if (typeof source !== 'object') {
|
3293
|
-
if (Array.isArray(target)) {
|
3294
|
-
target.push(source);
|
3295
|
-
} else {
|
3296
|
-
target[source] = true;
|
3297
|
-
}
|
3298
|
-
|
3299
|
-
return target;
|
3300
|
-
}
|
3301
|
-
|
3302
|
-
if (typeof target !== 'object') {
|
3303
|
-
target = [target].concat(source);
|
3304
|
-
return target;
|
3305
|
-
}
|
3306
|
-
|
3307
|
-
if (Array.isArray(target) && !Array.isArray(source)) {
|
3308
|
-
|
3309
|
-
target = exports.arrayToObject(target);
|
3310
|
-
}
|
3311
|
-
|
3312
|
-
var keys = Object.keys(source);
|
3313
|
-
for (var k = 0, kl = keys.length; k < kl; ++k) {
|
3314
|
-
var key = keys[k];
|
3315
|
-
var value = source[key];
|
3316
|
-
|
3317
|
-
if (!target[key]) {
|
3318
|
-
target[key] = value;
|
3319
|
-
} else {
|
3320
|
-
target[key] = exports.merge(target[key], value);
|
3321
|
-
}
|
3322
|
-
}
|
3323
|
-
|
3324
|
-
return target;
|
3325
|
-
};
|
3326
|
-
|
3327
|
-
exports.decode = function (str) {
|
3328
|
-
|
3329
|
-
try {
|
3330
|
-
return decodeURIComponent(str.replace(/\+/g, ' '));
|
3331
|
-
} catch (e) {
|
3332
|
-
return str;
|
3333
|
-
}
|
3334
|
-
};
|
3335
|
-
|
3336
|
-
exports.compact = function (obj, refs) {
|
3337
|
-
|
3338
|
-
if (typeof obj !== 'object' || obj === null) {
|
3339
|
-
|
3340
|
-
return obj;
|
3341
|
-
}
|
3342
|
-
|
3343
|
-
refs = refs || [];
|
3344
|
-
var lookup = refs.indexOf(obj);
|
3345
|
-
if (lookup !== -1) {
|
3346
|
-
return refs[lookup];
|
3347
|
-
}
|
3348
|
-
|
3349
|
-
refs.push(obj);
|
3350
|
-
|
3351
|
-
if (Array.isArray(obj)) {
|
3352
|
-
var compacted = [];
|
3353
|
-
|
3354
|
-
for (var i = 0, il = obj.length; i < il; ++i) {
|
3355
|
-
if (typeof obj[i] !== 'undefined') {
|
3356
|
-
compacted.push(obj[i]);
|
3357
|
-
}
|
3358
|
-
}
|
3359
|
-
|
3360
|
-
return compacted;
|
3361
|
-
}
|
3362
|
-
|
3363
|
-
var keys = Object.keys(obj);
|
3364
|
-
for (i = 0, il = keys.length; i < il; ++i) {
|
3365
|
-
var key = keys[i];
|
3366
|
-
obj[key] = exports.compact(obj[key], refs);
|
3367
|
-
}
|
3368
|
-
|
3369
|
-
return obj;
|
3370
|
-
};
|
3371
|
-
|
3372
|
-
exports.isRegExp = function (obj) {
|
3373
|
-
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
3374
|
-
};
|
3375
|
-
|
3376
|
-
exports.isBuffer = function (obj) {
|
3377
|
-
|
3378
|
-
if (obj === null || typeof obj === 'undefined') {
|
3379
|
-
|
3380
|
-
return false;
|
3381
|
-
}
|
3382
|
-
|
3383
|
-
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
3384
|
-
};
|
3385
|
-
|
3386
|
-
/***/ }
|
3387
|
-
/******/ ])
|
3388
|
-
});
|