@robotical/scratch-to-python-transpiler
Version:
Transpile Scratch project files to python code
171 lines (170 loc) • 4.85 kB
TypeScript
import { OpCode } from "../../OpCode";
import { KnownBlock, ProcedureBlock } from "../../Block";
import { TextToSpeechLanguage } from "../../Project";
import * as _BlockInput from "../../BlockInput";
export declare type ScalarValue = string | number | boolean;
export declare type AssetId = string;
export declare type Variable = [string, ScalarValue] | [string, ScalarValue, true];
export declare type List = [string, ScalarValue[]];
export interface Costume {
assetId: AssetId;
dataFormat: "png" | "svg" | "jpeg" | "jpg" | "bmp" | "gif";
name: string;
md5ext?: string;
bitmapResolution?: number;
rotationCenterX?: number;
rotationCenterY?: number;
}
export interface Sound {
assetId: AssetId;
dataFormat: "wav" | "wave" | "mp3";
name: string;
md5ext?: string;
rate?: number;
sampleCount?: number;
}
interface Mutation {
[attribute: string]: Mutation[] | string;
children: Mutation[];
}
export interface Block {
opcode: OpCode;
next: string | null;
parent: string | null;
inputs: {
[key: string]: BlockInput;
};
fields: {
[key: string]: BlockField;
};
mutation?: Mutation;
shadow: boolean;
topLevel: boolean;
x?: number;
y?: number;
}
export declare type BlockField = string[];
interface Comment {
blockId: string;
x: number;
y: number;
width: number;
height: number;
minimized: boolean;
text: string;
}
export interface Target {
isStage: boolean;
name: string;
variables: {
[key: string]: Variable;
};
lists: {
[key: string]: List;
};
broadcasts: {
[key: string]: string;
};
blocks: {
[key: string]: Block;
};
comments: {
[key: string]: Comment;
};
currentCostume: number;
costumes: Costume[];
sounds: Sound[];
volume: number;
layerOrder: number;
}
export interface Stage extends Target {
isStage: true;
tempo: number;
videoTransparency: number;
videoState: "on" | "off";
textToSpeechLanguage: TextToSpeechLanguage;
}
export interface Sprite extends Target {
isStage: false;
visible: boolean;
x: number;
y: number;
size: number;
direction: number;
draggable: boolean;
rotationStyle: "all around" | "left-right" | "don't rotate";
}
interface MonitorBase {
id: string;
mode: "default" | "large" | "slider" | "list";
opcode: "data_variable" | "data_listcontents";
params: {
[key: string]: string;
};
spriteName: string;
width: number;
height: number;
x: number;
y: number;
visible: boolean;
}
export interface VariableMonitor extends MonitorBase {
mode: "default" | "large" | "slider";
opcode: "data_variable";
params: {
VARIABLE: string;
};
value: ScalarValue;
sliderMin: number;
sliderMax: number;
isDiscrete: boolean;
}
export interface ListMonitor extends MonitorBase {
mode: "list";
opcode: "data_listcontents";
params: {
LIST: string;
};
value: ScalarValue[];
}
export declare type Monitor = VariableMonitor | ListMonitor;
interface Meta {
semver: string;
vm?: string;
agent?: string;
}
export interface ProjectJSON {
targets: Target[];
monitors?: Monitor[];
meta: Meta;
}
export declare const fieldTypeMap: {
[opcode in OpCode]?: {
[fieldName: string]: _BlockInput.Any["type"];
};
};
export declare enum BlockInputStatus {
INPUT_SAME_BLOCK_SHADOW = 1,
INPUT_BLOCK_NO_SHADOW = 2,
INPUT_DIFF_BLOCK_SHADOW = 3,
MATH_NUM_PRIMITIVE = 4,
POSITIVE_NUM_PRIMITIVE = 5,
WHOLE_NUM_PRIMITIVE = 6,
INTEGER_NUM_PRIMITIVE = 7,
ANGLE_NUM_PRIMITIVE = 8,
COLOR_PICKER_PRIMITIVE = 9,
TEXT_PRIMITIVE = 10,
BROADCAST_PRIMITIVE = 11,
VAR_PRIMITIVE = 12,
LIST_PRIMITIVE = 13
}
export import BIS = BlockInputStatus;
export declare const BooleanOrSubstackInputStatus = BIS.INPUT_BLOCK_NO_SHADOW;
export declare type BlockInput = [BIS.INPUT_SAME_BLOCK_SHADOW, BlockInputValue] | [BIS.INPUT_BLOCK_NO_SHADOW, BlockInputValue] | [BIS.INPUT_DIFF_BLOCK_SHADOW, BlockInputValue, BlockInputValue];
export declare type BlockInputValue = string | [BIS.MATH_NUM_PRIMITIVE, number | string] | [BIS.POSITIVE_NUM_PRIMITIVE, number | string] | [BIS.WHOLE_NUM_PRIMITIVE, number | string] | [BIS.INTEGER_NUM_PRIMITIVE, number | string] | [BIS.ANGLE_NUM_PRIMITIVE, number | string] | [BIS.COLOR_PICKER_PRIMITIVE, string] | [BIS.TEXT_PRIMITIVE, string] | [BIS.BROADCAST_PRIMITIVE, string, string] | [BIS.VAR_PRIMITIVE, string, string] | [BIS.LIST_PRIMITIVE, string, string];
export declare const inputPrimitiveOrShadowMap: {
[opcode in Exclude<KnownBlock["opcode"], ProcedureBlock["opcode"]>]: {
[fieldName: string]: number | OpCode;
};
};
export {};