mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-28 07:10:27 -04:00
Add code to load 'core' extensions
This commit is contained in:
parent
f8db6c3f02
commit
3be16eddb1
1 changed files with 23 additions and 3 deletions
|
@ -20,6 +20,18 @@ const {serializeSounds, serializeCostumes} = require('./serialization/serialize-
|
|||
|
||||
const RESERVED_NAMES = ['_mouse_', '_stage_', '_edge_', '_myself_', '_random_'];
|
||||
|
||||
const CORE_EXTENSIONS = [
|
||||
// 'motion',
|
||||
// 'looks',
|
||||
// 'sound',
|
||||
// 'events',
|
||||
// 'control',
|
||||
// 'sensing',
|
||||
// 'operators',
|
||||
// 'variables',
|
||||
// 'myBlocks'
|
||||
];
|
||||
|
||||
/**
|
||||
* Handles connections between blocks, stage, and extensions.
|
||||
* @constructor
|
||||
|
@ -314,6 +326,17 @@ class VirtualMachine extends EventEmitter {
|
|||
*/
|
||||
installTargets (targets, extensions, wholeProject) {
|
||||
const extensionPromises = [];
|
||||
|
||||
if (wholeProject) {
|
||||
this.clear();
|
||||
|
||||
CORE_EXTENSIONS.forEach(extensionID => {
|
||||
if (!this.extensionManager.isExtensionLoaded(extensionID)) {
|
||||
extensionPromises.push(this.extensionManager.loadExtensionURL(extensionID));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
extensions.extensionIDs.forEach(extensionID => {
|
||||
if (!this.extensionManager.isExtensionLoaded(extensionID)) {
|
||||
const extensionURL = extensions.extensionURLs.get(extensionID) || extensionID;
|
||||
|
@ -324,9 +347,6 @@ class VirtualMachine extends EventEmitter {
|
|||
targets = targets.filter(target => !!target);
|
||||
|
||||
return Promise.all(extensionPromises).then(() => {
|
||||
if (wholeProject) {
|
||||
this.clear();
|
||||
}
|
||||
targets.forEach(target => {
|
||||
this.runtime.targets.push(target);
|
||||
(/** @type RenderedTarget */ target).updateAllDrawableProperties();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue