mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 06:23:37 -05:00
delay extension evaluation until that extension is installed
Reduce the amount of code that needs to evaluated before we can starting the target project if there is one. It is key to note that the music extension includes ~2MB of base64 encoded sound samples. This skips evaluating those samples and decoding base64 into binary typed arrays.
This commit is contained in:
parent
a791a1e64e
commit
a5009b4c59
1 changed files with 14 additions and 25 deletions
|
@ -7,32 +7,21 @@ const BlockType = require('./block-type');
|
|||
// These extensions are currently built into the VM repository but should not be loaded at startup.
|
||||
// TODO: move these out into a separate repository?
|
||||
// TODO: change extension spec so that library info, including extension ID, can be collected through static methods
|
||||
const Scratch3PenBlocks = require('../extensions/scratch3_pen');
|
||||
const Scratch3WeDo2Blocks = require('../extensions/scratch3_wedo2');
|
||||
const Scratch3MusicBlocks = require('../extensions/scratch3_music');
|
||||
const Scratch3MicroBitBlocks = require('../extensions/scratch3_microbit');
|
||||
const Scratch3Text2SpeechBlocks = require('../extensions/scratch3_text2speech');
|
||||
const Scratch3TranslateBlocks = require('../extensions/scratch3_translate');
|
||||
const Scratch3VideoSensingBlocks = require('../extensions/scratch3_video_sensing');
|
||||
const Scratch3Speech2TextBlocks = require('../extensions/scratch3_speech2text');
|
||||
const Scratch3Ev3Blocks = require('../extensions/scratch3_ev3');
|
||||
const Scratch3MakeyMakeyBlocks = require('../extensions/scratch3_makeymakey');
|
||||
// todo: only load this extension once we have a compatible way to load its
|
||||
// Vernier module dependency.
|
||||
// const Scratch3GdxForBlocks = require('../extensions/scratch3_gdx_for');
|
||||
|
||||
const builtinExtensions = {
|
||||
pen: Scratch3PenBlocks,
|
||||
wedo2: Scratch3WeDo2Blocks,
|
||||
music: Scratch3MusicBlocks,
|
||||
microbit: Scratch3MicroBitBlocks,
|
||||
text2speech: Scratch3Text2SpeechBlocks,
|
||||
translate: Scratch3TranslateBlocks,
|
||||
videoSensing: Scratch3VideoSensingBlocks,
|
||||
speech2text: Scratch3Speech2TextBlocks,
|
||||
ev3: Scratch3Ev3Blocks,
|
||||
makeymakey: Scratch3MakeyMakeyBlocks
|
||||
// gdxfor: Scratch3GdxForBlocks
|
||||
pen: () => require('../extensions/scratch3_pen'),
|
||||
wedo2: () => require('../extensions/scratch3_wedo2'),
|
||||
music: () => require('../extensions/scratch3_music'),
|
||||
microbit: () => require('../extensions/scratch3_microbit'),
|
||||
text2speech: () => require('../extensions/scratch3_text2speech'),
|
||||
translate: () => require('../extensions/scratch3_translate'),
|
||||
videoSensing: () => require('../extensions/scratch3_video_sensing'),
|
||||
speech2text: () => require('../extensions/scratch3_speech2text'),
|
||||
ev3: () => require('../extensions/scratch3_ev3'),
|
||||
makeymakey: () => require('../extensions/scratch3_makeymakey')
|
||||
// todo: only load this extension once we have a compatible way to load its
|
||||
// Vernier module dependency.
|
||||
// gdxfor: () => require('../extensions/scratch3_gdx_for')
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -133,7 +122,7 @@ class ExtensionManager {
|
|||
return Promise.reject(new Error(message));
|
||||
}
|
||||
|
||||
const extension = builtinExtensions[extensionURL];
|
||||
const extension = builtinExtensions[extensionURL]();
|
||||
const extensionInstance = new extension(this.runtime);
|
||||
return this._registerInternalExtension(extensionInstance).then(serviceName => {
|
||||
this._loadedExtensions.set(extensionURL, serviceName);
|
||||
|
|
Loading…
Reference in a new issue