Coder Social home page Coder Social logo

turbowarp / types Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 13.0 77 KB

Type definitions for the Scratch VM and editor

Home Page: https://turbowarp.github.io/types/

License: Apache License 2.0

TypeScript 78.23% JavaScript 21.77%
scratch typescript help-wanted

types's People

Contributors

garbomuffin avatar seheon99 avatar tacodiva avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

types's Issues

some missing ones

  • vm._editingTarget
  • updateSVGSkin rotation center argument optional?
  • document getSpriteTargetByName never returns stage sprite
  • link target.sprite.name and target.getName() ?
  • document what updateSvgSkin updateBitmapSkin etc. do when skin is wrong type (reskin)
  • tw: SOUND and COSTUME arguments
  • tw: packaged runtime mode? document what it actually means
  • tw: costume.asset, sound.asset can be null if packaged runtime

SB3 Types

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.

Suggestion: Using strings instead of an enum for layer group in scratch-renderer

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.

`sprite.clones` and `sprite.soundBank` are missing

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:

interface Sprite {
runtime: Runtime;
blocks: Blocks;
name: string;
costumes: Costume[];
sounds: Sound[];
}

scratch-vm-extension not usable from index.d.ts

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.