pxt-core 9.3.13 → 9.3.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/README.md +11 -0
- package/built/cli.js +7 -2
- package/built/pxt.js +57 -3
- package/built/pxtblockly.js +97 -57
- package/built/pxtblocks.d.ts +59 -21
- package/built/pxtblocks.js +97 -57
- package/built/pxtlib.d.ts +22 -0
- package/built/pxtlib.js +50 -1
- package/built/target.js +1 -1
- package/built/tests/blocksrunner.js +1 -1
- package/built/web/main.js +1 -1
- package/built/web/multiplayer/js/{main.78cecdcb.js → main.75ca8c58.js} +2 -2
- package/built/web/pxtapp.js +1 -1
- package/built/web/pxtasseteditor.js +1 -1
- package/built/web/pxtblockly.js +2 -2
- package/built/web/pxtblocks.js +1 -1
- package/built/web/pxtembed.js +2 -2
- package/built/web/pxtlib.js +1 -1
- package/built/web/pxtworker.js +1 -1
- package/built/web/rtlsemantic.css +1 -1
- package/built/web/runnerembed.js +1 -0
- package/built/web/semantic.css +1 -1
- package/built/web/skillmap/js/{main.8222bb34.js → main.236bd49e.js} +2 -2
- package/built/web/teachertool/css/main.e9386f28.css +1 -0
- package/built/web/teachertool/js/{main.3a94a341.js → main.8aa6604c.js} +2 -2
- package/localtypings/projectheader.d.ts +21 -0
- package/{built → localtypings}/pxteditor.d.ts +1095 -1090
- package/package.json +1 -1
- package/react-common/components/controls/MenuDropdown.tsx +5 -2
- package/react-common/components/util.tsx +1 -1
- package/theme/pxt.less +1 -0
- package/theme/themepacks.less +41 -0
- package/webapp/public/embed.js +1 -1
- package/webapp/public/multiplayer.html +1 -1
- package/webapp/public/skillmap.html +1 -1
- package/webapp/public/teachertool.html +1 -3
- package/built/pxteditor.js +0 -1834
- package/built/pxtrunner.d.ts +0 -151
- package/built/pxtrunner.js +0 -2626
- package/built/web/pxteditor.js +0 -1
- package/built/web/pxtrunner.js +0 -1
- package/built/web/teachertool/css/main.59776cd1.css +0 -1
|
@@ -1,1201 +1,1206 @@
|
|
|
1
|
-
/// <reference path="../
|
|
2
|
-
/// <reference path="
|
|
3
|
-
/// <reference path="
|
|
1
|
+
/// <reference path="../built/pxtlib.d.ts" />
|
|
2
|
+
/// <reference path="../built/pxtblocks.d.ts" />
|
|
3
|
+
/// <reference path="./projectheader.d.ts" />
|
|
4
|
+
|
|
4
5
|
declare namespace pxt.editor {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export interface EditorMessage {
|
|
7
|
+
/**
|
|
8
|
+
* Constant identifier
|
|
9
|
+
*/
|
|
10
|
+
type: "pxteditor" | "pxthost" | "pxtpkgext" | "pxtsim",
|
|
11
|
+
/**
|
|
12
|
+
* Original request id
|
|
13
|
+
*/
|
|
14
|
+
id?: string;
|
|
15
|
+
/**
|
|
16
|
+
* flag to request response
|
|
17
|
+
*/
|
|
18
|
+
response?: boolean;
|
|
10
19
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
|
|
21
|
+
export interface EditorMessageResponse extends EditorMessage {
|
|
22
|
+
/**
|
|
23
|
+
* Additional response payload provided by the command
|
|
24
|
+
*/
|
|
25
|
+
resp?: any;
|
|
26
|
+
/**
|
|
27
|
+
* indicate if operation started or completed successfully
|
|
28
|
+
*/
|
|
29
|
+
success: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Error object if any
|
|
32
|
+
*/
|
|
33
|
+
error?: any;
|
|
20
34
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
35
|
+
|
|
36
|
+
export interface EditorMessageRequest extends EditorMessage {
|
|
37
|
+
/**
|
|
38
|
+
* Request action
|
|
39
|
+
*/
|
|
40
|
+
action: "switchblocks"
|
|
41
|
+
| "switchjavascript"
|
|
42
|
+
| "startsimulator"
|
|
43
|
+
| "restartsimulator"
|
|
44
|
+
| "stopsimulator" // EditorMessageStopRequest
|
|
45
|
+
| "hidesimulator"
|
|
46
|
+
| "showsimulator"
|
|
47
|
+
| "closeflyout"
|
|
48
|
+
| "newproject"
|
|
49
|
+
| "importproject"
|
|
50
|
+
| "importtutorial"
|
|
51
|
+
| "openheader"
|
|
52
|
+
| "proxytosim" // EditorMessageSimulatorMessageProxyRequest
|
|
53
|
+
| "undo"
|
|
54
|
+
| "redo"
|
|
55
|
+
| "renderblocks"
|
|
56
|
+
| "renderpython"
|
|
57
|
+
| "setscale"
|
|
58
|
+
| "startactivity"
|
|
59
|
+
| "saveproject"
|
|
60
|
+
| "unloadproject"
|
|
61
|
+
| "shareproject"
|
|
62
|
+
| "savelocalprojectstocloud"
|
|
63
|
+
| "projectcloudstatus"
|
|
64
|
+
| "requestprojectcloudstatus"
|
|
65
|
+
| "convertcloudprojectstolocal"
|
|
66
|
+
| "setlanguagerestriction"
|
|
67
|
+
|
|
68
|
+
| "toggletrace" // EditorMessageToggleTraceRequest
|
|
69
|
+
| "togglehighcontrast"
|
|
70
|
+
| "sethighcontrast" // EditorMessageSetHighContrastRequest
|
|
71
|
+
| "togglegreenscreen"
|
|
72
|
+
| "settracestate" //
|
|
73
|
+
| "setsimulatorfullscreen" // EditorMessageSimulatorFullScreenRequest
|
|
74
|
+
|
|
75
|
+
| "print" // print code
|
|
76
|
+
| "pair" // pair device
|
|
77
|
+
|
|
78
|
+
| "workspacesync" // EditorWorspaceSyncRequest
|
|
79
|
+
| "workspacereset"
|
|
80
|
+
| "workspacesave" // EditorWorkspaceSaveRequest
|
|
81
|
+
| "workspaceloaded"
|
|
82
|
+
| "workspaceevent" // EditorWorspaceEvent
|
|
83
|
+
|
|
84
|
+
| "workspacediagnostics" // compilation results
|
|
85
|
+
|
|
86
|
+
| "event"
|
|
87
|
+
| "simevent"
|
|
88
|
+
| "info" // return info data`
|
|
89
|
+
| "tutorialevent"
|
|
90
|
+
| "editorcontentloaded"
|
|
91
|
+
| "runeval"
|
|
92
|
+
|
|
93
|
+
// package extension messasges
|
|
94
|
+
| ExtInitializeType
|
|
95
|
+
| ExtDataStreamType
|
|
96
|
+
| ExtUserCodeType
|
|
97
|
+
| ExtReadCodeType
|
|
98
|
+
| ExtWriteCodeType
|
|
99
|
+
;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Request sent by the editor when a tick/error/expection is registered
|
|
104
|
+
*/
|
|
105
|
+
export interface EditorMessageEventRequest extends EditorMessageRequest {
|
|
106
|
+
action: "event";
|
|
107
|
+
// metric identifier
|
|
108
|
+
tick: string;
|
|
109
|
+
// error category if any
|
|
110
|
+
category?: string;
|
|
111
|
+
// error message if any
|
|
112
|
+
message?: string;
|
|
113
|
+
// custom data
|
|
114
|
+
data?: pxt.Map<string | number>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type EditorMessageTutorialEventRequest = EditorMessageTutorialProgressEventRequest |
|
|
118
|
+
EditorMessageTutorialCompletedEventRequest |
|
|
119
|
+
EditorMessageTutorialLoadedEventRequest |
|
|
120
|
+
EditorMessageTutorialExitEventRequest;
|
|
121
|
+
|
|
122
|
+
export interface EditorMessageTutorialProgressEventRequest extends EditorMessageRequest {
|
|
123
|
+
action: "tutorialevent";
|
|
124
|
+
tutorialEvent: "progress"
|
|
125
|
+
currentStep: number;
|
|
126
|
+
totalSteps: number;
|
|
127
|
+
isCompleted: boolean;
|
|
128
|
+
tutorialId: string;
|
|
129
|
+
projectHeaderId: string;
|
|
24
130
|
}
|
|
25
|
-
|
|
26
|
-
interface
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
131
|
+
|
|
132
|
+
export interface EditorMessageTutorialCompletedEventRequest extends EditorMessageRequest {
|
|
133
|
+
action: "tutorialevent";
|
|
134
|
+
tutorialEvent: "completed";
|
|
135
|
+
tutorialId: string;
|
|
136
|
+
projectHeaderId: string;
|
|
30
137
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
138
|
+
|
|
139
|
+
export interface EditorMessageTutorialLoadedEventRequest extends EditorMessageRequest {
|
|
140
|
+
action: "tutorialevent";
|
|
141
|
+
tutorialEvent: "loaded";
|
|
142
|
+
tutorialId: string;
|
|
143
|
+
projectHeaderId: string;
|
|
34
144
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
145
|
+
|
|
146
|
+
export interface EditorMessageTutorialExitEventRequest extends EditorMessageRequest {
|
|
147
|
+
action: "tutorialevent";
|
|
148
|
+
tutorialEvent: "exit";
|
|
149
|
+
tutorialId: string;
|
|
150
|
+
projectHeaderId: string;
|
|
38
151
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
152
|
+
|
|
153
|
+
export interface EditorMessageStopRequest extends EditorMessageRequest {
|
|
154
|
+
action: "stopsimulator";
|
|
155
|
+
/**
|
|
156
|
+
* Indicates if simulator iframes should be unloaded or kept hot.
|
|
157
|
+
*/
|
|
158
|
+
unload?: boolean;
|
|
43
159
|
}
|
|
44
|
-
|
|
160
|
+
|
|
161
|
+
export interface EditorMessageNewProjectRequest extends EditorMessageRequest {
|
|
162
|
+
action: "newproject";
|
|
163
|
+
/**
|
|
164
|
+
* Additional optional to create new project
|
|
165
|
+
*/
|
|
166
|
+
options?: ProjectCreationOptions;
|
|
45
167
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
editorState?: EditorState;
|
|
50
|
-
currFile?: IFile;
|
|
51
|
-
fileState?: string;
|
|
52
|
-
showFiles?: boolean;
|
|
53
|
-
sideDocsLoadUrl?: string;
|
|
54
|
-
sideDocsCollapsed?: boolean;
|
|
55
|
-
projectName?: string;
|
|
56
|
-
suppressPackageWarning?: boolean;
|
|
57
|
-
tutorialOptions?: pxt.tutorial.TutorialOptions;
|
|
58
|
-
lightbox?: boolean;
|
|
59
|
-
keymap?: boolean;
|
|
60
|
-
simState?: SimState;
|
|
61
|
-
autoRun?: boolean;
|
|
62
|
-
resumeOnVisibility?: boolean;
|
|
63
|
-
compiling?: boolean;
|
|
64
|
-
isSaving?: boolean;
|
|
65
|
-
publishing?: boolean;
|
|
66
|
-
hideEditorFloats?: boolean;
|
|
67
|
-
collapseEditorTools?: boolean;
|
|
68
|
-
showBlocks?: boolean;
|
|
69
|
-
showParts?: boolean;
|
|
70
|
-
fullscreen?: boolean;
|
|
71
|
-
showMiniSim?: boolean;
|
|
72
|
-
mute?: MuteState;
|
|
73
|
-
embedSimView?: boolean;
|
|
74
|
-
editorPosition?: {
|
|
75
|
-
lineNumber: number;
|
|
76
|
-
column: number;
|
|
77
|
-
file: IFile;
|
|
78
|
-
};
|
|
79
|
-
tracing?: boolean;
|
|
80
|
-
debugging?: boolean;
|
|
81
|
-
debugFirstRun?: boolean;
|
|
82
|
-
bannerVisible?: boolean;
|
|
83
|
-
pokeUserComponent?: string;
|
|
84
|
-
flashHint?: boolean;
|
|
85
|
-
editorOffset?: string;
|
|
86
|
-
print?: boolean;
|
|
87
|
-
greenScreen?: boolean;
|
|
88
|
-
accessibleBlocks?: boolean;
|
|
89
|
-
home?: boolean;
|
|
90
|
-
hasError?: boolean;
|
|
91
|
-
cancelledDownload?: boolean;
|
|
92
|
-
simSerialActive?: boolean;
|
|
93
|
-
deviceSerialActive?: boolean;
|
|
94
|
-
errorListState?: ErrorListState;
|
|
95
|
-
screenshoting?: boolean;
|
|
96
|
-
extensionsVisible?: boolean;
|
|
97
|
-
isMultiplayerGame?: boolean;
|
|
98
|
-
onboarding?: pxt.tour.BubbleStep[];
|
|
168
|
+
|
|
169
|
+
export interface EditorContentLoadedRequest extends EditorMessageRequest {
|
|
170
|
+
action: "editorcontentloaded";
|
|
99
171
|
}
|
|
100
|
-
|
|
101
|
-
|
|
172
|
+
|
|
173
|
+
export interface EditorMessageSetScaleRequest extends EditorMessageRequest {
|
|
174
|
+
action: "setscale";
|
|
175
|
+
scale: number;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface EditorMessageSimulatorMessageProxyRequest extends EditorMessageRequest {
|
|
179
|
+
action: "proxytosim";
|
|
180
|
+
/**
|
|
181
|
+
* Content to send to the simulator
|
|
182
|
+
*/
|
|
183
|
+
content: any;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface EditorWorkspaceSyncRequest extends EditorMessageRequest {
|
|
187
|
+
/**
|
|
188
|
+
* Synching projects from host into
|
|
189
|
+
*/
|
|
190
|
+
action: "workspacesync" | "workspacereset" | "workspaceloaded";
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface EditorWorkspaceEvent extends EditorMessageRequest {
|
|
194
|
+
action: "workspaceevent";
|
|
195
|
+
event: EditorEvent;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface EditorWorkspaceDiagnostics extends EditorMessageRequest {
|
|
199
|
+
action: "workspacediagnostics";
|
|
200
|
+
operation: "compile" | "decompile" | "typecheck";
|
|
201
|
+
output: string;
|
|
202
|
+
diagnostics: {
|
|
203
|
+
code: number;
|
|
204
|
+
category: "error" | "warning" | "message";
|
|
205
|
+
fileName?: string;
|
|
206
|
+
start?: number;
|
|
207
|
+
length?: number;
|
|
208
|
+
line?: number;
|
|
209
|
+
column?: number;
|
|
210
|
+
endLine?: number;
|
|
211
|
+
endColumn?: number;
|
|
212
|
+
}[];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// UI properties to sync on load
|
|
216
|
+
export interface EditorSyncState {
|
|
217
|
+
// (optional) filtering argument
|
|
218
|
+
filters?: ProjectFilters;
|
|
219
|
+
// (optional) show or hide the search bar
|
|
102
220
|
searchBar?: boolean;
|
|
103
|
-
hasCategories?: boolean;
|
|
104
221
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
222
|
+
|
|
223
|
+
export interface EditorWorkspaceSyncResponse extends EditorMessageResponse {
|
|
224
|
+
/*
|
|
225
|
+
* Full list of project, required for init
|
|
226
|
+
*/
|
|
227
|
+
projects: pxt.workspace.Project[];
|
|
228
|
+
// (optional) filtering argument
|
|
229
|
+
editor?: EditorSyncState;
|
|
230
|
+
// (optional) controller id, used for determining what the parent controller is
|
|
231
|
+
controllerId?: string;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface EditorWorkspaceSaveRequest extends EditorMessageRequest {
|
|
235
|
+
action: "workspacesave";
|
|
236
|
+
/*
|
|
237
|
+
* Modified project
|
|
238
|
+
*/
|
|
239
|
+
project: pxt.workspace.Project;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface EditorMessageImportProjectRequest extends EditorMessageRequest {
|
|
243
|
+
action: "importproject";
|
|
244
|
+
// project to load
|
|
245
|
+
project: pxt.workspace.Project;
|
|
246
|
+
// (optional) filtering argument
|
|
110
247
|
filters?: ProjectFilters;
|
|
111
|
-
|
|
112
|
-
tutorial?: pxt.tutorial.TutorialOptions;
|
|
113
|
-
dependencies?: pxt.Map<string>;
|
|
114
|
-
tsOnly?: boolean;
|
|
115
|
-
languageRestriction?: LanguageRestriction;
|
|
116
|
-
preferredEditor?: string;
|
|
117
|
-
extensionUnderTest?: string;
|
|
118
|
-
skillmapProject?: boolean;
|
|
119
|
-
simTheme?: Partial<pxt.PackageConfig>;
|
|
120
|
-
firstProject?: boolean;
|
|
248
|
+
searchBar?: boolean;
|
|
121
249
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
prj?: ProjectTemplate;
|
|
127
|
-
preferredEditor?: string;
|
|
250
|
+
|
|
251
|
+
export interface EditorMessageSaveLocalProjectsToCloud extends EditorMessageRequest {
|
|
252
|
+
action: "savelocalprojectstocloud";
|
|
253
|
+
headerIds: string[];
|
|
128
254
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
editor?: string;
|
|
134
|
-
focus?: boolean;
|
|
135
|
-
importOptions?: pxt.editor.ExampleImportOptions;
|
|
136
|
-
previousProjectHeaderId?: string;
|
|
137
|
-
carryoverPreviousCode?: boolean;
|
|
255
|
+
|
|
256
|
+
export interface EditorMessageSaveLocalProjectsToCloudResponse extends EditorMessageResponse {
|
|
257
|
+
action: "savelocalprojectstocloud";
|
|
258
|
+
headerIdMap?: pxt.Map<string>;
|
|
138
259
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
[index: string]: FilterState;
|
|
145
|
-
};
|
|
146
|
-
fns?: {
|
|
147
|
-
[index: string]: FilterState;
|
|
148
|
-
};
|
|
149
|
-
defaultState?: FilterState;
|
|
150
|
-
}
|
|
151
|
-
enum FilterState {
|
|
152
|
-
Hidden = 0,
|
|
153
|
-
Visible = 1,
|
|
154
|
-
Disabled = 2
|
|
260
|
+
|
|
261
|
+
export interface EditorMessageProjectCloudStatus extends EditorMessageRequest {
|
|
262
|
+
action: "projectcloudstatus";
|
|
263
|
+
headerId: string;
|
|
264
|
+
status: pxt.cloud.CloudStatus;
|
|
155
265
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
266
|
+
|
|
267
|
+
export interface EditorMessageRequestProjectCloudStatus extends EditorMessageRequest {
|
|
268
|
+
action: "requestprojectcloudstatus";
|
|
269
|
+
headerIds: string[];
|
|
159
270
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
271
|
+
|
|
272
|
+
export interface EditorMessageConvertCloudProjectsToLocal extends EditorMessageRequest {
|
|
273
|
+
action: "convertcloudprojectstolocal";
|
|
274
|
+
userId: string;
|
|
164
275
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
276
|
+
|
|
277
|
+
export interface EditorMessageImportTutorialRequest extends EditorMessageRequest {
|
|
278
|
+
action: "importtutorial";
|
|
279
|
+
// markdown to load
|
|
280
|
+
markdown: string;
|
|
169
281
|
}
|
|
170
|
-
|
|
171
|
-
|
|
282
|
+
|
|
283
|
+
export interface EditorMessageOpenHeaderRequest extends EditorMessageRequest {
|
|
284
|
+
action: "openheader";
|
|
285
|
+
headerId: string;
|
|
172
286
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
287
|
+
|
|
288
|
+
export interface EditorMessageRenderBlocksRequest extends EditorMessageRequest {
|
|
289
|
+
action: "renderblocks";
|
|
290
|
+
// typescript code to render
|
|
291
|
+
ts: string;
|
|
292
|
+
// rendering options
|
|
293
|
+
snippetMode?: boolean;
|
|
294
|
+
layout?: pxt.blocks.BlockLayout;
|
|
176
295
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
profile?: string;
|
|
182
|
-
loginHint?: string;
|
|
183
|
-
initials?: string;
|
|
184
|
-
photo?: string;
|
|
296
|
+
|
|
297
|
+
export interface EditorMessageRunEvalRequest extends EditorMessageRequest {
|
|
298
|
+
action: "runeval";
|
|
299
|
+
validatorPlan: pxt.blocks.ValidatorPlan;
|
|
185
300
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
editor?: string;
|
|
191
|
-
simulator?: string;
|
|
192
|
-
url?: string;
|
|
193
|
-
};
|
|
194
|
-
qr?: string;
|
|
195
|
-
error?: any;
|
|
301
|
+
|
|
302
|
+
export interface EditorMessageRenderBlocksResponse {
|
|
303
|
+
svg: SVGSVGElement;
|
|
304
|
+
xml: Promise<any>;
|
|
196
305
|
}
|
|
197
|
-
|
|
198
|
-
interface
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
reloadEditor(): void;
|
|
203
|
-
openBlocks(): void;
|
|
204
|
-
openJavaScript(giveFocusOnLoading?: boolean): void;
|
|
205
|
-
openPython(giveFocusOnLoading?: boolean): void;
|
|
206
|
-
openAssets(): void;
|
|
207
|
-
openSettings(): void;
|
|
208
|
-
openSimView(): void;
|
|
209
|
-
openSimSerial(): void;
|
|
210
|
-
openDeviceSerial(): void;
|
|
211
|
-
openPreviousEditor(): void;
|
|
212
|
-
switchTypeScript(): void;
|
|
213
|
-
openTypeScriptAsync(): Promise<void>;
|
|
214
|
-
openPythonAsync(): Promise<void>;
|
|
215
|
-
saveBlocksToTypeScriptAsync(): Promise<string>;
|
|
216
|
-
saveFileAsync(): Promise<void>;
|
|
217
|
-
saveCurrentSourceAsync(): Promise<void>;
|
|
218
|
-
saveProjectAsync(): Promise<void>;
|
|
219
|
-
loadHeaderAsync(h: pxt.workspace.Header): Promise<void>;
|
|
220
|
-
reloadHeaderAsync(): Promise<void>;
|
|
221
|
-
importProjectAsync(prj: pxt.workspace.Project, editorState?: pxt.editor.EditorState): Promise<void>;
|
|
222
|
-
importTutorialAsync(markdown: string): Promise<void>;
|
|
223
|
-
openProjectByHeaderIdAsync(headerId: string): Promise<void>;
|
|
224
|
-
overrideTypescriptFile(text: string): void;
|
|
225
|
-
overrideBlocksFile(text: string): void;
|
|
226
|
-
resetTutorialTemplateCode(keepAssets: boolean): Promise<void>;
|
|
227
|
-
exportAsync(): Promise<string>;
|
|
228
|
-
newEmptyProject(name?: string, documentation?: string, preferredEditor?: string): void;
|
|
229
|
-
newProject(options?: ProjectCreationOptions): void;
|
|
230
|
-
createProjectAsync(options: ProjectCreationOptions): Promise<void>;
|
|
231
|
-
importExampleAsync(options: ExampleImportOptions): Promise<void>;
|
|
232
|
-
showScriptManager(): void;
|
|
233
|
-
importProjectDialog(): void;
|
|
234
|
-
removeProject(): void;
|
|
235
|
-
editText(): void;
|
|
236
|
-
hasCloudSync(): boolean;
|
|
237
|
-
getPreferredEditor(): string;
|
|
238
|
-
saveAndCompile(): void;
|
|
239
|
-
updateHeaderName(name: string): void;
|
|
240
|
-
updateHeaderNameAsync(name: string): Promise<void>;
|
|
241
|
-
compile(): void;
|
|
242
|
-
setFile(fn: IFile, line?: number): void;
|
|
243
|
-
setSideFile(fn: IFile, line?: number): void;
|
|
244
|
-
navigateToError(diag: pxtc.KsDiagnostic): void;
|
|
245
|
-
setSideDoc(path: string, blocksEditor?: boolean): void;
|
|
246
|
-
setSideMarkdown(md: string): void;
|
|
247
|
-
setSideDocCollapsed(shouldCollapse?: boolean): void;
|
|
248
|
-
removeFile(fn: IFile, skipConfirm?: boolean): void;
|
|
249
|
-
updateFileAsync(name: string, content: string, open?: boolean): Promise<void>;
|
|
250
|
-
openHome(): void;
|
|
251
|
-
unloadProjectAsync(home?: boolean): Promise<void>;
|
|
252
|
-
setTutorialStep(step: number): void;
|
|
253
|
-
setTutorialInstructionsExpanded(value: boolean): void;
|
|
254
|
-
exitTutorial(): void;
|
|
255
|
-
completeTutorialAsync(): Promise<void>;
|
|
256
|
-
showTutorialHint(): void;
|
|
257
|
-
isTutorial(): boolean;
|
|
258
|
-
onEditorContentLoaded(): void;
|
|
259
|
-
pokeUserActivity(): void;
|
|
260
|
-
stopPokeUserActivity(): void;
|
|
261
|
-
clearUserPoke(): void;
|
|
262
|
-
setHintSeen(step: number): void;
|
|
263
|
-
setEditorOffset(): void;
|
|
264
|
-
anonymousPublishHeaderByIdAsync(headerId: string, projectName?: string): Promise<ShareData>;
|
|
265
|
-
publishCurrentHeaderAsync(persistent: boolean, screenshotUri?: string): Promise<string>;
|
|
266
|
-
publishAsync(name: string, screenshotUri?: string, forceAnonymous?: boolean): Promise<pxt.editor.ShareData>;
|
|
267
|
-
startStopSimulator(opts?: SimulatorStartOptions): void;
|
|
268
|
-
stopSimulator(unload?: boolean, opts?: SimulatorStartOptions): void;
|
|
269
|
-
restartSimulator(): void;
|
|
270
|
-
startSimulator(opts?: SimulatorStartOptions): void;
|
|
271
|
-
runSimulator(): void;
|
|
272
|
-
isSimulatorRunning(): boolean;
|
|
273
|
-
expandSimulator(): void;
|
|
274
|
-
collapseSimulator(): void;
|
|
275
|
-
toggleSimulatorCollapse(): void;
|
|
276
|
-
toggleSimulatorFullscreen(): void;
|
|
277
|
-
setSimulatorFullScreen(enabled: boolean): void;
|
|
278
|
-
proxySimulatorMessage(content: string): void;
|
|
279
|
-
toggleTrace(intervalSpeed?: number): void;
|
|
280
|
-
setTrace(enabled: boolean, intervalSpeed?: number): void;
|
|
281
|
-
toggleMute(): void;
|
|
282
|
-
setMute(state: MuteState): void;
|
|
283
|
-
openInstructions(): void;
|
|
284
|
-
closeFlyout(): void;
|
|
285
|
-
printCode(): void;
|
|
286
|
-
requestScreenshotAsync(): Promise<string>;
|
|
287
|
-
downloadScreenshotAsync(): Promise<void>;
|
|
288
|
-
toggleDebugging(): void;
|
|
289
|
-
dbgPauseResume(): void;
|
|
290
|
-
dbgStepInto(): void;
|
|
291
|
-
dbgStepOver(): void;
|
|
292
|
-
dbgInsertBreakpoint(): void;
|
|
293
|
-
setBannerVisible(b: boolean): void;
|
|
294
|
-
typecheckNow(): void;
|
|
295
|
-
shouldPreserveUndoStack(): boolean;
|
|
296
|
-
openExtension(extension: string, url: string, consentRequired?: boolean, trusted?: boolean): void;
|
|
297
|
-
handleExtensionRequest(request: ExtensionRequest): void;
|
|
298
|
-
fireResize(): void;
|
|
299
|
-
updateEditorLogo(left: number, rgba?: string): number;
|
|
300
|
-
loadBlocklyAsync(): Promise<void>;
|
|
301
|
-
isBlocksEditor(): boolean;
|
|
302
|
-
isTextEditor(): boolean;
|
|
303
|
-
isPxtJsonEditor(): boolean;
|
|
304
|
-
blocksScreenshotAsync(pixelDensity?: number, encodeBlocks?: boolean): Promise<string>;
|
|
305
|
-
renderBlocksAsync(req: EditorMessageRenderBlocksRequest): Promise<EditorMessageRenderBlocksResponse>;
|
|
306
|
-
renderPythonAsync(req: EditorMessageRenderPythonRequest): Promise<EditorMessageRenderPythonResponse>;
|
|
307
|
-
toggleHighContrast(): void;
|
|
308
|
-
setHighContrast(on: boolean): void;
|
|
309
|
-
toggleGreenScreen(): void;
|
|
310
|
-
toggleAccessibleBlocks(): void;
|
|
311
|
-
setAccessibleBlocks(enabled: boolean): void;
|
|
312
|
-
launchFullEditor(): void;
|
|
313
|
-
resetWorkspace(): void;
|
|
314
|
-
settings: EditorSettings;
|
|
315
|
-
isEmbedSimActive(): boolean;
|
|
316
|
-
isBlocksActive(): boolean;
|
|
317
|
-
isJavaScriptActive(): boolean;
|
|
318
|
-
isPythonActive(): boolean;
|
|
319
|
-
isAssetsActive(): boolean;
|
|
320
|
-
editor: IEditor;
|
|
321
|
-
startActivity(options: StartActivityOptions): void;
|
|
322
|
-
showLightbox(): void;
|
|
323
|
-
hideLightbox(): void;
|
|
324
|
-
showOnboarding(): void;
|
|
325
|
-
hideOnboarding(): void;
|
|
326
|
-
showKeymap(show: boolean): void;
|
|
327
|
-
toggleKeymap(): void;
|
|
328
|
-
signOutGithub(): void;
|
|
329
|
-
showReportAbuse(): void;
|
|
330
|
-
showLanguagePicker(): void;
|
|
331
|
-
showShareDialog(title?: string, kind?: "multiplayer" | "vscode" | "share"): void;
|
|
332
|
-
showAboutDialog(): void;
|
|
333
|
-
showTurnBackTimeDialogAsync(): Promise<void>;
|
|
334
|
-
showLoginDialog(continuationHash?: string): void;
|
|
335
|
-
showProfileDialog(location?: string): void;
|
|
336
|
-
showImportUrlDialog(): void;
|
|
337
|
-
showImportFileDialog(options?: ImportFileOptions): void;
|
|
338
|
-
showImportGithubDialog(): void;
|
|
339
|
-
showResetDialog(): void;
|
|
340
|
-
showExitAndSaveDialog(): void;
|
|
341
|
-
showChooseHwDialog(skipDownload?: boolean): void;
|
|
342
|
-
showExperimentsDialog(): void;
|
|
343
|
-
showPackageDialog(query?: string): void;
|
|
344
|
-
showBoardDialogAsync(features?: string[], closeIcon?: boolean): Promise<void>;
|
|
345
|
-
checkForHwVariant(): boolean;
|
|
346
|
-
pairAsync(): Promise<boolean>;
|
|
347
|
-
createModalClasses(classes?: string): string;
|
|
348
|
-
showModalDialogAsync(options: ModalDialogOptions): Promise<void>;
|
|
349
|
-
askForProjectCreationOptionsAsync(): Promise<ProjectCreationOptions>;
|
|
350
|
-
pushScreenshotHandler(handler: (msg: ScreenshotData) => void): void;
|
|
351
|
-
popScreenshotHandler(): void;
|
|
352
|
-
openNewTab(header: pxt.workspace.Header, dependent: boolean): void;
|
|
353
|
-
createGitHubRepositoryAsync(): Promise<void>;
|
|
354
|
-
saveLocalProjectsToCloudAsync(headerIds: string[]): Promise<pxt.Map<string> | undefined>;
|
|
355
|
-
requestProjectCloudStatus(headerIds: string[]): Promise<void>;
|
|
356
|
-
convertCloudProjectsToLocal(userId: string): Promise<void>;
|
|
357
|
-
setLanguageRestrictionAsync(restriction: pxt.editor.LanguageRestriction): Promise<void>;
|
|
358
|
-
hasHeaderBeenPersistentShared(): boolean;
|
|
359
|
-
getSharePreferenceForHeader(): boolean;
|
|
360
|
-
saveSharePreferenceForHeaderAsync(anonymousByDefault: boolean): Promise<void>;
|
|
306
|
+
|
|
307
|
+
export interface EditorMessageRenderPythonRequest extends EditorMessageRequest {
|
|
308
|
+
action: "renderpython";
|
|
309
|
+
// typescript code to render
|
|
310
|
+
ts: string;
|
|
361
311
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
importAsync(project: IProjectView, data: pxt.cpp.HexFile): Promise<void>;
|
|
312
|
+
|
|
313
|
+
export interface EditorMessageRenderPythonResponse {
|
|
314
|
+
python: string;
|
|
366
315
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
316
|
+
|
|
317
|
+
export interface EditorSimulatorEvent extends EditorMessageRequest {
|
|
318
|
+
action: "simevent";
|
|
319
|
+
subtype: "toplevelfinished" | "started" | "stopped" | "resumed"
|
|
371
320
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
simSerialActive?: boolean;
|
|
377
|
-
devSerialActive?: boolean;
|
|
321
|
+
|
|
322
|
+
export interface EditorSimulatorStoppedEvent extends EditorSimulatorEvent {
|
|
323
|
+
subtype: "stopped";
|
|
324
|
+
exception?: string;
|
|
378
325
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
326
|
+
|
|
327
|
+
export interface EditorMessageToggleTraceRequest extends EditorMessageRequest {
|
|
328
|
+
action: "toggletrace";
|
|
329
|
+
// interval speed for the execution trace
|
|
330
|
+
intervalSpeed?: number;
|
|
384
331
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
332
|
+
|
|
333
|
+
export interface EditorMessageSetTraceStateRequest extends EditorMessageRequest {
|
|
334
|
+
action: "settracestate";
|
|
335
|
+
enabled: boolean;
|
|
336
|
+
// interval speed for the execution trace
|
|
337
|
+
intervalSpeed?: number;
|
|
389
338
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
339
|
+
|
|
340
|
+
export interface EditorMessageSetSimulatorFullScreenRequest extends EditorMessageRequest {
|
|
341
|
+
action: "setsimulatorfullscreen";
|
|
342
|
+
enabled: boolean;
|
|
393
343
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
patchCompileResultAsync?: (r: pxtc.CompileResult) => Promise<void>;
|
|
399
|
-
deployAsync?: (r: pxtc.CompileResult) => Promise<void>;
|
|
400
|
-
saveOnlyAsync?: (r: ts.pxtc.CompileResult) => Promise<void>;
|
|
401
|
-
saveProjectAsync?: (project: pxt.cpp.HexFile) => Promise<void>;
|
|
402
|
-
renderBrowserDownloadInstructions?: () => any;
|
|
403
|
-
renderUsbPairDialog?: (firmwareUrl?: string, failedOnce?: boolean) => any;
|
|
404
|
-
renderIncompatibleHardwareDialog?: (unsupportedParts: string[]) => any;
|
|
405
|
-
showUploadInstructionsAsync?: (fn: string, url: string, confirmAsync: (options: any) => Promise<number>) => Promise<void>;
|
|
406
|
-
showProgramTooLargeErrorAsync?: (variants: string[], confirmAsync: (options: any) => Promise<number>) => Promise<pxt.commands.RecompileOptions>;
|
|
407
|
-
toolboxOptions?: IToolboxOptions;
|
|
408
|
-
blocklyPatch?: (pkgTargetVersion: string, dom: Element) => void;
|
|
409
|
-
webUsbPairDialogAsync?: (pairAsync: () => Promise<boolean>, confirmAsync: (options: any) => Promise<number>) => Promise<number>;
|
|
410
|
-
mkPacketIOWrapper?: (io: pxt.packetio.PacketIO) => pxt.packetio.PacketIOWrapper;
|
|
411
|
-
onTutorialCompleted?: () => void;
|
|
412
|
-
onCodeStart?: () => void;
|
|
413
|
-
onCodeStop?: () => void;
|
|
344
|
+
|
|
345
|
+
export interface EditorMessageSetHighContrastRequest extends EditorMessageRequest {
|
|
346
|
+
action: "sethighcontrast";
|
|
347
|
+
on: boolean;
|
|
414
348
|
}
|
|
415
|
-
|
|
349
|
+
|
|
350
|
+
export interface EditorMessageStartActivity extends EditorMessageRequest {
|
|
351
|
+
action: "startactivity";
|
|
352
|
+
activityType: "tutorial" | "example" | "recipe";
|
|
353
|
+
path: string;
|
|
354
|
+
title?: string;
|
|
355
|
+
previousProjectHeaderId?: string;
|
|
356
|
+
carryoverPreviousCode?: boolean;
|
|
416
357
|
}
|
|
417
|
-
|
|
418
|
-
|
|
358
|
+
|
|
359
|
+
export interface InfoMessage {
|
|
360
|
+
versions: pxt.TargetVersions;
|
|
361
|
+
locale: string;
|
|
362
|
+
availableLocales?: string[];
|
|
419
363
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
maths?: ToolboxCategoryDefinition;
|
|
425
|
-
text?: ToolboxCategoryDefinition;
|
|
426
|
-
arrays?: ToolboxCategoryDefinition;
|
|
427
|
-
functions?: ToolboxCategoryDefinition;
|
|
364
|
+
|
|
365
|
+
export interface PackageExtensionData {
|
|
366
|
+
ts: string;
|
|
367
|
+
json?: any;
|
|
428
368
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
name?: string;
|
|
434
|
-
/**
|
|
435
|
-
* The icon of this category
|
|
436
|
-
*/
|
|
437
|
-
icon?: string;
|
|
438
|
-
/**
|
|
439
|
-
* The color of this category
|
|
440
|
-
*/
|
|
441
|
-
color?: string;
|
|
442
|
-
/**
|
|
443
|
-
* The weight of the category relative to other categories in the toolbox
|
|
444
|
-
*/
|
|
445
|
-
weight?: number;
|
|
446
|
-
/**
|
|
447
|
-
* Whether or not the category should be placed in the advanced category
|
|
448
|
-
*/
|
|
449
|
-
advanced?: boolean;
|
|
450
|
-
/**
|
|
451
|
-
* Blocks to appear in the category. Specifying this field will override
|
|
452
|
-
* all existing blocks in the category. The ordering of the blocks is
|
|
453
|
-
* determined by the ordering of this array.
|
|
454
|
-
*/
|
|
455
|
-
blocks?: ToolboxBlockDefinition[];
|
|
456
|
-
/**
|
|
457
|
-
* Ordering of category groups
|
|
458
|
-
*/
|
|
459
|
-
groups?: string[];
|
|
369
|
+
|
|
370
|
+
export interface EditorPkgExtMessageRequest extends EditorMessageRequest {
|
|
371
|
+
// extension identifier
|
|
372
|
+
package: string;
|
|
460
373
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
name: string;
|
|
466
|
-
/**
|
|
467
|
-
* Group label used to categorize block. Blocks are arranged with other
|
|
468
|
-
* blocks that share the same group.
|
|
469
|
-
*/
|
|
470
|
-
group?: string;
|
|
471
|
-
/**
|
|
472
|
-
* Indicates an advanced API. Advanced APIs appear after basic ones in the
|
|
473
|
-
* toolbox
|
|
474
|
-
*/
|
|
475
|
-
advanced?: boolean;
|
|
476
|
-
/**
|
|
477
|
-
* The weight for the block. Blocks are arranged in order of they appear in the category
|
|
478
|
-
* definition's array but the weight can be specified in the case that other APIs are
|
|
479
|
-
* dynamically added to the category (eg. loops.forever())
|
|
480
|
-
*/
|
|
481
|
-
weight?: number;
|
|
482
|
-
/**
|
|
483
|
-
* Description of code to appear in the hover text
|
|
484
|
-
*/
|
|
485
|
-
jsDoc?: string;
|
|
486
|
-
/**
|
|
487
|
-
* TypeScript snippet of code to insert when dragged into editor
|
|
488
|
-
*/
|
|
489
|
-
snippet?: string;
|
|
490
|
-
/**
|
|
491
|
-
* Python snippet of code to insert when dragged into editor
|
|
492
|
-
*/
|
|
493
|
-
pySnippet?: string;
|
|
494
|
-
/**
|
|
495
|
-
* TypeScript name used for highlighting the snippet, uses name if not defined
|
|
496
|
-
*/
|
|
497
|
-
snippetName?: string;
|
|
498
|
-
/**
|
|
499
|
-
* Python name used for highlighting the snippet, uses name if not defined
|
|
500
|
-
*/
|
|
501
|
-
pySnippetName?: string;
|
|
502
|
-
/**
|
|
503
|
-
* Display just the snippet and nothing else. Should be set to true for
|
|
504
|
-
* language constructs (eg. for-loops) and to false for function
|
|
505
|
-
* calls (eg. Math.random())
|
|
506
|
-
*/
|
|
507
|
-
snippetOnly?: boolean;
|
|
508
|
-
/**
|
|
509
|
-
* The return type of the block. This is used to determine the shape of the block rendered.
|
|
510
|
-
*/
|
|
511
|
-
retType?: string;
|
|
512
|
-
/**
|
|
513
|
-
* The block definition in XML for the blockly toolbox.
|
|
514
|
-
*/
|
|
515
|
-
blockXml?: string;
|
|
516
|
-
/**
|
|
517
|
-
* The Blockly block id used to identify this block.
|
|
518
|
-
*/
|
|
519
|
-
blockId?: string;
|
|
374
|
+
|
|
375
|
+
export interface EditorPkgExtMessageResponse extends EditorMessageResponse {
|
|
376
|
+
// extension identifier
|
|
377
|
+
package: string;
|
|
520
378
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
379
|
+
|
|
380
|
+
export interface EditorSimulatorTickEvent extends EditorMessageEventRequest {
|
|
381
|
+
type: "pxtsim";
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export interface EditorShareRequest extends EditorMessageRequest {
|
|
385
|
+
action: "shareproject";
|
|
386
|
+
headerId: string;
|
|
387
|
+
projectName: string;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export interface EditorShareResponse extends EditorMessageRequest {
|
|
391
|
+
action: "shareproject";
|
|
392
|
+
script: pxt.Cloud.JsonScript;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export interface EditorSetLanguageRestriction extends EditorMessageRequest {
|
|
396
|
+
action: "setlanguagerestriction";
|
|
397
|
+
restriction: pxt.editor.LanguageRestriction;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export interface DataStreams<T> {
|
|
401
|
+
console?: T;
|
|
402
|
+
messages?: T;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export interface ExtensionFiles {
|
|
406
|
+
code?: string;
|
|
407
|
+
json?: string;
|
|
408
|
+
jres?: string;
|
|
409
|
+
asm?: string;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export interface WriteExtensionFiles extends ExtensionFiles {
|
|
413
|
+
dependencies?: pxt.Map<string>;
|
|
528
414
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
declare namespace pxt.editor {
|
|
533
|
-
interface EditorMessage {
|
|
534
|
-
/**
|
|
535
|
-
* Constant identifier
|
|
536
|
-
*/
|
|
537
|
-
type: "pxteditor" | "pxthost" | "pxtpkgext" | "pxtsim";
|
|
538
|
-
/**
|
|
539
|
-
* Original request id
|
|
540
|
-
*/
|
|
541
|
-
id?: string;
|
|
542
|
-
/**
|
|
543
|
-
* flag to request response
|
|
544
|
-
*/
|
|
545
|
-
response?: boolean;
|
|
415
|
+
|
|
416
|
+
export interface ExtensionMessage extends EditorMessage {
|
|
417
|
+
type: "pxtpkgext";
|
|
546
418
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
resp?: any;
|
|
552
|
-
/**
|
|
553
|
-
* indicate if operation started or completed successfully
|
|
554
|
-
*/
|
|
555
|
-
success: boolean;
|
|
556
|
-
/**
|
|
557
|
-
* Error object if any
|
|
558
|
-
*/
|
|
559
|
-
error?: any;
|
|
419
|
+
|
|
420
|
+
export interface ExtensionResponse extends EditorMessageResponse {
|
|
421
|
+
type: "pxtpkgext";
|
|
422
|
+
extId: string;
|
|
560
423
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
424
|
+
|
|
425
|
+
export interface ExtensionRequest extends EditorMessageRequest {
|
|
426
|
+
type: "pxtpkgext";
|
|
427
|
+
extId: string;
|
|
428
|
+
body?: any;
|
|
566
429
|
}
|
|
430
|
+
|
|
567
431
|
/**
|
|
568
|
-
*
|
|
432
|
+
* Events are fired by the editor on the extension iFrame. Extensions
|
|
433
|
+
* receive events, they don't send them.
|
|
569
434
|
*/
|
|
570
|
-
interface
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
category?: string;
|
|
574
|
-
message?: string;
|
|
575
|
-
data?: Map<string | number>;
|
|
576
|
-
}
|
|
577
|
-
type EditorMessageTutorialEventRequest = EditorMessageTutorialProgressEventRequest | EditorMessageTutorialCompletedEventRequest | EditorMessageTutorialLoadedEventRequest | EditorMessageTutorialExitEventRequest;
|
|
578
|
-
interface EditorMessageTutorialProgressEventRequest extends EditorMessageRequest {
|
|
579
|
-
action: "tutorialevent";
|
|
580
|
-
tutorialEvent: "progress";
|
|
581
|
-
currentStep: number;
|
|
582
|
-
totalSteps: number;
|
|
583
|
-
isCompleted: boolean;
|
|
584
|
-
tutorialId: string;
|
|
585
|
-
projectHeaderId: string;
|
|
435
|
+
export interface ExtensionEvent extends ExtensionMessage {
|
|
436
|
+
event: string;
|
|
437
|
+
target: string;
|
|
586
438
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Event fired when the extension is loaded.
|
|
442
|
+
*/
|
|
443
|
+
export interface LoadedEvent extends ExtensionEvent {
|
|
444
|
+
event: "extloaded";
|
|
592
445
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Event fired when the extension becomes visible.
|
|
449
|
+
*/
|
|
450
|
+
export interface ShownEvent extends ExtensionEvent {
|
|
451
|
+
event: "extshown";
|
|
598
452
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Event fired when the extension becomes hidden.
|
|
456
|
+
*/
|
|
457
|
+
export interface HiddenEvent extends ExtensionEvent {
|
|
458
|
+
event: "exthidden";
|
|
459
|
+
body: HiddenReason;
|
|
604
460
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
461
|
+
|
|
462
|
+
export type HiddenReason = "useraction" | "other";
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Event fired when console data is received
|
|
466
|
+
*/
|
|
467
|
+
export interface ConsoleEvent extends ExtensionEvent {
|
|
468
|
+
event: "extconsole";
|
|
469
|
+
body: {
|
|
470
|
+
source: string;
|
|
471
|
+
sim: boolean;
|
|
472
|
+
data: string;
|
|
473
|
+
}
|
|
611
474
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Event fired when a message packet is received
|
|
478
|
+
*/
|
|
479
|
+
export interface MessagePacketEvent extends ExtensionEvent {
|
|
480
|
+
event: "extmessagepacket";
|
|
481
|
+
body: {
|
|
482
|
+
source?: string;
|
|
483
|
+
channel: string;
|
|
484
|
+
data: Uint8Array;
|
|
485
|
+
}
|
|
618
486
|
}
|
|
619
|
-
|
|
620
|
-
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Event fired when extension is first shown. Extension
|
|
490
|
+
* should send init request in response
|
|
491
|
+
*/
|
|
492
|
+
export type ExtInitializeType = "extinit";
|
|
493
|
+
|
|
494
|
+
export interface InitializeRequest extends ExtensionRequest {
|
|
495
|
+
action: ExtInitializeType;
|
|
496
|
+
body: string;
|
|
621
497
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
498
|
+
|
|
499
|
+
export interface InitializeResponse extends ExtensionResponse {
|
|
500
|
+
target?: pxt.AppTarget;
|
|
625
501
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Requests data stream event to be fired. Permission will
|
|
505
|
+
* be requested if not already received.
|
|
506
|
+
*/
|
|
507
|
+
export type ExtDataStreamType = "extdatastream";
|
|
508
|
+
|
|
509
|
+
export interface DataStreamRequest extends ExtensionRequest {
|
|
510
|
+
action: ExtDataStreamType;
|
|
511
|
+
body: DataStreams<boolean>;
|
|
632
512
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
*/
|
|
637
|
-
action: "workspacesync" | "workspacereset" | "workspaceloaded";
|
|
513
|
+
|
|
514
|
+
export interface DataStreamResponse extends ExtensionResponse {
|
|
515
|
+
resp: DataStreams<boolean>;
|
|
638
516
|
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Request to read the user's code. Will request permission if
|
|
520
|
+
* not already granted
|
|
521
|
+
*/
|
|
522
|
+
export type ExtUserCodeType = "extusercode";
|
|
523
|
+
|
|
524
|
+
export interface UserCodeRequest extends ExtensionRequest {
|
|
525
|
+
action: ExtUserCodeType;
|
|
642
526
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
diagnostics: {
|
|
648
|
-
code: number;
|
|
649
|
-
category: "error" | "warning" | "message";
|
|
650
|
-
fileName?: string;
|
|
651
|
-
start?: number;
|
|
652
|
-
length?: number;
|
|
653
|
-
line?: number;
|
|
654
|
-
column?: number;
|
|
655
|
-
endLine?: number;
|
|
656
|
-
endColumn?: number;
|
|
657
|
-
}[];
|
|
527
|
+
|
|
528
|
+
export interface UserCodeResponse extends ExtensionResponse {
|
|
529
|
+
/* A mapping of file names to their contents */
|
|
530
|
+
resp?: { [index: string]: string };
|
|
658
531
|
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Request to read the files saved by this extension
|
|
535
|
+
*/
|
|
536
|
+
export type ExtReadCodeType = "extreadcode";
|
|
537
|
+
|
|
538
|
+
export interface ReadCodeRequest extends ExtensionRequest {
|
|
539
|
+
action: ExtReadCodeType;
|
|
662
540
|
}
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
541
|
+
|
|
542
|
+
export interface ReadCodeResponse extends ExtensionResponse {
|
|
543
|
+
action: ExtReadCodeType;
|
|
544
|
+
|
|
545
|
+
body?: ExtensionFiles;
|
|
667
546
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Request to write the JSON and/or TS files saved
|
|
550
|
+
* by this extension
|
|
551
|
+
*/
|
|
552
|
+
export type ExtWriteCodeType = "extwritecode";
|
|
553
|
+
|
|
554
|
+
export interface WriteCodeRequest extends ExtensionRequest {
|
|
555
|
+
action: ExtWriteCodeType;
|
|
556
|
+
|
|
557
|
+
body?: WriteExtensionFiles;
|
|
671
558
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
project: pxt.workspace.Project;
|
|
675
|
-
filters?: pxt.editor.ProjectFilters;
|
|
676
|
-
searchBar?: boolean;
|
|
559
|
+
|
|
560
|
+
export interface WriteCodeResponse extends ExtensionResponse {
|
|
677
561
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
562
|
+
|
|
563
|
+
export interface ProjectCreationOptions {
|
|
564
|
+
prj?: pxt.ProjectTemplate;
|
|
565
|
+
name?: string;
|
|
566
|
+
documentation?: string;
|
|
567
|
+
filesOverride?: pxt.Map<string>;
|
|
568
|
+
filters?: ProjectFilters;
|
|
569
|
+
temporary?: boolean;
|
|
570
|
+
tutorial?: pxt.tutorial.TutorialOptions;
|
|
571
|
+
dependencies?: pxt.Map<string>;
|
|
572
|
+
tsOnly?: boolean; // DEPRECATED: use LanguageRestriction.NoBlocks or LanguageRestriction.JavaScriptOnly instead
|
|
573
|
+
languageRestriction?: pxt.editor.LanguageRestriction;
|
|
574
|
+
preferredEditor?: string; // preferred editor to open, pxt.BLOCKS_PROJECT_NAME, ...
|
|
575
|
+
extensionUnderTest?: string; // workspace id of the extension under test
|
|
576
|
+
skillmapProject?: boolean;
|
|
577
|
+
simTheme?: Partial<pxt.PackageConfig>;
|
|
578
|
+
firstProject?: boolean;
|
|
681
579
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
580
|
+
|
|
581
|
+
export interface ProjectFilters {
|
|
582
|
+
namespaces?: { [index: string]: FilterState; }; // Disabled = 2, Hidden = 0, Visible = 1
|
|
583
|
+
blocks?: { [index: string]: FilterState; }; // Disabled = 2, Hidden = 0, Visible = 1
|
|
584
|
+
fns?: { [index: string]: FilterState; }; // Disabled = 2, Hidden = 0, Visible = 1
|
|
585
|
+
defaultState?: FilterState; // hide, show or disable all by default
|
|
685
586
|
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
587
|
+
|
|
588
|
+
export const enum FilterState {
|
|
589
|
+
Hidden = 0,
|
|
590
|
+
Visible = 1,
|
|
591
|
+
Disabled = 2
|
|
690
592
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
593
|
+
|
|
594
|
+
export type EditorType = 'blocks' | 'ts';
|
|
595
|
+
|
|
596
|
+
export interface EditorEvent {
|
|
597
|
+
type: string;
|
|
598
|
+
editor: EditorType;
|
|
694
599
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
600
|
+
|
|
601
|
+
export interface CreateEvent extends EditorEvent {
|
|
602
|
+
type: "create";
|
|
603
|
+
blockId: string;
|
|
698
604
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
605
|
+
|
|
606
|
+
export interface UIEvent extends EditorEvent {
|
|
607
|
+
type: "ui";
|
|
608
|
+
action: "groupHelpClicked";
|
|
609
|
+
data?: pxt.Map<string>;
|
|
702
610
|
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
611
|
+
|
|
612
|
+
export interface IEditor {
|
|
613
|
+
undo(): void;
|
|
614
|
+
redo(): void;
|
|
615
|
+
hasUndo(): boolean;
|
|
616
|
+
hasRedo(): boolean;
|
|
617
|
+
zoomIn(): void;
|
|
618
|
+
zoomOut(): void;
|
|
619
|
+
resize(): void;
|
|
620
|
+
setScale(scale: number): void;
|
|
706
621
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
layout?: pxt.blocks.BlockLayout;
|
|
622
|
+
|
|
623
|
+
export interface IFile {
|
|
624
|
+
name: string;
|
|
625
|
+
virtual?: boolean; // gimmick to switch views
|
|
712
626
|
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
627
|
+
|
|
628
|
+
export interface FileHistoryEntry {
|
|
629
|
+
id: string;
|
|
630
|
+
name: string;
|
|
631
|
+
pos: any;
|
|
716
632
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
633
|
+
|
|
634
|
+
export interface EditorSettings {
|
|
635
|
+
editorFontSize: number;
|
|
636
|
+
fileHistory: FileHistoryEntry[];
|
|
720
637
|
}
|
|
721
|
-
|
|
722
|
-
|
|
638
|
+
|
|
639
|
+
export const enum ErrorListState {
|
|
640
|
+
HeaderOnly = "errorListHeader",
|
|
641
|
+
Expanded = "errorListExpanded"
|
|
723
642
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
643
|
+
|
|
644
|
+
export const enum MuteState {
|
|
645
|
+
Muted = "muted",
|
|
646
|
+
Unmuted = "unmuted",
|
|
647
|
+
Disabled = "disabled"
|
|
727
648
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
649
|
+
|
|
650
|
+
export const enum SimState {
|
|
651
|
+
Stopped,
|
|
652
|
+
// waiting to be started
|
|
653
|
+
Pending,
|
|
654
|
+
Starting,
|
|
655
|
+
Running
|
|
731
656
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
657
|
+
|
|
658
|
+
export interface NativeHostMessage {
|
|
659
|
+
name?: string;
|
|
660
|
+
download?: string;
|
|
661
|
+
save?: string;
|
|
662
|
+
cmd?: string;
|
|
735
663
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
664
|
+
|
|
665
|
+
export interface IAppProps { }
|
|
666
|
+
export interface IAppState {
|
|
667
|
+
active?: boolean; // is this tab visible at all
|
|
668
|
+
header?: pxt.workspace.Header;
|
|
669
|
+
editorState?: EditorState;
|
|
670
|
+
currFile?: IFile;
|
|
671
|
+
fileState?: string;
|
|
672
|
+
showFiles?: boolean;
|
|
673
|
+
sideDocsLoadUrl?: string; // set once to load the side docs frame
|
|
674
|
+
sideDocsCollapsed?: boolean;
|
|
675
|
+
projectName?: string;
|
|
676
|
+
suppressPackageWarning?: boolean;
|
|
677
|
+
tutorialOptions?: pxt.tutorial.TutorialOptions;
|
|
678
|
+
lightbox?: boolean;
|
|
679
|
+
keymap?: boolean;
|
|
680
|
+
simState?: SimState;
|
|
681
|
+
autoRun?: boolean;
|
|
682
|
+
resumeOnVisibility?: boolean;
|
|
683
|
+
compiling?: boolean;
|
|
684
|
+
isSaving?: boolean;
|
|
685
|
+
publishing?: boolean;
|
|
686
|
+
hideEditorFloats?: boolean;
|
|
687
|
+
collapseEditorTools?: boolean;
|
|
688
|
+
showBlocks?: boolean;
|
|
689
|
+
showParts?: boolean;
|
|
690
|
+
fullscreen?: boolean;
|
|
691
|
+
showMiniSim?: boolean;
|
|
692
|
+
mute?: MuteState;
|
|
693
|
+
embedSimView?: boolean;
|
|
694
|
+
editorPosition?: {
|
|
695
|
+
lineNumber: number;
|
|
696
|
+
column: number;
|
|
697
|
+
file: IFile;
|
|
698
|
+
}; // ensure that this line is visible when loading the editor
|
|
699
|
+
tracing?: boolean;
|
|
700
|
+
debugging?: boolean;
|
|
701
|
+
debugFirstRun?: boolean;
|
|
702
|
+
bannerVisible?: boolean;
|
|
703
|
+
pokeUserComponent?: string;
|
|
704
|
+
flashHint?: boolean;
|
|
705
|
+
editorOffset?: string;
|
|
706
|
+
print?: boolean;
|
|
707
|
+
greenScreen?: boolean;
|
|
708
|
+
accessibleBlocks?: boolean;
|
|
709
|
+
home?: boolean;
|
|
710
|
+
hasError?: boolean;
|
|
711
|
+
cancelledDownload?: boolean;
|
|
712
|
+
simSerialActive?: boolean;
|
|
713
|
+
deviceSerialActive?: boolean;
|
|
714
|
+
errorListState?: ErrorListState;
|
|
715
|
+
screenshoting?: boolean;
|
|
716
|
+
extensionsVisible?: boolean;
|
|
717
|
+
isMultiplayerGame?: boolean; // Arcade: Does the current project contain multiplayer blocks?
|
|
718
|
+
onboarding?: pxt.tour.BubbleStep[];
|
|
740
719
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
720
|
+
|
|
721
|
+
export interface EditorState {
|
|
722
|
+
filters?: pxt.editor.ProjectFilters;
|
|
723
|
+
searchBar?: boolean; // show the search bar in editor
|
|
724
|
+
hasCategories?: boolean; // show categories in toolbox
|
|
744
725
|
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
726
|
+
|
|
727
|
+
export interface ExampleImportOptions {
|
|
728
|
+
name: string;
|
|
729
|
+
path: string;
|
|
730
|
+
loadBlocks?: boolean;
|
|
731
|
+
prj?: pxt.ProjectTemplate;
|
|
732
|
+
preferredEditor?: string;
|
|
748
733
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
734
|
+
|
|
735
|
+
export interface StartActivityOptions {
|
|
736
|
+
activity: Activity;
|
|
752
737
|
path: string;
|
|
753
738
|
title?: string;
|
|
739
|
+
editor?: string;
|
|
740
|
+
focus?: boolean;
|
|
741
|
+
importOptions?: ExampleImportOptions;
|
|
754
742
|
previousProjectHeaderId?: string;
|
|
755
743
|
carryoverPreviousCode?: boolean;
|
|
756
744
|
}
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}
|
|
762
|
-
interface PackageExtensionData {
|
|
763
|
-
ts: string;
|
|
764
|
-
json?: any;
|
|
765
|
-
}
|
|
766
|
-
interface EditorPkgExtMessageRequest extends EditorMessageRequest {
|
|
767
|
-
package: string;
|
|
768
|
-
}
|
|
769
|
-
interface EditorPkgExtMessageResponse extends EditorMessageResponse {
|
|
770
|
-
package: string;
|
|
745
|
+
|
|
746
|
+
export interface ModalDialogButton {
|
|
747
|
+
label: string;
|
|
748
|
+
url?: string;
|
|
771
749
|
}
|
|
772
|
-
|
|
773
|
-
|
|
750
|
+
|
|
751
|
+
export interface ModalDialogOptions {
|
|
752
|
+
header: string;
|
|
753
|
+
body: string;
|
|
754
|
+
buttons?: ModalDialogButton[];
|
|
774
755
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
756
|
+
|
|
757
|
+
export interface ScreenshotData {
|
|
758
|
+
data?: ImageData;
|
|
759
|
+
delay?: number;
|
|
760
|
+
event?: "start" | "stop";
|
|
779
761
|
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
762
|
+
|
|
763
|
+
export interface SimulatorStartOptions {
|
|
764
|
+
clickTrigger?: boolean;
|
|
783
765
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
766
|
+
|
|
767
|
+
export interface ImportFileOptions {
|
|
768
|
+
extension?: boolean;
|
|
769
|
+
openHomeIfFailed?: boolean;
|
|
787
770
|
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
function bindEditorMessages(getEditorAsync: () => Promise<IProjectView>): void;
|
|
798
|
-
/**
|
|
799
|
-
* Sends analytics messages upstream to container if any
|
|
800
|
-
*/
|
|
801
|
-
function enableControllerAnalytics(): void;
|
|
802
|
-
/**
|
|
803
|
-
* Determines if host messages should be posted
|
|
804
|
-
*/
|
|
805
|
-
function shouldPostHostMessages(): boolean;
|
|
806
|
-
/**
|
|
807
|
-
* Posts a message from the editor to the host
|
|
808
|
-
*/
|
|
809
|
-
function postHostMessageAsync(msg: EditorMessageRequest): Promise<EditorMessageResponse>;
|
|
810
|
-
}
|
|
811
|
-
declare namespace pxt.editor.events {
|
|
812
|
-
type EditorType = 'blocks' | 'ts';
|
|
813
|
-
interface Event {
|
|
814
|
-
type: string;
|
|
815
|
-
editor: EditorType;
|
|
771
|
+
|
|
772
|
+
export interface UserInfo {
|
|
773
|
+
id: string;
|
|
774
|
+
userName?: string;
|
|
775
|
+
name: string;
|
|
776
|
+
profile?: string;
|
|
777
|
+
loginHint?: string;
|
|
778
|
+
initials?: string;
|
|
779
|
+
photo?: string;
|
|
816
780
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
781
|
+
|
|
782
|
+
export interface ShareData {
|
|
783
|
+
url: string;
|
|
784
|
+
embed: {
|
|
785
|
+
code?: string;
|
|
786
|
+
editor?: string;
|
|
787
|
+
simulator?: string;
|
|
788
|
+
url?: string;
|
|
789
|
+
}
|
|
790
|
+
qr?: string;
|
|
791
|
+
error?: any;
|
|
820
792
|
}
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
793
|
+
|
|
794
|
+
export type Activity = "tutorial" | "recipe" | "example";
|
|
795
|
+
|
|
796
|
+
export interface IProjectView {
|
|
797
|
+
state: IAppState;
|
|
798
|
+
setState(st: IAppState): void;
|
|
799
|
+
forceUpdate(): void;
|
|
800
|
+
|
|
801
|
+
reloadEditor(): void;
|
|
802
|
+
openBlocks(): void;
|
|
803
|
+
openJavaScript(giveFocusOnLoading?: boolean): void;
|
|
804
|
+
openPython(giveFocusOnLoading?: boolean): void;
|
|
805
|
+
openAssets(): void;
|
|
806
|
+
openSettings(): void;
|
|
807
|
+
openSimView(): void;
|
|
808
|
+
openSimSerial(): void;
|
|
809
|
+
openDeviceSerial(): void;
|
|
810
|
+
openPreviousEditor(): void;
|
|
811
|
+
|
|
812
|
+
switchTypeScript(): void;
|
|
813
|
+
openTypeScriptAsync(): Promise<void>;
|
|
814
|
+
openPythonAsync(): Promise<void>;
|
|
815
|
+
saveBlocksToTypeScriptAsync(): Promise<string>;
|
|
816
|
+
|
|
817
|
+
saveFileAsync(): Promise<void>;
|
|
818
|
+
saveCurrentSourceAsync(): Promise<void>;
|
|
819
|
+
saveProjectAsync(): Promise<void>;
|
|
820
|
+
loadHeaderAsync(h: pxt.workspace.Header): Promise<void>;
|
|
821
|
+
reloadHeaderAsync(): Promise<void>;
|
|
822
|
+
importProjectAsync(prj: pxt.workspace.Project, editorState?: EditorState): Promise<void>;
|
|
823
|
+
importTutorialAsync(markdown: string): Promise<void>;
|
|
824
|
+
openProjectByHeaderIdAsync(headerId: string): Promise<void>;
|
|
825
|
+
overrideTypescriptFile(text: string): void;
|
|
826
|
+
overrideBlocksFile(text: string): void;
|
|
827
|
+
resetTutorialTemplateCode(keepAssets: boolean): Promise<void>;
|
|
828
|
+
|
|
829
|
+
exportAsync(): Promise<string>;
|
|
830
|
+
|
|
831
|
+
newEmptyProject(name?: string, documentation?: string, preferredEditor?: string): void;
|
|
832
|
+
newProject(options?: pxt.editor.ProjectCreationOptions): void;
|
|
833
|
+
createProjectAsync(options: pxt.editor.ProjectCreationOptions): Promise<void>;
|
|
834
|
+
importExampleAsync(options: ExampleImportOptions): Promise<void>;
|
|
835
|
+
showScriptManager(): void;
|
|
836
|
+
importProjectDialog(): void;
|
|
837
|
+
removeProject(): void;
|
|
838
|
+
editText(): void;
|
|
839
|
+
|
|
840
|
+
hasCloudSync(): boolean;
|
|
841
|
+
|
|
842
|
+
getPreferredEditor(): string;
|
|
843
|
+
saveAndCompile(): void;
|
|
844
|
+
updateHeaderName(name: string): void;
|
|
845
|
+
updateHeaderNameAsync(name: string): Promise<void>;
|
|
846
|
+
compile(): void;
|
|
847
|
+
|
|
848
|
+
setFile(fn: IFile, line?: number): void;
|
|
849
|
+
setSideFile(fn: IFile, line?: number): void;
|
|
850
|
+
navigateToError(diag: pxtc.KsDiagnostic): void;
|
|
851
|
+
setSideDoc(path: string, blocksEditor?: boolean): void;
|
|
852
|
+
setSideMarkdown(md: string): void;
|
|
853
|
+
setSideDocCollapsed(shouldCollapse?: boolean): void;
|
|
854
|
+
removeFile(fn: IFile, skipConfirm?: boolean): void;
|
|
855
|
+
updateFileAsync(name: string, content: string, open?: boolean): Promise<void>;
|
|
856
|
+
|
|
857
|
+
openHome(): void;
|
|
858
|
+
unloadProjectAsync(home?: boolean): Promise<void>;
|
|
859
|
+
setTutorialStep(step: number): void;
|
|
860
|
+
setTutorialInstructionsExpanded(value: boolean): void;
|
|
861
|
+
exitTutorial(): void;
|
|
862
|
+
completeTutorialAsync(): Promise<void>;
|
|
863
|
+
showTutorialHint(): void;
|
|
864
|
+
isTutorial(): boolean;
|
|
865
|
+
onEditorContentLoaded(): void;
|
|
866
|
+
pokeUserActivity(): void;
|
|
867
|
+
stopPokeUserActivity(): void;
|
|
868
|
+
clearUserPoke(): void;
|
|
869
|
+
setHintSeen(step: number): void;
|
|
870
|
+
setEditorOffset(): void;
|
|
871
|
+
|
|
872
|
+
anonymousPublishHeaderByIdAsync(headerId: string, projectName?: string): Promise<ShareData>;
|
|
873
|
+
publishCurrentHeaderAsync(persistent: boolean, screenshotUri?: string): Promise<string>;
|
|
874
|
+
publishAsync (name: string, screenshotUri?: string, forceAnonymous?: boolean): Promise<ShareData>;
|
|
875
|
+
|
|
876
|
+
startStopSimulator(opts?: SimulatorStartOptions): void;
|
|
877
|
+
stopSimulator(unload?: boolean, opts?: SimulatorStartOptions): void;
|
|
878
|
+
restartSimulator(): void;
|
|
879
|
+
startSimulator(opts?: SimulatorStartOptions): void;
|
|
880
|
+
runSimulator(): void;
|
|
881
|
+
isSimulatorRunning(): boolean;
|
|
882
|
+
expandSimulator(): void;
|
|
883
|
+
collapseSimulator(): void;
|
|
884
|
+
toggleSimulatorCollapse(): void;
|
|
885
|
+
toggleSimulatorFullscreen(): void;
|
|
886
|
+
setSimulatorFullScreen(enabled: boolean): void;
|
|
887
|
+
proxySimulatorMessage(content: string): void;
|
|
888
|
+
toggleTrace(intervalSpeed?: number): void;
|
|
889
|
+
setTrace(enabled: boolean, intervalSpeed?: number): void;
|
|
890
|
+
toggleMute(): void;
|
|
891
|
+
setMute(state: MuteState): void;
|
|
892
|
+
openInstructions(): void;
|
|
893
|
+
closeFlyout(): void;
|
|
894
|
+
printCode(): void;
|
|
895
|
+
requestScreenshotAsync(): Promise<string>;
|
|
896
|
+
downloadScreenshotAsync(): Promise<void>;
|
|
897
|
+
|
|
898
|
+
toggleDebugging(): void;
|
|
899
|
+
dbgPauseResume(): void;
|
|
900
|
+
dbgStepInto(): void;
|
|
901
|
+
dbgStepOver(): void;
|
|
902
|
+
dbgInsertBreakpoint(): void;
|
|
903
|
+
|
|
904
|
+
setBannerVisible(b: boolean): void;
|
|
905
|
+
typecheckNow(): void;
|
|
906
|
+
shouldPreserveUndoStack(): boolean;
|
|
907
|
+
|
|
908
|
+
openExtension(extension: string, url: string, consentRequired?: boolean, trusted?: boolean): void;
|
|
909
|
+
handleExtensionRequest(request: pxt.editor.ExtensionRequest): void;
|
|
910
|
+
|
|
911
|
+
fireResize(): void;
|
|
912
|
+
updateEditorLogo(left: number, rgba?: string): number;
|
|
913
|
+
|
|
914
|
+
loadBlocklyAsync(): Promise<void>;
|
|
915
|
+
isBlocksEditor(): boolean;
|
|
916
|
+
isTextEditor(): boolean;
|
|
917
|
+
isPxtJsonEditor(): boolean;
|
|
918
|
+
blocksScreenshotAsync(pixelDensity?: number, encodeBlocks?: boolean): Promise<string>;
|
|
919
|
+
renderBlocksAsync(req: pxt.editor.EditorMessageRenderBlocksRequest): Promise<pxt.editor.EditorMessageRenderBlocksResponse>;
|
|
920
|
+
renderPythonAsync(req: pxt.editor.EditorMessageRenderPythonRequest): Promise<pxt.editor.EditorMessageRenderPythonResponse>;
|
|
921
|
+
getBlocks(): Blockly.Block[];
|
|
922
|
+
|
|
923
|
+
toggleHighContrast(): void;
|
|
924
|
+
setHighContrast(on: boolean): void;
|
|
925
|
+
toggleGreenScreen(): void;
|
|
926
|
+
toggleAccessibleBlocks(): void;
|
|
927
|
+
setAccessibleBlocks(enabled: boolean): void;
|
|
928
|
+
launchFullEditor(): void;
|
|
929
|
+
resetWorkspace(): void;
|
|
930
|
+
|
|
931
|
+
settings: EditorSettings;
|
|
932
|
+
|
|
933
|
+
isEmbedSimActive(): boolean;
|
|
934
|
+
isBlocksActive(): boolean;
|
|
935
|
+
isJavaScriptActive(): boolean;
|
|
936
|
+
isPythonActive(): boolean;
|
|
937
|
+
isAssetsActive(): boolean;
|
|
938
|
+
|
|
939
|
+
editor: IEditor;
|
|
940
|
+
|
|
941
|
+
startActivity(options: StartActivityOptions): void;
|
|
942
|
+
showLightbox(): void;
|
|
943
|
+
hideLightbox(): void;
|
|
944
|
+
showOnboarding(): void;
|
|
945
|
+
hideOnboarding(): void;
|
|
946
|
+
showKeymap(show: boolean): void;
|
|
947
|
+
toggleKeymap(): void;
|
|
948
|
+
signOutGithub(): void;
|
|
949
|
+
|
|
950
|
+
showReportAbuse(): void;
|
|
951
|
+
showLanguagePicker(): void;
|
|
952
|
+
showShareDialog(title?: string, kind?: "multiplayer" | "vscode" | "share"): void;
|
|
953
|
+
showAboutDialog(): void;
|
|
954
|
+
showTurnBackTimeDialogAsync(): Promise<void>;
|
|
955
|
+
|
|
956
|
+
showLoginDialog(continuationHash?: string): void;
|
|
957
|
+
showProfileDialog(location?: string): void;
|
|
958
|
+
|
|
959
|
+
showImportUrlDialog(): void;
|
|
960
|
+
showImportFileDialog(options?: ImportFileOptions): void;
|
|
961
|
+
showImportGithubDialog(): void;
|
|
962
|
+
|
|
963
|
+
showResetDialog(): void;
|
|
964
|
+
showExitAndSaveDialog(): void;
|
|
965
|
+
showChooseHwDialog(skipDownload?: boolean): void;
|
|
966
|
+
showExperimentsDialog(): void;
|
|
967
|
+
|
|
968
|
+
showPackageDialog(query?: string): void;
|
|
969
|
+
showBoardDialogAsync(features?: string[], closeIcon?: boolean): Promise<void>;
|
|
970
|
+
checkForHwVariant(): boolean;
|
|
971
|
+
pairAsync(): Promise<boolean>;
|
|
972
|
+
|
|
973
|
+
createModalClasses(classes?: string): string;
|
|
974
|
+
showModalDialogAsync(options: ModalDialogOptions): Promise<void>;
|
|
975
|
+
|
|
976
|
+
askForProjectCreationOptionsAsync(): Promise<pxt.editor.ProjectCreationOptions>;
|
|
977
|
+
|
|
978
|
+
pushScreenshotHandler(handler: (msg: ScreenshotData) => void): void;
|
|
979
|
+
popScreenshotHandler(): void;
|
|
980
|
+
|
|
981
|
+
openNewTab(header: pxt.workspace.Header, dependent: boolean): void;
|
|
982
|
+
createGitHubRepositoryAsync(): Promise<void>;
|
|
983
|
+
saveLocalProjectsToCloudAsync(headerIds: string[]): Promise<pxt.Map<string> | undefined>;
|
|
984
|
+
requestProjectCloudStatus(headerIds: string[]): Promise<void>;
|
|
985
|
+
convertCloudProjectsToLocal(userId: string): Promise<void>;
|
|
986
|
+
setLanguageRestrictionAsync(restriction: pxt.editor.LanguageRestriction): Promise<void>;
|
|
987
|
+
hasHeaderBeenPersistentShared(): boolean;
|
|
988
|
+
getSharePreferenceForHeader(): boolean;
|
|
989
|
+
saveSharePreferenceForHeaderAsync(anonymousByDefault: boolean): Promise<void>;
|
|
825
990
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
interface Experiment {
|
|
991
|
+
|
|
992
|
+
export interface IHexFileImporter {
|
|
829
993
|
id: string;
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
feedbackUrl?: string;
|
|
833
|
-
enableOnline?: boolean;
|
|
834
|
-
}
|
|
835
|
-
function syncTheme(): AppTheme;
|
|
836
|
-
function all(): Experiment[];
|
|
837
|
-
function clear(): void;
|
|
838
|
-
function someEnabled(): boolean;
|
|
839
|
-
function isEnabled(experiment: Experiment | string): boolean;
|
|
840
|
-
function toggle(experiment: Experiment): void;
|
|
841
|
-
function state(): string;
|
|
842
|
-
function setState(experiment: Experiment, enabled: boolean): void;
|
|
843
|
-
}
|
|
844
|
-
declare namespace pxt.editor {
|
|
845
|
-
interface DataStreams<T> {
|
|
846
|
-
console?: T;
|
|
847
|
-
messages?: T;
|
|
848
|
-
}
|
|
849
|
-
interface ExtensionFiles {
|
|
850
|
-
code?: string;
|
|
851
|
-
json?: string;
|
|
852
|
-
jres?: string;
|
|
853
|
-
asm?: string;
|
|
854
|
-
}
|
|
855
|
-
interface WriteExtensionFiles extends ExtensionFiles {
|
|
856
|
-
dependencies?: pxt.Map<string>;
|
|
857
|
-
}
|
|
858
|
-
interface ExtensionMessage extends EditorMessage {
|
|
859
|
-
type: "pxtpkgext";
|
|
860
|
-
}
|
|
861
|
-
interface ExtensionResponse extends EditorMessageResponse {
|
|
862
|
-
type: "pxtpkgext";
|
|
863
|
-
extId: string;
|
|
864
|
-
}
|
|
865
|
-
interface ExtensionRequest extends EditorMessageRequest {
|
|
866
|
-
type: "pxtpkgext";
|
|
867
|
-
extId: string;
|
|
868
|
-
body?: any;
|
|
869
|
-
}
|
|
870
|
-
/**
|
|
871
|
-
* Events are fired by the editor on the extension iFrame. Extensions
|
|
872
|
-
* receive events, they don't send them.
|
|
873
|
-
*/
|
|
874
|
-
interface ExtensionEvent extends ExtensionMessage {
|
|
875
|
-
event: string;
|
|
876
|
-
target: string;
|
|
877
|
-
}
|
|
878
|
-
/**
|
|
879
|
-
* Event fired when the extension is loaded.
|
|
880
|
-
*/
|
|
881
|
-
interface LoadedEvent extends ExtensionEvent {
|
|
882
|
-
event: "extloaded";
|
|
883
|
-
}
|
|
884
|
-
/**
|
|
885
|
-
* Event fired when the extension becomes visible.
|
|
886
|
-
*/
|
|
887
|
-
interface ShownEvent extends ExtensionEvent {
|
|
888
|
-
event: "extshown";
|
|
889
|
-
}
|
|
890
|
-
/**
|
|
891
|
-
* Event fired when the extension becomes hidden.
|
|
892
|
-
*/
|
|
893
|
-
interface HiddenEvent extends ExtensionEvent {
|
|
894
|
-
event: "exthidden";
|
|
895
|
-
body: HiddenReason;
|
|
896
|
-
}
|
|
897
|
-
type HiddenReason = "useraction" | "other";
|
|
898
|
-
/**
|
|
899
|
-
* Event fired when console data is received
|
|
900
|
-
*/
|
|
901
|
-
interface ConsoleEvent extends ExtensionEvent {
|
|
902
|
-
event: "extconsole";
|
|
903
|
-
body: {
|
|
904
|
-
source: string;
|
|
905
|
-
sim: boolean;
|
|
906
|
-
data: string;
|
|
907
|
-
};
|
|
908
|
-
}
|
|
909
|
-
/**
|
|
910
|
-
* Event fired when a message packet is received
|
|
911
|
-
*/
|
|
912
|
-
interface MessagePacketEvent extends ExtensionEvent {
|
|
913
|
-
event: "extmessagepacket";
|
|
914
|
-
body: {
|
|
915
|
-
source?: string;
|
|
916
|
-
channel: string;
|
|
917
|
-
data: Uint8Array;
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
/**
|
|
921
|
-
* Event fired when extension is first shown. Extension
|
|
922
|
-
* should send init request in response
|
|
923
|
-
*/
|
|
924
|
-
type ExtInitializeType = "extinit";
|
|
925
|
-
interface InitializeRequest extends ExtensionRequest {
|
|
926
|
-
action: ExtInitializeType;
|
|
927
|
-
body: string;
|
|
994
|
+
canImport(data: pxt.cpp.HexFile): boolean;
|
|
995
|
+
importAsync(project: IProjectView, data: pxt.cpp.HexFile): Promise<void>;
|
|
928
996
|
}
|
|
929
|
-
|
|
930
|
-
|
|
997
|
+
|
|
998
|
+
export interface IResourceImporter {
|
|
999
|
+
id: string;
|
|
1000
|
+
canImport(data: File): boolean;
|
|
1001
|
+
importAsync(project: IProjectView, data: File): Promise<void>;
|
|
931
1002
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
body: DataStreams<boolean>;
|
|
1003
|
+
|
|
1004
|
+
export interface ISettingsProps {
|
|
1005
|
+
parent: IProjectView;
|
|
1006
|
+
visible?: boolean;
|
|
1007
|
+
collapsed?: boolean;
|
|
1008
|
+
simSerialActive?: boolean;
|
|
1009
|
+
devSerialActive?: boolean;
|
|
940
1010
|
}
|
|
941
|
-
|
|
942
|
-
|
|
1011
|
+
|
|
1012
|
+
export interface IFieldCustomOptions {
|
|
1013
|
+
selector: string;
|
|
1014
|
+
editor: Blockly.FieldCustomConstructor;
|
|
1015
|
+
text?: string;
|
|
1016
|
+
validator?: any;
|
|
943
1017
|
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
action: ExtUserCodeType;
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
export interface ExtensionOptions {
|
|
1021
|
+
blocklyToolbox: ToolboxDefinition;
|
|
1022
|
+
monacoToolbox: ToolboxDefinition;
|
|
1023
|
+
projectView: IProjectView;
|
|
951
1024
|
}
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1025
|
+
|
|
1026
|
+
export interface IToolboxOptions {
|
|
1027
|
+
blocklyToolbox?: ToolboxDefinition;
|
|
1028
|
+
monacoToolbox?: ToolboxDefinition;
|
|
956
1029
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
1030
|
+
|
|
1031
|
+
export interface ExtensionResult {
|
|
1032
|
+
hexFileImporters?: IHexFileImporter[];
|
|
1033
|
+
resourceImporters?: IResourceImporter[];
|
|
1034
|
+
beforeCompile?: () => void;
|
|
1035
|
+
patchCompileResultAsync?: (r: pxtc.CompileResult) => Promise<void>;
|
|
1036
|
+
deployAsync?: (r: pxtc.CompileResult) => Promise<void>;
|
|
1037
|
+
saveOnlyAsync?: (r: ts.pxtc.CompileResult) => Promise<void>;
|
|
1038
|
+
saveProjectAsync?: (project: pxt.cpp.HexFile) => Promise<void>;
|
|
1039
|
+
renderBrowserDownloadInstructions?: () => any /* JSX.Element */;
|
|
1040
|
+
renderUsbPairDialog?: (firmwareUrl?: string, failedOnce?: boolean) => any /* JSX.Element */;
|
|
1041
|
+
renderIncompatibleHardwareDialog?: (unsupportedParts: string[]) => any /* JSX.Element */;
|
|
1042
|
+
showUploadInstructionsAsync?: (fn: string, url: string, confirmAsync: (options: any) => Promise<number>) => Promise<void>;
|
|
1043
|
+
showProgramTooLargeErrorAsync?: (variants: string[], confirmAsync: (options: any) => Promise<number>) => Promise<pxt.commands.RecompileOptions>;
|
|
1044
|
+
toolboxOptions?: IToolboxOptions;
|
|
1045
|
+
blocklyPatch?: (pkgTargetVersion: string, dom: Element) => void;
|
|
1046
|
+
webUsbPairDialogAsync?: (pairAsync: () => Promise<boolean>, confirmAsync: (options: any) => Promise<number>) => Promise<number>;
|
|
1047
|
+
mkPacketIOWrapper?: (io: pxt.packetio.PacketIO) => pxt.packetio.PacketIOWrapper;
|
|
1048
|
+
|
|
1049
|
+
// Used with the @tutorialCompleted macro. See docs/writing-docs/tutorials.md for more info
|
|
1050
|
+
onTutorialCompleted?: () => void;
|
|
1051
|
+
|
|
1052
|
+
// Used with @codeStart, @codeStop metadata (MINECRAFT HOC ONLY)
|
|
1053
|
+
onCodeStart?: () => void;
|
|
1054
|
+
onCodeStop?: () => void;
|
|
963
1055
|
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
body?: ExtensionFiles;
|
|
1056
|
+
|
|
1057
|
+
export interface FieldExtensionOptions {
|
|
967
1058
|
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
*/
|
|
972
|
-
type ExtWriteCodeType = "extwritecode";
|
|
973
|
-
interface WriteCodeRequest extends ExtensionRequest {
|
|
974
|
-
action: ExtWriteCodeType;
|
|
975
|
-
body?: WriteExtensionFiles;
|
|
1059
|
+
|
|
1060
|
+
export interface FieldExtensionResult {
|
|
1061
|
+
fieldEditors?: IFieldCustomOptions[];
|
|
976
1062
|
}
|
|
977
|
-
|
|
1063
|
+
|
|
1064
|
+
export interface ToolboxDefinition {
|
|
1065
|
+
loops?: ToolboxCategoryDefinition;
|
|
1066
|
+
logic?: ToolboxCategoryDefinition;
|
|
1067
|
+
variables?: ToolboxCategoryDefinition;
|
|
1068
|
+
maths?: ToolboxCategoryDefinition;
|
|
1069
|
+
text?: ToolboxCategoryDefinition;
|
|
1070
|
+
arrays?: ToolboxCategoryDefinition;
|
|
1071
|
+
functions?: ToolboxCategoryDefinition;
|
|
978
1072
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1073
|
+
|
|
1074
|
+
export interface ToolboxCategoryDefinition {
|
|
1075
|
+
/**
|
|
1076
|
+
* The display name for the category
|
|
1077
|
+
*/
|
|
1078
|
+
name?: string;
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* The icon of this category
|
|
1082
|
+
*/
|
|
1083
|
+
icon?: string;
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* The color of this category
|
|
1087
|
+
*/
|
|
1088
|
+
color?: string;
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* The weight of the category relative to other categories in the toolbox
|
|
1092
|
+
*/
|
|
1093
|
+
weight?: number;
|
|
1094
|
+
|
|
1095
|
+
/**
|
|
1096
|
+
* Whether or not the category should be placed in the advanced category
|
|
1097
|
+
*/
|
|
1098
|
+
advanced?: boolean;
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Blocks to appear in the category. Specifying this field will override
|
|
1102
|
+
* all existing blocks in the category. The ordering of the blocks is
|
|
1103
|
+
* determined by the ordering of this array.
|
|
1104
|
+
*/
|
|
1105
|
+
blocks?: ToolboxBlockDefinition[];
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* Ordering of category groups
|
|
1109
|
+
*/
|
|
1110
|
+
groups?: string[],
|
|
999
1111
|
}
|
|
1000
|
-
|
|
1001
|
-
interface
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1112
|
+
|
|
1113
|
+
export interface ToolboxBlockDefinition {
|
|
1114
|
+
/**
|
|
1115
|
+
* Internal id used to refer to this block or snippet, must be unique
|
|
1116
|
+
*/
|
|
1117
|
+
name: string;
|
|
1118
|
+
|
|
1119
|
+
/**
|
|
1120
|
+
* Group label used to categorize block. Blocks are arranged with other
|
|
1121
|
+
* blocks that share the same group.
|
|
1122
|
+
*/
|
|
1123
|
+
group?: string,
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* Indicates an advanced API. Advanced APIs appear after basic ones in the
|
|
1127
|
+
* toolbox
|
|
1128
|
+
*/
|
|
1129
|
+
advanced?: boolean;
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* The weight for the block. Blocks are arranged in order of they appear in the category
|
|
1133
|
+
* definition's array but the weight can be specified in the case that other APIs are
|
|
1134
|
+
* dynamically added to the category (eg. loops.forever())
|
|
1135
|
+
*/
|
|
1136
|
+
weight?: number;
|
|
1137
|
+
|
|
1138
|
+
/**
|
|
1139
|
+
* Description of code to appear in the hover text
|
|
1140
|
+
*/
|
|
1141
|
+
jsDoc?: string
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* TypeScript snippet of code to insert when dragged into editor
|
|
1145
|
+
*/
|
|
1146
|
+
snippet?: string;
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* Python snippet of code to insert when dragged into editor
|
|
1150
|
+
*/
|
|
1151
|
+
pySnippet?: string;
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* TypeScript name used for highlighting the snippet, uses name if not defined
|
|
1155
|
+
*/
|
|
1156
|
+
snippetName?: string;
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* Python name used for highlighting the snippet, uses name if not defined
|
|
1160
|
+
*/
|
|
1161
|
+
pySnippetName?: string;
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* Display just the snippet and nothing else. Should be set to true for
|
|
1165
|
+
* language constructs (eg. for-loops) and to false for function
|
|
1166
|
+
* calls (eg. Math.random())
|
|
1167
|
+
*/
|
|
1043
1168
|
snippetOnly?: boolean;
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* The return type of the block. This is used to determine the shape of the block rendered.
|
|
1172
|
+
*/
|
|
1173
|
+
retType?: string;
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* The block definition in XML for the blockly toolbox.
|
|
1177
|
+
*/
|
|
1178
|
+
blockXml?: string;
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* The Blockly block id used to identify this block.
|
|
1182
|
+
*/
|
|
1183
|
+
blockId?: string;
|
|
1044
1184
|
}
|
|
1045
|
-
interface NameDefiniton {
|
|
1046
|
-
fns: {
|
|
1047
|
-
[fn: string]: MethodDef;
|
|
1048
|
-
};
|
|
1049
|
-
vars?: {
|
|
1050
|
-
[index: string]: string;
|
|
1051
|
-
};
|
|
1052
|
-
metaData?: pxtc.CommentAttrs;
|
|
1053
|
-
builtin?: boolean;
|
|
1054
|
-
}
|
|
1055
|
-
type DefinitionMap = {
|
|
1056
|
-
[ns: string]: NameDefiniton;
|
|
1057
|
-
};
|
|
1058
|
-
function syncModels(mainPkg: MainPackage, libs: {
|
|
1059
|
-
[path: string]: monaco.IDisposable;
|
|
1060
|
-
}, currFile: string, readOnly: boolean): void;
|
|
1061
|
-
function initMonacoAsync(element: HTMLElement): Promise<monaco.editor.IStandaloneCodeEditor>;
|
|
1062
|
-
function createEditor(element: HTMLElement): monaco.editor.IStandaloneCodeEditor;
|
|
1063
1185
|
}
|
|
1186
|
+
|
|
1064
1187
|
declare namespace pxt.workspace {
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
text?: ScriptText
|
|
1069
|
-
|
|
1070
|
-
interface Asset {
|
|
1071
|
-
name: string;
|
|
1072
|
-
size: number;
|
|
1073
|
-
url: string;
|
|
1074
|
-
}
|
|
1075
|
-
type Version = any;
|
|
1076
|
-
interface File {
|
|
1077
|
-
header: Header;
|
|
1078
|
-
text: ScriptText;
|
|
1079
|
-
version: Version;
|
|
1080
|
-
}
|
|
1081
|
-
interface WorkspaceProvider {
|
|
1082
|
-
listAsync(): Promise<Header[]>;
|
|
1083
|
-
getAsync(h: Header): Promise<File>;
|
|
1084
|
-
setAsync(h: Header, prevVersion: Version, text?: ScriptText): Promise<Version>;
|
|
1085
|
-
deleteAsync?: (h: Header, prevVersion: Version) => Promise<void>;
|
|
1188
|
+
export interface WorkspaceProvider {
|
|
1189
|
+
listAsync(): Promise<pxt.workspace.Header[]>; // called from workspace.syncAsync (including upon startup)
|
|
1190
|
+
getAsync(h: pxt.workspace.Header): Promise<File>;
|
|
1191
|
+
setAsync(h: pxt.workspace.Header, prevVersion: pxt.workspace.Version, text?: pxt.workspace.ScriptText): Promise<pxt.workspace.Version>;
|
|
1192
|
+
deleteAsync?: (h: pxt.workspace.Header, prevVersion: pxt.workspace.Version) => Promise<void>;
|
|
1086
1193
|
resetAsync(): Promise<void>;
|
|
1087
1194
|
loadedAsync?: () => Promise<void>;
|
|
1088
1195
|
getSyncState?: () => pxt.editor.EditorSyncState;
|
|
1089
|
-
|
|
1196
|
+
|
|
1197
|
+
// optional screenshot support
|
|
1198
|
+
saveScreenshotAsync?: (h: pxt.workspace.Header, screenshot: string, icon: string) => Promise<void>;
|
|
1199
|
+
|
|
1200
|
+
// optional asset (large binary file) support
|
|
1090
1201
|
saveAssetAsync?: (id: string, filename: string, data: Uint8Array) => Promise<void>;
|
|
1091
1202
|
listAssetsAsync?: (id: string) => Promise<Asset[]>;
|
|
1092
|
-
|
|
1203
|
+
|
|
1204
|
+
fireEvent?: (ev: pxt.editor.EditorEvent) => void;
|
|
1093
1205
|
}
|
|
1094
|
-
|
|
1095
|
-
}
|
|
1096
|
-
declare namespace pxt.editor {
|
|
1097
|
-
interface TextEdit {
|
|
1098
|
-
range: monaco.Range;
|
|
1099
|
-
replacement: string;
|
|
1100
|
-
}
|
|
1101
|
-
interface MonacoFieldEditorHost {
|
|
1102
|
-
contentDiv(): HTMLDivElement;
|
|
1103
|
-
getText(range: monaco.Range): string;
|
|
1104
|
-
blocksInfo(): pxtc.BlocksInfo;
|
|
1105
|
-
package(): pxt.MainPackage;
|
|
1106
|
-
writeFileAsync(filename: string, content: string): Promise<void>;
|
|
1107
|
-
readFile(filename: string): string;
|
|
1108
|
-
}
|
|
1109
|
-
interface MonacoFieldEditor {
|
|
1110
|
-
getId(): string;
|
|
1111
|
-
showEditorAsync(fileType: FileType, editrange: monaco.Range, host: MonacoFieldEditorHost): Promise<TextEdit>;
|
|
1112
|
-
onClosed(): void;
|
|
1113
|
-
dispose(): void;
|
|
1114
|
-
}
|
|
1115
|
-
interface MonacoFieldEditorDefinition {
|
|
1116
|
-
id: string;
|
|
1117
|
-
matcher: MonacoFindArguments;
|
|
1118
|
-
foldMatches?: boolean;
|
|
1119
|
-
alwaysBuildOnClose?: boolean;
|
|
1120
|
-
glyphCssClass?: string;
|
|
1121
|
-
weight?: number;
|
|
1122
|
-
proto: {
|
|
1123
|
-
new (): MonacoFieldEditor;
|
|
1124
|
-
};
|
|
1125
|
-
heightInPixels?: number;
|
|
1126
|
-
}
|
|
1127
|
-
interface MonacoFindArguments {
|
|
1128
|
-
searchString: string;
|
|
1129
|
-
isRegex: boolean;
|
|
1130
|
-
matchWholeWord: boolean;
|
|
1131
|
-
matchCase: boolean;
|
|
1132
|
-
validateRange?: (range: monaco.Range, model: monaco.editor.ITextModel) => monaco.Range;
|
|
1133
|
-
}
|
|
1134
|
-
function registerMonacoFieldEditor(name: string, definition: MonacoFieldEditorDefinition): void;
|
|
1135
|
-
function getMonacoFieldEditor(name: string): MonacoFieldEditorDefinition;
|
|
1136
|
-
}
|
|
1137
|
-
declare namespace pxt.editor {
|
|
1138
|
-
class MonacoReactFieldEditor<U> implements MonacoFieldEditor {
|
|
1139
|
-
private resolver;
|
|
1140
|
-
private rejecter;
|
|
1141
|
-
protected fileType: pxt.editor.FileType;
|
|
1142
|
-
protected editrange: monaco.Range;
|
|
1143
|
-
protected host: MonacoFieldEditorHost;
|
|
1144
|
-
protected fv: pxt.react.FieldEditorView<U>;
|
|
1145
|
-
getId(): string;
|
|
1146
|
-
showEditorAsync(fileType: FileType, editrange: monaco.Range, host: MonacoFieldEditorHost): Promise<TextEdit>;
|
|
1147
|
-
onClosed(): void;
|
|
1148
|
-
dispose(): void;
|
|
1149
|
-
protected initAsync(): Promise<void>;
|
|
1150
|
-
protected textToValue(text: string): U;
|
|
1151
|
-
protected resultToText(result: U): string;
|
|
1152
|
-
protected getFieldEditorId(): string;
|
|
1153
|
-
protected getOptions(): any;
|
|
1154
|
-
}
|
|
1155
|
-
}
|
|
1156
|
-
declare namespace pxt.editor {
|
|
1157
|
-
class MonacoSongEditor extends MonacoReactFieldEditor<pxt.Song> {
|
|
1158
|
-
protected isPython: boolean;
|
|
1159
|
-
protected isAsset: boolean;
|
|
1160
|
-
protected text: string;
|
|
1161
|
-
protected textToValue(text: string): pxt.Song;
|
|
1162
|
-
protected resultToText(result: pxt.Song): string;
|
|
1163
|
-
protected getFieldEditorId(): string;
|
|
1164
|
-
protected getOptions(): any;
|
|
1165
|
-
}
|
|
1166
|
-
const songEditorDefinition: MonacoFieldEditorDefinition;
|
|
1167
|
-
}
|
|
1168
|
-
declare namespace pxt.editor {
|
|
1169
|
-
class MonacoSoundEffectEditor extends MonacoReactFieldEditor<pxt.assets.Sound> {
|
|
1170
|
-
protected value: pxt.assets.Sound;
|
|
1171
|
-
protected textToValue(text: string): pxt.assets.Sound;
|
|
1172
|
-
protected resultToText(result: pxt.assets.Sound): string;
|
|
1173
|
-
protected getFieldEditorId(): string;
|
|
1174
|
-
protected getOptions(): any;
|
|
1175
|
-
}
|
|
1176
|
-
const soundEditorDefinition: MonacoFieldEditorDefinition;
|
|
1177
|
-
}
|
|
1178
|
-
declare namespace pxt.editor {
|
|
1179
|
-
class MonacoSpriteEditor extends MonacoReactFieldEditor<pxt.ProjectImage> {
|
|
1180
|
-
protected isPython: boolean;
|
|
1181
|
-
protected isAsset: boolean;
|
|
1182
|
-
protected textToValue(text: string): pxt.ProjectImage;
|
|
1183
|
-
protected resultToText(result: pxt.ProjectImage): string;
|
|
1184
|
-
protected getFieldEditorId(): string;
|
|
1185
|
-
protected getOptions(): any;
|
|
1186
|
-
}
|
|
1187
|
-
const spriteEditorDefinition: MonacoFieldEditorDefinition;
|
|
1188
|
-
}
|
|
1189
|
-
declare namespace pxt.editor {
|
|
1190
|
-
class MonacoTilemapEditor extends MonacoReactFieldEditor<pxt.ProjectTilemap> {
|
|
1191
|
-
protected isTilemapLiteral: boolean;
|
|
1192
|
-
protected tilemapLiteral: string;
|
|
1193
|
-
protected textToValue(text: string): pxt.ProjectTilemap;
|
|
1194
|
-
protected readTilemap(text: string): pxt.ProjectTilemap;
|
|
1195
|
-
protected resultToText(asset: pxt.ProjectTilemap): string;
|
|
1196
|
-
protected getFieldEditorId(): string;
|
|
1197
|
-
protected getOptions(): any;
|
|
1198
|
-
protected getCreateTilemapRange(): monaco.Range;
|
|
1199
|
-
}
|
|
1200
|
-
const tilemapEditorDefinition: MonacoFieldEditorDefinition;
|
|
1201
|
-
}
|
|
1206
|
+
}
|