| 
									
										
										
										
											2020-08-20 05:17:33 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const ExternalsPlugin = require("../ExternalsPlugin"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** @typedef {import("../Compiler")} Compiler */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ElectronTargetPlugin { | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2020-09-10 16:42:29 +08:00
										 |  |  | 	 * @param {"main" | "preload" | "renderer"=} context in main, preload or renderer context? | 
					
						
							| 
									
										
										
										
											2020-08-20 05:17:33 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2020-09-10 16:42:29 +08:00
										 |  |  | 	constructor(context) { | 
					
						
							|  |  |  | 		this._context = context; | 
					
						
							| 
									
										
										
										
											2020-08-20 05:17:33 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * Apply the plugin | 
					
						
							|  |  |  | 	 * @param {Compiler} compiler the compiler instance | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	apply(compiler) { | 
					
						
							| 
									
										
										
										
											2020-09-10 16:42:29 +08:00
										 |  |  | 		new ExternalsPlugin("commonjs", [ | 
					
						
							|  |  |  | 			"clipboard", | 
					
						
							|  |  |  | 			"crash-reporter", | 
					
						
							|  |  |  | 			"electron", | 
					
						
							|  |  |  | 			"ipc", | 
					
						
							|  |  |  | 			"native-image", | 
					
						
							|  |  |  | 			"original-fs", | 
					
						
							|  |  |  | 			"screen", | 
					
						
							|  |  |  | 			"shell" | 
					
						
							| 
									
										
										
										
											2020-10-08 07:06:31 +08:00
										 |  |  | 		]).apply(compiler); | 
					
						
							| 
									
										
										
										
											2020-09-10 16:42:29 +08:00
										 |  |  | 		switch (this._context) { | 
					
						
							|  |  |  | 			case "main": | 
					
						
							|  |  |  | 				new ExternalsPlugin("commonjs", [ | 
					
						
							|  |  |  | 					"app", | 
					
						
							|  |  |  | 					"auto-updater", | 
					
						
							|  |  |  | 					"browser-window", | 
					
						
							|  |  |  | 					"content-tracing", | 
					
						
							|  |  |  | 					"dialog", | 
					
						
							|  |  |  | 					"global-shortcut", | 
					
						
							|  |  |  | 					"ipc-main", | 
					
						
							|  |  |  | 					"menu", | 
					
						
							|  |  |  | 					"menu-item", | 
					
						
							|  |  |  | 					"power-monitor", | 
					
						
							|  |  |  | 					"power-save-blocker", | 
					
						
							|  |  |  | 					"protocol", | 
					
						
							|  |  |  | 					"session", | 
					
						
							|  |  |  | 					"tray", | 
					
						
							|  |  |  | 					"web-contents" | 
					
						
							|  |  |  | 				]).apply(compiler); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			case "preload": | 
					
						
							|  |  |  | 			case "renderer": | 
					
						
							|  |  |  | 				new ExternalsPlugin("commonjs", [ | 
					
						
							|  |  |  | 					"desktop-capturer", | 
					
						
							|  |  |  | 					"ipc-renderer", | 
					
						
							|  |  |  | 					"remote", | 
					
						
							|  |  |  | 					"web-frame" | 
					
						
							|  |  |  | 				]).apply(compiler); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-08-20 05:17:33 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = ElectronTargetPlugin; |