react-isomorphic-tools
Advanced tools
Comparing version 3.0.0-alpha.10 to 3.0.0-alpha.11
@@ -24,3 +24,3 @@ 'use strict'; | ||
var AbstractResolver = function AbstractResolver(routes, resolved) { | ||
var AbstractResolver = function AbstractResolver() { | ||
var _this = this; | ||
@@ -126,8 +126,4 @@ | ||
}; | ||
this.routes = routes; | ||
this.resolved = resolved; | ||
this.match = []; | ||
}; | ||
exports.default = AbstractResolver; |
@@ -41,109 +41,126 @@ 'use strict'; | ||
function ReduxResolver(routes, store) { | ||
var _this2 = this; | ||
function ReduxResolver() { | ||
var _ref; | ||
var resolved = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, ReduxResolver); | ||
var _this = _possibleConstructorReturn(this, (ReduxResolver.__proto__ || Object.getPrototypeOf(ReduxResolver)).call(this, routes, resolved)); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this.resolveData = function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(location) { | ||
var _this$store, getState, dispatch, _ref2, _fetchToState, fetcher, pathname, _location$search, search, unResolved, i, _unResolved$i, params, _unResolved$i$route, preload, path; | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ReduxResolver.__proto__ || Object.getPrototypeOf(ReduxResolver)).call.apply(_ref, [this].concat(args))), _this), _initialiseProps.call(_this), _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_this$store = _this.store, getState = _this$store.getState, dispatch = _this$store.dispatch; | ||
_ref2 = new _FetchToState2.default(), _fetchToState = _ref2.fetchToState, fetcher = _ref2.fetcher; | ||
pathname = location.pathname, _location$search = location.search, search = _location$search === undefined ? '' : _location$search; | ||
unResolved = (0, _reactRouterConfig.matchRoutes)(_this.routes, pathname).filter(function (item) { | ||
return typeof item.route.preload === 'function' && !_this.isResolved(item, location); | ||
}); | ||
return ReduxResolver; | ||
}(_AbstractResolver3.default); | ||
if (!(unResolved.length === 0)) { | ||
_context.next = 6; | ||
break; | ||
} | ||
var _initialiseProps = function _initialiseProps() { | ||
var _this2 = this; | ||
return _context.abrupt('return'); | ||
this.init = function (routes, store, resolved) { | ||
if (!resolved) { | ||
_this2.routes = routes; | ||
_this2.store = store; | ||
_this2.resolved = []; | ||
} else { | ||
ReduxResolver.prototype.routes = routes; | ||
ReduxResolver.prototype.store = store; | ||
ReduxResolver.prototype.resolved = resolved; | ||
} | ||
}; | ||
case 6: | ||
this.resolveData = function () { | ||
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(location) { | ||
var _store, getState, dispatch, _ref3, _fetchToState, fetcher, pathname, _location$search, search, unResolved, i, _unResolved$i, params, _unResolved$i$route, preload, path; | ||
dispatch((0, _preload.start)()); | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_store = _this2.store, getState = _store.getState, dispatch = _store.dispatch; | ||
_ref3 = new _FetchToState2.default(), _fetchToState = _ref3.fetchToState, fetcher = _ref3.fetcher; | ||
pathname = location.pathname, _location$search = location.search, search = _location$search === undefined ? '' : _location$search; | ||
unResolved = (0, _reactRouterConfig.matchRoutes)(_this2.routes, pathname).filter(function (item) { | ||
return typeof item.route.preload === 'function' && !_this2.isResolved(item, location); | ||
}); | ||
_context.t0 = regeneratorRuntime.keys(unResolved); | ||
if (!(unResolved.length === 0)) { | ||
_context.next = 6; | ||
break; | ||
} | ||
case 8: | ||
if ((_context.t1 = _context.t0()).done) { | ||
_context.next = 17; | ||
break; | ||
} | ||
return _context.abrupt('return'); | ||
i = _context.t1.value; | ||
case 6: | ||
if (!Object.prototype.hasOwnProperty.call(unResolved, i)) { | ||
_context.next = 15; | ||
break; | ||
} | ||
dispatch((0, _preload.start)()); | ||
_unResolved$i = unResolved[i], params = _unResolved$i.match.params, _unResolved$i$route = _unResolved$i.route, preload = _unResolved$i$route.preload, path = _unResolved$i$route.path; | ||
_context.next = 14; | ||
return preload({ | ||
getState: getState, | ||
dispatch: dispatch, | ||
params: params, | ||
location: _extends({}, location, { query: (0, _.parseQuery)(search) }), | ||
fetcher: fetcher, | ||
fetchToState: function fetchToState() { | ||
return dispatch(_fetchToState.apply(undefined, arguments)); | ||
}, | ||
redirect: function redirect(props) { | ||
throw { | ||
code: 303, | ||
to: props, | ||
type: 'redirect' | ||
}; | ||
} | ||
}); | ||
_context.t0 = regeneratorRuntime.keys(unResolved); | ||
case 14: | ||
case 8: | ||
if ((_context.t1 = _context.t0()).done) { | ||
_context.next = 17; | ||
break; | ||
} | ||
_this.push({ | ||
params: params, | ||
path: path, | ||
search: search, | ||
isServer: !_isBrowser2.default | ||
}); | ||
i = _context.t1.value; | ||
case 15: | ||
_context.next = 8; | ||
if (!Object.prototype.hasOwnProperty.call(unResolved, i)) { | ||
_context.next = 15; | ||
break; | ||
} | ||
case 17: | ||
_unResolved$i = unResolved[i], params = _unResolved$i.match.params, _unResolved$i$route = _unResolved$i.route, preload = _unResolved$i$route.preload, path = _unResolved$i$route.path; | ||
_context.next = 14; | ||
return preload({ | ||
getState: getState, | ||
dispatch: dispatch, | ||
params: params, | ||
location: _extends({}, location, { query: (0, _.parseQuery)(search) }), | ||
fetcher: fetcher, | ||
fetchToState: function fetchToState() { | ||
return dispatch(_fetchToState.apply(undefined, arguments)); | ||
}, | ||
redirect: function redirect(props) { | ||
throw { | ||
code: 303, | ||
to: props, | ||
type: 'redirect' | ||
}; | ||
} | ||
}); | ||
dispatch((0, _preload.success)()); | ||
case 14: | ||
case 18: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, _this2); | ||
})); | ||
_this2.push({ | ||
params: params, | ||
path: path, | ||
search: search, | ||
isServer: !_isBrowser2.default | ||
}); | ||
return function (_x2) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
case 15: | ||
_context.next = 8; | ||
break; | ||
_this.store = store; | ||
return _this; | ||
} | ||
case 17: | ||
return ReduxResolver; | ||
}(_AbstractResolver3.default); | ||
dispatch((0, _preload.success)()); | ||
case 18: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, _this2); | ||
})); | ||
return function (_x) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}(); | ||
}; | ||
exports.default = ReduxResolver; |
{ | ||
"name": "react-isomorphic-tools", | ||
"version": "3.0.0-alpha.10", | ||
"version": "3.0.0-alpha.11", | ||
"description": "Authorization, Fetcher, Preload. Tools for ServerSide rendering", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
141434
1392