pxt-core 12.3.20 → 12.3.22
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/built/cli.js +2 -2
- package/built/pxt.js +262 -81
- package/built/pxtcompiler.d.ts +6 -0
- package/built/pxtcompiler.js +62 -17
- package/built/pxtlib.d.ts +11 -5
- package/built/pxtlib.js +198 -62
- package/built/target.js +1 -1
- package/built/targetlight.js +1 -1
- package/built/tests/blocksrunner.js +29 -9
- package/built/tests/blockssetup.js +29 -9
- package/built/web/main.js +2 -2
- package/built/web/pxtapp.js +1 -1
- package/built/web/pxtasseteditor.js +2 -2
- package/built/web/pxtcompiler.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/react-common-authcode.css +1 -1
- package/built/web/react-common-multiplayer.css +1 -1
- package/built/web/react-common-skillmap.css +1 -1
- package/built/web/rtlreact-common-authcode.css +1 -1
- package/built/web/rtlreact-common-multiplayer.css +1 -1
- package/built/web/rtlreact-common-skillmap.css +1 -1
- package/built/web/rtlsemantic.css +1 -1
- package/built/web/runnerembed.js +2 -2
- package/built/web/semantic.css +1 -1
- package/localtypings/pxtarget.d.ts +4 -0
- package/package.json +1 -1
- package/react-common/styles/react-common-variables.less +1 -1
- package/theme/errorList.less +38 -0
package/built/cli.js
CHANGED
|
@@ -215,8 +215,8 @@ class FileGithubDb {
|
|
|
215
215
|
loadConfigAsync(repopath, tag) {
|
|
216
216
|
return this.loadAsync(repopath, tag, "pxt", (r, t) => this.db.loadConfigAsync(r, t));
|
|
217
217
|
}
|
|
218
|
-
loadPackageAsync(repopath, tag) {
|
|
219
|
-
return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t));
|
|
218
|
+
loadPackageAsync(repopath, tag, fallbackPackageFiles) {
|
|
219
|
+
return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t, fallbackPackageFiles));
|
|
220
220
|
}
|
|
221
221
|
loadTutorialMarkdown(repopath, tag) {
|
|
222
222
|
return this.loadAsync(repopath, tag, "tutorial", (r, t) => this.db.loadTutorialMarkdown(r, t));
|
package/built/pxt.js
CHANGED
|
@@ -101957,6 +101957,7 @@ var pxt;
|
|
|
101957
101957
|
pxt.TUTORIAL_CODE_STOP = "_onCodeStop.ts";
|
|
101958
101958
|
pxt.TUTORIAL_INFO_FILE = "tutorial-info-cache.json";
|
|
101959
101959
|
pxt.TUTORIAL_CUSTOM_TS = "tutorial.custom.ts";
|
|
101960
|
+
pxt.PACKAGED_EXTENSIONS = "_packaged-extensions.json";
|
|
101960
101961
|
pxt.BREAKPOINT_TABLET = 991; // TODO (shakao) revisit when tutorial stuff is more settled
|
|
101961
101962
|
pxt.PALETTES_FILE = "_palettes.json";
|
|
101962
101963
|
pxt.HISTORY_FILE = "_history";
|
|
@@ -102003,6 +102004,30 @@ var pxt;
|
|
|
102003
102004
|
};
|
|
102004
102005
|
// Like MATH_FUNCTIONS, but used only for rounding operations
|
|
102005
102006
|
blocks.ROUNDING_FUNCTIONS = ["round", "ceil", "floor", "trunc"];
|
|
102007
|
+
function parameterDefaultLocalizationKey(qName, actualName) {
|
|
102008
|
+
return qName ? `${qName}|param|${actualName}|defl` : undefined;
|
|
102009
|
+
}
|
|
102010
|
+
blocks.parameterDefaultLocalizationKey = parameterDefaultLocalizationKey;
|
|
102011
|
+
function parameterDefaultToLocalizationString(defaultValue, type) {
|
|
102012
|
+
if (!defaultValue)
|
|
102013
|
+
return undefined;
|
|
102014
|
+
if (type === "string" && defaultValue.charAt(0) !== "\"")
|
|
102015
|
+
return defaultValue;
|
|
102016
|
+
if (defaultValue.charAt(0) !== "\"")
|
|
102017
|
+
return undefined;
|
|
102018
|
+
try {
|
|
102019
|
+
const value = JSON.parse(defaultValue);
|
|
102020
|
+
return typeof value === "string" ? value : undefined;
|
|
102021
|
+
}
|
|
102022
|
+
catch (e) {
|
|
102023
|
+
return undefined;
|
|
102024
|
+
}
|
|
102025
|
+
}
|
|
102026
|
+
blocks.parameterDefaultToLocalizationString = parameterDefaultToLocalizationString;
|
|
102027
|
+
function localizationStringToParameterDefault(value) {
|
|
102028
|
+
return JSON.stringify(value);
|
|
102029
|
+
}
|
|
102030
|
+
blocks.localizationStringToParameterDefault = localizationStringToParameterDefault;
|
|
102006
102031
|
// Information for blocks that compile to function calls but are defined by vanilla Blockly
|
|
102007
102032
|
// and not dynamically by BlocklyLoader
|
|
102008
102033
|
blocks.builtinFunctionInfo = {
|
|
@@ -105784,6 +105809,13 @@ int main() {
|
|
|
105784
105809
|
});
|
|
105785
105810
|
}
|
|
105786
105811
|
hexloader.recordGetAsync = recordGetAsync;
|
|
105812
|
+
function stringifyHexInfoForCache(hexInfo) {
|
|
105813
|
+
if (!(hexInfo === null || hexInfo === void 0 ? void 0 : hexInfo.hex))
|
|
105814
|
+
return undefined;
|
|
105815
|
+
const cachedMeta = Object.assign(Object.assign({}, hexInfo), { hex: compressHex(hexInfo.hex) });
|
|
105816
|
+
return JSON.stringify(cachedMeta);
|
|
105817
|
+
}
|
|
105818
|
+
hexloader.stringifyHexInfoForCache = stringifyHexInfoForCache;
|
|
105787
105819
|
function getHexInfoAsync(host, extInfo, cloudModule) {
|
|
105788
105820
|
if (!extInfo.sha)
|
|
105789
105821
|
return Promise.resolve(null);
|
|
@@ -105812,10 +105844,7 @@ int main() {
|
|
|
105812
105844
|
else {
|
|
105813
105845
|
return downloadHexInfoAsync(extInfo)
|
|
105814
105846
|
.then(meta => {
|
|
105815
|
-
let
|
|
105816
|
-
meta.hex = compressHex(meta.hex);
|
|
105817
|
-
let store = JSON.stringify(meta);
|
|
105818
|
-
meta.hex = origHex;
|
|
105847
|
+
let store = stringifyHexInfoForCache(meta);
|
|
105819
105848
|
return storeWithLimitAsync(host, "hex-keys", key, store)
|
|
105820
105849
|
.then(() => meta);
|
|
105821
105850
|
}).catch(e => {
|
|
@@ -108407,6 +108436,18 @@ var pxt;
|
|
|
108407
108436
|
}
|
|
108408
108437
|
github.shouldUseProxyForRepo = shouldUseProxyForRepo;
|
|
108409
108438
|
const isPrivateRepoCache = {};
|
|
108439
|
+
function copyCachedPackage(cachedPackage) {
|
|
108440
|
+
return {
|
|
108441
|
+
files: Object.assign({}, cachedPackage.files)
|
|
108442
|
+
};
|
|
108443
|
+
}
|
|
108444
|
+
function cachedPackageFromFallback(fallbackPackageFiles) {
|
|
108445
|
+
if (!fallbackPackageFiles)
|
|
108446
|
+
return undefined;
|
|
108447
|
+
return {
|
|
108448
|
+
files: Object.assign({}, fallbackPackageFiles)
|
|
108449
|
+
};
|
|
108450
|
+
}
|
|
108410
108451
|
function ghRequestAsync(options) {
|
|
108411
108452
|
var _a;
|
|
108412
108453
|
options.method = (_a = options.method) !== null && _a !== void 0 ? _a : "GET";
|
|
@@ -108518,7 +108559,7 @@ var pxt;
|
|
|
108518
108559
|
}
|
|
108519
108560
|
return resolved;
|
|
108520
108561
|
}
|
|
108521
|
-
async loadPackageAsync(repopath, tag) {
|
|
108562
|
+
async loadPackageAsync(repopath, tag, fallbackPackageFiles) {
|
|
108522
108563
|
if (!tag) {
|
|
108523
108564
|
pxt.debug(`load pkg: default to master branch`);
|
|
108524
108565
|
tag = "master";
|
|
@@ -108526,45 +108567,46 @@ var pxt;
|
|
|
108526
108567
|
// try using github proxy first
|
|
108527
108568
|
if (hasProxy()) {
|
|
108528
108569
|
try {
|
|
108529
|
-
return await this.proxyWithCdnLoadPackageAsync(repopath, tag).then(
|
|
108570
|
+
return await this.proxyWithCdnLoadPackageAsync(repopath, tag).then(copyCachedPackage);
|
|
108530
108571
|
}
|
|
108531
108572
|
catch (e) {
|
|
108532
108573
|
ghProxyHandleException(e);
|
|
108533
108574
|
}
|
|
108534
108575
|
}
|
|
108535
108576
|
// try using github apis
|
|
108536
|
-
return await this.githubLoadPackageAsync(repopath, tag);
|
|
108577
|
+
return await this.githubLoadPackageAsync(repopath, tag, fallbackPackageFiles);
|
|
108537
108578
|
}
|
|
108538
|
-
githubLoadPackageAsync(repopath, tag) {
|
|
108539
|
-
|
|
108540
|
-
|
|
108579
|
+
async githubLoadPackageAsync(repopath, tag, fallbackPackageFiles) {
|
|
108580
|
+
try {
|
|
108581
|
+
const sha = await tagToShaAsync(repopath, tag);
|
|
108541
108582
|
// cache lookup
|
|
108542
108583
|
const key = `${repopath}/${sha}`;
|
|
108543
108584
|
let res = this.packages[key];
|
|
108544
108585
|
if (res) {
|
|
108545
108586
|
pxt.debug(`github cache ${repopath}/${tag}/text`);
|
|
108546
|
-
return
|
|
108587
|
+
return copyCachedPackage(res);
|
|
108547
108588
|
}
|
|
108548
108589
|
// load and cache
|
|
108549
108590
|
pxt.log(`Downloading ${repopath}/${tag} -> ${sha}`);
|
|
108550
|
-
|
|
108551
|
-
|
|
108552
|
-
|
|
108553
|
-
|
|
108554
|
-
|
|
108555
|
-
|
|
108556
|
-
|
|
108557
|
-
|
|
108558
|
-
.then(text => {
|
|
108559
|
-
current.files[fn] = text;
|
|
108560
|
-
}))
|
|
108561
|
-
.then(() => {
|
|
108562
|
-
// cache!
|
|
108563
|
-
this.packages[key] = current;
|
|
108564
|
-
return pxt.U.clone(current);
|
|
108565
|
-
});
|
|
108591
|
+
const pkg = await downloadTextAsync(repopath, sha, pxt.CONFIG_NAME);
|
|
108592
|
+
const current = {
|
|
108593
|
+
files: {}
|
|
108594
|
+
};
|
|
108595
|
+
current.files[pxt.CONFIG_NAME] = pkg;
|
|
108596
|
+
const cfg = JSON.parse(pkg);
|
|
108597
|
+
await pxt.U.promiseMapAll(pxt.allPkgFiles(cfg).slice(1), async (fn) => {
|
|
108598
|
+
current.files[fn] = await downloadTextAsync(repopath, sha, fn);
|
|
108566
108599
|
});
|
|
108567
|
-
|
|
108600
|
+
// cache!
|
|
108601
|
+
this.packages[key] = current;
|
|
108602
|
+
return copyCachedPackage(current);
|
|
108603
|
+
}
|
|
108604
|
+
catch (e) {
|
|
108605
|
+
const fallbackPackage = cachedPackageFromFallback(fallbackPackageFiles);
|
|
108606
|
+
if (fallbackPackage)
|
|
108607
|
+
return fallbackPackage;
|
|
108608
|
+
throw e;
|
|
108609
|
+
}
|
|
108568
108610
|
}
|
|
108569
108611
|
async loadTutorialMarkdown(repopath, tag) {
|
|
108570
108612
|
repopath = normalizeTutorialPath(repopath);
|
|
@@ -108920,7 +108962,7 @@ var pxt;
|
|
|
108920
108962
|
return await github.db.loadConfigAsync(repopath, tag);
|
|
108921
108963
|
}
|
|
108922
108964
|
github.pkgConfigAsync = pkgConfigAsync;
|
|
108923
|
-
async function downloadPackageAsync(repoWithTag, config) {
|
|
108965
|
+
async function downloadPackageAsync(repoWithTag, config, fallbackPackageFiles) {
|
|
108924
108966
|
const p = parseRepoId(repoWithTag);
|
|
108925
108967
|
if (!p) {
|
|
108926
108968
|
pxt.log('Unknown GitHub syntax');
|
|
@@ -108933,9 +108975,17 @@ var pxt;
|
|
|
108933
108975
|
}
|
|
108934
108976
|
// always try to upgrade unbound versions
|
|
108935
108977
|
if (!p.tag) {
|
|
108936
|
-
|
|
108978
|
+
try {
|
|
108979
|
+
p.tag = await github.db.latestVersionAsync(p.slug, config);
|
|
108980
|
+
}
|
|
108981
|
+
catch (e) {
|
|
108982
|
+
const fallbackPackage = cachedPackageFromFallback(fallbackPackageFiles);
|
|
108983
|
+
if (fallbackPackage)
|
|
108984
|
+
return fallbackPackage;
|
|
108985
|
+
throw e;
|
|
108986
|
+
}
|
|
108937
108987
|
}
|
|
108938
|
-
const cached = await github.db.loadPackageAsync(p.fullName, p.tag);
|
|
108988
|
+
const cached = await github.db.loadPackageAsync(p.fullName, p.tag, fallbackPackageFiles);
|
|
108939
108989
|
const dv = upgradedDisablesVariants(config, repoWithTag);
|
|
108940
108990
|
if (dv) {
|
|
108941
108991
|
const cfg = pxt.Package.parseAndValidConfig(cached.files[pxt.CONFIG_NAME]);
|
|
@@ -108960,7 +109010,11 @@ var pxt;
|
|
|
108960
109010
|
return { version, config };
|
|
108961
109011
|
}
|
|
108962
109012
|
github.downloadLatestPackageAsync = downloadLatestPackageAsync;
|
|
108963
|
-
async function cacheProjectDependenciesAsync(cfg) {
|
|
109013
|
+
async function cacheProjectDependenciesAsync(cfg, fallbackPackageFilesById) {
|
|
109014
|
+
await cacheProjectDependenciesCoreAsync(cfg, {}, fallbackPackageFilesById);
|
|
109015
|
+
}
|
|
109016
|
+
github.cacheProjectDependenciesAsync = cacheProjectDependenciesAsync;
|
|
109017
|
+
async function cacheProjectDependenciesCoreAsync(cfg, checked, fallbackPackageFilesById) {
|
|
108964
109018
|
var _a;
|
|
108965
109019
|
const ghExtensions = (_a = Object.keys(cfg.dependencies)) === null || _a === void 0 ? void 0 : _a.filter(dep => isGithubId(cfg.dependencies[dep]));
|
|
108966
109020
|
if (ghExtensions.length) {
|
|
@@ -108968,14 +109022,19 @@ var pxt;
|
|
|
108968
109022
|
// Make sure external packages load before installing header.
|
|
108969
109023
|
await Promise.all(ghExtensions.map(async (ext) => {
|
|
108970
109024
|
const extSrc = cfg.dependencies[ext];
|
|
108971
|
-
|
|
109025
|
+
if (checked[extSrc])
|
|
109026
|
+
return;
|
|
109027
|
+
checked[extSrc] = true;
|
|
109028
|
+
const ghPkg = await downloadPackageAsync(extSrc, pkgConfig, fallbackPackageFilesById === null || fallbackPackageFilesById === void 0 ? void 0 : fallbackPackageFilesById[extSrc]);
|
|
108972
109029
|
if (!ghPkg) {
|
|
108973
109030
|
throw new Error(lf("Cannot load extension {0} from {1}", ext, extSrc));
|
|
108974
109031
|
}
|
|
109032
|
+
const ghPkgCfg = pxt.Package.parseAndValidConfig(ghPkg.files[pxt.CONFIG_NAME]);
|
|
109033
|
+
if (ghPkgCfg)
|
|
109034
|
+
await cacheProjectDependenciesCoreAsync(ghPkgCfg, checked, fallbackPackageFilesById);
|
|
108975
109035
|
}));
|
|
108976
109036
|
}
|
|
108977
109037
|
}
|
|
108978
|
-
github.cacheProjectDependenciesAsync = cacheProjectDependenciesAsync;
|
|
108979
109038
|
let GitRepoStatus;
|
|
108980
109039
|
(function (GitRepoStatus) {
|
|
108981
109040
|
GitRepoStatus[GitRepoStatus["Unknown"] = 0] = "Unknown";
|
|
@@ -115025,7 +115084,7 @@ var pxt;
|
|
|
115025
115084
|
this.config.binaryonly ||
|
|
115026
115085
|
!opts.target.isNative;
|
|
115027
115086
|
if (!noFileEmbed) {
|
|
115028
|
-
const files = await this.filesToBePublishedAsync(true);
|
|
115087
|
+
const files = await this.filesToBePublishedAsync(true, !pxt.appTarget.compile.useUF2);
|
|
115029
115088
|
const headerString = JSON.stringify({
|
|
115030
115089
|
name: this.config.name,
|
|
115031
115090
|
comment: this.config.description,
|
|
@@ -115097,25 +115156,61 @@ var pxt;
|
|
|
115097
115156
|
cfg.files = cfg.files.filter(fn => fn !== pxt.HISTORY_FILE);
|
|
115098
115157
|
return cfg;
|
|
115099
115158
|
}
|
|
115100
|
-
filesToBePublishedAsync(allowPrivate = false) {
|
|
115159
|
+
async filesToBePublishedAsync(allowPrivate = false, packExternalExtensions = false) {
|
|
115101
115160
|
const files = {};
|
|
115102
|
-
|
|
115103
|
-
|
|
115104
|
-
|
|
115105
|
-
|
|
115106
|
-
|
|
115107
|
-
|
|
115108
|
-
|
|
115109
|
-
|
|
115110
|
-
|
|
115161
|
+
await this.loadAsync();
|
|
115162
|
+
if (!allowPrivate && !this.config.public)
|
|
115163
|
+
pxt.U.userError('Only packages with "public":true can be published');
|
|
115164
|
+
const cfg = this.prepareConfigToBePublished();
|
|
115165
|
+
files[pxt.CONFIG_NAME] = pxt.Package.stringifyConfig(cfg);
|
|
115166
|
+
for (let f of this.getFiles()) {
|
|
115167
|
+
// already stored
|
|
115168
|
+
if (f === pxt.CONFIG_NAME || f === pxt.HISTORY_FILE)
|
|
115169
|
+
continue;
|
|
115170
|
+
let str = this.readFile(f);
|
|
115171
|
+
if (str == null)
|
|
115172
|
+
pxt.U.userError("referenced file missing: " + f);
|
|
115173
|
+
files[f] = str;
|
|
115174
|
+
}
|
|
115175
|
+
if (packExternalExtensions) {
|
|
115176
|
+
const packagedExtensions = this.packagedExternalExtensions();
|
|
115177
|
+
if (Object.keys(packagedExtensions).length)
|
|
115178
|
+
files[pxt.PACKAGED_EXTENSIONS] = JSON.stringify(packagedExtensions);
|
|
115179
|
+
}
|
|
115180
|
+
return pxt.U.sortObjectFields(files);
|
|
115181
|
+
}
|
|
115182
|
+
packagedExternalExtensions() {
|
|
115183
|
+
const packaged = {};
|
|
115184
|
+
const seen = {};
|
|
115185
|
+
const packDeps = (pkg) => {
|
|
115186
|
+
for (const dep of pkg.resolvedDependencies()) {
|
|
115187
|
+
if (!dep)
|
|
115111
115188
|
continue;
|
|
115112
|
-
|
|
115113
|
-
if (
|
|
115114
|
-
|
|
115115
|
-
|
|
115189
|
+
const seenKey = `${dep.id}:${dep.version()}`;
|
|
115190
|
+
if (seen[seenKey])
|
|
115191
|
+
continue;
|
|
115192
|
+
seen[seenKey] = true;
|
|
115193
|
+
if (dep.verProtocol() === "github" || dep.verProtocol() === "pub") {
|
|
115194
|
+
const depFiles = {};
|
|
115195
|
+
for (const fn of dep.getFiles()) {
|
|
115196
|
+
if (fn === pxt.CONFIG_NAME || fn === pxt.HISTORY_FILE)
|
|
115197
|
+
continue;
|
|
115198
|
+
const content = dep.readFile(fn);
|
|
115199
|
+
if (content != null)
|
|
115200
|
+
depFiles[fn] = content;
|
|
115201
|
+
}
|
|
115202
|
+
depFiles[pxt.CONFIG_NAME] = pxt.Package.stringifyConfig(dep.config);
|
|
115203
|
+
packaged[dep._verspec] = depFiles;
|
|
115204
|
+
if (dep.version() !== dep._verspec)
|
|
115205
|
+
packaged[dep.version()] = depFiles;
|
|
115206
|
+
if (dep.verProtocol() === "pub")
|
|
115207
|
+
packaged[dep.verArgument()] = depFiles;
|
|
115208
|
+
}
|
|
115209
|
+
packDeps(dep);
|
|
115116
115210
|
}
|
|
115117
|
-
|
|
115118
|
-
|
|
115211
|
+
};
|
|
115212
|
+
packDeps(this);
|
|
115213
|
+
return packaged;
|
|
115119
115214
|
}
|
|
115120
115215
|
saveToJsonAsync() {
|
|
115121
115216
|
return this.filesToBePublishedAsync(true)
|
|
@@ -116060,18 +116155,25 @@ var ts;
|
|
|
116060
116155
|
const langLower = lang.toLowerCase();
|
|
116061
116156
|
const attrJsLocsKey = langLower + "|jsdoc";
|
|
116062
116157
|
const attrBlockLocsKey = langLower + "|block";
|
|
116158
|
+
const attrAriaLabelLocsKey = langLower + "|ariaLabel";
|
|
116063
116159
|
const loc = await mainPkg.localizationStringsAsync(lang);
|
|
116064
116160
|
if (pxtc.apiLocalizationStrings)
|
|
116065
116161
|
pxtc.Util.jsonMergeFrom(loc, pxtc.apiLocalizationStrings);
|
|
116066
116162
|
const toLocalize = pxtc.Util.values(apis.byQName).filter(fn => fn.attributes._translatedLanguageCode !== lang);
|
|
116067
116163
|
await pxtc.Util.promiseMapAll(toLocalize, async (fn) => {
|
|
116068
|
-
var _a, _b, _c;
|
|
116164
|
+
var _a, _b, _c, _d;
|
|
116069
116165
|
const altLocSrc = fn.attributes.useLoc || fn.attributes.blockAliasFor;
|
|
116070
116166
|
const altLocSrcFn = altLocSrc && apis.byQName[altLocSrc];
|
|
116071
116167
|
if (fn.attributes._untranslatedJsDoc)
|
|
116072
116168
|
fn.attributes.jsDoc = fn.attributes._untranslatedJsDoc;
|
|
116073
116169
|
if (fn.attributes._untranslatedBlock)
|
|
116074
|
-
fn.attributes.
|
|
116170
|
+
fn.attributes.block = fn.attributes._untranslatedBlock;
|
|
116171
|
+
if (fn.attributes._untranslatedAriaLabel)
|
|
116172
|
+
fn.attributes.ariaLabel = fn.attributes._untranslatedAriaLabel;
|
|
116173
|
+
if (fn.attributes._untranslatedParamDefl) {
|
|
116174
|
+
fn.attributes.paramDefl = pxtc.U.clone(fn.attributes._untranslatedParamDefl);
|
|
116175
|
+
syncParameterDefaults(fn);
|
|
116176
|
+
}
|
|
116075
116177
|
const lookupLoc = (locSuff, attrKey) => {
|
|
116076
116178
|
var _a, _b;
|
|
116077
116179
|
return loc[fn.qName + locSuff] || ((_a = fn.attributes.locs) === null || _a === void 0 ? void 0 : _a[attrKey])
|
|
@@ -116093,6 +116195,7 @@ var ts;
|
|
|
116093
116195
|
});
|
|
116094
116196
|
const nsDoc = loc['{id:category}' + pxtc.Util.capitalize(fn.qName)];
|
|
116095
116197
|
let locBlock = loc[`${fn.qName}|block`] || ((_b = fn.attributes.locs) === null || _b === void 0 ? void 0 : _b[attrBlockLocsKey]);
|
|
116198
|
+
const locAriaLabel = loc[`${fn.qName}|ariaLabel`] || ((_c = fn.attributes.locs) === null || _c === void 0 ? void 0 : _c[attrAriaLabelLocsKey]);
|
|
116096
116199
|
if (fn.attributes.block) {
|
|
116097
116200
|
const comp = pxt.blocks.compileInfo(fn);
|
|
116098
116201
|
if (comp.handlerArgs) {
|
|
@@ -116107,20 +116210,35 @@ var ts;
|
|
|
116107
116210
|
}
|
|
116108
116211
|
const paramsWithLabels = comp.thisParameter ? [comp.thisParameter, ...comp.parameters] : comp.parameters;
|
|
116109
116212
|
for (const param of paramsWithLabels) {
|
|
116110
|
-
if (
|
|
116111
|
-
|
|
116112
|
-
|
|
116113
|
-
|
|
116114
|
-
|
|
116115
|
-
|
|
116213
|
+
if (param.labelLocalizationKey) {
|
|
116214
|
+
const locSuff = param.labelLocalizationKey.slice(fn.qName.length);
|
|
116215
|
+
const paramLabel = lookupLoc(locSuff, langLower + locSuff);
|
|
116216
|
+
if (paramLabel) {
|
|
116217
|
+
setBlockTranslationCacheKey(param.labelLocalizationKey, paramLabel);
|
|
116218
|
+
}
|
|
116219
|
+
else {
|
|
116220
|
+
clearBlockTranslationCacheKey(param.labelLocalizationKey);
|
|
116221
|
+
}
|
|
116116
116222
|
}
|
|
116117
|
-
|
|
116118
|
-
|
|
116223
|
+
const defaultString = pxt.blocks.parameterDefaultToLocalizationString(param.defaultValue, param.type);
|
|
116224
|
+
const defaultLocalizationKey = pxt.blocks.parameterDefaultLocalizationKey(fn.qName, param.actualName);
|
|
116225
|
+
if (defaultLocalizationKey && defaultString !== undefined) {
|
|
116226
|
+
const locSuff = defaultLocalizationKey.slice(fn.qName.length);
|
|
116227
|
+
const paramDefault = lookupLoc(locSuff, langLower + locSuff);
|
|
116228
|
+
if (paramDefault !== undefined) {
|
|
116229
|
+
if (!fn.attributes._untranslatedParamDefl) {
|
|
116230
|
+
fn.attributes._untranslatedParamDefl = pxtc.U.clone(fn.attributes.paramDefl || {});
|
|
116231
|
+
}
|
|
116232
|
+
if (!fn.attributes.paramDefl)
|
|
116233
|
+
fn.attributes.paramDefl = {};
|
|
116234
|
+
fn.attributes.paramDefl[param.actualName] = pxt.blocks.localizationStringToParameterDefault(paramDefault);
|
|
116235
|
+
syncParameterDefaults(fn);
|
|
116236
|
+
}
|
|
116119
116237
|
}
|
|
116120
116238
|
}
|
|
116121
116239
|
}
|
|
116122
116240
|
if (!locBlock && altLocSrcFn) {
|
|
116123
|
-
const otherTranslation = loc[`${altLocSrcFn.qName}|block`] || ((
|
|
116241
|
+
const otherTranslation = loc[`${altLocSrcFn.qName}|block`] || ((_d = altLocSrcFn.attributes.locs) === null || _d === void 0 ? void 0 : _d[attrBlockLocsKey]);
|
|
116124
116242
|
const isSameBlockDef = fn.attributes.block === (altLocSrcFn.attributes._untranslatedBlock || altLocSrcFn.attributes.block);
|
|
116125
116243
|
if (isSameBlockDef && !!otherTranslation) {
|
|
116126
116244
|
locBlock = otherTranslation;
|
|
@@ -116177,11 +116295,24 @@ var ts;
|
|
|
116177
116295
|
else {
|
|
116178
116296
|
updateBlockDef(fn.attributes);
|
|
116179
116297
|
}
|
|
116298
|
+
if (locAriaLabel) {
|
|
116299
|
+
if (!fn.attributes._untranslatedAriaLabel) {
|
|
116300
|
+
fn.attributes._untranslatedAriaLabel = fn.attributes.ariaLabel;
|
|
116301
|
+
}
|
|
116302
|
+
fn.attributes.ariaLabel = locAriaLabel;
|
|
116303
|
+
}
|
|
116180
116304
|
fn.attributes._translatedLanguageCode = lang;
|
|
116181
116305
|
});
|
|
116182
116306
|
return cleanLocalizations(apis);
|
|
116183
116307
|
}
|
|
116184
116308
|
pxtc.localizeApisAsync = localizeApisAsync;
|
|
116309
|
+
function syncParameterDefaults(fn) {
|
|
116310
|
+
if (!fn.parameters)
|
|
116311
|
+
return;
|
|
116312
|
+
for (const param of fn.parameters) {
|
|
116313
|
+
param.default = fn.attributes.paramDefl && fn.attributes.paramDefl[param.name];
|
|
116314
|
+
}
|
|
116315
|
+
}
|
|
116185
116316
|
function cleanLocalizations(apis) {
|
|
116186
116317
|
pxtc.Util.values(apis.byQName)
|
|
116187
116318
|
.filter(fb => fb.attributes.block && /^{[^:]+:[^}]+}/.test(fb.attributes.block))
|
|
@@ -116305,6 +116436,11 @@ var ts;
|
|
|
116305
116436
|
res.locs = {};
|
|
116306
116437
|
res.locs[n.slice("jsdoc.loc.".length).toLowerCase() + "|jsdoc"] = v;
|
|
116307
116438
|
}
|
|
116439
|
+
else if (pxtc.U.startsWith(n, "ariaLabel.loc.")) {
|
|
116440
|
+
if (!res.locs)
|
|
116441
|
+
res.locs = {};
|
|
116442
|
+
res.locs[n.slice("ariaLabel.loc.".length).toLowerCase() + "|ariaLabel"] = v;
|
|
116443
|
+
}
|
|
116308
116444
|
else if (pxtc.U.contains(n, ".loc.")) {
|
|
116309
116445
|
if (!res.locs)
|
|
116310
116446
|
res.locs = {};
|
|
@@ -124727,8 +124863,8 @@ var pxt;
|
|
|
124727
124863
|
loadConfigAsync(repopath, tag) {
|
|
124728
124864
|
return this.loadAsync(repopath, tag, "pxt", (r, t) => this.db.loadConfigAsync(r, t));
|
|
124729
124865
|
}
|
|
124730
|
-
loadPackageAsync(repopath, tag) {
|
|
124731
|
-
return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t));
|
|
124866
|
+
loadPackageAsync(repopath, tag, fallbackPackageFiles) {
|
|
124867
|
+
return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t, fallbackPackageFiles));
|
|
124732
124868
|
}
|
|
124733
124869
|
loadTutorialMarkdown(repopath, tag) {
|
|
124734
124870
|
return this.loadAsync(repopath, tag, "tutorial", (r, t) => this.db.loadTutorialMarkdown(r, t));
|
|
@@ -133951,7 +134087,7 @@ var ts;
|
|
|
133951
134087
|
function inspect(n) {
|
|
133952
134088
|
pxt.log(stringKind(n));
|
|
133953
134089
|
}
|
|
133954
|
-
// next free error
|
|
134090
|
+
// next free error 9285
|
|
133955
134091
|
function userError(code, msg, secondary = false) {
|
|
133956
134092
|
let e = new Error(msg);
|
|
133957
134093
|
e.ksEmitterUserError = true;
|
|
@@ -137656,9 +137792,35 @@ ${lbl}: .short 0xffff
|
|
|
137656
137792
|
let v = emitExpr(node);
|
|
137657
137793
|
return v;
|
|
137658
137794
|
}
|
|
137795
|
+
function maybeWarnOnBareFunctionReference(node) {
|
|
137796
|
+
if (!opts.enhancedErrors)
|
|
137797
|
+
return;
|
|
137798
|
+
if (!node || node.kind !== pxtc.SK.Identifier)
|
|
137799
|
+
return;
|
|
137800
|
+
if (hasPrecedingTsIgnoreComment(node))
|
|
137801
|
+
return;
|
|
137802
|
+
const exprType = typeOf(node);
|
|
137803
|
+
const signatures = exprType && !(exprType.flags & ts.TypeFlags.Any)
|
|
137804
|
+
&& checker.getSignaturesOfType(exprType, ts.SignatureKind.Call);
|
|
137805
|
+
if (signatures && signatures.length)
|
|
137806
|
+
warning(node, 9284, lf("Function reference used as a statement; did you mean to call it with '()'?"));
|
|
137807
|
+
}
|
|
137808
|
+
function hasPrecedingTsIgnoreComment(node) {
|
|
137809
|
+
const src = node.getSourceFile();
|
|
137810
|
+
const line = ts.getLineAndCharacterOfPosition(src, node.getStart(src)).line;
|
|
137811
|
+
if (line <= 0)
|
|
137812
|
+
return false;
|
|
137813
|
+
const lineStarts = src.getLineStarts();
|
|
137814
|
+
const previousLineStart = lineStarts[line - 1];
|
|
137815
|
+
const previousLineEnd = lineStarts[line];
|
|
137816
|
+
const previousLine = src.text.slice(previousLineStart, previousLineEnd);
|
|
137817
|
+
return /^\s*\/\/\s*@ts-ignore\b/.test(previousLine);
|
|
137818
|
+
}
|
|
137659
137819
|
function emitExprAsStmt(node) {
|
|
137660
|
-
if (isNoopExpr(node))
|
|
137820
|
+
if (isNoopExpr(node)) {
|
|
137821
|
+
maybeWarnOnBareFunctionReference(node);
|
|
137661
137822
|
return;
|
|
137823
|
+
}
|
|
137662
137824
|
emitBrk(node);
|
|
137663
137825
|
let v = emitIgnored(node);
|
|
137664
137826
|
proc.emitExpr(v);
|
|
@@ -138640,6 +138802,14 @@ var ts;
|
|
|
138640
138802
|
});
|
|
138641
138803
|
}
|
|
138642
138804
|
pxtc.patchUpDiagnostics = patchUpDiagnostics;
|
|
138805
|
+
function hasErrorDiagnostics(diags) {
|
|
138806
|
+
return diags.some(d => d.category == pxtc.DiagnosticCategory.Error);
|
|
138807
|
+
}
|
|
138808
|
+
pxtc.hasErrorDiagnostics = hasErrorDiagnostics;
|
|
138809
|
+
function hasBlockingDiagnostics(opts, diags) {
|
|
138810
|
+
return opts.enhancedErrors ? hasErrorDiagnostics(diags) : diags.length > 0;
|
|
138811
|
+
}
|
|
138812
|
+
pxtc.hasBlockingDiagnostics = hasBlockingDiagnostics;
|
|
138643
138813
|
function py2tsIfNecessary(opts) {
|
|
138644
138814
|
if (opts.target.preferredEditor == pxt.PYTHON_PROJECT_NAME) {
|
|
138645
138815
|
let res = pxtc.transpile.pyToTs(opts);
|
|
@@ -138766,26 +138936,26 @@ var ts;
|
|
|
138766
138936
|
}
|
|
138767
138937
|
else {
|
|
138768
138938
|
runConversionsAndStoreResults(opts, res);
|
|
138769
|
-
if (res.diagnostics
|
|
138939
|
+
if (hasBlockingDiagnostics(opts, res.diagnostics))
|
|
138770
138940
|
return res;
|
|
138771
138941
|
program = buildProgram(opts, res);
|
|
138772
138942
|
}
|
|
138773
138943
|
const entryPoint = opts.sourceFiles.filter(f => pxtc.U.endsWith(f, ".ts")).pop().replace(/.*\//, "");
|
|
138774
138944
|
// First get and report any syntactic errors.
|
|
138775
|
-
res.diagnostics = patchUpDiagnostics(program.getSyntacticDiagnostics(), opts.ignoreFileResolutionErrors);
|
|
138776
|
-
if (res.diagnostics
|
|
138945
|
+
res.diagnostics = res.diagnostics.concat(patchUpDiagnostics(program.getSyntacticDiagnostics(), opts.ignoreFileResolutionErrors));
|
|
138946
|
+
if (hasBlockingDiagnostics(opts, res.diagnostics)) {
|
|
138777
138947
|
if (opts.forceEmit) {
|
|
138778
138948
|
pxt.debug('syntactic errors, forcing emit');
|
|
138779
138949
|
pxtc.compileBinary(program, opts, res, entryPoint);
|
|
138780
138950
|
}
|
|
138781
138951
|
return res;
|
|
138782
138952
|
}
|
|
138783
|
-
// If we didn't have any syntactic errors, then also try getting the global and
|
|
138953
|
+
// If we didn't have any blocking syntactic errors, then also try getting the global and
|
|
138784
138954
|
// semantic errors.
|
|
138785
|
-
res.diagnostics = patchUpDiagnostics(program.getOptionsDiagnostics().concat(pxtc.Util.toArray(program.getGlobalDiagnostics())), opts.ignoreFileResolutionErrors);
|
|
138955
|
+
res.diagnostics = res.diagnostics.concat(patchUpDiagnostics(program.getOptionsDiagnostics().concat(pxtc.Util.toArray(program.getGlobalDiagnostics())), opts.ignoreFileResolutionErrors));
|
|
138786
138956
|
const semStart = pxtc.U.cpuUs();
|
|
138787
|
-
if (res.diagnostics
|
|
138788
|
-
res.diagnostics = patchUpDiagnostics(program.getSemanticDiagnostics(), opts.ignoreFileResolutionErrors);
|
|
138957
|
+
if (!hasBlockingDiagnostics(opts, res.diagnostics)) {
|
|
138958
|
+
res.diagnostics = res.diagnostics.concat(patchUpDiagnostics(program.getSemanticDiagnostics(), opts.ignoreFileResolutionErrors));
|
|
138789
138959
|
}
|
|
138790
138960
|
const emitStart = pxtc.U.cpuUs();
|
|
138791
138961
|
res.times["typescript-syn"] = semStart - startTime;
|
|
@@ -138794,12 +138964,12 @@ var ts;
|
|
|
138794
138964
|
if (opts.ast) {
|
|
138795
138965
|
res.ast = program;
|
|
138796
138966
|
}
|
|
138797
|
-
if (opts.ast || opts.forceEmit || res.diagnostics
|
|
138967
|
+
if (opts.ast || opts.forceEmit || !hasBlockingDiagnostics(opts, res.diagnostics)) {
|
|
138798
138968
|
const binOutput = pxtc.compileBinary(program, opts, res, entryPoint);
|
|
138799
138969
|
res.times["compilebinary"] = pxtc.U.cpuUs() - emitStart;
|
|
138800
138970
|
res.diagnostics = res.diagnostics.concat(patchUpDiagnostics(binOutput.diagnostics));
|
|
138801
138971
|
}
|
|
138802
|
-
if (res.diagnostics
|
|
138972
|
+
if (!hasBlockingDiagnostics(opts, res.diagnostics))
|
|
138803
138973
|
res.success = true;
|
|
138804
138974
|
for (let f of opts.sourceFiles) {
|
|
138805
138975
|
if (pxtc.Util.startsWith(f, "built/"))
|
|
@@ -142580,6 +142750,11 @@ var ts;
|
|
|
142580
142750
|
if (param.labelLocalizationKey && param.label) {
|
|
142581
142751
|
locStrings[param.labelLocalizationKey] = param.label;
|
|
142582
142752
|
}
|
|
142753
|
+
const defaultString = pxt.blocks.parameterDefaultToLocalizationString(param.defaultValue, param.type);
|
|
142754
|
+
const defaultLocalizationKey = pxt.blocks.parameterDefaultLocalizationKey(si.qName, param.actualName);
|
|
142755
|
+
if (defaultLocalizationKey && defaultString !== undefined) {
|
|
142756
|
+
locStrings[defaultLocalizationKey] = defaultString;
|
|
142757
|
+
}
|
|
142583
142758
|
}
|
|
142584
142759
|
if ((_a = comp.handlerArgs) === null || _a === void 0 ? void 0 : _a.length) {
|
|
142585
142760
|
for (const arg of comp.handlerArgs) {
|
|
@@ -142587,6 +142762,9 @@ var ts;
|
|
|
142587
142762
|
}
|
|
142588
142763
|
}
|
|
142589
142764
|
}
|
|
142765
|
+
if (si.attributes.ariaLabel) {
|
|
142766
|
+
locStrings[`${si.qName}|ariaLabel`] = si.attributes.ariaLabel;
|
|
142767
|
+
}
|
|
142590
142768
|
};
|
|
142591
142769
|
const mapLocs = (m, name) => {
|
|
142592
142770
|
if (!options.locs)
|
|
@@ -142609,6 +142787,8 @@ var ts;
|
|
|
142609
142787
|
enumMembers.forEach(em => {
|
|
142610
142788
|
if (em.attributes.block)
|
|
142611
142789
|
locStrings[`${em.qName}|block`] = em.attributes.block;
|
|
142790
|
+
if (em.attributes.ariaLabel)
|
|
142791
|
+
locStrings[`${em.qName}|ariaLabel`] = em.attributes.ariaLabel;
|
|
142612
142792
|
if (em.attributes.jsDoc)
|
|
142613
142793
|
locStrings[em.qName] = em.attributes.jsDoc;
|
|
142614
142794
|
});
|
|
@@ -143519,7 +143699,8 @@ var ts;
|
|
|
143519
143699
|
for (let k of Object.keys(newFS))
|
|
143520
143700
|
service_1.host.setFile(k, newFS[k]); // update version numbers
|
|
143521
143701
|
res.fileSystem = pxtc.U.flatClone(newFS);
|
|
143522
|
-
if (res.diagnostics
|
|
143702
|
+
if (!pxtc.hasBlockingDiagnostics(service_1.host.opts, res.diagnostics)) {
|
|
143703
|
+
const conversionDiagnostics = res.diagnostics;
|
|
143523
143704
|
service_1.host.opts.skipPxtModulesEmit = false;
|
|
143524
143705
|
service_1.host.opts.skipPxtModulesTSC = false;
|
|
143525
143706
|
const currKey = service_1.host.opts.target.isNative ? "native" : "js";
|
|
@@ -143534,13 +143715,13 @@ var ts;
|
|
|
143534
143715
|
service_1.host.opts.skipPxtModulesEmit = true;
|
|
143535
143716
|
}
|
|
143536
143717
|
let ts2asm = pxtc.compile(service_1.host.opts, service_1.service);
|
|
143537
|
-
res = Object.assign({ sourceMap: res.sourceMap, fileSystem: res.fileSystem }, ts2asm);
|
|
143538
|
-
if (res.needsFullRecompile || ((!res.success || res.diagnostics
|
|
143718
|
+
res = Object.assign(Object.assign({ sourceMap: res.sourceMap, fileSystem: res.fileSystem }, ts2asm), { diagnostics: conversionDiagnostics.concat(ts2asm.diagnostics) });
|
|
143719
|
+
if (res.needsFullRecompile || ((!res.success || pxtc.hasBlockingDiagnostics(service_1.host.opts, res.diagnostics)) && service_1.host.opts.clearIncrBuildAndRetryOnError)) {
|
|
143539
143720
|
pxt.debug("triggering full recompile");
|
|
143540
143721
|
pxt.tickEvent("compile.fullrecompile");
|
|
143541
143722
|
service_1.host.opts.skipPxtModulesEmit = false;
|
|
143542
143723
|
ts2asm = pxtc.compile(service_1.host.opts, service_1.service);
|
|
143543
|
-
res = Object.assign({ sourceMap: res.sourceMap }, ts2asm);
|
|
143724
|
+
res = Object.assign(Object.assign({ sourceMap: res.sourceMap }, ts2asm), { diagnostics: conversionDiagnostics.concat(ts2asm.diagnostics) });
|
|
143544
143725
|
}
|
|
143545
143726
|
if (res.diagnostics.every(d => !pxtc.isPxtModulesFilename(d.fileName)))
|
|
143546
143727
|
service_1.host.pxtModulesOK = currKey;
|
|
@@ -164195,8 +164376,8 @@ class FileGithubDb {
|
|
|
164195
164376
|
loadConfigAsync(repopath, tag) {
|
|
164196
164377
|
return this.loadAsync(repopath, tag, "pxt", (r, t) => this.db.loadConfigAsync(r, t));
|
|
164197
164378
|
}
|
|
164198
|
-
loadPackageAsync(repopath, tag) {
|
|
164199
|
-
return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t));
|
|
164379
|
+
loadPackageAsync(repopath, tag, fallbackPackageFiles) {
|
|
164380
|
+
return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t, fallbackPackageFiles));
|
|
164200
164381
|
}
|
|
164201
164382
|
loadTutorialMarkdown(repopath, tag) {
|
|
164202
164383
|
return this.loadAsync(repopath, tag, "tutorial", (r, t) => this.db.loadTutorialMarkdown(r, t));
|
package/built/pxtcompiler.d.ts
CHANGED
|
@@ -753,6 +753,12 @@ declare namespace ts.pxtc {
|
|
|
753
753
|
function getTsCompilerOptions(opts: CompileOptions): any;
|
|
754
754
|
function nodeLocationInfo(node: ts.Node): LocationInfo;
|
|
755
755
|
function patchUpDiagnostics(diags: ReadonlyArray<Diagnostic>, ignoreFileResolutionErorrs?: boolean): KsDiagnostic[];
|
|
756
|
+
function hasErrorDiagnostics(diags: ReadonlyArray<{
|
|
757
|
+
category: DiagnosticCategory;
|
|
758
|
+
}>): boolean;
|
|
759
|
+
function hasBlockingDiagnostics(opts: CompileOptions, diags: ReadonlyArray<{
|
|
760
|
+
category: DiagnosticCategory;
|
|
761
|
+
}>): boolean;
|
|
756
762
|
function py2tsIfNecessary(opts: CompileOptions): transpile.TranspileResult | undefined;
|
|
757
763
|
function storeGeneratedFiles(opts: CompileOptions, res: CompileResult): void;
|
|
758
764
|
function runConversionsAndStoreResults(opts: CompileOptions, res?: CompileResult): CompileResult;
|