@turbowarp/types 0.0.14 → 0.0.15

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.14",
3
+ "version": "0.0.15",
4
4
  "description": "Type definitions for the Scratch VM and editor",
5
5
  "keywords": [
6
6
  "scratch"
package/types/events.d.ts CHANGED
@@ -6,6 +6,7 @@ type EventEmitterCallback<Events, K extends keyof Events> = (...args: Events[K]
6
6
 
7
7
  declare class EventEmitter<Events> {
8
8
  on<K extends keyof Events>(event: K, callback: EventEmitterCallback<Events, K>): void;
9
+ addListener<K extends keyof Events>(event: K, callback: EventEmitterCallback<Events, K>): void;
9
10
  once<K extends keyof Events>(event: K, callback: EventEmitterCallback<Events, K>): void;
10
11
  off<K extends keyof Events>(event: K, callback: EventEmitterCallback<Events, K>): void;
11
12
  removeListener<K extends keyof Events>(event: K, callback: EventEmitterCallback<Events, K>): void;
@@ -14,7 +14,9 @@ declare namespace AudioEngine {
14
14
  mic: MediaStreamAudioSourceNode;
15
15
 
16
16
  /**
17
- * @returns Loudness measured from 0-100.
17
+ * Get the current loudness of sound received by the microphone.
18
+ * Sound is measured in RMS and smoothed.
19
+ * @returns Loudness scaled 0 to 100, or -1 if there is no microphone input.
18
20
  */
19
21
  getLoudness(): number;
20
22
  }
@@ -32,7 +34,7 @@ declare namespace AudioEngine {
32
34
  target: Target;
33
35
  connect(target: Target): void;
34
36
  get name(): string;
35
- get DEFAULT_VALUE(): string;
37
+ get DEFAULT_VALUE(): number;
36
38
  get _isPatch(): boolean;
37
39
  _set(value: number): void;
38
40
  set(value: number): void;
@@ -44,6 +46,10 @@ declare namespace AudioEngine {
44
46
  interface PitchEffect extends AbstractEffect {
45
47
  get name(): 'pitch';
46
48
  ratio: number;
49
+ /**
50
+ * The playback ratio is scaled so that a change of 10 in the effect value
51
+ * gives a change of 1 semitone in the ratio.
52
+ */
47
53
  getRatio(val: number): number;
48
54
  updatePlayer(soundPlayer: SoundPlayer): void;
49
55
  updatePlayers(soundPlayers: Record<string, SoundPlayer> | SoundPlayer[]): void;
@@ -101,6 +107,10 @@ declare namespace AudioEngine {
101
107
  isStarting: boolean;
102
108
  isPlaying: boolean;
103
109
  startingUntil: number;
110
+ playbackRate: number;
111
+ volumeEffect: VolumeEffect | null;
112
+ target: AudioEngine | Effect | EffectChain | null;
113
+ initialized: boolean;
104
114
  handleEvent(event: Event): void;
105
115
  onEnded(): void;
106
116
  _createSource(): void;
@@ -112,7 +122,7 @@ declare namespace AudioEngine {
112
122
  finished(): Promise<void>;
113
123
  setPlaybackRate(playbackRate: number): void;
114
124
  take(): SoundPlayer;
115
- connect(connectable: AudioEngine | Effect | EffectChain): void;
125
+ connect(connectable: AudioEngine | Effect | EffectChain): SoundPlayer | undefined;
116
126
  }
117
127
 
118
128
  interface SoundBank {
@@ -144,7 +154,7 @@ declare namespace AudioEngine {
144
154
  playSound(target: Target, soundId: string): Promise<void>;
145
155
  setEffects(target: Target): void;
146
156
  stop(target: Target, soundId: string): void;
147
- stopAllSounds(target: Target | '*'): void;
157
+ stopAllSounds(target?: Target | '*'): void;
148
158
  dispose(): void;
149
159
  }
150
160
 
@@ -2,6 +2,9 @@
2
2
  // Project: https://github.com/LLK/scratch-blocks
3
3
 
4
4
  declare namespace ScratchBlocks {
5
+ const Blocks: Record<string, unknown>;
6
+ const Msg: Record<string, string>;
7
+
5
8
  class Block {
6
9
 
7
10
  }
@@ -178,6 +181,14 @@ declare namespace ScratchBlocks {
178
181
  interface BlocklyGlobal {
179
182
  getMainWorkspace(): Workspace | null;
180
183
  }
184
+
185
+ function prompt(
186
+ message: string,
187
+ defaultValue: string,
188
+ callback: (value: string | null) => void,
189
+ title?: string,
190
+ varType?: string
191
+ ): void;
181
192
  }
182
193
 
183
194
  declare const Blockly: ScratchBlocks.BlocklyGlobal | undefined;
@@ -24,6 +24,7 @@ declare namespace RenderWebGL {
24
24
  Fisheye = 'fisheye',
25
25
  Whirl = 'whirl',
26
26
  Pixelate = 'pixelate',
27
+ Mosaic = 'mosaic',
27
28
  Brightness = 'brightness',
28
29
  Ghost = 'ghost'
29
30
  }
@@ -56,6 +57,11 @@ declare namespace RenderWebGL {
56
57
  snapToInt(): void;
57
58
  }
58
59
 
60
+ namespace Rectangle {
61
+ function intersect(a: Rectangle, b: Rectangle, result?: Rectangle): Rectangle;
62
+ function union(a: Rectangle, b: Rectangle, result?: Rectangle): Rectangle;
63
+ }
64
+
59
65
  /**
60
66
  * Suggested properties of a drawing region. Strictly, this can really be whatever you want it to be.
61
67
  */
@@ -79,7 +85,7 @@ declare namespace RenderWebGL {
79
85
  static DRAW_MODE: Record<DrawMode, DrawMode>;
80
86
 
81
87
  _gl: AnyWebGLContext;
82
- _shaderCache: Record<DrawMode, Record<EffectMask, twgl.ProgramInfo[]>>;
88
+ _shaderCache: Record<DrawMode, twgl.ProgramInfo[]>;
83
89
  _buildShader(drawMode: DrawMode, effectMask: EffectMask): twgl.ProgramInfo;
84
90
  getShader(drawMode: DrawMode, effectMask: EffectMask): twgl.ProgramInfo;
85
91
  }
@@ -102,8 +108,8 @@ declare namespace RenderWebGL {
102
108
  colorAtNearest(textureCoordinate: twgl.V3, destination?: Uint8ClampedArray): Uint8ClampedArray;
103
109
  colorAtLinear(textureCoordinate: twgl.V3, destination?: Uint8ClampedArray): Uint8ClampedArray;
104
110
 
105
- isTouchingNearest(textureCoordinate: twgl.V3): void;
106
- isTouchingLinear(textureCoordinate: twgl.V3): void;
111
+ isTouchingNearest(textureCoordinate: twgl.V3): boolean;
112
+ isTouchingLinear(textureCoordinate: twgl.V3): boolean;
107
113
  }
108
114
 
109
115
  interface SkinEventMap {
@@ -131,7 +137,7 @@ declare namespace RenderWebGL {
131
137
  u_skinSize: [number, number];
132
138
  u_skin: WebGLTexture | null;
133
139
  };
134
- getUniforms(): Skin['_uniforms'];
140
+ getUniforms(scale?: [number, number]): Skin['_uniforms'];
135
141
 
136
142
  _silhouette: Silhouette;
137
143
  updateSilhouette(): void;
@@ -148,11 +154,15 @@ declare namespace RenderWebGL {
148
154
 
149
155
  useNearest(scale: [number, number], drawable: Drawable): boolean;
150
156
 
151
- getTexture(scale: [number, number]): WebGLTexture;
157
+ getTexture(scale?: [number, number]): WebGLTexture;
152
158
  _setTexture(image: BitmapData): void;
153
159
  setEmptyImageData(): void;
154
160
 
155
- getFenceBounds(): Rectangle;
161
+ /**
162
+ * Get the bounds of the drawable for determining its fenced position.
163
+ * For compatibility with Scratch 2, we always use getAABB.
164
+ */
165
+ getFenceBounds(drawable: Drawable, result?: Rectangle): Rectangle;
156
166
 
157
167
  dispose(): void;
158
168
  }
@@ -201,15 +211,15 @@ declare namespace RenderWebGL {
201
211
  /**
202
212
  * Pen color in RGBA from 0-1.
203
213
  */
204
- color4f: [number, number, number, number];
205
- diameter: number;
214
+ color4f?: [number, number, number, number];
215
+ diameter?: number;
206
216
  }
207
217
 
208
218
  class PenSkin extends Skin {
209
219
  _renderer: RenderWebGL;
210
220
 
211
221
  _size: [number, number];
212
- _framebuffer: WebGLFramebuffer;
222
+ _framebuffer: twgl.FrameBufferInfo;
213
223
  _silhouetteDirty: boolean;
214
224
  _silhouettePixels: Uint8Array;
215
225
  _silhouetteImageData: ImageData;
@@ -272,6 +282,7 @@ declare namespace RenderWebGL {
272
282
  width: number;
273
283
  height: number
274
284
  };
285
+ _text: string;
275
286
  _bubbleType: TextBubbleType;
276
287
  _pointsLeft: boolean;
277
288
  _textDirty: boolean;
@@ -324,7 +335,7 @@ declare namespace RenderWebGL {
324
335
 
325
336
  _scale: twgl.V3;
326
337
  get scale(): twgl.V3;
327
- updateScale(scale: number): void;
338
+ updateScale(scale: [number, number]): void;
328
339
 
329
340
  _direction: number;
330
341
  updateDirection(direction: number): void;
@@ -361,7 +372,7 @@ declare namespace RenderWebGL {
361
372
  _convexHullPoints: Array<[number, number]>;
362
373
  _convexHullDirty: boolean;
363
374
  needsConvexHullPoints(): boolean;
364
- setConvexHullDirty(): boolean;
375
+ setConvexHullDirty(): void;
365
376
  setConvexHullPoints(points: Array<[number, number]>): void;
366
377
 
367
378
  _transformedHullPoints: Array<[number, number]>;
@@ -380,6 +391,11 @@ declare namespace RenderWebGL {
380
391
  getFastBounds(result?: Rectangle): Rectangle;
381
392
 
382
393
  updateCPURenderAttributes(): void;
394
+ /**
395
+ * Check if the world position touches the skin.
396
+ * The caller is responsible for ensuring this drawable's inverse matrix & its skin's silhouette are up-to-date.
397
+ * @see updateCPURenderAttributes
398
+ */
383
399
  isTouching(textureCoordinate: twgl.V3): boolean;
384
400
  _isTouchingNearest(textureCoordinate: twgl.V3): boolean;
385
401
  _isTouchingLinear(textureCoordinate: twgl.V3): boolean;
@@ -556,7 +572,7 @@ declare class RenderWebGL extends EventEmitter<RenderWebGL.ScratchRenderEventMap
556
572
  pick(centerX: number, centerY: number, width?: number, height?: number, candidateIds?: number[]): number | -1 | false;
557
573
 
558
574
  extractDrawableScreenSpace(drawableId: number): {
559
- data: ImageData;
575
+ imageData: ImageData;
560
576
  x: number;
561
577
  y: number;
562
578
  width: number;
@@ -17,7 +17,8 @@ declare namespace ScratchStorage {
17
17
  contentType: string;
18
18
  name: string;
19
19
  runtimeFormat: DataFormat;
20
- immutable: true;
20
+ /** Indicates if the asset id is determined by the asset content. */
21
+ immutable: boolean;
21
22
  }
22
23
  namespace AssetType {
23
24
  const ImageBitmap: AssetType;
@@ -39,6 +40,8 @@ declare namespace ScratchStorage {
39
40
  */
40
41
  assetId: string;
41
42
 
43
+ data: Uint8Array;
44
+
42
45
  setData(data: Uint8Array, dataFormat: DataFormat, generateId?: boolean): void;
43
46
  encodeTextData(text: string, dataFormat: DataFormat, generateId?: boolean): void;
44
47
 
@@ -54,6 +57,7 @@ declare namespace ScratchStorage {
54
57
  type UrlFunction = (asset: Asset) => string;
55
58
 
56
59
  interface Helper {
60
+ parent: ScratchStorage;
57
61
  load(assetType: AssetType, assetId: string, dataFormat: DataFormat): Promise<Asset>;
58
62
  store(assetType: AssetType, dataFormat: DataFormat, data: Uint8Array, assetId: string): Promise<unknown>;
59
63
  }
@@ -76,7 +80,10 @@ declare class ScratchStorage {
76
80
 
77
81
  load(assetType: ScratchStorage.AssetType, assetId: string, dataFormat: ScratchStorage.DataFormat): Promise<ScratchStorage.Asset | null>;
78
82
 
79
- store(assetType: ScratchStorage.Asset, dataFormat: ScratchStorage.DataFormat, data: Uint8Array, assetId: string): Promise<unknown>;
83
+ store(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data: Uint8Array, assetId: string): Promise<unknown>;
84
+
85
+ getDefaultAssetId(type: ScratchStorage.AssetType): string | undefined;
86
+ setDefaultAssetId(type: ScratchStorage.AssetType, id: string): void;
80
87
 
81
88
  createAsset(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data: Uint8Array, assetId: null, generateId: true): ScratchStorage.Asset;
82
89
  createAsset(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data: Uint8Array, assetId: string, generateId?: boolean): ScratchStorage.Asset;
@@ -45,6 +45,8 @@ declare namespace VM {
45
45
  */
46
46
  md5?: string;
47
47
 
48
+ md5ext?: string;
49
+
48
50
  name: string;
49
51
 
50
52
  asset: ScratchStorage.Asset;
@@ -75,6 +77,32 @@ declare namespace VM {
75
77
  sounds: Sound[];
76
78
  clones: RenderedTarget[];
77
79
  soundBank: AudioEngine.SoundBank | null;
80
+
81
+ /**
82
+ * Create a clone of this sprite.
83
+ * @param optLayerGroup Optional layer group the clone's drawable should be added to. Defaults to the sprite layer group.
84
+ */
85
+ createClone(optLayerGroup?: string): RenderedTarget;
86
+
87
+ duplicate(): Promise<Sprite>;
88
+
89
+ /**
90
+ * Add a costume at the given index, taking care to avoid duplicate names.
91
+ */
92
+ addCostumeAt(costumeObject: Costume, index: number): void;
93
+
94
+ /**
95
+ * Delete a costume by index.
96
+ * @returns The deleted costume, or undefined if none existed at that index.
97
+ */
98
+ deleteCostumeAt(index: number): Costume | undefined;
99
+
100
+ /**
101
+ * Disconnect a clone from this sprite. The clone is unmodified; in particular its dispose() is not called.
102
+ */
103
+ removeClone(clone: RenderedTarget): void;
104
+
105
+ dispose(): void;
78
106
  }
79
107
 
80
108
  interface Field {
@@ -145,11 +173,21 @@ declare namespace VM {
145
173
 
146
174
  getBlock(id: string): Block | undefined;
147
175
 
148
- getOpcode(id: string): string | null;
176
+ getOpcode(block: Block): string | null;
149
177
 
150
- getFields(id: string): object | null;
178
+ getFields(block: Block): Record<string, Field> | null;
151
179
 
152
- getInputs(id: string): object | null;
180
+ getInputs(block: Block): Record<string, Input> | null;
181
+
182
+ getMutation(block: Block): ProcedureCallMutation | ProcedurePrototypeMutation | null;
183
+
184
+ getScripts(): string[];
185
+
186
+ getNextBlock(id: string): string | null;
187
+
188
+ getBranch(id: string, branchNum?: number): string | null;
189
+
190
+ getTopLevelScript(id: string): string | null;
153
191
 
154
192
  getProcedureDefinition(procedureCode: string): string | null;
155
193
 
@@ -230,6 +268,7 @@ declare namespace VM {
230
268
  y: number;
231
269
  width: number;
232
270
  height: number;
271
+ toXML(): string;
233
272
  }
234
273
 
235
274
  interface PostedSpriteInfo {
@@ -338,6 +377,77 @@ declare namespace VM {
338
377
  */
339
378
  createVariable(id: string, name: string, type: VariableType, isCloud?: boolean): void;
340
379
 
380
+ /**
381
+ * Renames the variable with the given id to newName.
382
+ */
383
+ renameVariable(id: string, newName: string): void;
384
+
385
+ /**
386
+ * Removes the variable with the given id from the dictionary of variables.
387
+ */
388
+ deleteVariable(id: string): void;
389
+
390
+ /**
391
+ * Create a clone of the variable with the given id.
392
+ * Returns null if the original variable was not found.
393
+ */
394
+ duplicateVariable(id: string, optKeepOriginalId?: boolean): Variable | null;
395
+
396
+ /**
397
+ * Duplicate the dictionary of this target's variables as part of duplicating this target or making a clone.
398
+ */
399
+ duplicateVariables(optBlocks?: Blocks): Record<string, Variable>;
400
+
401
+ /**
402
+ * Remove this target's monitors from the runtime state and remove the
403
+ * target-specific monitored blocks (e.g. local variables, x-position).
404
+ * Does not delete stage monitors like backdrop name.
405
+ */
406
+ deleteMonitors(): void;
407
+
408
+ /**
409
+ * Get the names of all the variables of the given type that are in scope for this target.
410
+ * @param type Defaults to the scalar type.
411
+ * @param skipStage Optional flag to skip the stage.
412
+ */
413
+ getAllVariableNamesInScopeByType(type?: VariableType, skipStage?: boolean): string[];
414
+
415
+ /**
416
+ * Merge variable references with another variable.
417
+ */
418
+ mergeVariables(idToBeMerged: string, idToMergeWith: string, optReferencesToUpdate?: object[], optNewName?: string): void;
419
+
420
+ /**
421
+ * Fixes up variable references in this target avoiding conflicts with
422
+ * pre-existing variables in the same scope. Used when uploading a target as a new sprite.
423
+ */
424
+ fixUpVariableReferences(): void;
425
+
426
+ /**
427
+ * Share the given variable-referencing fields with the target of the given id, resolving conflicts.
428
+ */
429
+ resolveVariableSharingConflictsWithTarget(blocks: Block[], receivingTarget: Target): void;
430
+
431
+ /**
432
+ * Share a local variable (and given references for that variable) to the stage.
433
+ */
434
+ shareLocalVariableToStage(varId: string, varRefs: object[]): void;
435
+
436
+ /**
437
+ * Share a local variable with a sprite, merging with one of the same name and type if it exists.
438
+ */
439
+ shareLocalVariableToSprite(varId: string, sprite: Target, varRefs: object[]): void;
440
+
441
+ /**
442
+ * Update an edge-activated hat block value.
443
+ * @return The old value for the edge-activated hat.
444
+ */
445
+ updateEdgeActivatedValue(blockId: string, newValue: unknown): unknown;
446
+
447
+ hasEdgeActivatedValue(blockId: string): boolean;
448
+
449
+ clearEdgeActivatedValues(): void;
450
+
341
451
  _customState: Partial<CustomState>;
342
452
  getCustomState<T extends keyof CustomState>(name: T): CustomState[T] | undefined;
343
453
  setCustomState<T extends keyof CustomState>(name: T, value: CustomState[T]): void;
@@ -353,7 +463,7 @@ declare namespace VM {
353
463
  }
354
464
 
355
465
  const enum RotationStyle {
356
- AllAround = 'all-around',
466
+ AllAround = 'all around',
357
467
  LeftRight = 'left-right',
358
468
  None = "don't rotate"
359
469
  }
@@ -396,6 +506,8 @@ declare namespace VM {
396
506
 
397
507
  isStage: boolean;
398
508
 
509
+ dragging: boolean;
510
+
399
511
  /**
400
512
  * Returns true if the target is not the stage and is not a clone.
401
513
  */
@@ -411,7 +523,7 @@ declare namespace VM {
411
523
  */
412
524
  setXY(x: number, y: number, force?: boolean): void;
413
525
 
414
- keepInFence(newX: number, newY: number, fence?: SimpleRectangle): [number, number];
526
+ keepInFence(newX: number, newY: number, fence?: SimpleRectangle): [number, number] | undefined;
415
527
 
416
528
  /**
417
529
  * Direction in degrees. Defaults to 90 (right). Can be from -179 to 180.
@@ -589,7 +701,7 @@ declare namespace VM {
589
701
  tempo: number;
590
702
 
591
703
  videoTransparency: number;
592
-
704
+ videoState: 'off' | 'on' | 'on-flipped';
593
705
 
594
706
  /**
595
707
  * Create a clone of this sprite if the clone limit has not been reached.
@@ -609,6 +721,23 @@ declare namespace VM {
609
721
 
610
722
  updateAllDrawableProperties(): void;
611
723
 
724
+ /**
725
+ * The language to use for speech synthesis, in the text2speech extension.
726
+ * Initialized to null; on extension load it may be set from the editor locale.
727
+ */
728
+ textToSpeechLanguage: string | null;
729
+
730
+ /**
731
+ * Create a drawable with this.renderer.
732
+ * @param layerGroup The layer group this drawable should be added to (a StageLayering value).
733
+ */
734
+ initDrawable(layerGroup: string): void;
735
+
736
+ /**
737
+ * Initialize the audio player for this sprite or clone.
738
+ */
739
+ initAudio(): void;
740
+
612
741
  toJSON(): SerializedTarget;
613
742
  }
614
743
 
@@ -630,7 +759,7 @@ declare namespace VM {
630
759
  waitingReporter: unknown;
631
760
  params: unknown;
632
761
  executionContext: unknown;
633
- reset(): void;
762
+ reset(): StackFrame;
634
763
  }
635
764
 
636
765
  interface BlockUtility {
@@ -661,14 +790,18 @@ declare namespace VM {
661
790
  * @see {Thread.stopThisScript}
662
791
  */
663
792
  stopThisScript(): void;
793
+ /**
794
+ * @see {Sequencer.stepToProcedure}
795
+ */
796
+ startProcedure(procedureCode: string): void;
664
797
  /**
665
798
  * @see {Blocks.getProcedureParamNamesAndIds}
666
799
  */
667
- getProcedureParamNamesAndIds(): [string[], string[]];
800
+ getProcedureParamNamesAndIds(procedureCode: string): [string[], string[]];
668
801
  /**
669
802
  * @see {Blocks.getProcedureParamNamesIdsAndDefaults}
670
803
  */
671
- getProcedureParamNamesIdsAndDefaults(): [string[], string[], string[]];
804
+ getProcedureParamNamesIdsAndDefaults(procedureCode: string): [string[], string[], string[]];
672
805
  /**
673
806
  * @see {Thread.initParams}
674
807
  */
@@ -712,7 +845,7 @@ declare namespace VM {
712
845
  reuseStackForNextBlock(blockId: string): void;
713
846
  pushStack(blockId: string): void;
714
847
  popStack(): string;
715
- peekStack(): string;
848
+ peekStack(): string | null;
716
849
  peekStackFrame(): StackFrame | null;
717
850
  peekParentStackFrame(): StackFrame | null;
718
851
  pushReportedValue(value: ScratchCompatibleValue): void;
@@ -763,17 +896,17 @@ declare namespace VM {
763
896
  start(id: number, arg: unknown): void;
764
897
  stop(): void;
765
898
  increment(id: number): void;
766
- frame(id: string, arg: unknown): ProfilerFrame;
899
+ frame(id: number, arg: unknown): ProfilerFrame;
767
900
  reportFrames(): void;
768
901
  idByName(name: string): number;
769
- nameById(id: number): string;
902
+ nameById(id: number): string | null;
770
903
  }
771
904
 
772
905
  interface Sequencer {
773
906
  timer: Timer;
774
907
  runtime: Runtime;
775
908
  activeThread: Thread | null;
776
- stepThreads(): void;
909
+ stepThreads(): Thread[];
777
910
  stepThread(thread: Thread): void;
778
911
  stepToBranch(thread: Thread, branch: number, isLoop: boolean): void;
779
912
  stepToProcedure(thread: Thread, procedureCode: string): void;
@@ -781,12 +914,13 @@ declare namespace VM {
781
914
  }
782
915
 
783
916
  interface ImportedExtensionsInfo {
784
- extensionIDs: string[];
785
- extensionURLs: string[];
917
+ extensionIDs: Set<string>;
918
+ extensionURLs: Map<string, string>;
786
919
  }
787
920
 
788
921
  interface ExtensionManager {
789
922
  runtime: Runtime;
923
+ _loadedExtensions: Map<string, string>;
790
924
 
791
925
  refreshBlocks(): Promise<void[]>;
792
926
 
@@ -810,9 +944,9 @@ declare namespace VM {
810
944
  interface Timer {
811
945
  startTime: number;
812
946
 
813
- time(): number;
947
+ nowObj: { now(): number };
814
948
 
815
- relativeTime(): number;
949
+ time(): number;
816
950
 
817
951
  start(): void;
818
952
 
@@ -901,6 +1035,7 @@ declare namespace VM {
901
1035
  canvasWidth?: number;
902
1036
  canvasHeight?: number;
903
1037
  isDown?: boolean;
1038
+ wasDragged?: boolean;
904
1039
  }
905
1040
 
906
1041
  interface Mouse {
@@ -944,11 +1079,44 @@ declare namespace VM {
944
1079
  }
945
1080
 
946
1081
  interface VideoData {
947
- // TODO
1082
+ forceTransparentPreview: boolean;
948
1083
  }
949
1084
 
950
1085
  interface Video {
951
- // TODO
1086
+ runtime: Runtime;
1087
+ provider: VideoProvider | null;
1088
+ _drawable: number;
1089
+ _skinId: number;
1090
+ mirror?: boolean;
1091
+ readonly videoReady: boolean;
1092
+
1093
+ enableVideo(): Promise<void> | null;
1094
+ disableVideo(): void;
1095
+
1096
+ getFrame(frameInfo: {
1097
+ dimensions?: [number, number];
1098
+ mirror?: boolean;
1099
+ format?: 'image-data';
1100
+ cacheTimeout?: number;
1101
+ }): ImageData | null;
1102
+ getFrame(frameInfo: {
1103
+ dimensions?: [number, number];
1104
+ mirror?: boolean;
1105
+ format?: 'canvas';
1106
+ cacheTimeout?: number;
1107
+ }): HTMLCanvasElement | null;
1108
+ getFrame(frameInfo: {
1109
+ dimensions?: [number, number];
1110
+ mirror?: boolean;
1111
+ format?: 'image-data' | 'canvas' | string;
1112
+ cacheTimeout?: number;
1113
+ }): ImageData | HTMLCanvasElement | string | null;
1114
+
1115
+ /**
1116
+ * @param ghost from 0 (visible) to 100 (invisible)
1117
+ */
1118
+ setPreviewGhost(ghost: number): void;
1119
+
952
1120
  postData(data: VideoData): void;
953
1121
  }
954
1122
 
@@ -1127,6 +1295,11 @@ declare namespace VM {
1127
1295
  */
1128
1296
  compatibilityMode: boolean;
1129
1297
 
1298
+ /**
1299
+ * Set whether the runtime is in 30 TPS "compatibility mode".
1300
+ */
1301
+ setCompatibilityMode(compatibilityMode: boolean): void;
1302
+
1130
1303
  renderer: IfRenderer<RenderWebGL, undefined>;
1131
1304
 
1132
1305
  attachRenderer(renderer: RenderWebGL): void;
@@ -1237,6 +1410,22 @@ declare namespace VM {
1237
1410
 
1238
1411
  monitorBlocks: Blocks;
1239
1412
 
1413
+ monitorBlockInfo: Record<string, unknown>;
1414
+
1415
+ requestAddMonitor(monitor: unknown): void;
1416
+
1417
+ requestUpdateMonitor(delta: unknown): boolean;
1418
+
1419
+ requestRemoveMonitor(monitorId: string): void;
1420
+
1421
+ requestHideMonitor(monitorId: string): boolean;
1422
+
1423
+ requestShowMonitor(monitorId: string): boolean;
1424
+
1425
+ requestRemoveMonitorByTargetId(targetId: string): void;
1426
+
1427
+ addMonitorScript(topBlockId: string, optTarget?: Target): void;
1428
+
1240
1429
  visualReport(blockId: string, value: any): void;
1241
1430
 
1242
1431
  _primitives: Record<string, Function>;
@@ -1253,6 +1442,8 @@ declare namespace VM {
1253
1442
  xml: string;
1254
1443
  }>;
1255
1444
 
1445
+ getBlocksJSON(): object[];
1446
+
1256
1447
  _blockInfo: ExtensionInfo[];
1257
1448
 
1258
1449
  _hats: Record<string, HatInfo>;
@@ -1339,6 +1530,8 @@ declare namespace VM {
1339
1530
 
1340
1531
  emitProjectLoaded(): void;
1341
1532
 
1533
+ handleProjectLoaded(): void;
1534
+
1342
1535
  emitProjectChanged(): void;
1343
1536
 
1344
1537
  _editingTarget: Target | null;
@@ -1354,6 +1547,16 @@ declare namespace VM {
1354
1547
 
1355
1548
  getPeripheralIsConnected(extensionID: string): boolean;
1356
1549
 
1550
+ peripheralExtensions: Record<string, unknown>;
1551
+
1552
+ registerPeripheralExtension(extensionId: string, extension: unknown): void;
1553
+
1554
+ getScratchLinkSocket(type: 'BLE' | 'BT'): unknown;
1555
+
1556
+ configureScratchLinkSocketFactory(factory: (type: string) => unknown): void;
1557
+
1558
+ emitMicListening(listening: boolean): void;
1559
+
1357
1560
  profiler: Profiler | null;
1358
1561
  enableProfiling(callback: (profilerFrame: ProfilerFrame) => void): void;
1359
1562
  disableProfiling(): void;
@@ -1376,7 +1579,7 @@ declare namespace VM {
1376
1579
  playgroundData: [{
1377
1580
  blocks: Blocks;
1378
1581
  // Stringified JSON of Thread[]
1379
- thread: string;
1582
+ threads: string;
1380
1583
  }];
1381
1584
  }
1382
1585
  }
@@ -1527,13 +1730,13 @@ declare class VM extends EventEmitter<VM.VirtualMachineEventMap> {
1527
1730
  */
1528
1731
  addSprite(data: ArrayBufferView | ArrayBuffer | string | object): Promise<void>;
1529
1732
 
1530
- addCostume(md5ext: string, costume?: VM.Costume, targetId?: string, version?: 2): Promise<void>;
1733
+ addCostume(md5ext: string, costume?: Partial<VM.Costume>, targetId?: string, version?: 2): Promise<void>;
1531
1734
 
1532
- addCostumeFromLibrary(md5ext: string, costume: VM.Costume): Promise<void>;
1735
+ addCostumeFromLibrary(md5ext: string, costume: Partial<VM.Costume>): Promise<void>;
1533
1736
 
1534
1737
  addBackdrop(md5ext: string, costume?: VM.Costume): Promise<void>;
1535
1738
 
1536
- addSound(sound: VM.Sound, targetId?: string): Promise<void>;
1739
+ addSound(sound: Partial<VM.Sound>, targetId?: string): Promise<void>;
1537
1740
 
1538
1741
  duplicateSprite(targetId: string): Promise<void>;
1539
1742
 
@@ -1656,4 +1859,50 @@ declare class VM extends EventEmitter<VM.VirtualMachineEventMap> {
1656
1859
  * @see {VM.Runtime.getPeripheralIsConnected}
1657
1860
  */
1658
1861
  getPeripheralIsConnected(extensionID: string): boolean;
1862
+
1863
+ /**
1864
+ * Get data for playground. Data comes back in an emitted playgroundData event.
1865
+ */
1866
+ getPlaygroundData(): void;
1867
+
1868
+ /**
1869
+ * Set the current locale and builtin messages for the VM. Resolves once all blocks have
1870
+ * been updated for the new locale.
1871
+ */
1872
+ setLocale(locale: string, messages: Record<string, string>): Promise<void[]>;
1873
+
1874
+ /**
1875
+ * Get the current locale for the VM.
1876
+ */
1877
+ getLocale(): string;
1878
+
1879
+ /**
1880
+ * Delete all of the flyout blocks.
1881
+ */
1882
+ clearFlyoutBlocks(): void;
1883
+
1884
+ /**
1885
+ * Handle a Blockly event for the current editing target.
1886
+ */
1887
+ blockListener(e: unknown): void;
1888
+
1889
+ /**
1890
+ * Handle a Blockly event for the flyout.
1891
+ */
1892
+ flyoutBlockListener(e: unknown): void;
1893
+
1894
+ /**
1895
+ * Handle a Blockly event for the flyout to be passed to the monitor container.
1896
+ */
1897
+ monitorBlockListener(e: unknown): void;
1898
+
1899
+ /**
1900
+ * Handle a Blockly event for the variable map.
1901
+ */
1902
+ variableListener(e: unknown): void;
1903
+
1904
+ /**
1905
+ * Allow VM consumer to configure the ScratchLink socket creator.
1906
+ */
1907
+ configureScratchLinkSocketFactory(factory: Function): void;
1659
1908
  }
package/types/twgl.d.ts CHANGED
@@ -3,14 +3,23 @@
3
3
 
4
4
  declare namespace twgl {
5
5
  interface BufferInfo {
6
- // TODO: returned by createBufferInfoFromArrays
7
- // might not be able to meaningfully type?
6
+ numElements: number;
7
+ attribs: Record<string, {
8
+ buffer: WebGLBuffer;
9
+ }>;
8
10
  }
9
11
 
10
12
  interface ProgramInfo {
11
13
  // TODO: returned by createProgramInfo
12
14
  }
13
15
 
16
+ interface FrameBufferInfo {
17
+ attachments: WebGLTexture[];
18
+ framebuffer: WebGLFramebuffer;
19
+ width: number;
20
+ height: number;
21
+ }
22
+
14
23
  interface M4 {
15
24
  // TODO
16
25
  }
@@ -19,3 +28,14 @@ declare namespace twgl {
19
28
  // TODO
20
29
  }
21
30
  }
31
+
32
+ declare class twgl {
33
+ createFramebufferInfo(...args: unknown[]): twgl.FrameBufferInfo;
34
+ resizeFramebufferInfo(...args: unknown[]): void;
35
+ createProgramInfo(...args: unknown[]): twgl.ProgramInfo;
36
+ createBufferInfoFromArrays(...args: unknown[]): twgl.BufferInfo;
37
+ createTexture(...args: unknown[]): WebGLTexture;
38
+ setBuffersAndAttributes(...args: unknown[]): void;
39
+ setUniforms(...args: unknown[]): void;
40
+ drawBufferInfo(...args: unknown[]): void;
41
+ }
@@ -1,44 +0,0 @@
1
- name: Deploy documentation to GitHub Pages
2
-
3
- on:
4
- workflow_dispatch:
5
- push:
6
- branches: [master]
7
-
8
- concurrency:
9
- group: "deploy"
10
- cancel-in-progress: true
11
-
12
- jobs:
13
- build:
14
- runs-on: ubuntu-latest
15
- steps:
16
- - uses: actions/checkout@v6
17
- with:
18
- persist-credentials: false
19
- - name: Install Node.js
20
- uses: actions/setup-node@v6
21
- with:
22
- node-version: 24
23
- - name: Install dependencies
24
- run: npm ci
25
- - name: Build documentation
26
- run: npm run build
27
- - name: Upload artifact
28
- uses: actions/upload-pages-artifact@v4
29
- with:
30
- path: ./docs/
31
-
32
- deploy:
33
- environment:
34
- name: github-pages
35
- url: ${{ steps.deployment.outputs.page_url }}
36
- permissions:
37
- pages: write
38
- id-token: write
39
- runs-on: ubuntu-latest
40
- needs: build
41
- steps:
42
- - name: Deploy to GitHub Pages
43
- id: deployment
44
- uses: actions/deploy-pages@v4
@@ -1,22 +0,0 @@
1
- name: Publish to npm
2
-
3
- on:
4
- push:
5
- tags:
6
- - 'v*'
7
-
8
- permissions:
9
- id-token: write
10
- contents: read
11
-
12
- jobs:
13
- publish:
14
- runs-on: ubuntu-latest
15
- steps:
16
- - uses: actions/checkout@v6
17
- - uses: actions/setup-node@v6
18
- with:
19
- node-version: 24
20
- - run: npm ci
21
- - run: npm test
22
- - run: npm publish
@@ -1,25 +0,0 @@
1
- name: Validate TypeScript
2
-
3
- on:
4
- push:
5
- pull_request:
6
-
7
- jobs:
8
- test:
9
- runs-on: ubuntu-latest
10
-
11
- steps:
12
- - uses: actions/checkout@v6
13
- with:
14
- persist-credentials: false
15
- - name: Setup Node.js
16
- uses: actions/setup-node@v6
17
- with:
18
- node-version: 24
19
- - name: Install dependencies
20
- run: npm ci
21
- - name: Validate TypeScript
22
- run: npm test
23
- - name: Validate individual .d.ts files
24
- run: |
25
- parallel -v npx tsc --target es6 --noEmit ::: index.d.ts types/*.d.ts
package/CONTRIBUTING.md DELETED
@@ -1,9 +0,0 @@
1
- # Contributing
2
-
3
- Our goal is to document all the APIs exposed by Scratch. We accept any contributions that work towards that goal.
4
-
5
- Even if you aren't able to write types, please open issues to report missing or incorrect types.
6
-
7
- In terms of code style, we aren't super picky. Just keep it consistent with whatever is already there.
8
-
9
- For very complex types, please add a small test case in the `tests` directory. Presumably you already wrote some test code while writing the types, so just don't delete that once you're done.
@@ -1,15 +0,0 @@
1
- declare const RealBlockly: ScratchBlocks.RealBlockly;
2
-
3
- if (typeof Blockly === 'undefined') {
4
- throw new Error('blockly doesnt exist')
5
- }
6
-
7
- const workspace = Blockly.getMainWorkspace();
8
- if (!workspace) {
9
- throw new Error('no workspace');
10
- }
11
-
12
- workspace.id.toString();
13
-
14
- const fakeWorkspace = new RealBlockly.Workspace({});
15
- fakeWorkspace.id.charAt(0);
@@ -1,4 +0,0 @@
1
- import VM from 'scratch-vm';
2
-
3
- const vm = new VM();
4
- vm.clear();
@@ -1,3 +0,0 @@
1
- const VirtualMachine = require('scratch-vm');
2
- const vm = new VirtualMachine();
3
- vm.clear();
@@ -1,4 +0,0 @@
1
- import VM from 'scratch-vm';
2
- const vm = new VM();
3
- // Your editor probably makes it clear that fromJSON is deprecated below
4
- vm.fromJSON(new ArrayBuffer(10));
@@ -1,15 +0,0 @@
1
- import VM from 'scratch-vm';
2
-
3
- const vm = new VM();
4
- const callback = (i: unknown) => console.log(i);
5
-
6
- vm.on('VISUAL_REPORT', callback);
7
- vm.off('VISUAL_REPORT', callback);
8
- vm.listeners('VISUAL_REPORT').forEach((i) => i({
9
- id: 'def',
10
- value: 'xyz'
11
- }));
12
- vm.emit('VISUAL_REPORT', {
13
- id: 'abc',
14
- value: 'def'
15
- });
@@ -1,16 +0,0 @@
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
- });
@@ -1,25 +0,0 @@
1
- import AudioEngine from 'scratch-audio';
2
-
3
- declare const vm: VM;
4
- const audioEngine = new AudioEngine();
5
- vm.attachAudioEngine(audioEngine);
6
-
7
- audioEngine.decodeSoundPlayer({
8
- data: {
9
- buffer: new ArrayBuffer(10)
10
- }
11
- })
12
- .then((player) => {
13
- player.on('stop', () => {
14
-
15
- });
16
- return player.finished();
17
- });
18
-
19
- declare const pitchEffect: AudioEngine.PitchEffect;
20
- pitchEffect.ratio as number
21
- pitchEffect.updatePlayers([]);
22
-
23
- declare const soundPlayer: AudioEngine.SoundPlayer;
24
-
25
- new audioEngine.effects[0](audioEngine, soundPlayer, pitchEffect);
@@ -1,16 +0,0 @@
1
- declare const state: ScratchGUI.ReduxState;
2
- declare function dispatch(event: ScratchGUI.ReduxEvent): void;
3
-
4
- const vm = state.scratchGui.vm;
5
- vm.greenFlag();
6
- vm.renderer._allDrawables[0].updateVisible(false);
7
-
8
- dispatch({
9
- type: 'scratch-gui/navigation/ACTIVATE_TAB',
10
- activeTabIndex: 0
11
- });
12
-
13
- state.scratchPaint.cursor.charAt(0);
14
- dispatch({
15
- type: 'scratch-paint/undo/CLEAR'
16
- });
@@ -1,9 +0,0 @@
1
- import unpack from 'scratch-parser';
2
-
3
- unpack('{}', false, (error, unpacked) => {
4
- if (error) {
5
- console.error(error);
6
- } else {
7
- const [target, zip] = unpacked;
8
- }
9
- });
@@ -1,4 +0,0 @@
1
- import getFonts from 'scratch-render-fonts';
2
-
3
- const fonts = getFonts();
4
- console.log(atob(fonts['Curly']));
@@ -1,8 +0,0 @@
1
- const canvas = document.createElement('canvas');
2
- const renderer = new RenderWebGL(canvas, 100, 200, 100, 200);
3
-
4
- // updateDrawableProperties should be deprecated
5
- renderer.updateDrawableProperties(10, {
6
- whirl: 10,
7
- position: [20, 30]
8
- });
@@ -1,37 +0,0 @@
1
- import ScratchStorage from 'scratch-storage';
2
-
3
- declare const vm: VM;
4
-
5
- const storage = new ScratchStorage();
6
- vm.attachStorage(storage);
7
-
8
- ScratchStorage.DataFormat.JPG === 'jpg';
9
- storage.DataFormat.JPG === 'jpg';
10
-
11
- storage.addWebStore(
12
- [
13
- ScratchStorage.AssetType.ImageVector,
14
- ScratchStorage.AssetType.ImageBitmap,
15
- storage.AssetType.Sound,
16
- ],
17
- asset => {
18
- const assetId = asset.assetId;
19
- const dataFormat = asset.dataFormat;
20
- return `https://assets.scratch.mit.edu/${assetId}.${dataFormat}`;
21
- }
22
- );
23
-
24
- storage.createAsset(
25
- storage.AssetType.ImageBitmap,
26
- storage.DataFormat.PNG,
27
- new Uint8Array([]),
28
- null,
29
- true
30
- ) as ScratchStorage.Asset;
31
- storage.createAsset(
32
- storage.AssetType.ImageBitmap,
33
- storage.DataFormat.PNG,
34
- new Uint8Array([]),
35
- "1234567",
36
- false
37
- ) as ScratchStorage.Asset;
@@ -1,8 +0,0 @@
1
- import * as SvgRenderer from 'scratch-svg-renderer';
2
-
3
- const svg = SvgRenderer.loadSvgString('imagine that this is an SVG', false);
4
- const serialized = SvgRenderer.serializeSvgToString(svg);
5
- const inlinedFonts = SvgRenderer.inlineSvgFonts('an svg here');
6
- const fixedFonts = SvgRenderer.convertFonts(SvgRenderer.SvgElement.create('svg'));
7
-
8
- const bitmapAdapter = new SvgRenderer.BitmapAdapter();
@@ -1,105 +0,0 @@
1
- (function(Scratch) {
2
- 'use strict';
3
-
4
- class Fetch {
5
- /** @returns {Scratch.Info} */
6
- getInfo () {
7
- return {
8
- id: 'fetch',
9
- name: 'Fetch',
10
- blocks: [
11
- {
12
- opcode: 'get',
13
- blockType: Scratch.BlockType.REPORTER,
14
- text: 'GET [URL]',
15
- arguments: {
16
- URL: {
17
- type: Scratch.ArgumentType.STRING,
18
- defaultValue: 'https://extensions.turbowarp.org/hello.txt'
19
- }
20
- }
21
- },
22
- '---',
23
- {
24
- opcode: 'test',
25
- text: 'test [STRING] [IMAGE] [BOOLEAN] [NUMBER] [MATRIX] [NOTE] [ANGLE] [COLOR]',
26
- blockType: Scratch.BlockType.COMMAND,
27
- hideFromPalette: false,
28
- isTerminal: true,
29
- arguments: {
30
- STRING: {
31
- type: Scratch.ArgumentType.STRING,
32
- defaultValue: 'test',
33
- menu: 'test1'
34
- },
35
- IMAGE: {
36
- type: Scratch.ArgumentType.IMAGE,
37
- dataURI: 'https://extensions.turbowarp.org/dango.png'
38
- },
39
- BOOLEAN: {
40
- type: Scratch.ArgumentType.BOOLEAN
41
- },
42
- NUMBER: {
43
- type: Scratch.ArgumentType.NUMBER,
44
- defaultValue: 5,
45
- },
46
- MATRIX: {
47
- type: Scratch.ArgumentType.MATRIX,
48
- defaultValue: '0101001010000001000101110'
49
- },
50
- NOTE: {
51
- type: Scratch.ArgumentType.NOTE,
52
- defaultValue: '30'
53
- },
54
- ANGLE: {
55
- type: Scratch.ArgumentType.ANGLE,
56
- defaultValue: 30
57
- },
58
- COLOR: {
59
- type: Scratch.ArgumentType.COLOR,
60
- defaultValue: '#123456'
61
- }
62
- }
63
- },
64
- {
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
- ]
78
- }
79
- }
80
- };
81
- }
82
-
83
- /**
84
- * @param {{URL: string;}} args
85
- */
86
- get (args) {
87
- return fetch(args.URL)
88
- .then(r => r.text())
89
- .catch(() => '');
90
- }
91
-
92
- /**
93
- * @param {unknown} args
94
- */
95
- test (args) {
96
- console.log(args);
97
- }
98
- }
99
-
100
- if (Scratch.extensions.unsandboxed) {
101
- // ...
102
- }
103
-
104
- Scratch.extensions.register(new Fetch());
105
- })(Scratch);
@@ -1,84 +0,0 @@
1
- import VM from 'scratch-vm';
2
- import AudioEngine from 'scratch-audio';
3
-
4
- const vm = new VM();
5
- const runtime = vm.runtime;
6
-
7
- runtime.on('SCRIPT_GLOW_ON', (glowData) => {
8
- const id: string = glowData.id;
9
- });
10
- vm.on('SCRIPT_GLOW_OFF', (glowData) => {
11
- const id: string = glowData.id;
12
- });
13
-
14
- vm.emit('targetsUpdate', {
15
- targetList: [],
16
- editingTarget: 'abc 123'
17
- });
18
-
19
- const target = vm.runtime.getSpriteTargetByName('Sprite1');
20
- if (target) {
21
- const variable = target.lookupVariableByNameAndType('test', 'list');
22
- if (variable) {
23
- const name: string = variable.name;
24
- const upToDate: boolean | undefined = variable._monitorUpToDate;
25
- variable.value.filter(i => i.toString());
26
- }
27
-
28
- target.lookupOrCreateVariable(')(!@*#)!(@#*()', 'my variable').value;
29
-
30
- // @ts-expect-error
31
- target.lookupVariableById('#@)$(*%)(#').id;
32
-
33
- target.effects.ghost += 10;
34
-
35
- const block = target.blocks.getBlock('123');
36
- if (!block) {
37
- throw new Error('no block :(');
38
- }
39
- if (block.opcode === 'procedures_call') {
40
- const mutation = block.mutation as VM.ProcedureCallMutation;
41
- JSON.parse(mutation.argumentids);
42
- }
43
-
44
- const bubbleState = target.getCustomState('Scratch.looks');
45
- if (bubbleState) {
46
- bubbleState.text.charAt(0);
47
- target.setCustomState('Scratch.looks', bubbleState);
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
- });
59
-
60
- runtime.on('STOP_FOR_TARGET', (t: VM.RenderedTarget) => {
61
-
62
- });
63
- } else {
64
- const doesNotExist: undefined = target;
65
- }
66
-
67
- runtime._editingTarget as VM.Target;
68
- runtime.getEditingTarget() as VM.Target;
69
-
70
- const audioEngine = new AudioEngine();
71
- vm.attachAudioEngine(audioEngine);
72
- audioEngine.audioContext.suspend();
73
-
74
- vm.setTurboMode(true);
75
- vm.runtime.turboMode as boolean
76
- vm.setCompatibilityMode(true);
77
- vm.runtime.compatibilityMode as boolean
78
-
79
- const costume = vm.runtime.getTargetForStage()?.getCostumes()?.[0];
80
- costume?.skinId as number;
81
-
82
- declare const util: VM.BlockUtility;
83
- util.startHats('hats', {BROADCAST_OPTION: 'test'}) as VM.Thread[];
84
- util.ioQuery('mouse', 'getIsDown', []);
@@ -1,29 +0,0 @@
1
- (function () {
2
- const ext = {};
3
-
4
- ext._getStatus = () => ({
5
- status: 2,
6
- msg: 'Ready'
7
- });
8
-
9
- ext.testReporter = () => Math.random();
10
-
11
- /**
12
- * @param {number} delay
13
- * @param {function} callback
14
- */
15
- ext.testReporterWait = (delay, callback) => {
16
- setTimeout(() => {
17
- callback(Math.random())
18
- }, delay * 1000);
19
- };
20
-
21
- var descriptor = {
22
- blocks: [
23
- ['r', 'test reporter', 'testReporter'],
24
- ['R', 'test reporter 2 %n', 'testReporterWait', '1'],
25
- ],
26
- };
27
-
28
- ScratchExtensions.register('ScratchX Test', descriptor, ext);
29
- }());
@@ -1,4 +0,0 @@
1
- import VM from 'scratch-vm';
2
-
3
- const vm = new VM();
4
- vm.clear();
@@ -1,4 +0,0 @@
1
- import VM = require('scratch-vm');
2
-
3
- const vm = new VM();
4
- vm.clear();