turbowarp / types Goto Github PK
View Code? Open in Web Editor NEWType definitions for the Scratch VM and editor
Home Page: https://turbowarp.github.io/types/
License: Apache License 2.0
Type definitions for the Scratch VM and editor
Home Page: https://turbowarp.github.io/types/
License: Apache License 2.0
I'm not sure if these types belong in this or not, because while it's not technically a library, it is used by library in methods like this, but it would be helpful if this library contained types for the project.json
object in SB3 files.
If you're happy to add these types, I just wrote some simple ones for my project here that shouldn't be difficult to copy and paste over to here. I will eventually be adding types for each opcode individually to get rid of the records in ProjectSB3BlockBase
, but that could be a while.
In my opinion, it's kind of strange that these typing as they are right now only allow you to use the layer groups that scratch uses. As the comment in the enum says:
const enum LayerGroup {
// The renderer can be configured to use any strings as group names, but these are the groups
// that scratch-vm uses, listed in order.
Background = 'background',
Video = 'video',
Pen = 'pen',
Sprite = 'sprite'
}
What you name your layer groups is really a decision made by consumers of the scratch-renderer library and shouldn't be arbitrarily enforced by these typings. Because of this odd restriction, things like the playground example which come directly from scratch-render repo will not compile without casting or changing the layer group name to one of the four prescribed by the enum above.
I think this should be changed, but I though I'd create an issue because it seems to be a very deliberate decision and I was curious to hear your thoughts.
I found in the scratch-vm repository that RenderedTarget.setXY()
emits TARGET_MOVED
and EVENT_TARGET_VISUAL_CHANGE
:
And I found this TODO:
Lines 358 to 360 in 720689f
code:
const myCat = vm.runtime.getSpriteTargetByName('Cat');
console.log(myCat.sprite);
log:
Sprite {
runtime: Runtime {},
blocks: Blocks {},
name: 'Cat',
costumes_: [],
sounds: [],
clones: [],
soundBank: null
}
But Sprite
interface isn't have clones
and soundBank
properties:
Lines 73 to 79 in b57ba60
they are constructors not instances
For extensions you can't use the scratch extension vm with import Scratch from 'scratch-vm-extension';
as it isn't used in index.d.ts
.
just a quick note as right now you can't use the types for extensions.
(if I'm just stupid and missed something, please tell me)
import Anina R Cross (others?) in costume library
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.