This is an idea for what the future of extensions could be like.
Scratch Children Properties
Scratch.blocks
Scratch.blocks
could be an object containing functions that can be called to execute blocks. Vanilla Scratch blocks can be executed here (except motion, sound, and music blocks, as that could be annoying and unwanted to the user.)
Some blocks with large power over sprites or simply blocks that could do unwanted actions to the user could require permission from the user. Whether that be a simple confirm
prompt or a custom popup, that part does not matter.
Scratch.extensions
Scratch.extensions.register
A class reference should be passed to this function, to load an extension into Turbowarp.
Main class's getInfo()
configuration properties
Main Class's getInfo().allowExternal
The allowExternal
is a boolean value that can control whether other extensions can use them via Scratch.blocks
. If it is not specified, or is undefined, than it will default to true. If it is changed after the class is first called, then the changes are to be ignored.
Main Class's getInfo().visible
This property allows an extension to specify if it is visible to the user. This is useful for extensions meant to be used as dependencies for other blocks. Turbowarp is to check if it has changed every frame, and if it has, then the block's visibility is to be updated. If it is changed, it will not affect the blocks the user has already placed, but become invisible from the toolbar. If it is not specified, or is undefined, than it will default to true.
Main Class's getInfo().dependencies
This is an array full of URLs to extensions that this one depends on to function. For built-in extensions, it is simply the extension's name, with the first letter capitalized. If it is not specified, is undefined, or it is not an array-like object, it defaults to an empty array. If this extension has any dependencies, the user must be notified of the dependencies that will be installed with the extension they originally intended to install. Not only the name of this extension must be specified, but the URL must also be specified to the user so that a misleading name does not trick the user into installing a potentially unwanted extension. If it is a built-in extension, one that you might include in a project using the built-in "Choose an extension" menu, then the URL is not provided, and simply the name, with a note telling the user this is the legitimate scratch extension and not a misleadingly named one.