@turbowarp/types 0.0.13 → 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 +3 -3
- package/types/events.d.ts +1 -0
- package/types/scratch-audio.d.ts +14 -4
- package/types/scratch-blocks.d.ts +11 -0
- package/types/scratch-render.d.ts +28 -12
- package/types/scratch-storage.d.ts +15 -8
- package/types/scratch-vm.d.ts +299 -29
- package/types/twgl.d.ts +22 -2
- package/.github/workflows/deploy.yml +0 -45
- package/.github/workflows/validate.yml +0 -26
- package/CONTRIBUTING.md +0 -9
- package/tests/test-blockly.ts +0 -15
- package/tests/test-cjs-es6.js +0 -4
- package/tests/test-cjs-js.js +0 -3
- package/tests/test-deprecated.js +0 -4
- package/tests/test-events.ts +0 -15
- package/tests/test-jszip.ts +0 -16
- package/tests/test-scratch-audio.ts +0 -25
- package/tests/test-scratch-gui.ts +0 -16
- package/tests/test-scratch-parser.ts +0 -9
- package/tests/test-scratch-render-fonts.ts +0 -4
- package/tests/test-scratch-render.ts +0 -8
- package/tests/test-scratch-storage.ts +0 -37
- package/tests/test-scratch-svg-renderer.ts +0 -8
- package/tests/test-scratch-vm-extension.js +0 -105
- package/tests/test-scratch-vm.ts +0 -84
- package/tests/test-scratchx-extension.js +0 -29
- package/tests/test-ts-es6.ts +0 -4
- package/tests/test-ts-require.ts +0 -4
package/types/scratch-vm.d.ts
CHANGED
|
@@ -41,9 +41,11 @@ declare namespace VM {
|
|
|
41
41
|
assetId: string;
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* The md5 + file extension of this asset.
|
|
44
|
+
* The md5 + file extension of this asset. May be missing.
|
|
45
45
|
*/
|
|
46
|
-
md5
|
|
46
|
+
md5?: string;
|
|
47
|
+
|
|
48
|
+
md5ext?: string;
|
|
47
49
|
|
|
48
50
|
name: string;
|
|
49
51
|
|
|
@@ -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(
|
|
176
|
+
getOpcode(block: Block): string | null;
|
|
177
|
+
|
|
178
|
+
getFields(block: Block): Record<string, Field> | null;
|
|
149
179
|
|
|
150
|
-
|
|
180
|
+
getInputs(block: Block): Record<string, Input> | null;
|
|
151
181
|
|
|
152
|
-
|
|
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
|
|
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():
|
|
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;
|
|
@@ -740,19 +873,40 @@ declare namespace VM {
|
|
|
740
873
|
// TODO
|
|
741
874
|
}
|
|
742
875
|
|
|
743
|
-
interface
|
|
744
|
-
|
|
876
|
+
interface ProfilerFrame {
|
|
877
|
+
id: number;
|
|
878
|
+
totalTime: number;
|
|
879
|
+
selfTime: number;
|
|
880
|
+
arg: unknown;
|
|
881
|
+
depth: number;
|
|
882
|
+
count: number;
|
|
745
883
|
}
|
|
746
884
|
|
|
747
|
-
|
|
748
|
-
|
|
885
|
+
type FrameCallback = (frame: ProfilerFrame) => void;
|
|
886
|
+
|
|
887
|
+
interface Profiler {
|
|
888
|
+
records: unknown[];
|
|
889
|
+
increments: ProfilerFrame[];
|
|
890
|
+
counters: ProfilerFrame[];
|
|
891
|
+
nullFrame: ProfilerFrame;
|
|
892
|
+
_stack: ProfilerFrame[];
|
|
893
|
+
onFrame: FrameCallback;
|
|
894
|
+
START: 0;
|
|
895
|
+
STOP: 1;
|
|
896
|
+
start(id: number, arg: unknown): void;
|
|
897
|
+
stop(): void;
|
|
898
|
+
increment(id: number): void;
|
|
899
|
+
frame(id: number, arg: unknown): ProfilerFrame;
|
|
900
|
+
reportFrames(): void;
|
|
901
|
+
idByName(name: string): number;
|
|
902
|
+
nameById(id: number): string | null;
|
|
749
903
|
}
|
|
750
904
|
|
|
751
905
|
interface Sequencer {
|
|
752
906
|
timer: Timer;
|
|
753
907
|
runtime: Runtime;
|
|
754
908
|
activeThread: Thread | null;
|
|
755
|
-
stepThreads():
|
|
909
|
+
stepThreads(): Thread[];
|
|
756
910
|
stepThread(thread: Thread): void;
|
|
757
911
|
stepToBranch(thread: Thread, branch: number, isLoop: boolean): void;
|
|
758
912
|
stepToProcedure(thread: Thread, procedureCode: string): void;
|
|
@@ -760,12 +914,13 @@ declare namespace VM {
|
|
|
760
914
|
}
|
|
761
915
|
|
|
762
916
|
interface ImportedExtensionsInfo {
|
|
763
|
-
extensionIDs: string
|
|
764
|
-
extensionURLs: string
|
|
917
|
+
extensionIDs: Set<string>;
|
|
918
|
+
extensionURLs: Map<string, string>;
|
|
765
919
|
}
|
|
766
920
|
|
|
767
921
|
interface ExtensionManager {
|
|
768
922
|
runtime: Runtime;
|
|
923
|
+
_loadedExtensions: Map<string, string>;
|
|
769
924
|
|
|
770
925
|
refreshBlocks(): Promise<void[]>;
|
|
771
926
|
|
|
@@ -789,9 +944,9 @@ declare namespace VM {
|
|
|
789
944
|
interface Timer {
|
|
790
945
|
startTime: number;
|
|
791
946
|
|
|
792
|
-
|
|
947
|
+
nowObj: { now(): number };
|
|
793
948
|
|
|
794
|
-
|
|
949
|
+
time(): number;
|
|
795
950
|
|
|
796
951
|
start(): void;
|
|
797
952
|
|
|
@@ -880,6 +1035,7 @@ declare namespace VM {
|
|
|
880
1035
|
canvasWidth?: number;
|
|
881
1036
|
canvasHeight?: number;
|
|
882
1037
|
isDown?: boolean;
|
|
1038
|
+
wasDragged?: boolean;
|
|
883
1039
|
}
|
|
884
1040
|
|
|
885
1041
|
interface Mouse {
|
|
@@ -923,11 +1079,44 @@ declare namespace VM {
|
|
|
923
1079
|
}
|
|
924
1080
|
|
|
925
1081
|
interface VideoData {
|
|
926
|
-
|
|
1082
|
+
forceTransparentPreview: boolean;
|
|
927
1083
|
}
|
|
928
1084
|
|
|
929
1085
|
interface Video {
|
|
930
|
-
|
|
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
|
+
|
|
931
1120
|
postData(data: VideoData): void;
|
|
932
1121
|
}
|
|
933
1122
|
|
|
@@ -1106,6 +1295,11 @@ declare namespace VM {
|
|
|
1106
1295
|
*/
|
|
1107
1296
|
compatibilityMode: boolean;
|
|
1108
1297
|
|
|
1298
|
+
/**
|
|
1299
|
+
* Set whether the runtime is in 30 TPS "compatibility mode".
|
|
1300
|
+
*/
|
|
1301
|
+
setCompatibilityMode(compatibilityMode: boolean): void;
|
|
1302
|
+
|
|
1109
1303
|
renderer: IfRenderer<RenderWebGL, undefined>;
|
|
1110
1304
|
|
|
1111
1305
|
attachRenderer(renderer: RenderWebGL): void;
|
|
@@ -1181,7 +1375,7 @@ declare namespace VM {
|
|
|
1181
1375
|
|
|
1182
1376
|
_stopThread(thread: Thread): void;
|
|
1183
1377
|
|
|
1184
|
-
_restartThread(thread: Thread):
|
|
1378
|
+
_restartThread(thread: Thread): Thread;
|
|
1185
1379
|
|
|
1186
1380
|
/**
|
|
1187
1381
|
* A thread is considered active if it is in the thread list and is not STATUS_DONE.
|
|
@@ -1199,7 +1393,7 @@ declare namespace VM {
|
|
|
1199
1393
|
|
|
1200
1394
|
_getMonitorThreadCount(threads: Thread[]): number;
|
|
1201
1395
|
|
|
1202
|
-
startHats(opcode: string, matchFields?: Record<string, unknown>, target?: Target): Thread[];
|
|
1396
|
+
startHats(opcode: string, matchFields?: Record<string, unknown>, target?: Target): Thread[] | undefined;
|
|
1203
1397
|
|
|
1204
1398
|
toggleScript(topBlockId: string, options?: {
|
|
1205
1399
|
target?: string;
|
|
@@ -1216,6 +1410,22 @@ declare namespace VM {
|
|
|
1216
1410
|
|
|
1217
1411
|
monitorBlocks: Blocks;
|
|
1218
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
|
+
|
|
1219
1429
|
visualReport(blockId: string, value: any): void;
|
|
1220
1430
|
|
|
1221
1431
|
_primitives: Record<string, Function>;
|
|
@@ -1232,6 +1442,8 @@ declare namespace VM {
|
|
|
1232
1442
|
xml: string;
|
|
1233
1443
|
}>;
|
|
1234
1444
|
|
|
1445
|
+
getBlocksJSON(): object[];
|
|
1446
|
+
|
|
1235
1447
|
_blockInfo: ExtensionInfo[];
|
|
1236
1448
|
|
|
1237
1449
|
_hats: Record<string, HatInfo>;
|
|
@@ -1318,6 +1530,8 @@ declare namespace VM {
|
|
|
1318
1530
|
|
|
1319
1531
|
emitProjectLoaded(): void;
|
|
1320
1532
|
|
|
1533
|
+
handleProjectLoaded(): void;
|
|
1534
|
+
|
|
1321
1535
|
emitProjectChanged(): void;
|
|
1322
1536
|
|
|
1323
1537
|
_editingTarget: Target | null;
|
|
@@ -1333,6 +1547,16 @@ declare namespace VM {
|
|
|
1333
1547
|
|
|
1334
1548
|
getPeripheralIsConnected(extensionID: string): boolean;
|
|
1335
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
|
+
|
|
1336
1560
|
profiler: Profiler | null;
|
|
1337
1561
|
enableProfiling(callback: (profilerFrame: ProfilerFrame) => void): void;
|
|
1338
1562
|
disableProfiling(): void;
|
|
@@ -1355,7 +1579,7 @@ declare namespace VM {
|
|
|
1355
1579
|
playgroundData: [{
|
|
1356
1580
|
blocks: Blocks;
|
|
1357
1581
|
// Stringified JSON of Thread[]
|
|
1358
|
-
|
|
1582
|
+
threads: string;
|
|
1359
1583
|
}];
|
|
1360
1584
|
}
|
|
1361
1585
|
}
|
|
@@ -1506,13 +1730,13 @@ declare class VM extends EventEmitter<VM.VirtualMachineEventMap> {
|
|
|
1506
1730
|
*/
|
|
1507
1731
|
addSprite(data: ArrayBufferView | ArrayBuffer | string | object): Promise<void>;
|
|
1508
1732
|
|
|
1509
|
-
addCostume(md5ext: string, costume?: VM.Costume
|
|
1733
|
+
addCostume(md5ext: string, costume?: Partial<VM.Costume>, targetId?: string, version?: 2): Promise<void>;
|
|
1510
1734
|
|
|
1511
|
-
addCostumeFromLibrary(md5ext: string, costume: VM.Costume): Promise<void>;
|
|
1735
|
+
addCostumeFromLibrary(md5ext: string, costume: Partial<VM.Costume>): Promise<void>;
|
|
1512
1736
|
|
|
1513
1737
|
addBackdrop(md5ext: string, costume?: VM.Costume): Promise<void>;
|
|
1514
1738
|
|
|
1515
|
-
addSound(sound: VM.Sound
|
|
1739
|
+
addSound(sound: Partial<VM.Sound>, targetId?: string): Promise<void>;
|
|
1516
1740
|
|
|
1517
1741
|
duplicateSprite(targetId: string): Promise<void>;
|
|
1518
1742
|
|
|
@@ -1635,4 +1859,50 @@ declare class VM extends EventEmitter<VM.VirtualMachineEventMap> {
|
|
|
1635
1859
|
* @see {VM.Runtime.getPeripheralIsConnected}
|
|
1636
1860
|
*/
|
|
1637
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;
|
|
1638
1908
|
}
|
package/types/twgl.d.ts
CHANGED
|
@@ -3,14 +3,23 @@
|
|
|
3
3
|
|
|
4
4
|
declare namespace twgl {
|
|
5
5
|
interface BufferInfo {
|
|
6
|
-
|
|
7
|
-
|
|
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,45 +0,0 @@
|
|
|
1
|
-
name: Deploy playground
|
|
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@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
17
|
-
with:
|
|
18
|
-
persist-credentials: false
|
|
19
|
-
- name: Install Node.js
|
|
20
|
-
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
|
|
21
|
-
with:
|
|
22
|
-
node-version: 20
|
|
23
|
-
cache: npm
|
|
24
|
-
- name: Install dependencies
|
|
25
|
-
run: npm ci
|
|
26
|
-
- name: Build documentation
|
|
27
|
-
run: npm run build
|
|
28
|
-
- name: Upload artifact
|
|
29
|
-
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa
|
|
30
|
-
with:
|
|
31
|
-
path: ./docs/
|
|
32
|
-
|
|
33
|
-
deploy:
|
|
34
|
-
environment:
|
|
35
|
-
name: github-pages
|
|
36
|
-
url: ${{ steps.deployment.outputs.page_url }}
|
|
37
|
-
permissions:
|
|
38
|
-
pages: write
|
|
39
|
-
id-token: write
|
|
40
|
-
runs-on: ubuntu-latest
|
|
41
|
-
needs: build
|
|
42
|
-
steps:
|
|
43
|
-
- name: Deploy to GitHub Pages
|
|
44
|
-
id: deployment
|
|
45
|
-
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e
|
|
@@ -1,26 +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@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
13
|
-
with:
|
|
14
|
-
persist-credentials: false
|
|
15
|
-
- name: Setup Node.js
|
|
16
|
-
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
|
|
17
|
-
with:
|
|
18
|
-
node-version: 20
|
|
19
|
-
cache: npm
|
|
20
|
-
- name: Install dependencies
|
|
21
|
-
run: npm ci
|
|
22
|
-
- name: Validate TypeScript
|
|
23
|
-
run: npm test
|
|
24
|
-
- name: Validate individual .d.ts files
|
|
25
|
-
run: |
|
|
26
|
-
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.
|
package/tests/test-blockly.ts
DELETED
|
@@ -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);
|
package/tests/test-cjs-es6.js
DELETED
package/tests/test-cjs-js.js
DELETED
package/tests/test-deprecated.js
DELETED