@turbowarp/types 0.0.1
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/validate.yml +24 -0
- package/LICENSE +202 -0
- package/README.md +87 -0
- package/index.d.ts +40 -0
- package/package.json +28 -0
- package/tests/blockly.ts +15 -0
- package/tests/cjs-es6.js +4 -0
- package/tests/cjs-js.js +3 -0
- package/tests/deprecated.js +4 -0
- package/tests/events.ts +15 -0
- package/tests/render.ts +8 -0
- package/tests/ts-es6.ts +4 -0
- package/tests/ts-require.ts +4 -0
- package/tests/vm.ts +49 -0
- package/tsconfig.json +18 -0
- package/types/events.d.ts +14 -0
- package/types/immutable.d.ts +6 -0
- package/types/jszip.d.ts +10 -0
- package/types/scratch-audio.d.ts +29 -0
- package/types/scratch-blocks.d.ts +183 -0
- package/types/scratch-parser.d.ts +6 -0
- package/types/scratch-render-fonts.d.ts +6 -0
- package/types/scratch-render.d.ts +686 -0
- package/types/scratch-storage.d.ts +20 -0
- package/types/scratch-svg-renderer.d.ts +6 -0
- package/types/scratch-vm.d.ts +1460 -0
- package/types/twgl.d.ts +21 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// Type definitions for scratch-blocks
|
|
2
|
+
// Project: https://github.com/LLK/scratch-blocks
|
|
3
|
+
|
|
4
|
+
declare namespace ScratchBlocks {
|
|
5
|
+
class Block {
|
|
6
|
+
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class BlockSvg extends Block {
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface EventsAbstract {
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
class WorkspaceComment {
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const enum VariableType {
|
|
22
|
+
Scalar = '',
|
|
23
|
+
List = 'list',
|
|
24
|
+
Broadcast = 'broadcast_msg'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class VariableModel {
|
|
28
|
+
workspace: Workspace;
|
|
29
|
+
name: string;
|
|
30
|
+
type: VariableType;
|
|
31
|
+
id_: string;
|
|
32
|
+
getId(): string;
|
|
33
|
+
isLocal: boolean
|
|
34
|
+
isCloud: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface VariableModelConstructor {
|
|
38
|
+
new(workspace: Workspace, name: string, type?: VariableType, id?: string, isLocal?: boolean, isCloud?: boolean): VariableModel;
|
|
39
|
+
compareByName(var1: VariableModel, var2: VariableModel): number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class VariableMap {
|
|
43
|
+
variableMap_: Record<string, VariableModel>;
|
|
44
|
+
workspace: Workspace;
|
|
45
|
+
clear(): void;
|
|
46
|
+
renameVariable(variable: VariableModel, newName: string): void;
|
|
47
|
+
renameVariableById(id: string, newName: string): void;
|
|
48
|
+
renameVariableAndUses_(variable: VariableModel, newName: string, uses: Block[]): void;
|
|
49
|
+
renameVariableWithConflict_(variable: VariableModel, newName: string, conflictingVariable: VariableModel, uses: Block[]): void;
|
|
50
|
+
createVariable(name: string, type?: VariableType, id?: string, isLocal?: boolean, isCloud?: boolean): VariableModel;
|
|
51
|
+
deleteVariable(variable: VariableModel): void;
|
|
52
|
+
deleteVariableById(id: string): void;
|
|
53
|
+
deleteVariableInternal_(variable: VariableModel, uses: Block[]): void;
|
|
54
|
+
getVariable(name: string, type?: VariableType): VariableModel | null;
|
|
55
|
+
getVariableById(id: string): VariableModel | null;
|
|
56
|
+
getVariablesOfType(type: VariableType): VariableModel[];
|
|
57
|
+
getVariableTypes(): VariableType[];
|
|
58
|
+
getAllVariables(): VariableModel[];
|
|
59
|
+
getVariableUsesById(id: string): Block[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
class Flyout {
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface WorkspaceOptions {
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
class Workspace {
|
|
71
|
+
id: string;
|
|
72
|
+
options: WorkspaceOptions;
|
|
73
|
+
RTL: boolean;
|
|
74
|
+
horizontalLayout: boolean;
|
|
75
|
+
toolboxPosition: number; // TODO
|
|
76
|
+
topBlocks_: Block[];
|
|
77
|
+
listeners_: Function[];
|
|
78
|
+
tapListeners_: Function[];
|
|
79
|
+
undoStack_: EventsAbstract[];
|
|
80
|
+
redoStack_: EventsAbstract[];
|
|
81
|
+
blockDB_: Record<string, Block>;
|
|
82
|
+
variableMap_: VariableMap;
|
|
83
|
+
getVariableMap(): VariableMap;
|
|
84
|
+
potentialVariableMap_: VariableMap | null;
|
|
85
|
+
getPotentialVariableMap(): VariableMap;
|
|
86
|
+
createPotentialVariableMap(): void;
|
|
87
|
+
// default value defined on prototype
|
|
88
|
+
rendered: boolean;
|
|
89
|
+
// default value defined on prototype
|
|
90
|
+
isClearing: boolean;
|
|
91
|
+
// default value defined on prototype
|
|
92
|
+
MAX_UNDO: 1024;
|
|
93
|
+
refreshToolboxSelection_(): void;
|
|
94
|
+
dispose(): void;
|
|
95
|
+
addTopBlock(block: Block): void;
|
|
96
|
+
removeTopBlock(block: Block): void;
|
|
97
|
+
getTopBlocks(): Block[];
|
|
98
|
+
addTopComment(comment: WorkspaceComment): void;
|
|
99
|
+
removeTopComment(comment: WorkspaceComment): void;
|
|
100
|
+
getTopComments(): WorkspaceComment[];
|
|
101
|
+
getAllBlocks(): Block[];
|
|
102
|
+
clear(): void;
|
|
103
|
+
renameVariableById(id: string, newName: string): void;
|
|
104
|
+
/**
|
|
105
|
+
* @see {VariableMap.createVariable}
|
|
106
|
+
*/
|
|
107
|
+
createVariable(name: string, type?: VariableType, id?: string, isLocal?: boolean, isCloud?: boolean): VariableModel;
|
|
108
|
+
/**
|
|
109
|
+
* @see {VariableMap.getVariableUsesById}
|
|
110
|
+
*/
|
|
111
|
+
getVariableUsesById(id: string): Block[];
|
|
112
|
+
/**
|
|
113
|
+
* @see {VariableMap.deleteVariableById}
|
|
114
|
+
*/
|
|
115
|
+
deleteVariableById(id: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* @see {VariableMap.deleteVariableInternal_}
|
|
118
|
+
*/
|
|
119
|
+
deleteVariableInternal_(variable: VariableModel, uses: Block[]): void;
|
|
120
|
+
/**
|
|
121
|
+
* @deprecated always returns -1
|
|
122
|
+
*/
|
|
123
|
+
variableIndexOf(name: string): -1;
|
|
124
|
+
/**
|
|
125
|
+
* @see {VariableMap.getVariable}
|
|
126
|
+
*/
|
|
127
|
+
getVariable(name: string, type?: VariableType): void;
|
|
128
|
+
/**
|
|
129
|
+
* @see {VariableMap.getVariableById}
|
|
130
|
+
*/
|
|
131
|
+
getVariableById(id: string): VariableModel;
|
|
132
|
+
/**
|
|
133
|
+
* @see {VariableMap.getVariablesOfType}
|
|
134
|
+
*/
|
|
135
|
+
getVariablesOfType(type: VariableType): VariableModel[];
|
|
136
|
+
/**
|
|
137
|
+
* @see {VariableMap.getVariableTypes}
|
|
138
|
+
*/
|
|
139
|
+
getVariableTypes(): VariableType[];
|
|
140
|
+
/**
|
|
141
|
+
* @see {VariableMap.getAllVariables}
|
|
142
|
+
*/
|
|
143
|
+
getAllVariables(): VariableModel[];
|
|
144
|
+
getWidth(): number;
|
|
145
|
+
newBlock(opcode: string, id?: string): Block;
|
|
146
|
+
/**
|
|
147
|
+
* @param redo true for redo, false for undo
|
|
148
|
+
*/
|
|
149
|
+
undo(redo: boolean): void;
|
|
150
|
+
clearUndo(): void;
|
|
151
|
+
hasRedoStack(): boolean;
|
|
152
|
+
hasUndoStack(): boolean;
|
|
153
|
+
addChangeListener(listener: Function): void;
|
|
154
|
+
removeChangeListener(listener: Function): void;
|
|
155
|
+
fireChangeListener(event: EventsAbstract): void;
|
|
156
|
+
getBlockById(id: string): Block | null;
|
|
157
|
+
getCommentById(id: string): WorkspaceComment | null;
|
|
158
|
+
getFlyout(): Flyout | null;
|
|
159
|
+
allInputsFilled(shadowBlocksAreFilled?: boolean): boolean;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface WorkspaceConstructor {
|
|
163
|
+
new(options?: WorkspaceOptions): Workspace;
|
|
164
|
+
SCAN_ANGLE: number;
|
|
165
|
+
WorkspaceDB_: Record<string, Workspace>;
|
|
166
|
+
getById(id: string): Workspace | null;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
class WorkspaceSvg extends Workspace {
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface RealBlockly {
|
|
174
|
+
Workspace: WorkspaceConstructor;
|
|
175
|
+
WorkspaceSvg: typeof WorkspaceSvg;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
interface BlocklyGlobal {
|
|
179
|
+
getMainWorkspace(): Workspace | null;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
declare const Blockly: ScratchBlocks.BlocklyGlobal | undefined;
|