types
1.0.0
스크래치는 라이브러리에 대한 유형 정의를 제공하지 않으므로 우리는 우리 자신을 썼습니다.
이 저장소에는 바닐라 (LLK) 스크래치 런타임 및 편집기 용 유형 만 포함되어 있습니다. Turbowarp Runtimes의 추가 유형은 @Turbowarp/Types-Tw를 참조하십시오.
https://turbowarp.github.io/types/
| 기준 치수 | 상태 |
|---|---|
| 스크래치 -VM | ✅ |
| 스크래치 렌더 | ✅ |
| 스크래치 -SVG 렌더러 | ✅ |
| 스크래치 렌즈-포트 | ✅ |
| 스크래치 아우 디오 | ✅ |
| 스크래치 스토리지 | ✅ |
| 스크래치 파서 | ✅ |
| 스크래치 블록 | ? |
| 스크래치 가이 레드 | ✅ |
| 스크래치 페인트 redux | ✅ |
| 스크래치 www redux |
먼저 유형을 설치하십시오.
npm install @turbowarp/types
다음으로 tsconfig.json 사용하여 TypeScript를 구성하여 유형을 찾는 방법을 알아야합니다.
{
"compilerOptions" : {
// If you use require() or "module": "CommonJS", remove these lines.
// If you use "module": "ES6", synthetic default imports are required.
"module" : "ES6" ,
"allowSyntheticDefaultImports" : true ,
// Tell TypeScript where to find the types for Scratch libraries.
"paths" : {
"scratch-vm" : [ "./node_modules/@turbowarp/types/index.d.ts" ] ,
"scratch-render" : [ "./node_modules/@turbowarp/types/index.d.ts" ] ,
"scratch-svg-renderer" : [ "./node_modules/@turbowarp/types/index.d.ts" ] ,
"scratch-render-fonts" : [ "./node_modules/@turbowarp/types/index.d.ts" ] ,
"scratch-storage" : [ "./node_modules/@turbowarp/types/index.d.ts" ] ,
"scratch-audio" : [ "./node_modules/@turbowarp/types/index.d.ts" ] ,
"scratch-parser" : [ "./node_modules/@turbowarp/types/index.d.ts" ] ,
"scratch-blocks" : [ "./node_modules/@turbowarp/types/index.d.ts" ]
} ,
// Recommended strictness settings. Change as you please.
"strictNullChecks" : true ,
"noImplicitAny" : true ,
"noImplicitThis" : true
}
}그런 다음 JavaScript 또는 TypeScript에서 :
import VM from 'scratch-vm' ;
const vm = new VM ( ) ;
vm . loadProject ( /* read a project somehow */ new ArrayBuffer ( 100 ) )
. then ( ( ) => {
vm . start ( ) ;
vm . greenFlag ( ) ;
} ) ;또는 여전히 요구 사항 ()을 사용하는 경우 :
const VM = require ( 'scratch-vm' ) ;
const vm = new VM ( ) ;
vm . loadProject ( /* read a project somehow */ new ArrayBuffer ( 100 ) )
. then ( ( ) => {
vm . start ( ) ;
vm . greenFlag ( ) ;
} ) ; tests 폴더에는 몇 가지 테스트가 있습니다. 이 파일은 실제로 실행되지 않지만 코드는 유형 확인됩니다.
유형 정의 및 테스트 코드는 Apache 2.0 라이센스에 따라 라이센스가 부여됩니다.
문서화 된 라이브러리는 다른 라이센스 아래에있을 수 있습니다.