@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turbowarp/types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "Type definitions for the Scratch VM and editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"scratch"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/TurboWarp/types#readme",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"typedoc": "^0.
|
|
30
|
-
"typescript": "^
|
|
29
|
+
"typedoc": "^0.28.15",
|
|
30
|
+
"typescript": "^5.9.3"
|
|
31
31
|
}
|
|
32
32
|
}
|
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;
|
package/types/scratch-audio.d.ts
CHANGED
|
@@ -14,7 +14,9 @@ declare namespace AudioEngine {
|
|
|
14
14
|
mic: MediaStreamAudioSourceNode;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
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():
|
|
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):
|
|
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
|
|
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,
|
|
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):
|
|
106
|
-
isTouchingLinear(textureCoordinate: twgl.V3):
|
|
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
|
|
157
|
+
getTexture(scale?: [number, number]): WebGLTexture;
|
|
152
158
|
_setTexture(image: BitmapData): void;
|
|
153
159
|
setEmptyImageData(): void;
|
|
154
160
|
|
|
155
|
-
|
|
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
|
|
205
|
-
diameter
|
|
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:
|
|
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():
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -28,7 +29,7 @@ declare namespace ScratchStorage {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
class Asset {
|
|
31
|
-
constructor(assetType: AssetType, assetId: string, dataFormat: DataFormat | null, data:
|
|
32
|
+
constructor(assetType: AssetType, assetId: string, dataFormat: DataFormat | null, data: Uint8Array, generateId?: boolean);
|
|
32
33
|
|
|
33
34
|
assetType: AssetType;
|
|
34
35
|
|
|
@@ -39,7 +40,9 @@ declare namespace ScratchStorage {
|
|
|
39
40
|
*/
|
|
40
41
|
assetId: string;
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
data: Uint8Array;
|
|
44
|
+
|
|
45
|
+
setData(data: Uint8Array, dataFormat: DataFormat, generateId?: boolean): void;
|
|
43
46
|
encodeTextData(text: string, dataFormat: DataFormat, generateId?: boolean): void;
|
|
44
47
|
|
|
45
48
|
decodeText(): string;
|
|
@@ -54,8 +57,9 @@ 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
|
-
store(assetType: AssetType, dataFormat: DataFormat, data:
|
|
62
|
+
store(assetType: AssetType, dataFormat: DataFormat, data: Uint8Array, assetId: string): Promise<unknown>;
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
|
|
@@ -72,14 +76,17 @@ declare class ScratchStorage {
|
|
|
72
76
|
*/
|
|
73
77
|
get(assetId: string): ScratchStorage.Asset | null;
|
|
74
78
|
|
|
75
|
-
cache(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data:
|
|
79
|
+
cache(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data: Uint8Array, assetId: string): string;
|
|
76
80
|
|
|
77
81
|
load(assetType: ScratchStorage.AssetType, assetId: string, dataFormat: ScratchStorage.DataFormat): Promise<ScratchStorage.Asset | null>;
|
|
78
82
|
|
|
79
|
-
store(assetType: ScratchStorage.
|
|
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
|
-
createAsset(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data:
|
|
82
|
-
createAsset(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data:
|
|
88
|
+
createAsset(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data: Uint8Array, assetId: null, generateId: true): ScratchStorage.Asset;
|
|
89
|
+
createAsset(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data: Uint8Array, assetId: string, generateId?: boolean): ScratchStorage.Asset;
|
|
83
90
|
|
|
84
91
|
addWebStore(types: ScratchStorage.AssetType[], getFunction: ScratchStorage.UrlFunction, createFunction?: ScratchStorage.UrlFunction, updateFunction?: ScratchStorage.UrlFunction): void;
|
|
85
92
|
|