If the URL is already loaded, resolve immediately.
Fixes https://github.com/TurboWarp/scratch-gui/issues/637
Caused by TWStateManager repeatedly calling loadExtensionURL on locale
change.
This could be fixed in GUI, but fixing it in VM is easier and loading
multiple instances of the same extension doesn't make sense anyways.
If the compiler's type analysis becomes smarter, being able to show that
its output matches what is expected will become more important. Snapshot
testing is how we will solve that.
This is a breaking change.
Replaces logic that was previously in our scratch-gui fork.
Upstream does the opposite; they disable cloud variables when video
sensing is used. We can't do the same because of custom extensions.
Disabling all custom extensions when video sensing is used would be too
limiting. The concern with custom extensions is not that they will steal
private skins, but that a project could use their blocks to fetch()
color information to a remote server similar to cloud variables.
The end result is not dissimilar: Cloud variables and video sensing
shouldn't be used together.
The parameters didn't work in the way that you would expect. Only the
values provided in the first call to addAddonBlock would do anything,
and this gives a false impression that this will color the blocks in the
editor. Color options may be re-added in the future as part of a more
significant API update.
This adds a new mode of custom extension that runs outside of any
sandbox -- they're just <script> tags. This is disabled by default and
needs explicit opt-in. Documentation will be written later.
This also will save the URLs of the loaded custom extensions to
project.json when serializing a project. When deserializing a project,
this list can be read to automatically load the extensions. This, again,
is disabled by default and requires explicit opt-in.
A new mechanism called the SecurityManager was added to the extension
manager to facilitate these new features. This replaces workerMode and
is a breaking change.
Various other custom extension related changes were also added:
- Reject invalid URLs in loadExtensionURL
- Various cleanup and refactoring
Browsers, especially Chrome, crumble when we try to create too many
image bitmaps at once. So we'll queue them up when too many are
happening. Projects will load slightly slower but this is still much
faster than <img> with data: URIs