Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Any documentation for project.json?
- ZZC12345
-
Scratcher
500+ posts
Any documentation for project.json?
^^
I was wondering if the project.json that can be fetched via "https://projects.scratch.mit.edu/$project_id" or by the `project.json` file inside the `.sb3` zip has any documentation? I'm working on a TypeScript-based Scratch project differ and I want to improve my types (right now I have `any` in a lot of places).
Here's my current `scratchproject_types.ts`:
Note: I know a lot of you all work in JavaScript. THIS IS NOT JAVASCRIPT, IT'S TYPESCRIPT.
I was wondering if the project.json that can be fetched via "https://projects.scratch.mit.edu/$project_id" or by the `project.json` file inside the `.sb3` zip has any documentation? I'm working on a TypeScript-based Scratch project differ and I want to improve my types (right now I have `any` in a lot of places).
Here's my current `scratchproject_types.ts`:
export interface ScratchComment { blockId: string, height: number, minimized: boolean, text: string, width: number, x: number, y: number } export interface ScratchProjectSprite { name: string, isStage: boolean, blocks: { [key: string]: ScratchBlock }, broadcasts: { [key: string]: string }, comments: { [key: string]: ScratchComment }, costumes: ScratchImageAsset[], currentCostume: number, direction: number, draggable: boolean, layerOrder: number, lists: { [key: string]: [string, string[]] }, rotationStyle: "all around" | "x" | "y", // Needs updating size: number, sounds: ScratchSoundAsset[], variables: { [key: string]: [string, string] }, visible: boolean, volume: number, x: number, y: number, diff?: "+" | "-" | "=" | undefined // For our purposes } export interface ScratchAsset { assetId: string, dataFormat: "svg" | "png" | "wav" | "mp3", md5ext: string, name: string, diff?: "+" | "-" | "=" | undefined // For our purposes } export interface ScratchSoundAsset extends ScratchAsset { dataFormat: "wav" | "mp3", format: string, rate: number, sampleCount: number } export interface ScratchImageAsset extends ScratchAsset { bitmapResolution: number, dataFormat: "svg" | "png", rotationCenterX: number, rotationCenterY: number } export interface ScratchBlock { opcode: string, parent: string | null, shadow: boolean, topLevel: boolean, next: string | null, fields: { [key: string]: any }, // TODO: Find definitions for fields and inputs (below) inputs: { [key: string]: any }, x?: number, y?: number, comment?: string, mutation?: any, diff?: "+" | "-" | undefined // For our purposes } export type ScratchProjectExtention = any; // TODO: Find definitions for extentions. export interface ScratchProjectMonitor { width: number, height: number, x: number, y: number, id: string, mode: "list" | "default", opcode: "data_listcontents" | "data_variable", params: { LIST: string } | { VARIABLE: string }, spriteName: string, value: string | string[], visible: boolean } export interface ScratchProjectJSON { meta: { agent: string, semver: string, vm: string } targets: ScratchProjectSprite[], monitors: ScratchProjectMonitor[], extention: ScratchProjectExtention[] } // Not technically in project.json, for our purposes. export interface ScratchProjectWorkspace { scripts: { [key: string]: ScratchBlock }, comments: { [key: string]: ScratchComment } }
Last edited by ZZC12345 (Aug. 8, 2022 07:31:16)
- Pufferfish_Test
-
Scratcher
500+ posts
Any documentation for project.json?
https://en.scratch-wiki.info/wiki/Scratch_File_Format provides a fairly thorough description of each part of the format. I've used it multiple times and updated it where I've found mistakes/missing info, so it should be pretty much correct.
I've recently written types for scratch projects in rust, I've just put them up at https://gist.github.com/pufferfish101007/9dee5d9ebd1f1132fbfd4af092a58c2c, so if you're at all comfortable with rust that might help.
I've recently written types for scratch projects in rust, I've just put them up at https://gist.github.com/pufferfish101007/9dee5d9ebd1f1132fbfd4af092a58c2c, so if you're at all comfortable with rust that might help.
Last edited by Pufferfish_Test (Aug. 8, 2022 16:44:31)
- ZZC12345
-
Scratcher
500+ posts
Any documentation for project.json?
https://en.scratch-wiki.info/wiki/Scratch_File_Format provides a fairly thorough description of each part of the format. I've used it multiple times and updated it where I've found mistakes/missing info, so it should be pretty much correct.Thank you so much! I don't know Rust (and I'm not using it) so I'll convert them to TypeScript to use. Thanks!
I've recently written types for scratch projects in rust, I've just put them up at https://gist.github.com/pufferfish101007/9dee5d9ebd1f1132fbfd4af092a58c2c, so if you're at all comfortable with rust that might help.
- Sheep_maker
-
Scratcher
1000+ posts
Any documentation for project.json?
You can also look at the schema for the 3.0 project.json: schema, definitions. From that it should be fairly easy to turn into TypeScript types
- ZZC12345
-
Scratcher
500+ posts
Any documentation for project.json?
You can also look at the schema for the 3.0 project.json: schema, definitions. From that it should be fairly easy to turn into TypeScript typesOh, even better! Technical documentation!
- Discussion Forums
- » Advanced Topics
-
» Any documentation for project.json?