@@ -82,13 +82,6 @@ class ExtensionManager {
8282 */
8383 this . pendingWorkers = [ ] ;
8484
85- /**
86- * Map of loaded extension URLs/IDs to sanitized extension info.
87- * @type {Map.<string, ExtensionInfo> }
88- * @private
89- */
90- this . _loadedExtensions = new Map ( ) ;
91-
9285 /**
9386 * Keep a reference to the runtime so we can construct internal extension objects.
9487 * TODO: remove this in favor of extensions accessing the runtime as a service.
@@ -107,19 +100,21 @@ class ExtensionManager {
107100 * `loadExtensionURL` if you need to wait until the extension is truly ready.
108101 * @param {string } extensionID - the ID of the extension.
109102 * @returns {boolean } - true if loaded, false otherwise.
103+ * @deprecated Please use `isExtensionLoaded` on the Runtime instead.
110104 */
111105 isExtensionLoaded ( extensionID ) {
112- return this . _loadedExtensions . has ( extensionID ) ;
106+ return this . runtime . isExtensionLoaded ( extensionID ) ;
113107 }
114108
115109 /**
116110 * Fetch the cached information about an extension. Does not call `getInfo` on the extension
117111 * @see {@link isExtensionLoaded } for details about registration timing.
118112 * @param {string } extensionID - the ID of the extension.
119113 * @return {ExtensionInfo } - cached information about the extension, or `undefined` if the extension is not loaded.
114+ * @deprecated Please use `getExtensionInfo` on the Runtime instead.
120115 */
121116 getExtensionInfo ( extensionID ) {
122- return this . _loadedExtensions . get ( extensionID ) ;
117+ return this . runtime . getExtensionInfo ( extensionID ) ;
123118 }
124119
125120 /**
@@ -133,7 +128,7 @@ class ExtensionManager {
133128 return ;
134129 }
135130
136- if ( this . isExtensionLoaded ( extensionId ) ) {
131+ if ( this . runtime . isExtensionLoaded ( extensionId ) ) {
137132 const message = `Rejecting attempt to load a second extension with ID ${ extensionId } ` ;
138133 log . warn ( message ) ;
139134 return ;
@@ -171,16 +166,17 @@ class ExtensionManager {
171166 * @returns {Promise } resolved once all the extensions have been reinitialized
172167 */
173168 refreshBlocks ( ) {
169+ const loadedExtensions = this . runtime . getLoadedExtensions ( ) ;
174170 const allPromises = [ ] ;
175- this . _loadedExtensions . forEach ( ( extensionInfo , oldId ) => {
171+ loadedExtensions . forEach ( ( extensionInfo , oldId ) => {
176172 const serviceName = extensionInfo . serviceName ;
177173 allPromises . push ( dispatch . call ( serviceName , 'getInfo' )
178174 . then ( info => {
179175 info = this . _prepareExtensionInfo ( serviceName , info ) ;
180- this . _loadedExtensions . set ( info . id , info ) ;
176+ loadedExtensions . set ( info . id , info ) ;
181177 if ( oldId !== info . id ) {
182178 log . warn ( `Extension changed ID from ${ oldId } to ${ info . id } !` ) ;
183- this . _loadedExtensions . delete ( oldId ) ;
179+ loadedExtensions . delete ( oldId ) ;
184180 }
185181 dispatch . call ( 'runtime' , '_refreshExtensionPrimitives' , info ) ;
186182 } )
@@ -244,7 +240,7 @@ class ExtensionManager {
244240 dispatch . setServiceSync ( serviceName , extensionObject ) ;
245241 this . registerExtensionServiceSync ( serviceName ) ;
246242 const extensionInfo = this . _prepareExtensionInfo ( serviceName , rawExtensionInfo ) ;
247- this . _loadedExtensions . set ( extensionInfo . id , extensionInfo ) ;
243+ this . runtime . getLoadedExtensions ( ) . set ( extensionInfo . id , extensionInfo ) ;
248244 }
249245
250246 /**
0 commit comments