forked from TurboWarp/extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScratch.d.ts
135 lines (113 loc) · 3.17 KB
/
Scratch.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/// <reference path="../node_modules/@turbowarp/types/types/scratch-vm.d.ts" />
// I really don't like the above but it works for now
declare namespace Scratch {
// TODO: move these types to @turbowarp/types once they're more complete
namespace ArgumentType {
/** @deprecated not tested -- do not rely on yet */
const ANGLE: 'angle';
const BOOLEAN: 'Boolean';
/** @deprecated not tested -- do not rely on yet */
const COLOR: 'color';
const NUMBER: 'number';
const STRING: 'string';
/** @deprecated not tested -- do not rely on yet */
const MATRIX: 'matrix';
/** @deprecated not tested -- do not rely on yet */
const NOTE: 'note';
/** @deprecated not tested -- do not rely on yet */
const IMAGE: 'image';
}
type ArgumentType = (typeof ArgumentType)[keyof typeof ArgumentType];
namespace BlockType {
// The B in Boolean is supposed to be capitalized
const BOOLEAN: 'Boolean';
/** @deprecated not tested -- do not rely on yet */
const BUTTON: 'button';
const COMMAND: 'command';
/** @deprecated not tested -- do not rely on yet */
const CONDITIONAL: 'conditional';
const EVENT: 'event';
const HAT: 'hat';
/** @deprecated not tested -- do not rely on yet */
const LOOP: 'loop';
const REPORTER: 'reporter';
}
type BlockType = (typeof BlockType)[keyof typeof BlockType];
namespace TargetType {
const SPRITE: 'sprite';
const STAGE: 'stage';
}
type TargetType = (typeof TargetType)[keyof typeof TargetType];
/**
* scratch-vm instance. Only for unsandboxed extensions.
*/
const vm: VM;
/**
* scratch-render instance. Only for unsandboxed extensions.
*/
const renderer: RenderWebGL;
/**
* Technically this can be a translatable object, but in reality it will probably just be
* a string here.
*/
type FormattableString = string;
interface ExtensionArgumentInfo {
type: ArgumentType;
defaultValue?: string | number;
menu?: string;
}
interface ExtensionBlock {
opcode: string;
blockType: BlockType;
text: FormattableString;
arguments?: Record<string, ExtensionArgumentInfo>;
// TODO: documentation mentions func, filter, branchCount, terminal, blockAllThreads
}
interface ExtensionMenu {
acceptReporters?: boolean;
items: Array<{
text: string;
value: string;
}>;
}
interface ExtensionInfo {
id: string;
/**
* Defaults to ID if not specified.
*/
name?: FormattableString;
/**
* Should be a hex color code.
*/
color1?: string;
/**
* Should be a hex color code.
*/
color2?: string;
/**
* Should be a hex color code.
*/
color3?: string;
/**
* Should be a data: URI
*/
menuIconURI?: string;
/**
* Should be a data: URI
*/
blockIconURI?: string;
docsURI?: string;
blocks: (ExtensionBlock | string)[];
menus?: Record<string, ExtensionMenu>;
}
interface Extension {
getInfo(): ExtensionInfo;
}
namespace extensions {
function register(extensionObject: Extension): void;
/**
* True if the extension is running unsandboxed.
*/
const unsandboxed: boolean;
}
}