| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** @typedef {import("./Dependency")} Dependency */ | 
					
						
							|  |  |  | /** @typedef {import("./Module")} Module */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ModuleGraphConnection { | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Module=} originModule the referencing module | 
					
						
							|  |  |  | 	 * @param {Dependency=} dependency the referencing dependency | 
					
						
							|  |  |  | 	 * @param {Module} module the referenced module | 
					
						
							|  |  |  | 	 * @param {string=} explanation some extra detail | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	constructor(originModule, dependency, module, explanation) { | 
					
						
							|  |  |  | 		this.originModule = originModule; | 
					
						
							| 
									
										
										
										
											2018-08-07 20:20:53 +08:00
										 |  |  | 		this.resolvedOriginModule = originModule; | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | 		this.dependency = dependency; | 
					
						
							|  |  |  | 		this.resolvedModule = module; | 
					
						
							|  |  |  | 		this.module = module; | 
					
						
							| 
									
										
										
										
											2018-11-07 21:03:25 +08:00
										 |  |  | 		/** @type {Set<string>} */ | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | 		this.explanations = new Set(); | 
					
						
							| 
									
										
										
										
											2018-11-07 21:03:25 +08:00
										 |  |  | 		if (explanation) { | 
					
						
							|  |  |  | 			this.explanations.add(explanation); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-07 21:03:25 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {string} explanation the explanation to add | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | 	addExplanation(explanation) { | 
					
						
							|  |  |  | 		this.explanations.add(explanation); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	get explanation() { | 
					
						
							|  |  |  | 		return Array.from(this.explanations).join(" "); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = ModuleGraphConnection; |