@turbowarp/types 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/package.json +1 -1
- package/tests/test-jszip.ts +16 -0
- package/tests/test-scratch-vm-extension.js +70 -1
- package/tests/test-scratch-vm.ts +14 -0
- package/types/jszip.d.ts +24 -0
- package/types/scratch-audio.d.ts +1 -0
- package/types/scratch-vm-extension.d.ts +185 -67
- package/types/scratch-vm.d.ts +75 -5
package/README.md
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Scratch doesn't provide type definitions for their libraries, so we wrote our own.
|
|
4
4
|
|
|
5
|
-
This
|
|
6
|
-
|
|
7
|
-
Despite being in the TurboWarp organization, this project is currently focused only on the vanilla (LLK) Scratch runtime and editor. Additional types for TurboWarp may be added later.
|
|
5
|
+
This repository only contains types for the vanilla (LLK) Scratch runtime and editor. For the additional types in the TurboWarp runtimes, see [@turbowarp/types-tw](https://github.com/TurboWarp/types-tw).
|
|
8
6
|
|
|
9
7
|
|Module|Status|
|
|
10
8
|
|:-:|:-:|
|
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare const stream: JSZip.StreamHelper<'uint8array'>;
|
|
2
|
+
|
|
3
|
+
stream.on('data', data => {
|
|
4
|
+
data as Uint8Array
|
|
5
|
+
});
|
|
6
|
+
stream.on('data', (data, metadata) => {
|
|
7
|
+
metadata.percent as number
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
stream.pause();
|
|
11
|
+
stream.resume();
|
|
12
|
+
|
|
13
|
+
// @ts-expect-error
|
|
14
|
+
stream.on('whatever', () => {
|
|
15
|
+
|
|
16
|
+
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
class Fetch {
|
|
5
|
+
/** @returns {Scratch.Info} */
|
|
5
6
|
getInfo () {
|
|
6
7
|
return {
|
|
7
8
|
id: 'fetch',
|
|
@@ -17,8 +18,65 @@
|
|
|
17
18
|
defaultValue: 'https://extensions.turbowarp.org/hello.txt'
|
|
18
19
|
}
|
|
19
20
|
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
opcode: 'test',
|
|
24
|
+
text: 'test [STRING] [IMAGE] [BOOLEAN] [NUMBER] [MATRIX] [NOTE] [ANGLE] [COLOR]',
|
|
25
|
+
blockType: Scratch.BlockType.COMMAND,
|
|
26
|
+
hideFromPalette: false,
|
|
27
|
+
isTerminal: true,
|
|
28
|
+
arguments: {
|
|
29
|
+
STRING: {
|
|
30
|
+
type: Scratch.ArgumentType.STRING,
|
|
31
|
+
defaultValue: 'test',
|
|
32
|
+
menu: 'test1'
|
|
33
|
+
},
|
|
34
|
+
IMAGE: {
|
|
35
|
+
type: Scratch.ArgumentType.IMAGE,
|
|
36
|
+
dataURI: 'https://extensions.turbowarp.org/dango.png'
|
|
37
|
+
},
|
|
38
|
+
BOOLEAN: {
|
|
39
|
+
type: Scratch.ArgumentType.BOOLEAN
|
|
40
|
+
},
|
|
41
|
+
NUMBER: {
|
|
42
|
+
type: Scratch.ArgumentType.NUMBER,
|
|
43
|
+
defaultValue: 5,
|
|
44
|
+
},
|
|
45
|
+
MATRIX: {
|
|
46
|
+
type: Scratch.ArgumentType.MATRIX,
|
|
47
|
+
defaultValue: '0101001010000001000101110'
|
|
48
|
+
},
|
|
49
|
+
NOTE: {
|
|
50
|
+
type: Scratch.ArgumentType.NOTE,
|
|
51
|
+
defaultValue: '30'
|
|
52
|
+
},
|
|
53
|
+
ANGLE: {
|
|
54
|
+
type: Scratch.ArgumentType.ANGLE,
|
|
55
|
+
defaultValue: 30
|
|
56
|
+
},
|
|
57
|
+
COLOR: {
|
|
58
|
+
type: Scratch.ArgumentType.COLOR,
|
|
59
|
+
defaultValue: '#123456'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
opcode: 'button',
|
|
65
|
+
blockType: Scratch.BlockType.BUTTON,
|
|
66
|
+
func: 'MAKE_A_VARIABLE',
|
|
67
|
+
text: 'button text'
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
menus: {
|
|
71
|
+
test1: ['1', '2', '3'],
|
|
72
|
+
test2: {
|
|
73
|
+
acceptReporters: false,
|
|
74
|
+
items: [
|
|
75
|
+
{ text: 'text', value: 'value' },
|
|
76
|
+
'another value'
|
|
77
|
+
]
|
|
20
78
|
}
|
|
21
|
-
|
|
79
|
+
}
|
|
22
80
|
};
|
|
23
81
|
}
|
|
24
82
|
|
|
@@ -30,6 +88,17 @@
|
|
|
30
88
|
.then(r => r.text())
|
|
31
89
|
.catch(() => '');
|
|
32
90
|
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @param {unknown} args
|
|
94
|
+
*/
|
|
95
|
+
test (args) {
|
|
96
|
+
console.log(args);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (Scratch.extensions.unsandboxed) {
|
|
101
|
+
// ...
|
|
33
102
|
}
|
|
34
103
|
|
|
35
104
|
Scratch.extensions.register(new Fetch());
|
package/tests/test-scratch-vm.ts
CHANGED
|
@@ -46,6 +46,16 @@ if (target) {
|
|
|
46
46
|
bubbleState.text.charAt(0);
|
|
47
47
|
target.setCustomState('Scratch.looks', bubbleState);
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
target.on('TARGET_MOVED', (target, fromX, fromY, forced) => {
|
|
51
|
+
const id: string = target.id;
|
|
52
|
+
const x: number = fromX;
|
|
53
|
+
const y: number = fromY;
|
|
54
|
+
const f: boolean | undefined = forced;
|
|
55
|
+
})
|
|
56
|
+
target.on('EVENT_TARGET_VISUAL_CHANGE', (target) => {
|
|
57
|
+
const id: string = target.id;
|
|
58
|
+
});
|
|
49
59
|
} else {
|
|
50
60
|
const doesNotExist: undefined = target;
|
|
51
61
|
}
|
|
@@ -61,3 +71,7 @@ vm.runtime.compatibilityMode as boolean
|
|
|
61
71
|
|
|
62
72
|
const costume = vm.runtime.getTargetForStage()?.getCostumes()?.[0];
|
|
63
73
|
costume?.skinId as number;
|
|
74
|
+
|
|
75
|
+
declare const util: VM.BlockUtility;
|
|
76
|
+
util.startHats('hats', {BROADCAST_OPTION: 'test'}) as VM.Thread[];
|
|
77
|
+
util.ioQuery('mouse', 'getIsDown', []);
|
package/types/jszip.d.ts
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
|
|
4
4
|
declare namespace JSZip {
|
|
5
5
|
// TODO
|
|
6
|
+
|
|
7
|
+
interface OutputTypes {
|
|
8
|
+
base64: string;
|
|
9
|
+
binarystring: string;
|
|
10
|
+
array: number[];
|
|
11
|
+
uint8array: Uint8Array;
|
|
12
|
+
arraybuffer: ArrayBuffer;
|
|
13
|
+
blob: Blob;
|
|
14
|
+
nodebuffer: Uint8Array; // actually a Node.js Buffer
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface ProgressMetadata {
|
|
18
|
+
percent: number;
|
|
19
|
+
currentFile: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface StreamHelper<T extends keyof OutputTypes> {
|
|
23
|
+
resume(): void;
|
|
24
|
+
pause(): void;
|
|
25
|
+
on(event: 'data', callback: (data: OutputTypes[T], metadata: ProgressMetadata) => void): void;
|
|
26
|
+
on(event: 'end', callback: () => void): void;
|
|
27
|
+
on(event: 'error', callback: (error: Error) => void): void;
|
|
28
|
+
accumulate(updateCallback?: (metadata: ProgressMetadata) => void): Promise<OutputTypes[T]>;
|
|
29
|
+
}
|
|
6
30
|
}
|
|
7
31
|
|
|
8
32
|
declare class JSZip {
|
package/types/scratch-audio.d.ts
CHANGED
|
@@ -1,133 +1,251 @@
|
|
|
1
|
-
/// <reference path="./scratch-vm.d.ts" />
|
|
2
|
-
/// <reference path="./scratch-render.d.ts" />
|
|
3
|
-
|
|
4
1
|
declare namespace Scratch {
|
|
2
|
+
// Note that the 'B' in the BOOLEAN enums are capitalized in Scratch. It is not a typo in this file.
|
|
3
|
+
|
|
5
4
|
namespace ArgumentType {
|
|
6
|
-
/** @deprecated not tested -- do not rely on yet */
|
|
7
5
|
const ANGLE: 'angle';
|
|
8
6
|
const BOOLEAN: 'Boolean';
|
|
9
|
-
/** @deprecated not tested -- do not rely on yet */
|
|
10
7
|
const COLOR: 'color';
|
|
11
|
-
const
|
|
12
|
-
const STRING: 'string';
|
|
13
|
-
/** @deprecated not tested -- do not rely on yet */
|
|
8
|
+
const IMAGE: 'image';
|
|
14
9
|
const MATRIX: 'matrix';
|
|
15
|
-
/** @deprecated not tested -- do not rely on yet */
|
|
16
10
|
const NOTE: 'note';
|
|
17
|
-
|
|
18
|
-
const
|
|
11
|
+
const NUMBER: 'number';
|
|
12
|
+
const STRING: 'string';
|
|
19
13
|
}
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
|
|
22
15
|
namespace BlockType {
|
|
23
|
-
// The B in Boolean is supposed to be capitalized
|
|
24
16
|
const BOOLEAN: 'Boolean';
|
|
25
|
-
/** @deprecated
|
|
17
|
+
/** @deprecated very incomplete and not useful yet */
|
|
26
18
|
const BUTTON: 'button';
|
|
27
19
|
const COMMAND: 'command';
|
|
28
|
-
/** @deprecated
|
|
20
|
+
/** @deprecated does not work in compiler */
|
|
29
21
|
const CONDITIONAL: 'conditional';
|
|
22
|
+
/** @deprecated use HAT instead */
|
|
30
23
|
const EVENT: 'event';
|
|
31
24
|
const HAT: 'hat';
|
|
32
|
-
/** @deprecated
|
|
25
|
+
/** @deprecated does not work in compiler */
|
|
33
26
|
const LOOP: 'loop';
|
|
34
27
|
const REPORTER: 'reporter';
|
|
35
28
|
}
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
|
|
38
30
|
namespace TargetType {
|
|
39
31
|
const SPRITE: 'sprite';
|
|
40
32
|
const STAGE: 'stage';
|
|
41
33
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
interface
|
|
61
|
-
type:
|
|
34
|
+
|
|
35
|
+
interface AngleArgument {
|
|
36
|
+
type: 'angle';
|
|
37
|
+
/**
|
|
38
|
+
* Defaults to 0.
|
|
39
|
+
*/
|
|
40
|
+
defaultValue?: string | number;
|
|
41
|
+
}
|
|
42
|
+
interface BooleanArgument {
|
|
43
|
+
type: 'Boolean';
|
|
44
|
+
}
|
|
45
|
+
interface ColorArgument {
|
|
46
|
+
type: 'color';
|
|
47
|
+
/**
|
|
48
|
+
* Should be a hex color code. No alpha channel supported. Defaults to random color.
|
|
49
|
+
*/
|
|
50
|
+
defaultValue?: string | number;
|
|
51
|
+
}
|
|
52
|
+
interface NumberArgument {
|
|
53
|
+
type: 'number';
|
|
54
|
+
/**
|
|
55
|
+
* Defaults to 0.
|
|
56
|
+
*/
|
|
62
57
|
defaultValue?: string | number;
|
|
63
58
|
menu?: string;
|
|
64
59
|
}
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
interface StringArgument {
|
|
61
|
+
type: 'string';
|
|
62
|
+
/**
|
|
63
|
+
* Defaults to empty string.
|
|
64
|
+
*/
|
|
65
|
+
defaultValue?: string | number;
|
|
66
|
+
menu?: string;
|
|
67
|
+
}
|
|
68
|
+
interface MatrixArgument {
|
|
69
|
+
type: 'matrix';
|
|
70
|
+
/**
|
|
71
|
+
* Should be a 25 character long string of 1s and 0s.
|
|
72
|
+
* Numbers are technically accepted, but be aware that due to floating point precision, some detail may be lost.
|
|
73
|
+
* Technically optional, but behaves strangely with no default value.
|
|
74
|
+
*/
|
|
75
|
+
defaultValue?: string | number;
|
|
76
|
+
}
|
|
77
|
+
interface NoteArgument {
|
|
78
|
+
type: 'note';
|
|
79
|
+
/**
|
|
80
|
+
* Defaults to 0 ("C (0)")
|
|
81
|
+
*/
|
|
82
|
+
defaultValue?: string | number;
|
|
83
|
+
}
|
|
84
|
+
interface ImageArgument {
|
|
85
|
+
type: 'image';
|
|
86
|
+
dataURI: string;
|
|
87
|
+
/**
|
|
88
|
+
* Defaults to false.
|
|
89
|
+
*/
|
|
90
|
+
flipRTL?: boolean;
|
|
91
|
+
}
|
|
92
|
+
type Argument = (
|
|
93
|
+
AngleArgument |
|
|
94
|
+
BooleanArgument |
|
|
95
|
+
ColorArgument |
|
|
96
|
+
NumberArgument |
|
|
97
|
+
StringArgument |
|
|
98
|
+
MatrixArgument |
|
|
99
|
+
NoteArgument |
|
|
100
|
+
ImageArgument
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
interface AbstractBlock {
|
|
67
104
|
opcode: string;
|
|
68
|
-
|
|
69
|
-
text:
|
|
70
|
-
arguments?: Record<string,
|
|
71
|
-
|
|
105
|
+
func?: string;
|
|
106
|
+
text: string | string[];
|
|
107
|
+
arguments?: Record<string, Argument>;
|
|
108
|
+
hideFromPalette?: boolean;
|
|
109
|
+
filter?: Array<'target' | 'sprite'>;
|
|
110
|
+
blockIconURI?: string;
|
|
72
111
|
}
|
|
73
|
-
|
|
74
|
-
|
|
112
|
+
interface BooleanBlock extends AbstractBlock {
|
|
113
|
+
blockType: 'Boolean';
|
|
114
|
+
}
|
|
115
|
+
interface ButtonBlock extends AbstractBlock {
|
|
116
|
+
blockType: 'button';
|
|
117
|
+
func: 'MAKE_A_LIST' | 'MAKE_A_PROCEDURE' | 'MAKE_A_VARIABLE';
|
|
118
|
+
}
|
|
119
|
+
interface CommandBlock extends AbstractBlock {
|
|
120
|
+
blockType: 'command';
|
|
121
|
+
/**
|
|
122
|
+
* Defaults to false.
|
|
123
|
+
*/
|
|
124
|
+
isTerminal?: boolean;
|
|
125
|
+
}
|
|
126
|
+
interface ConditionalBlock extends AbstractBlock {
|
|
127
|
+
blockType: 'conditional';
|
|
128
|
+
/**
|
|
129
|
+
* Defaults to false.
|
|
130
|
+
*/
|
|
131
|
+
isTerminal?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Defaults to 1.
|
|
134
|
+
*/
|
|
135
|
+
branchCount?: number;
|
|
136
|
+
}
|
|
137
|
+
interface EventBlock extends AbstractBlock {
|
|
138
|
+
blockType: 'event';
|
|
139
|
+
/**
|
|
140
|
+
* This must be explicitly set to false, otherwise the block will not work.
|
|
141
|
+
* Event blocks cannot be edge activated. Use hat instead.
|
|
142
|
+
*/
|
|
143
|
+
isEdgeActivated: false;
|
|
144
|
+
/**
|
|
145
|
+
* Defaults to false.
|
|
146
|
+
*/
|
|
147
|
+
shouldRestartExistingThreads?: boolean;
|
|
148
|
+
}
|
|
149
|
+
interface HatBlock extends AbstractBlock {
|
|
150
|
+
blockType: 'hat';
|
|
151
|
+
/**
|
|
152
|
+
* Defaults to true.
|
|
153
|
+
*/
|
|
154
|
+
isEdgeActivated?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Defaults to false.
|
|
157
|
+
*/
|
|
158
|
+
shouldRestartExistingThreads?: boolean;
|
|
159
|
+
}
|
|
160
|
+
interface ReporterBlock extends AbstractBlock {
|
|
161
|
+
blockType: 'reporter';
|
|
162
|
+
/**
|
|
163
|
+
* Defaults to false.
|
|
164
|
+
*/
|
|
165
|
+
disableMonitor?: boolean;
|
|
166
|
+
}
|
|
167
|
+
interface LoopBlock extends AbstractBlock {
|
|
168
|
+
blockType: 'loop';
|
|
169
|
+
/**
|
|
170
|
+
* Defaults to false.
|
|
171
|
+
*/
|
|
172
|
+
isTerminal?: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Defaults to 1.
|
|
175
|
+
*/
|
|
176
|
+
branchCount?: number;
|
|
177
|
+
}
|
|
178
|
+
type Block = (
|
|
179
|
+
BooleanBlock |
|
|
180
|
+
ButtonBlock |
|
|
181
|
+
CommandBlock |
|
|
182
|
+
ConditionalBlock |
|
|
183
|
+
EventBlock |
|
|
184
|
+
HatBlock |
|
|
185
|
+
ReporterBlock |
|
|
186
|
+
LoopBlock
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
interface Menu {
|
|
75
190
|
acceptReporters?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* A list of static items in the menu, or the name of the dynamic menu function.
|
|
193
|
+
*/
|
|
76
194
|
items: Array<string | {
|
|
77
195
|
text: string;
|
|
78
196
|
value: string;
|
|
79
|
-
}
|
|
197
|
+
}> | string;
|
|
80
198
|
}
|
|
81
|
-
|
|
82
|
-
interface
|
|
199
|
+
|
|
200
|
+
interface Info {
|
|
83
201
|
id: string;
|
|
84
|
-
|
|
202
|
+
|
|
85
203
|
/**
|
|
86
|
-
* Defaults to ID if not specified.
|
|
204
|
+
* Defaults to extension ID if not specified.
|
|
87
205
|
*/
|
|
88
|
-
name?:
|
|
89
|
-
|
|
206
|
+
name?: string;
|
|
207
|
+
|
|
90
208
|
/**
|
|
91
209
|
* Should be a hex color code.
|
|
92
210
|
*/
|
|
93
211
|
color1?: string;
|
|
94
|
-
|
|
212
|
+
|
|
95
213
|
/**
|
|
96
214
|
* Should be a hex color code.
|
|
97
215
|
*/
|
|
98
216
|
color2?: string;
|
|
99
|
-
|
|
217
|
+
|
|
100
218
|
/**
|
|
101
219
|
* Should be a hex color code.
|
|
102
220
|
*/
|
|
103
221
|
color3?: string;
|
|
104
|
-
|
|
222
|
+
|
|
105
223
|
/**
|
|
106
224
|
* Should be a data: URI
|
|
107
225
|
*/
|
|
108
226
|
menuIconURI?: string;
|
|
109
|
-
|
|
227
|
+
|
|
110
228
|
/**
|
|
111
229
|
* Should be a data: URI
|
|
112
230
|
*/
|
|
113
231
|
blockIconURI?: string;
|
|
114
|
-
|
|
232
|
+
|
|
115
233
|
docsURI?: string;
|
|
116
|
-
|
|
117
|
-
blocks: (
|
|
118
|
-
menus?: Record<string,
|
|
234
|
+
|
|
235
|
+
blocks: (Block | string)[];
|
|
236
|
+
menus?: Record<string, Menu | string[]>;
|
|
119
237
|
}
|
|
120
|
-
|
|
238
|
+
|
|
121
239
|
interface Extension {
|
|
122
|
-
getInfo():
|
|
240
|
+
getInfo(): Info;
|
|
123
241
|
}
|
|
124
|
-
|
|
242
|
+
|
|
125
243
|
namespace extensions {
|
|
126
244
|
function register(extensionObject: Extension): void;
|
|
127
245
|
|
|
128
246
|
/**
|
|
129
|
-
* True if the extension is running unsandboxed.
|
|
247
|
+
* True if the extension is running unsandboxed, otherwise undefined.
|
|
130
248
|
*/
|
|
131
|
-
const unsandboxed: boolean;
|
|
249
|
+
const unsandboxed: undefined | boolean;
|
|
132
250
|
}
|
|
133
251
|
}
|
package/types/scratch-vm.d.ts
CHANGED
|
@@ -289,7 +289,7 @@ declare namespace VM {
|
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
interface BaseTarget extends EventEmitter<
|
|
292
|
+
interface BaseTarget extends EventEmitter<RenderedTargetEventMap> {
|
|
293
293
|
runtime: Runtime;
|
|
294
294
|
|
|
295
295
|
id: string;
|
|
@@ -356,7 +356,9 @@ declare namespace VM {
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
interface RenderedTargetEventMap {
|
|
359
|
-
|
|
359
|
+
TARGET_MOVED: [RenderedTarget, number, number, boolean?];
|
|
360
|
+
|
|
361
|
+
EVENT_TARGET_VISUAL_CHANGE: [RenderedTarget];
|
|
360
362
|
}
|
|
361
363
|
|
|
362
364
|
const enum Effect {
|
|
@@ -614,7 +616,72 @@ declare namespace VM {
|
|
|
614
616
|
}
|
|
615
617
|
|
|
616
618
|
interface StackFrame {
|
|
617
|
-
|
|
619
|
+
isLoop: boolean;
|
|
620
|
+
warpMode: boolean;
|
|
621
|
+
justReported: unknown;
|
|
622
|
+
reporting: string;
|
|
623
|
+
reported: unknown;
|
|
624
|
+
/** @deprecated unused */
|
|
625
|
+
waitingReporter: unknown;
|
|
626
|
+
params: unknown;
|
|
627
|
+
executionContext: unknown;
|
|
628
|
+
reset(): void;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
interface BlockUtility {
|
|
632
|
+
sequencer: Sequencer;
|
|
633
|
+
thread: Thread;
|
|
634
|
+
_nowObj: {
|
|
635
|
+
now(): number;
|
|
636
|
+
};
|
|
637
|
+
nowObj: BlockUtility['_nowObj'],
|
|
638
|
+
target: Target;
|
|
639
|
+
runtime: Runtime;
|
|
640
|
+
stackFrame: StackFrame;
|
|
641
|
+
stackTimerFinished(): boolean;
|
|
642
|
+
stackTimerNeedsInit(): boolean;
|
|
643
|
+
startStackTimer(milliseconds: number): void;
|
|
644
|
+
yield(): void;
|
|
645
|
+
yieldTick(): void;
|
|
646
|
+
startBranch(branchNumber: number, isLoop: boolean): void;
|
|
647
|
+
/**
|
|
648
|
+
* @see {Runtime.stopAll}
|
|
649
|
+
*/
|
|
650
|
+
stopAll(): void;
|
|
651
|
+
/**
|
|
652
|
+
* @see {Runtime.stopForTarget}
|
|
653
|
+
*/
|
|
654
|
+
stopOtherTargetThreads(): void;
|
|
655
|
+
/**
|
|
656
|
+
* @see {Thread.stopThisScript}
|
|
657
|
+
*/
|
|
658
|
+
stopThisScript(): void;
|
|
659
|
+
/**
|
|
660
|
+
* @see {Blocks.getProcedureParamNamesAndIds}
|
|
661
|
+
*/
|
|
662
|
+
getProcedureParamNamesAndIds(): [string[], string[]];
|
|
663
|
+
/**
|
|
664
|
+
* @see {Blocks.getProcedureParamNamesIdsAndDefaults}
|
|
665
|
+
*/
|
|
666
|
+
getProcedureParamNamesIdsAndDefaults(): [string[], string[], string[]];
|
|
667
|
+
/**
|
|
668
|
+
* @see {Thread.initParams}
|
|
669
|
+
*/
|
|
670
|
+
initParams(): void;
|
|
671
|
+
/**
|
|
672
|
+
* @see {Thread.pushParam}
|
|
673
|
+
*/
|
|
674
|
+
pushParam(name: string, value: ScratchCompatibleValue): void;
|
|
675
|
+
/**
|
|
676
|
+
* @see {Thread.getParam}
|
|
677
|
+
*/
|
|
678
|
+
getParam(name: string): ScratchCompatibleValue;
|
|
679
|
+
/**
|
|
680
|
+
* Use instead of runtime.startHats inside blocks.
|
|
681
|
+
* @see {Runtime.startHats}
|
|
682
|
+
*/
|
|
683
|
+
startHats: Runtime['startHats'];
|
|
684
|
+
ioQuery<Device extends keyof IODevices>(device: Device, func: keyof IODevices[Device], args: unknown[]): unknown;
|
|
618
685
|
}
|
|
619
686
|
|
|
620
687
|
const enum ThreadStatus {
|
|
@@ -637,16 +704,19 @@ declare namespace VM {
|
|
|
637
704
|
blockGlowInFrame: string | null;
|
|
638
705
|
warpTimer: Timer | null;
|
|
639
706
|
justReported: unknown;
|
|
707
|
+
reuseStackForNextBlock(blockId: string): void;
|
|
640
708
|
pushStack(blockId: string): void;
|
|
641
709
|
popStack(): string;
|
|
642
710
|
peekStack(): string;
|
|
643
711
|
peekStackFrame(): StackFrame | null;
|
|
644
712
|
peekParentStackFrame(): StackFrame | null;
|
|
713
|
+
pushReportedValue(value: ScratchCompatibleValue): void;
|
|
645
714
|
initParams(): void;
|
|
646
715
|
pushParam(name: string, value: ScratchCompatibleValue): void;
|
|
647
716
|
getParam(name: string): ScratchCompatibleValue | null;
|
|
648
717
|
atStackTop(): boolean;
|
|
649
718
|
goToNextBlock(): void;
|
|
719
|
+
stopThisScript(): void;
|
|
650
720
|
isRecursiveCall(procedureCode: string): boolean;
|
|
651
721
|
stackClick: boolean;
|
|
652
722
|
updateMonitor: boolean;
|
|
@@ -1117,7 +1187,7 @@ declare namespace VM {
|
|
|
1117
1187
|
|
|
1118
1188
|
_getMonitorThreadCount(threads: Thread[]): number;
|
|
1119
1189
|
|
|
1120
|
-
startHats(opcode: string, matchFields?: Record<string, unknown>, target?: Target):
|
|
1190
|
+
startHats(opcode: string, matchFields?: Record<string, unknown>, target?: Target): Thread[];
|
|
1121
1191
|
|
|
1122
1192
|
toggleScript(topBlockId: string, options?: {
|
|
1123
1193
|
target?: string;
|
|
@@ -1506,7 +1576,7 @@ declare class VM extends EventEmitter<VM.VirtualMachineEventMap> {
|
|
|
1506
1576
|
* Emit a workspaceUpdate event.
|
|
1507
1577
|
*/
|
|
1508
1578
|
emitWorkspaceUpdate(): void;
|
|
1509
|
-
|
|
1579
|
+
|
|
1510
1580
|
/**
|
|
1511
1581
|
* Post sprite info to the target that's being dragged, otherwise the editing target.
|
|
1512
1582
|
* @see {VM.Target.postSpriteInfo}
|