-
Notifications
You must be signed in to change notification settings - Fork 593
/
Copy pathpxtpackage.d.ts
298 lines (262 loc) · 9.49 KB
/
pxtpackage.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
declare namespace pxt {
type CodeCardType = "file" | "example" | "codeExample" | "tutorial" | "side" | "template" | "package" | "hw" | "forumUrl" | "forumExample" | "sharedExample" | "link";
type CodeCardEditorType = "blocks" | "js" | "py";
interface Map<T> {
[index: string]: T;
}
interface TargetVersions {
target: string;
targetId?: string;
targetWebsite?: string;
pxt?: string;
tag?: string;
branch?: string;
commits?: string; // URL
}
interface Size {
width: number;
height: number;
}
interface CodeCardAction {
url: string,
editor?: CodeCardEditorType;
cardType?: CodeCardType;
}
/**
* The schema for the pxt.json package files
*/
interface PackageConfig {
name: string;
version?: string;
// installedVersion?: string; moved to Package class
// url to icon -- support for built-in packages only
icon?: string;
// semver description for support target version
documentation?: string; // doc page to open when loading project, used by sidedocs
targetVersions?: TargetVersions; // versions of the target/pxt the package was compiled against
description?: string;
dependencies: Map<string>;
license?: string;
authors?: string[];
files: string[];
simFiles?: string[];
testFiles?: string[];
fileDependencies?: Map<string>; // exclude certain files if dependencies are not fulfilled
preferredEditor?: string; // tsprj, blocksprj, pyprj
languageRestriction?: pxt.editor.LanguageRestriction; // language restrictions that have been placed on the package
testDependencies?: pxt.Map<string>;
cppDependencies?: pxt.Map<string>;
public?: boolean;
partial?: boolean; // true if project is not compileable on its own (eg base)
binaryonly?: boolean;
platformio?: PlatformIOConfig;
compileServiceVariant?: string;
palette?: string[];
paletteNames?: string[];
screenSize?: Size;
yotta?: YottaConfig;
codal?: CodalConfig;
npmDependencies?: Map<string>;
card?: CodeCard;
additionalFilePath?: string;
additionalFilePaths?: string[];
core?: boolean;
// used for sorting for core packages
weight?: number;
gistId?: string;
extension?: PackageExtension; // describe the associated extension if any
isExtension?: boolean; // is this package an extension
dalDTS?: {
corePackage?: string;
includeDirs?: string[];
excludePrefix?: string[];
compileServiceVariant?: string;
};
features?: string[];
hidden?: boolean; // hide package from package selection dialog
searchOnly?: boolean; // do not show by default, only as search result
skipLocalization?: boolean;
snippetBuilders?: SnippetConfig[];
experimentalHw?: boolean;
requiredCategories?: string[]; // ensure that those block categories are visible
supportedTargets?: string[]; // a hint about targets in which this extension is supported
firmwareUrl?: string; // link to documentation page about upgrading firmware
disablesVariants?: string[]; // don't build these variants, when this extension is enabled
utf8?: boolean; // force compilation with UTF8 enabled
disableTargetTemplateFiles?: boolean; // do not override target template files when commiting to github
theme?: string | pxt.Map<string>;
assetPack?: boolean; // if set to true, only the assets of this project will be imported when added as an extension (no code)
assetPacks?: Map<boolean>; // a map of dependency id to boolean that indicates which dependencies should be imported as asset packs
}
interface PackageExtension {
// Namespace to add the button under, defaults to package name
namespace?: string;
// Group to place button in
group?: string;
// Label for the flyout button, defaults to `Editor`
label?: string;
// for new category, category color
color?: string;
// for new category, is category advanced
advanced?: boolean;
// trusted custom editor url, must be register in targetconfig.json under approvedEditorExtensionUrls
url?: string;
// local debugging URL used when served through pxt serve and debugExtensions=1 mode
localUrl?: string;
}
interface PlatformIOConfig {
dependencies?: Map<string>;
}
interface CompilationConfig {
description: string;
config: any;
}
interface CodalConfig {
libraries?: string[];
}
interface CodalJson {
}
interface YottaConfig {
dependencies?: Map<string>;
config?: any;
/**
* Overridable config flags
*/
optionalConfig?: any;
userConfigs?: CompilationConfig[];
/* deprecated */
configIsJustDefaults?: boolean;
/* deprecated */
ignoreConflicts?: boolean;
}
interface CodeCard {
name?: string;
shortName?: string;
title?: string;
role?: string;
ariaLabel?: string;
label?: string;
labelIcon?: string;
labelClass?: string;
tags?: string[]; // tags shown in home screen, colors specified in theme
tabIndex?: number;
style?: string; // "card" | "item" | undefined;
color?: string; // one of semantic ui colors
description?: string;
extracontent?: string;
blocksXml?: string;
typeScript?: string;
imageUrl?: string;
largeImageUrl?: string;
videoUrl?: string;
youTubeId?: string;
youTubePlaylistId?: string; // playlist this video belongs to
buttonLabel?: string;
actionIcon?: string; // icon to override default icon on the action button
time?: number;
url?: string;
learnMoreUrl?: string;
buyUrl?: string;
feedbackUrl?: string;
responsive?: boolean;
cardType?: CodeCardType;
editor?: CodeCardEditorType;
otherActions?: CodeCardAction[];
directOpen?: boolean; // skip the details view, directly do the card action
projectId?: string; // the project's header ID
header?: string;
tutorialStep?: number;
tutorialLength?: number;
icon?: string;
iconContent?: string; // Text instead of icon name
iconColor?: string;
onClick?: (e: any) => void; // React event
onLabelClicked?: (e: any) => void;
target?: string;
className?: string;
variant?: string;
}
interface JRes {
id: string; // something like "sounds.bark"
data: string;
dataEncoding?: string; // must be "base64" or missing (meaning the same)
icon?: string; // URL (usually data-URI) for the icon
namespace?: string; // used to construct id
mimeType: string;
displayName?: string;
tilemapTile?: boolean;
tileset?: string[];
tags?: string[];
}
type SnippetOutputType = 'blocks'
type SnippetOutputBehavior = /*assumed default*/'merge' | 'replace'
interface SnippetConfig {
name: string;
namespace: string;
group?: string;
label: string;
outputType: SnippetOutputType;
outputBehavior?: SnippetOutputBehavior;
initialOutput?: string;
questions: SnippetQuestions[];
}
type SnippetAnswerTypes = 'number' | 'text' | 'variableName' | 'dropdown' | 'spriteEditor' | 'yesno' | string; // TODO(jb) Should include custom answer types for number, enums, string, image
interface SnippetGoToOptions {
question?: number;
validate?: SnippetValidate;
parameters?: SnippetParameters[]; // Answer token with corresponding question
}
interface SnippetOutputOptions {
type: 'error' | 'hint';
output: string;
}
interface SnippetParameters {
token?: string;
answer?: string;
question: number;
}
interface SnippetInputAnswerSingular {
answerToken: string;
defaultAnswer: SnippetAnswerTypes;
}
interface SnippetInputAnswerPlural {
answerTokens: string[];
defaultAnswers: SnippetAnswerTypes[];
}
interface SnippetInputOtherType {
type: string;
}
interface SnippetInputNumberType {
type: 'number' | 'positionPicker';
max?: number;
min?: number;
}
interface SnippetInputDropdownType {
type: "dropdown";
options: pxt.Map<string>;
}
interface SnippetInputYesNoType {
type: "yesno";
}
type SnippetQuestionInput = { label?: string; }
& (SnippetInputAnswerSingular | SnippetInputAnswerPlural)
& (SnippetInputOtherType | SnippetInputNumberType | SnippetInputDropdownType | SnippetInputYesNoType)
interface SnippetValidateRegex {
token: string;
regex: string;
match?: SnippetParameters;
noMatch?: SnippetParameters;
}
interface SnippetValidate {
regex?: SnippetValidateRegex;
}
interface SnippetQuestions {
title: string;
output?: string;
outputConditionalOnAnswer?: string;
errorMessage?: string;
goto?: SnippetGoToOptions;
inputs: SnippetQuestionInput[];
hint?: string;
}
}