| 
									
										
										
										
											2020-10-23 20:52:23 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const RuntimeGlobals = require("../RuntimeGlobals"); | 
					
						
							|  |  |  | const RuntimeModule = require("../RuntimeModule"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-13 01:24:59 +08:00
										 |  |  | /** @typedef {import("../Chunk")} Chunk */ | 
					
						
							|  |  |  | /** @typedef {import("../ChunkGraph")} ChunkGraph */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-23 20:52:23 +08:00
										 |  |  | class RuntimeIdRuntimeModule extends RuntimeModule { | 
					
						
							|  |  |  | 	constructor() { | 
					
						
							|  |  |  | 		super("runtimeId"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2023-06-17 01:13:03 +08:00
										 |  |  | 	 * @returns {string | null} runtime code | 
					
						
							| 
									
										
										
										
											2020-10-23 20:52:23 +08:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	generate() { | 
					
						
							| 
									
										
										
										
											2023-06-13 01:24:59 +08:00
										 |  |  | 		const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph); | 
					
						
							|  |  |  | 		const chunk = /** @type {Chunk} */ (this.chunk); | 
					
						
							| 
									
										
										
										
											2020-10-23 20:52:23 +08:00
										 |  |  | 		const runtime = chunk.runtime; | 
					
						
							|  |  |  | 		if (typeof runtime !== "string") | 
					
						
							|  |  |  | 			throw new Error("RuntimeIdRuntimeModule must be in a single runtime"); | 
					
						
							|  |  |  | 		const id = chunkGraph.getRuntimeId(runtime); | 
					
						
							|  |  |  | 		return `${RuntimeGlobals.runtimeId} = ${JSON.stringify(id)};`; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = RuntimeIdRuntimeModule; |