Repository navigation
Declare the scratch-vm surface scratch-gui uses - #1
Merged
Merged
Conversation
Type the VM, runtime, targets, blocks, threads, monitors, extension
manager, security manager, editing commands, font and asset managers,
and the renderer calls the GUI makes, all read from scratch-vm
vm-structure. The VM event map now lists only the runtime events the VM
forwards, plus its own events, so vm.on('PROJECT_LOADED') is rejected.
Underscore members the GUI reads live in separate *Internals interfaces.
Also declare the internal modules the GUI imports: argument-type,
block-type, fractch-context, rotur/core and opcodes.generated.json.
Consumers add their own VM and runtime events by augmenting the VirtualMachineCustomEvents and RuntimeCustomEvents interfaces in scratch-vm/events; undeclared names are still rejected. Declare the storage asset fields the GUI reads, type vm.assets, MonitorRecord.get, FontManager fonts, EditingCommands.extensions and the zip output types of saveProjectSb3 and exportSprite. Methods the editing handler wraps now return void or a promise. Drop declarations scratch-gui does not use.
scratch-gui's src/packager calls convertToPackagedRuntime and reads runtime.peripheralExtensions and runtime.v2BitmapAdapter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Exact TypeScript declarations for everything scratch-gui uses from scratch-vm, each written by reading the implementation on MistWarp/scratch-vm#37's branch.
What's declared
_blockInfo,_step,_cloneCounterand others) are kept apart in*Internalsinterfaces.scratch-vm/events, as the GUI does for restore points and pausing.reorder*,rename*,update*andpostSpriteInfocan return a Promise, andsaveProjectSb3andexportSpritereturn types follow the zip type passed in.Checks
npm run checktype-checks the declarations and compile tests intest/, with@ts-expect-errornegatives for every rejected case.import VM from 'scratch-vm',import = requireand checked JS.Bugs found while reading the VM. These are fixed or tracked separately:
PROJECT_LOADEDonvm, where it never fires (fixed in Listen for PROJECT_LOADED on the runtime, where the VM emits it scratch-gui#199).There is no visible change.