Skip to content

Commit 0022756

Browse files
committed
report extensions that the project uses
1 parent 1eb9f72 commit 0022756

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/virtual-machine.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,33 @@ class VirtualMachine extends EventEmitter {
259259
};
260260
}
261261

262+
getLoadedExtensionsInfo () {
263+
const extensionManager = this.extensionManager;
264+
const runtime = this.runtime;
265+
266+
if (!extensionManager || !runtime) {
267+
console.error('Virtual Machine is not properly initialized with an ExtensionManager and Runtime.');
268+
return [];
269+
}
270+
271+
const loadedExtensionIds = new Set(extensionManager._loadedExtensions.keys());
272+
const allRegisteredCategories = runtime._blockInfo;
273+
const extensionsInfo = [];
274+
275+
for (const category of allRegisteredCategories) {
276+
if (loadedExtensionIds.has(category.id)) {
277+
extensionsInfo.push({
278+
id: category.id,
279+
name: category.name,
280+
icon: category.blockIconURI || category.menuIconURI,
281+
color: category.color1
282+
});
283+
}
284+
}
285+
286+
return extensionsInfo;
287+
}
288+
262289
/**
263290
* Start running the VM - do this before anything else.
264291
*/

0 commit comments

Comments
 (0)