@turbowarp/types 0.0.11 → 0.0.13

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.
@@ -0,0 +1,45 @@
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
@@ -2,28 +2,25 @@ 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@v3
15
- - name: Setup Node.js environment
16
- uses: actions/setup-node@v3.4.1
12
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
17
13
  with:
18
- node-version: 14.x
14
+ persist-credentials: false
15
+ - name: Setup Node.js
16
+ uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
17
+ with:
18
+ node-version: 20
19
+ cache: npm
19
20
  - name: Install dependencies
20
21
  run: npm ci
21
22
  - name: Validate TypeScript
22
23
  run: npm test
23
24
  - name: Validate individual .d.ts files
24
25
  run: |
25
- set -e
26
- for i in index.d.ts types/*.d.ts; do
27
- echo "Validating $i"
28
- npx tsc "$i" --target es6 --noEmit
29
- done
26
+ 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.11",
3
+ "version": "0.0.13",
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
+ "typedoc": "^0.25.12",
29
30
  "typescript": "^4.7.4"
30
31
  }
31
32
  }
@@ -20,3 +20,18 @@ storage.addWebStore(
20
20
  return `https://assets.scratch.mit.edu/${assetId}.${dataFormat}`;
21
21
  }
22
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;
@@ -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
  /**
@@ -78,7 +78,8 @@ declare class ScratchStorage {
78
78
 
79
79
  store(assetType: ScratchStorage.Asset, dataFormat: ScratchStorage.DataFormat, data: ArrayBuffer, assetId: string): Promise<unknown>;
80
80
 
81
- createAsset(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data: ArrayBuffer, assetId: string, generateId?: boolean): void;
81
+ createAsset(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data: ArrayBuffer, assetId: null, generateId: true): ScratchStorage.Asset;
82
+ createAsset(assetType: ScratchStorage.AssetType, dataFormat: ScratchStorage.DataFormat, data: ArrayBuffer, assetId: string, generateId?: boolean): ScratchStorage.Asset;
82
83
 
83
84
  addWebStore(types: ScratchStorage.AssetType[], getFunction: ScratchStorage.UrlFunction, createFunction?: ScratchStorage.UrlFunction, updateFunction?: ScratchStorage.UrlFunction): void;
84
85
 
@@ -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;
@@ -601,6 +607,8 @@ declare namespace VM {
601
607
  */
602
608
  onStopAll(): void;
603
609
 
610
+ updateAllDrawableProperties(): void;
611
+
604
612
  toJSON(): SerializedTarget;
605
613
  }
606
614
 
@@ -772,7 +780,7 @@ declare namespace VM {
772
780
  /**
773
781
  * Load a remote extension. Does not work on scratch.mit.edu.
774
782
  */
775
- loadExtensionURL(extensionID: string): void;
783
+ loadExtensionURL(extensionID: string): Promise<number>;
776
784
  }
777
785
 
778
786
  /**
@@ -907,7 +915,7 @@ declare namespace VM {
907
915
  interface UserData {
908
916
  _username: string;
909
917
  getUsername(): string;
910
- postData(data: UserData): void;
918
+ postData(data: UserDataData): void;
911
919
  }
912
920
 
913
921
  interface VideoProvider {
@@ -1200,7 +1208,7 @@ declare namespace VM {
1200
1208
 
1201
1209
  allScriptsDo(callback: (blockId: string, target: Target) => void, target?: Target): void;
1202
1210
 
1203
- allScriptsByOpcodeDo(opcode: string, callback: (blockId: string, target: Target) => void, target?: Target): void;
1211
+ allScriptsByOpcodeDo(opcode: string, callback: (script: RuntimeScriptCache, target: Target) => void, target?: Target): void;
1204
1212
 
1205
1213
  sequencer: Sequencer;
1206
1214