@angular/router
Advanced tools
Comparing version 3.1.1 to 3.1.2
/** | ||
* @license Angular v3.1.1 | ||
* @license Angular v3.1.2 | ||
* (c) 2010-2016 Google, Inc. https://angular.io/ | ||
@@ -4,0 +4,0 @@ * License: MIT |
{ | ||
"name": "@angular/router", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"description": "Angular - the routing library", | ||
@@ -24,7 +24,7 @@ "main": "bundles/router.umd.js", | ||
"peerDependencies": { | ||
"@angular/core": "2.1.1", | ||
"@angular/common": "2.1.1", | ||
"@angular/platform-browser": "2.1.1", | ||
"@angular/core": "2.1.2", | ||
"@angular/common": "2.1.2", | ||
"@angular/platform-browser": "2.1.2", | ||
"rxjs": "5.0.0-beta.12" | ||
} | ||
} |
@@ -8,2 +8,3 @@ /** | ||
*/ | ||
import { PRIMARY_OUTLET } from './shared'; | ||
export function validateConfig(config) { | ||
@@ -16,2 +17,5 @@ config.forEach(validateNode); | ||
} | ||
if (route.component === undefined && (route.outlet && route.outlet !== PRIMARY_OUTLET)) { | ||
throw new Error("Invalid route configuration of route '" + route.path + "': a componentless route cannot have a named outlet set"); | ||
} | ||
if (!!route.redirectTo && !!route.children) { | ||
@@ -18,0 +22,0 @@ throw new Error("Invalid configuration of route '" + route.path + "': redirectTo and children cannot be used together"); |
@@ -79,2 +79,5 @@ /** | ||
RouterOutlet.prototype.activate = function (activatedRoute, loadedResolver, loadedInjector, providers, outletMap) { | ||
if (this.isActivated) { | ||
throw new Error('Cannot activate an already activated outlet'); | ||
} | ||
this.outletMap = outletMap; | ||
@@ -81,0 +84,0 @@ this._activatedRoute = activatedRoute; |
@@ -10,3 +10,3 @@ /** | ||
import { of } from 'rxjs/observable/of'; | ||
import { ActivatedRouteSnapshot, InheritedResolve, RouterStateSnapshot } from './router_state'; | ||
import { ActivatedRouteSnapshot, RouterStateSnapshot, inheritedParamsDataResolve } from './router_state'; | ||
import { PRIMARY_OUTLET } from './shared'; | ||
@@ -21,27 +21,2 @@ import { UrlSegmentGroup, mapChildrenIntoArray } from './url_tree'; | ||
}()); | ||
var InheritedFromParent = (function () { | ||
function InheritedFromParent(parent, snapshot, params, data, resolve) { | ||
this.parent = parent; | ||
this.snapshot = snapshot; | ||
this.params = params; | ||
this.data = data; | ||
this.resolve = resolve; | ||
} | ||
Object.defineProperty(InheritedFromParent.prototype, "allParams", { | ||
get: function () { | ||
return this.parent ? merge(this.parent.allParams, this.params) : this.params; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(InheritedFromParent.prototype, "allData", { | ||
get: function () { return this.parent ? merge(this.parent.allData, this.data) : this.data; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
InheritedFromParent.empty = function (snapshot) { | ||
return new InheritedFromParent(null, snapshot, {}, {}, new InheritedResolve(null, {})); | ||
}; | ||
return InheritedFromParent; | ||
}()); | ||
export function recognize(rootComponentType, config, urlTree, url) { | ||
@@ -60,6 +35,8 @@ return new Recognizer(rootComponentType, config, urlTree, url).recognize(); | ||
var rootSegmentGroup = split(this.urlTree.root, [], [], this.config).segmentGroup; | ||
var children = this.processSegmentGroup(this.config, rootSegmentGroup, InheritedFromParent.empty(null), PRIMARY_OUTLET); | ||
var root = new ActivatedRouteSnapshot([], Object.freeze({}), Object.freeze(this.urlTree.queryParams), this.urlTree.fragment, {}, PRIMARY_OUTLET, this.rootComponentType, null, this.urlTree.root, -1, InheritedResolve.empty); | ||
var children = this.processSegmentGroup(this.config, rootSegmentGroup, PRIMARY_OUTLET); | ||
var root = new ActivatedRouteSnapshot([], Object.freeze({}), Object.freeze(this.urlTree.queryParams), this.urlTree.fragment, {}, PRIMARY_OUTLET, this.rootComponentType, null, this.urlTree.root, -1, {}); | ||
var rootNode = new TreeNode(root, children); | ||
return of(new RouterStateSnapshot(this.url, rootNode)); | ||
var routeState = new RouterStateSnapshot(this.url, rootNode); | ||
this.inheriteParamsAndData(routeState._root); | ||
return of(routeState); | ||
} | ||
@@ -70,13 +47,21 @@ catch (e) { | ||
}; | ||
Recognizer.prototype.processSegmentGroup = function (config, segmentGroup, inherited, outlet) { | ||
Recognizer.prototype.inheriteParamsAndData = function (routeNode) { | ||
var _this = this; | ||
var route = routeNode.value; | ||
var i = inheritedParamsDataResolve(route); | ||
route.params = Object.freeze(i.params); | ||
route.data = Object.freeze(i.data); | ||
routeNode.children.forEach(function (n) { return _this.inheriteParamsAndData(n); }); | ||
}; | ||
Recognizer.prototype.processSegmentGroup = function (config, segmentGroup, outlet) { | ||
if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) { | ||
return this.processChildren(config, segmentGroup, inherited); | ||
return this.processChildren(config, segmentGroup); | ||
} | ||
else { | ||
return this.processSegment(config, segmentGroup, 0, segmentGroup.segments, inherited, outlet); | ||
return this.processSegment(config, segmentGroup, 0, segmentGroup.segments, outlet); | ||
} | ||
}; | ||
Recognizer.prototype.processChildren = function (config, segmentGroup, inherited) { | ||
Recognizer.prototype.processChildren = function (config, segmentGroup) { | ||
var _this = this; | ||
var children = mapChildrenIntoArray(segmentGroup, function (child, childOutlet) { return _this.processSegmentGroup(config, child, inherited, childOutlet); }); | ||
var children = mapChildrenIntoArray(segmentGroup, function (child, childOutlet) { return _this.processSegmentGroup(config, child, childOutlet); }); | ||
checkOutletNameUniqueness(children); | ||
@@ -86,7 +71,7 @@ sortActivatedRouteSnapshots(children); | ||
}; | ||
Recognizer.prototype.processSegment = function (config, segmentGroup, pathIndex, segments, inherited, outlet) { | ||
Recognizer.prototype.processSegment = function (config, segmentGroup, pathIndex, segments, outlet) { | ||
for (var _i = 0, config_1 = config; _i < config_1.length; _i++) { | ||
var r = config_1[_i]; | ||
try { | ||
return this.processSegmentAgainstRoute(r, segmentGroup, pathIndex, segments, inherited, outlet); | ||
return this.processSegmentAgainstRoute(r, segmentGroup, pathIndex, segments, outlet); | ||
} | ||
@@ -100,3 +85,3 @@ catch (e) { | ||
}; | ||
Recognizer.prototype.processSegmentAgainstRoute = function (route, rawSegment, pathIndex, segments, inherited, outlet) { | ||
Recognizer.prototype.processSegmentAgainstRoute = function (route, rawSegment, pathIndex, segments, outlet) { | ||
if (route.redirectTo) | ||
@@ -106,18 +91,14 @@ throw new NoMatch(); | ||
throw new NoMatch(); | ||
var newInheritedResolve = new InheritedResolve(inherited.resolve, getResolve(route)); | ||
if (route.path === '**') { | ||
var params = segments.length > 0 ? last(segments).parameters : {}; | ||
var snapshot_1 = new ActivatedRouteSnapshot(segments, Object.freeze(merge(inherited.allParams, params)), Object.freeze(this.urlTree.queryParams), this.urlTree.fragment, merge(inherited.allData, getData(route)), outlet, route.component, route, getSourceSegmentGroup(rawSegment), getPathIndexShift(rawSegment) + segments.length, newInheritedResolve); | ||
var snapshot_1 = new ActivatedRouteSnapshot(segments, params, Object.freeze(this.urlTree.queryParams), this.urlTree.fragment, getData(route), outlet, route.component, route, getSourceSegmentGroup(rawSegment), getPathIndexShift(rawSegment) + segments.length, getResolve(route)); | ||
return [new TreeNode(snapshot_1, [])]; | ||
} | ||
var _a = match(rawSegment, route, segments, inherited.snapshot), consumedSegments = _a.consumedSegments, parameters = _a.parameters, lastChild = _a.lastChild; | ||
var _a = match(rawSegment, route, segments), consumedSegments = _a.consumedSegments, parameters = _a.parameters, lastChild = _a.lastChild; | ||
var rawSlicedSegments = segments.slice(lastChild); | ||
var childConfig = getChildConfig(route); | ||
var _b = split(rawSegment, consumedSegments, rawSlicedSegments, childConfig), segmentGroup = _b.segmentGroup, slicedSegments = _b.slicedSegments; | ||
var snapshot = new ActivatedRouteSnapshot(consumedSegments, Object.freeze(merge(inherited.allParams, parameters)), Object.freeze(this.urlTree.queryParams), this.urlTree.fragment, merge(inherited.allData, getData(route)), outlet, route.component, route, getSourceSegmentGroup(rawSegment), getPathIndexShift(rawSegment) + consumedSegments.length, newInheritedResolve); | ||
var newInherited = route.component ? | ||
InheritedFromParent.empty(snapshot) : | ||
new InheritedFromParent(inherited, snapshot, parameters, getData(route), newInheritedResolve); | ||
var snapshot = new ActivatedRouteSnapshot(consumedSegments, parameters, Object.freeze(this.urlTree.queryParams), this.urlTree.fragment, getData(route), outlet, route.component, route, getSourceSegmentGroup(rawSegment), getPathIndexShift(rawSegment) + consumedSegments.length, getResolve(route)); | ||
if (slicedSegments.length === 0 && segmentGroup.hasChildren()) { | ||
var children = this.processChildren(childConfig, segmentGroup, newInherited); | ||
var children = this.processChildren(childConfig, segmentGroup); | ||
return [new TreeNode(snapshot, children)]; | ||
@@ -129,3 +110,3 @@ } | ||
else { | ||
var children = this.processSegment(childConfig, segmentGroup, pathIndex + lastChild, slicedSegments, newInherited, PRIMARY_OUTLET); | ||
var children = this.processSegment(childConfig, segmentGroup, pathIndex + lastChild, slicedSegments, PRIMARY_OUTLET); | ||
return [new TreeNode(snapshot, children)]; | ||
@@ -156,3 +137,3 @@ } | ||
} | ||
function match(segmentGroup, route, segments, parent) { | ||
function match(segmentGroup, route, segments) { | ||
if (route.path === '') { | ||
@@ -163,4 +144,3 @@ if (route.pathMatch === 'full' && (segmentGroup.hasChildren() || segments.length > 0)) { | ||
else { | ||
var params = parent ? parent.params : {}; | ||
return { consumedSegments: [], lastChild: 0, parameters: params }; | ||
return { consumedSegments: [], lastChild: 0, parameters: {} }; | ||
} | ||
@@ -167,0 +147,0 @@ } |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"recognize":{"__symbolic":"function","parameters":["rootComponentType","config","urlTree","url"],"value":{"__symbolic":"error","message":"Reference to non-exported class","line":44,"character":0,"context":{"className":"Recognizer"}}}}} | ||
{"__symbolic":"module","version":1,"metadata":{"recognize":{"__symbolic":"function","parameters":["rootComponentType","config","urlTree","url"],"value":{"__symbolic":"error","message":"Reference to non-exported class","line":28,"character":0,"context":{"className":"Recognizer"}}}}} |
@@ -78,3 +78,3 @@ /** | ||
var fragment = ''; | ||
var activated = new ActivatedRouteSnapshot([], emptyParams, emptyQueryParams, fragment, emptyData, PRIMARY_OUTLET, rootComponent, null, urlTree.root, -1, InheritedResolve.empty); | ||
var activated = new ActivatedRouteSnapshot([], emptyParams, emptyQueryParams, fragment, emptyData, PRIMARY_OUTLET, rootComponent, null, urlTree.root, -1, {}); | ||
return new RouterStateSnapshot('', new TreeNode(activated, [])); | ||
@@ -209,29 +209,26 @@ } | ||
*/ | ||
export var InheritedResolve = (function () { | ||
function InheritedResolve(parent, current) { | ||
this.parent = parent; | ||
this.current = current; | ||
/** | ||
* @internal | ||
*/ | ||
this.resolvedData = {}; | ||
export function inheritedParamsDataResolve(route) { | ||
var pathToRoot = route.pathFromRoot; | ||
var inhertingStartingFrom = pathToRoot.length - 1; | ||
while (inhertingStartingFrom >= 1) { | ||
var current = pathToRoot[inhertingStartingFrom]; | ||
var parent_1 = pathToRoot[inhertingStartingFrom - 1]; | ||
// current route is an empty path => inherits its parent's params and data | ||
if (current.routeConfig && current.routeConfig.path === '') { | ||
inhertingStartingFrom--; | ||
} | ||
else if (!parent_1.component) { | ||
inhertingStartingFrom--; | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
Object.defineProperty(InheritedResolve.prototype, "flattenedResolvedData", { | ||
/** | ||
* @internal | ||
*/ | ||
get: function () { | ||
return this.parent ? merge(this.parent.flattenedResolvedData, this.resolvedData) : | ||
this.resolvedData; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(InheritedResolve, "empty", { | ||
get: function () { return new InheritedResolve(null, {}); }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return InheritedResolve; | ||
}()); | ||
return pathToRoot.slice(inhertingStartingFrom).reduce(function (res, curr) { | ||
var params = merge(res.params, curr.params); | ||
var data = merge(res.data, curr.data); | ||
var resolve = merge(res.resolve, curr._resolvedData); | ||
return { params: params, data: data, resolve: resolve }; | ||
}, { params: {}, data: {}, resolve: {} }); | ||
} | ||
/** | ||
@@ -238,0 +235,0 @@ * @whatItDoes Contains the information about a route associated with a component loaded in an |
@@ -435,4 +435,3 @@ /** | ||
traverseRoutes(futureNode: TreeNode<ActivatedRouteSnapshot>, currNode: TreeNode<ActivatedRouteSnapshot>, parentOutletMap: RouterOutletMap, futurePath: ActivatedRouteSnapshot[]): void; | ||
private deactivateOutletAndItChildren(route, outlet); | ||
private deactivateOutletMap(outletMap); | ||
private deactiveRouteAndItsChildren(route, outlet); | ||
private runCanActivate(future); | ||
@@ -439,0 +438,0 @@ private runCanActivateChild(path); |
@@ -25,3 +25,3 @@ /** | ||
import { RouterOutletMap } from './router_outlet_map'; | ||
import { ActivatedRoute, advanceActivatedRoute, createEmptyState } from './router_state'; | ||
import { ActivatedRoute, advanceActivatedRoute, createEmptyState, inheritedParamsDataResolve } from './router_state'; | ||
import { NavigationCancelingError, PRIMARY_OUTLET } from './shared'; | ||
@@ -568,3 +568,3 @@ import { UrlTree, containsTree, createEmptyUrlTree } from './url_tree'; | ||
}); | ||
forEach(prevChildren, function (v, k) { return _this.deactivateOutletAndItChildren(v, outletMap._outlets[k]); }); | ||
forEach(prevChildren, function (v, k) { return _this.deactiveRouteAndItsChildren(v, outletMap._outlets[k]); }); | ||
}; | ||
@@ -583,2 +583,3 @@ PreActivation.prototype.traverseRoutes = function (futureNode, currNode, parentOutletMap, futurePath) { | ||
future.data = curr.data; | ||
future._resolvedData = curr._resolvedData; | ||
} | ||
@@ -595,9 +596,3 @@ // If we have a component, we need to go through an outlet. | ||
if (curr) { | ||
// if we had a normal route, we need to deactivate only that outlet. | ||
if (curr.component) { | ||
this.deactivateOutletAndItChildren(curr, outlet); | ||
} | ||
else { | ||
this.deactivateOutletMap(parentOutletMap); | ||
} | ||
this.deactiveRouteAndItsChildren(currNode, outlet); | ||
} | ||
@@ -614,15 +609,11 @@ this.checks.push(new CanActivate(futurePath)); | ||
}; | ||
PreActivation.prototype.deactivateOutletAndItChildren = function (route, outlet) { | ||
if (outlet && outlet.isActivated) { | ||
this.deactivateOutletMap(outlet.outletMap); | ||
this.checks.push(new CanDeactivate(outlet.component, route)); | ||
} | ||
}; | ||
PreActivation.prototype.deactivateOutletMap = function (outletMap) { | ||
PreActivation.prototype.deactiveRouteAndItsChildren = function (route, outlet) { | ||
var _this = this; | ||
forEach(outletMap._outlets, function (v) { | ||
if (v.isActivated) { | ||
_this.deactivateOutletAndItChildren(v.activatedRoute.snapshot, v); | ||
} | ||
var prevChildren = nodeChildrenAsMap(route); | ||
forEach(prevChildren, function (v, k) { | ||
var childOutlet = outlet ? outlet.outletMap._outlets[k] : null; | ||
_this.deactiveRouteAndItsChildren(v, childOutlet); | ||
}); | ||
var component = outlet && outlet.isActivated ? outlet.component : null; | ||
this.checks.push(new CanDeactivate(component, route.value)); | ||
}; | ||
@@ -690,5 +681,5 @@ PreActivation.prototype.runCanActivate = function (future) { | ||
var resolve = future._resolve; | ||
return map.call(this.resolveNode(resolve.current, future), function (resolvedData) { | ||
resolve.resolvedData = resolvedData; | ||
future.data = merge(future.data, resolve.flattenedResolvedData); | ||
return map.call(this.resolveNode(resolve, future), function (resolvedData) { | ||
future._resolvedData = resolvedData; | ||
future.data = merge(future.data, inheritedParamsDataResolve(future).resolve); | ||
return null; | ||
@@ -730,3 +721,3 @@ }); | ||
}); | ||
forEach(prevChildren, function (v, k) { return _this.deactivateOutletAndItChildren(outletMap._outlets[k]); }); | ||
forEach(prevChildren, function (v, k) { return _this.deactiveRouteAndItsChildren(v, outletMap); }); | ||
}; | ||
@@ -742,3 +733,3 @@ ActivateRoutes.prototype.activateRoutes = function (futureNode, currNode, parentOutletMap) { | ||
if (future.component) { | ||
var outlet = getOutlet(parentOutletMap, futureNode.value); | ||
var outlet = getOutlet(parentOutletMap, future); | ||
this.activateChildRoutes(futureNode, currNode, outlet.outletMap); | ||
@@ -752,10 +743,3 @@ } | ||
if (curr) { | ||
// if we had a normal route, we need to deactivate only that outlet. | ||
if (curr.component) { | ||
var outlet = getOutlet(parentOutletMap, futureNode.value); | ||
this.deactivateOutletAndItChildren(outlet); | ||
} | ||
else { | ||
this.deactivateOutletMap(parentOutletMap); | ||
} | ||
this.deactiveRouteAndItsChildren(currNode, parentOutletMap); | ||
} | ||
@@ -792,12 +776,27 @@ // if we have a normal route, we need to advance the route | ||
}; | ||
ActivateRoutes.prototype.deactivateOutletAndItChildren = function (outlet) { | ||
ActivateRoutes.prototype.deactiveRouteAndItsChildren = function (route, parentOutletMap) { | ||
var _this = this; | ||
var prevChildren = nodeChildrenAsMap(route); | ||
var outlet = null; | ||
// getOutlet throws when cannot find the right outlet, | ||
// which can happen if an outlet was in an NgIf and was removed | ||
try { | ||
outlet = getOutlet(parentOutletMap, route.value); | ||
} | ||
catch (e) { | ||
return; | ||
} | ||
var childOutletMap = outlet.outletMap; | ||
forEach(prevChildren, function (v, k) { | ||
if (route.value.component) { | ||
_this.deactiveRouteAndItsChildren(v, childOutletMap); | ||
} | ||
else { | ||
_this.deactiveRouteAndItsChildren(v, parentOutletMap); | ||
} | ||
}); | ||
if (outlet && outlet.isActivated) { | ||
this.deactivateOutletMap(outlet.outletMap); | ||
outlet.deactivate(); | ||
} | ||
}; | ||
ActivateRoutes.prototype.deactivateOutletMap = function (outletMap) { | ||
var _this = this; | ||
forEach(outletMap._outlets, function (v) { return _this.deactivateOutletAndItChildren(v); }); | ||
}; | ||
return ActivateRoutes; | ||
@@ -804,0 +803,0 @@ }()); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 9 instances in 1 package
0
100
813415
10920