@turbowarp/types 0.0.12 → 0.0.14
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/.github/workflows/deploy.yml +44 -0
- package/.github/workflows/publish.yml +22 -0
- package/.github/workflows/validate.yml +7 -11
- package/README.md +2 -0
- package/package.json +5 -4
- package/types/scratch-render.d.ts +2 -2
- package/types/scratch-storage.d.ts +7 -7
- package/types/scratch-vm.d.ts +37 -10
|
@@ -0,0 +1,44 @@
|
|
|
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
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
|
@@ -2,28 +2,24 @@ name: Validate TypeScript
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
-
branches: [ "master" ]
|
|
6
5
|
pull_request:
|
|
7
|
-
branches: [ "master" ]
|
|
8
6
|
|
|
9
7
|
jobs:
|
|
10
8
|
test:
|
|
11
9
|
runs-on: ubuntu-latest
|
|
12
10
|
|
|
13
11
|
steps:
|
|
14
|
-
- uses: actions/checkout@
|
|
15
|
-
- name: Setup Node.js environment
|
|
16
|
-
uses: actions/setup-node@v3.4.1
|
|
12
|
+
- uses: actions/checkout@v6
|
|
17
13
|
with:
|
|
18
|
-
|
|
14
|
+
persist-credentials: false
|
|
15
|
+
- name: Setup Node.js
|
|
16
|
+
uses: actions/setup-node@v6
|
|
17
|
+
with:
|
|
18
|
+
node-version: 24
|
|
19
19
|
- name: Install dependencies
|
|
20
20
|
run: npm ci
|
|
21
21
|
- name: Validate TypeScript
|
|
22
22
|
run: npm test
|
|
23
23
|
- name: Validate individual .d.ts files
|
|
24
24
|
run: |
|
|
25
|
-
|
|
26
|
-
for i in index.d.ts types/*.d.ts; do
|
|
27
|
-
echo "Validating $i"
|
|
28
|
-
npx tsc "$i" --target es6 --noEmit
|
|
29
|
-
done
|
|
25
|
+
parallel -v npx tsc --target es6 --noEmit ::: index.d.ts types/*.d.ts
|
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Scratch doesn't provide type definitions for their libraries, so we wrote our ow
|
|
|
4
4
|
|
|
5
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).
|
|
6
6
|
|
|
7
|
+
A possibly more human-readable version of the TypeScript definitions can be found at: https://turbowarp.github.io/types/
|
|
8
|
+
|
|
7
9
|
|Module|Status|
|
|
8
10
|
|:-:|:-:|
|
|
9
11
|
|scratch-vm|✅|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turbowarp/types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "Type definitions for the Scratch VM and editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"scratch"
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"test": "tsc",
|
|
15
|
-
"watch": "tsc -w"
|
|
15
|
+
"watch": "tsc -w",
|
|
16
|
+
"build": "typedoc types/*"
|
|
16
17
|
},
|
|
17
18
|
"repository": {
|
|
18
19
|
"type": "git",
|
|
@@ -24,8 +25,8 @@
|
|
|
24
25
|
"url": "https://github.com/TurboWarp/types/issues"
|
|
25
26
|
},
|
|
26
27
|
"homepage": "https://github.com/TurboWarp/types#readme",
|
|
27
|
-
"dependencies": {},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"
|
|
29
|
+
"typedoc": "^0.28.15",
|
|
30
|
+
"typescript": "^5.9.3"
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -604,8 +604,8 @@ declare class RenderWebGL extends EventEmitter<RenderWebGL.ScratchRenderEventMap
|
|
|
604
604
|
updateDrawableSkinId(drawableId: number, skinId: number): void;
|
|
605
605
|
updateDrawablePosition(drawableId: number, position: [number, number]): void;
|
|
606
606
|
updateDrawableDirection(drawableId: number, direction: number): void;
|
|
607
|
-
updateDrawableScale(drawableId: number, scale: number): void;
|
|
608
|
-
updateDrawableDirectionScale(drawableId: number, direction: number, scale: number): void;
|
|
607
|
+
updateDrawableScale(drawableId: number, scale: [number, number]): void;
|
|
608
|
+
updateDrawableDirectionScale(drawableId: number, direction: number, scale: [number, number]): void;
|
|
609
609
|
updateDrawableVisible(drawableId: number, visible: boolean): void;
|
|
610
610
|
updateDrawableEffect(drawableId: number, effectName: RenderWebGL.Effect, value: number): void;
|
|
611
611
|
/**
|
|
@@ -28,7 +28,7 @@ declare namespace ScratchStorage {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
class Asset {
|
|
31
|
-
constructor(assetType: AssetType, assetId: string, dataFormat: DataFormat | null, data:
|
|
31
|
+
constructor(assetType: AssetType, assetId: string, dataFormat: DataFormat | null, data: Uint8Array, generateId?: boolean);
|
|
32
32
|
|
|
33
33
|
assetType: AssetType;
|
|
34
34
|
|
|
@@ -39,7 +39,7 @@ declare namespace ScratchStorage {
|
|
|
39
39
|
*/
|
|
40
40
|
assetId: string;
|
|
41
41
|
|
|
42
|
-
setData(data:
|
|
42
|
+
setData(data: Uint8Array, dataFormat: DataFormat, generateId?: boolean): void;
|
|
43
43
|
encodeTextData(text: string, dataFormat: DataFormat, generateId?: boolean): void;
|
|
44
44
|
|
|
45
45
|
decodeText(): string;
|
|
@@ -55,7 +55,7 @@ declare namespace ScratchStorage {
|
|
|
55
55
|
|
|
56
56
|
interface Helper {
|
|
57
57
|
load(assetType: AssetType, assetId: string, dataFormat: DataFormat): Promise<Asset>;
|
|
58
|
-
store(assetType: AssetType, dataFormat: DataFormat, data:
|
|
58
|
+
store(assetType: AssetType, dataFormat: DataFormat, data: Uint8Array, assetId: string): Promise<unknown>;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -72,14 +72,14 @@ declare class ScratchStorage {
|
|
|
72
72
|
*/
|
|
73
73
|
get(assetId: string): ScratchStorage.Asset | null;
|
|
74
74
|
|
|
75
|
-
cache(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data:
|
|
75
|
+
cache(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data: Uint8Array, assetId: string): string;
|
|
76
76
|
|
|
77
77
|
load(assetType: ScratchStorage.AssetType, assetId: string, dataFormat: ScratchStorage.DataFormat): Promise<ScratchStorage.Asset | null>;
|
|
78
78
|
|
|
79
|
-
store(assetType: ScratchStorage.Asset, dataFormat: ScratchStorage.DataFormat, data:
|
|
79
|
+
store(assetType: ScratchStorage.Asset, dataFormat: ScratchStorage.DataFormat, data: Uint8Array, assetId: string): Promise<unknown>;
|
|
80
80
|
|
|
81
|
-
createAsset(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data:
|
|
82
|
-
createAsset(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data:
|
|
81
|
+
createAsset(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data: Uint8Array, assetId: null, generateId: true): ScratchStorage.Asset;
|
|
82
|
+
createAsset(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data: Uint8Array, assetId: string, generateId?: boolean): ScratchStorage.Asset;
|
|
83
83
|
|
|
84
84
|
addWebStore(types: ScratchStorage.AssetType[], getFunction: ScratchStorage.UrlFunction, createFunction?: ScratchStorage.UrlFunction, updateFunction?: ScratchStorage.UrlFunction): void;
|
|
85
85
|
|
package/types/scratch-vm.d.ts
CHANGED
|
@@ -41,9 +41,9 @@ 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
47
|
|
|
48
48
|
name: string;
|
|
49
49
|
|
|
@@ -180,6 +180,12 @@ declare namespace VM {
|
|
|
180
180
|
forceNoGlow: boolean;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
interface RuntimeScriptCache {
|
|
184
|
+
container: Blocks;
|
|
185
|
+
blockId: string;
|
|
186
|
+
fieldsOfInputs: Record<string, Field>;
|
|
187
|
+
}
|
|
188
|
+
|
|
183
189
|
interface BaseVariable {
|
|
184
190
|
id: string;
|
|
185
191
|
name: string;
|
|
@@ -734,12 +740,33 @@ declare namespace VM {
|
|
|
734
740
|
// TODO
|
|
735
741
|
}
|
|
736
742
|
|
|
737
|
-
interface
|
|
738
|
-
|
|
743
|
+
interface ProfilerFrame {
|
|
744
|
+
id: number;
|
|
745
|
+
totalTime: number;
|
|
746
|
+
selfTime: number;
|
|
747
|
+
arg: unknown;
|
|
748
|
+
depth: number;
|
|
749
|
+
count: number;
|
|
739
750
|
}
|
|
740
751
|
|
|
741
|
-
|
|
742
|
-
|
|
752
|
+
type FrameCallback = (frame: ProfilerFrame) => void;
|
|
753
|
+
|
|
754
|
+
interface Profiler {
|
|
755
|
+
records: unknown[];
|
|
756
|
+
increments: ProfilerFrame[];
|
|
757
|
+
counters: ProfilerFrame[];
|
|
758
|
+
nullFrame: ProfilerFrame;
|
|
759
|
+
_stack: ProfilerFrame[];
|
|
760
|
+
onFrame: FrameCallback;
|
|
761
|
+
START: 0;
|
|
762
|
+
STOP: 1;
|
|
763
|
+
start(id: number, arg: unknown): void;
|
|
764
|
+
stop(): void;
|
|
765
|
+
increment(id: number): void;
|
|
766
|
+
frame(id: string, arg: unknown): ProfilerFrame;
|
|
767
|
+
reportFrames(): void;
|
|
768
|
+
idByName(name: string): number;
|
|
769
|
+
nameById(id: number): string;
|
|
743
770
|
}
|
|
744
771
|
|
|
745
772
|
interface Sequencer {
|
|
@@ -909,7 +936,7 @@ declare namespace VM {
|
|
|
909
936
|
interface UserData {
|
|
910
937
|
_username: string;
|
|
911
938
|
getUsername(): string;
|
|
912
|
-
postData(data:
|
|
939
|
+
postData(data: UserDataData): void;
|
|
913
940
|
}
|
|
914
941
|
|
|
915
942
|
interface VideoProvider {
|
|
@@ -1175,7 +1202,7 @@ declare namespace VM {
|
|
|
1175
1202
|
|
|
1176
1203
|
_stopThread(thread: Thread): void;
|
|
1177
1204
|
|
|
1178
|
-
_restartThread(thread: Thread):
|
|
1205
|
+
_restartThread(thread: Thread): Thread;
|
|
1179
1206
|
|
|
1180
1207
|
/**
|
|
1181
1208
|
* A thread is considered active if it is in the thread list and is not STATUS_DONE.
|
|
@@ -1193,7 +1220,7 @@ declare namespace VM {
|
|
|
1193
1220
|
|
|
1194
1221
|
_getMonitorThreadCount(threads: Thread[]): number;
|
|
1195
1222
|
|
|
1196
|
-
startHats(opcode: string, matchFields?: Record<string, unknown>, target?: Target): Thread[];
|
|
1223
|
+
startHats(opcode: string, matchFields?: Record<string, unknown>, target?: Target): Thread[] | undefined;
|
|
1197
1224
|
|
|
1198
1225
|
toggleScript(topBlockId: string, options?: {
|
|
1199
1226
|
target?: string;
|
|
@@ -1202,7 +1229,7 @@ declare namespace VM {
|
|
|
1202
1229
|
|
|
1203
1230
|
allScriptsDo(callback: (blockId: string, target: Target) => void, target?: Target): void;
|
|
1204
1231
|
|
|
1205
|
-
allScriptsByOpcodeDo(opcode: string, callback: (
|
|
1232
|
+
allScriptsByOpcodeDo(opcode: string, callback: (script: RuntimeScriptCache, target: Target) => void, target?: Target): void;
|
|
1206
1233
|
|
|
1207
1234
|
sequencer: Sequencer;
|
|
1208
1235
|
|