@turbowarp/types 0.0.8 → 0.0.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turbowarp/types",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Type definitions for the Scratch VM and editor",
5
5
  "keywords": [
6
6
  "scratch"
@@ -19,6 +19,7 @@
19
19
  }
20
20
  }
21
21
  },
22
+ '---',
22
23
  {
23
24
  opcode: 'test',
24
25
  text: 'test [STRING] [IMAGE] [BOOLEAN] [NUMBER] [MATRIX] [NOTE] [ANGLE] [COLOR]',
@@ -61,7 +62,6 @@
61
62
  }
62
63
  },
63
64
  {
64
- opcode: 'button',
65
65
  blockType: Scratch.BlockType.BUTTON,
66
66
  func: 'MAKE_A_VARIABLE',
67
67
  text: 'button text'
@@ -21,7 +21,7 @@ if (target) {
21
21
  const variable = target.lookupVariableByNameAndType('test', 'list');
22
22
  if (variable) {
23
23
  const name: string = variable.name;
24
- const upToDate: boolean | undefined = variable.value._monitorUpToDate;
24
+ const upToDate: boolean | undefined = variable._monitorUpToDate;
25
25
  variable.value.filter(i => i.toString());
26
26
  }
27
27
 
@@ -64,6 +64,9 @@ if (target) {
64
64
  const doesNotExist: undefined = target;
65
65
  }
66
66
 
67
+ runtime._editingTarget as VM.Target;
68
+ runtime.getEditingTarget() as VM.Target;
69
+
67
70
  const audioEngine = new AudioEngine();
68
71
  vm.attachAudioEngine(audioEngine);
69
72
  audioEngine.audioContext.suspend();
@@ -14,12 +14,10 @@ declare namespace Scratch {
14
14
 
15
15
  namespace BlockType {
16
16
  const BOOLEAN: 'Boolean';
17
- /** @deprecated very incomplete and not useful yet */
18
17
  const BUTTON: 'button';
19
18
  const COMMAND: 'command';
20
19
  /** @deprecated does not work in compiler */
21
20
  const CONDITIONAL: 'conditional';
22
- /** @deprecated use HAT instead */
23
21
  const EVENT: 'event';
24
22
  const HAT: 'hat';
25
23
  /** @deprecated does not work in compiler */
@@ -101,29 +99,31 @@ declare namespace Scratch {
101
99
  );
102
100
 
103
101
  interface AbstractBlock {
102
+ text: string | string[];
103
+ filter?: Array<'target' | 'sprite'>;
104
+ }
105
+ interface ExecutableBlock extends AbstractBlock {
104
106
  opcode: string;
105
107
  func?: string;
106
- text: string | string[];
107
108
  arguments?: Record<string, Argument>;
108
109
  hideFromPalette?: boolean;
109
- filter?: Array<'target' | 'sprite'>;
110
110
  blockIconURI?: string;
111
111
  }
112
- interface BooleanBlock extends AbstractBlock {
112
+ interface BooleanBlock extends ExecutableBlock {
113
113
  blockType: 'Boolean';
114
114
  }
115
115
  interface ButtonBlock extends AbstractBlock {
116
116
  blockType: 'button';
117
117
  func: 'MAKE_A_LIST' | 'MAKE_A_PROCEDURE' | 'MAKE_A_VARIABLE';
118
118
  }
119
- interface CommandBlock extends AbstractBlock {
119
+ interface CommandBlock extends ExecutableBlock {
120
120
  blockType: 'command';
121
121
  /**
122
122
  * Defaults to false.
123
123
  */
124
124
  isTerminal?: boolean;
125
125
  }
126
- interface ConditionalBlock extends AbstractBlock {
126
+ interface ConditionalBlock extends ExecutableBlock {
127
127
  blockType: 'conditional';
128
128
  /**
129
129
  * Defaults to false.
@@ -134,7 +134,7 @@ declare namespace Scratch {
134
134
  */
135
135
  branchCount?: number;
136
136
  }
137
- interface EventBlock extends AbstractBlock {
137
+ interface EventBlock extends ExecutableBlock {
138
138
  blockType: 'event';
139
139
  /**
140
140
  * This must be explicitly set to false, otherwise the block will not work.
@@ -146,7 +146,7 @@ declare namespace Scratch {
146
146
  */
147
147
  shouldRestartExistingThreads?: boolean;
148
148
  }
149
- interface HatBlock extends AbstractBlock {
149
+ interface HatBlock extends ExecutableBlock {
150
150
  blockType: 'hat';
151
151
  /**
152
152
  * Defaults to true.
@@ -157,14 +157,14 @@ declare namespace Scratch {
157
157
  */
158
158
  shouldRestartExistingThreads?: boolean;
159
159
  }
160
- interface ReporterBlock extends AbstractBlock {
160
+ interface ReporterBlock extends ExecutableBlock {
161
161
  blockType: 'reporter';
162
162
  /**
163
163
  * Defaults to false.
164
164
  */
165
165
  disableMonitor?: boolean;
166
166
  }
167
- interface LoopBlock extends AbstractBlock {
167
+ interface LoopBlock extends ExecutableBlock {
168
168
  blockType: 'loop';
169
169
  /**
170
170
  * Defaults to false.
@@ -186,6 +186,8 @@ declare namespace Scratch {
186
186
  LoopBlock
187
187
  );
188
188
 
189
+ type Separator = '---';
190
+
189
191
  interface Menu {
190
192
  acceptReporters?: boolean;
191
193
  /**
@@ -232,7 +234,7 @@ declare namespace Scratch {
232
234
 
233
235
  docsURI?: string;
234
236
 
235
- blocks: (Block | string)[];
237
+ blocks: (Block | Separator)[];
236
238
  menus?: Record<string, Menu | string[]>;
237
239
  }
238
240
 
@@ -31,11 +31,7 @@ declare namespace VM {
31
31
  type IfGui<HasGui, NoGui> = HasGui;
32
32
 
33
33
  type ScratchCompatibleValue = string | boolean | number;
34
-
35
- interface ScratchList extends Array<ScratchCompatibleValue> {
36
- _monitorUpToDate?: boolean;
37
- }
38
-
34
+ type ScratchList = ScratchCompatibleValue[];
39
35
  type VariableValue = ScratchCompatibleValue | ScratchList;
40
36
 
41
37
  interface BaseAsset {
@@ -205,6 +201,7 @@ declare namespace VM {
205
201
  interface ListVariable extends BaseVariable {
206
202
  type: 'list';
207
203
  value: ScratchList;
204
+ _monitorUpToDate?: boolean;
208
205
  }
209
206
 
210
207
  interface BroadcastVariable extends BaseVariable {
@@ -762,6 +759,8 @@ declare namespace VM {
762
759
  interface ExtensionManager {
763
760
  runtime: Runtime;
764
761
 
762
+ refreshBlocks(): Promise<void[]>;
763
+
765
764
  isExtensionLoaded(extensionID: string): boolean;
766
765
 
767
766
  /**
@@ -1144,7 +1143,7 @@ declare namespace VM {
1144
1143
  getTargetById(targetId: string): Target | undefined;
1145
1144
 
1146
1145
  /**
1147
- * Find a sprite's original target (not a clone) using the sprite's name.
1146
+ * Find a sprite's original target (not a clone or stage) using the sprite's name.
1148
1147
  * Returns undefined if the target doesn't exist.
1149
1148
  */
1150
1149
  getSpriteTargetByName(spriteName: string): Target | undefined;
@@ -1313,6 +1312,7 @@ declare namespace VM {
1313
1312
 
1314
1313
  emitProjectChanged(): void;
1315
1314
 
1315
+ _editingTarget: Target | null;
1316
1316
  getEditingTarget(): Target | null;
1317
1317
 
1318
1318
  setEditingTarget(target: Target): void;