pxt-core 12.3.20 → 12.3.21
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 +213 -63
- package/built/pxtcompiler.js +7 -2
- package/built/pxtlib.d.ts +14 -5
- package/built/pxtlib.js +204 -59
- package/built/target.js +1 -1
- package/built/targetlight.js +1 -1
- package/built/tests/blocksrunner.js +19 -8
- package/built/tests/blockssetup.js +19 -8
- package/built/web/main.js +2 -2
- package/built/web/pxtapp.js +1 -1
- package/built/web/pxtasseteditor.js +1 -1
- package/built/web/pxtcompiler.js +1 -1
- package/built/web/pxtembed.js +1 -1
- 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 +1 -1
- package/built/web/semantic.css +1 -1
- package/localtypings/pxtarget.d.ts +1 -0
- package/package.json +1 -1
- package/react-common/styles/react-common-variables.less +1 -1
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,8 @@ 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";
|
|
101961
|
+
pxt.PACKAGED_EXT_INFO = "_packaged-ext-info.json";
|
|
101960
101962
|
pxt.BREAKPOINT_TABLET = 991; // TODO (shakao) revisit when tutorial stuff is more settled
|
|
101961
101963
|
pxt.PALETTES_FILE = "_palettes.json";
|
|
101962
101964
|
pxt.HISTORY_FILE = "_history";
|
|
@@ -102003,6 +102005,30 @@ var pxt;
|
|
|
102003
102005
|
};
|
|
102004
102006
|
// Like MATH_FUNCTIONS, but used only for rounding operations
|
|
102005
102007
|
blocks.ROUNDING_FUNCTIONS = ["round", "ceil", "floor", "trunc"];
|
|
102008
|
+
function parameterDefaultLocalizationKey(qName, actualName) {
|
|
102009
|
+
return qName ? `${qName}|param|${actualName}|defl` : undefined;
|
|
102010
|
+
}
|
|
102011
|
+
blocks.parameterDefaultLocalizationKey = parameterDefaultLocalizationKey;
|
|
102012
|
+
function parameterDefaultToLocalizationString(defaultValue, type) {
|
|
102013
|
+
if (!defaultValue)
|
|
102014
|
+
return undefined;
|
|
102015
|
+
if (type === "string" && defaultValue.charAt(0) !== "\"")
|
|
102016
|
+
return defaultValue;
|
|
102017
|
+
if (defaultValue.charAt(0) !== "\"")
|
|
102018
|
+
return undefined;
|
|
102019
|
+
try {
|
|
102020
|
+
const value = JSON.parse(defaultValue);
|
|
102021
|
+
return typeof value === "string" ? value : undefined;
|
|
102022
|
+
}
|
|
102023
|
+
catch (e) {
|
|
102024
|
+
return undefined;
|
|
102025
|
+
}
|
|
102026
|
+
}
|
|
102027
|
+
blocks.parameterDefaultToLocalizationString = parameterDefaultToLocalizationString;
|
|
102028
|
+
function localizationStringToParameterDefault(value) {
|
|
102029
|
+
return JSON.stringify(value);
|
|
102030
|
+
}
|
|
102031
|
+
blocks.localizationStringToParameterDefault = localizationStringToParameterDefault;
|
|
102006
102032
|
// Information for blocks that compile to function calls but are defined by vanilla Blockly
|
|
102007
102033
|
// and not dynamically by BlocklyLoader
|
|
102008
102034
|
blocks.builtinFunctionInfo = {
|
|
@@ -105784,6 +105810,19 @@ int main() {
|
|
|
105784
105810
|
});
|
|
105785
105811
|
}
|
|
105786
105812
|
hexloader.recordGetAsync = recordGetAsync;
|
|
105813
|
+
function stringifyHexInfoForCache(hexInfo) {
|
|
105814
|
+
if (!(hexInfo === null || hexInfo === void 0 ? void 0 : hexInfo.hex))
|
|
105815
|
+
return undefined;
|
|
105816
|
+
const cachedMeta = Object.assign(Object.assign({}, hexInfo), { hex: compressHex(hexInfo.hex) });
|
|
105817
|
+
return JSON.stringify(cachedMeta);
|
|
105818
|
+
}
|
|
105819
|
+
hexloader.stringifyHexInfoForCache = stringifyHexInfoForCache;
|
|
105820
|
+
function storeHexInfoCacheEntryAsync(host, sha, cachedHexInfo) {
|
|
105821
|
+
if (!sha || !cachedHexInfo)
|
|
105822
|
+
return Promise.resolve();
|
|
105823
|
+
return storeWithLimitAsync(host, "hex-keys", "hex-" + sha, cachedHexInfo);
|
|
105824
|
+
}
|
|
105825
|
+
hexloader.storeHexInfoCacheEntryAsync = storeHexInfoCacheEntryAsync;
|
|
105787
105826
|
function getHexInfoAsync(host, extInfo, cloudModule) {
|
|
105788
105827
|
if (!extInfo.sha)
|
|
105789
105828
|
return Promise.resolve(null);
|
|
@@ -105812,10 +105851,7 @@ int main() {
|
|
|
105812
105851
|
else {
|
|
105813
105852
|
return downloadHexInfoAsync(extInfo)
|
|
105814
105853
|
.then(meta => {
|
|
105815
|
-
let
|
|
105816
|
-
meta.hex = compressHex(meta.hex);
|
|
105817
|
-
let store = JSON.stringify(meta);
|
|
105818
|
-
meta.hex = origHex;
|
|
105854
|
+
let store = stringifyHexInfoForCache(meta);
|
|
105819
105855
|
return storeWithLimitAsync(host, "hex-keys", key, store)
|
|
105820
105856
|
.then(() => meta);
|
|
105821
105857
|
}).catch(e => {
|
|
@@ -108407,6 +108443,18 @@ var pxt;
|
|
|
108407
108443
|
}
|
|
108408
108444
|
github.shouldUseProxyForRepo = shouldUseProxyForRepo;
|
|
108409
108445
|
const isPrivateRepoCache = {};
|
|
108446
|
+
function copyCachedPackage(cachedPackage) {
|
|
108447
|
+
return {
|
|
108448
|
+
files: Object.assign({}, cachedPackage.files)
|
|
108449
|
+
};
|
|
108450
|
+
}
|
|
108451
|
+
function cachedPackageFromFallback(fallbackPackageFiles) {
|
|
108452
|
+
if (!fallbackPackageFiles)
|
|
108453
|
+
return undefined;
|
|
108454
|
+
return {
|
|
108455
|
+
files: Object.assign({}, fallbackPackageFiles)
|
|
108456
|
+
};
|
|
108457
|
+
}
|
|
108410
108458
|
function ghRequestAsync(options) {
|
|
108411
108459
|
var _a;
|
|
108412
108460
|
options.method = (_a = options.method) !== null && _a !== void 0 ? _a : "GET";
|
|
@@ -108518,7 +108566,7 @@ var pxt;
|
|
|
108518
108566
|
}
|
|
108519
108567
|
return resolved;
|
|
108520
108568
|
}
|
|
108521
|
-
async loadPackageAsync(repopath, tag) {
|
|
108569
|
+
async loadPackageAsync(repopath, tag, fallbackPackageFiles) {
|
|
108522
108570
|
if (!tag) {
|
|
108523
108571
|
pxt.debug(`load pkg: default to master branch`);
|
|
108524
108572
|
tag = "master";
|
|
@@ -108526,45 +108574,46 @@ var pxt;
|
|
|
108526
108574
|
// try using github proxy first
|
|
108527
108575
|
if (hasProxy()) {
|
|
108528
108576
|
try {
|
|
108529
|
-
return await this.proxyWithCdnLoadPackageAsync(repopath, tag).then(
|
|
108577
|
+
return await this.proxyWithCdnLoadPackageAsync(repopath, tag).then(copyCachedPackage);
|
|
108530
108578
|
}
|
|
108531
108579
|
catch (e) {
|
|
108532
108580
|
ghProxyHandleException(e);
|
|
108533
108581
|
}
|
|
108534
108582
|
}
|
|
108535
108583
|
// try using github apis
|
|
108536
|
-
return await this.githubLoadPackageAsync(repopath, tag);
|
|
108584
|
+
return await this.githubLoadPackageAsync(repopath, tag, fallbackPackageFiles);
|
|
108537
108585
|
}
|
|
108538
|
-
githubLoadPackageAsync(repopath, tag) {
|
|
108539
|
-
|
|
108540
|
-
|
|
108586
|
+
async githubLoadPackageAsync(repopath, tag, fallbackPackageFiles) {
|
|
108587
|
+
try {
|
|
108588
|
+
const sha = await tagToShaAsync(repopath, tag);
|
|
108541
108589
|
// cache lookup
|
|
108542
108590
|
const key = `${repopath}/${sha}`;
|
|
108543
108591
|
let res = this.packages[key];
|
|
108544
108592
|
if (res) {
|
|
108545
108593
|
pxt.debug(`github cache ${repopath}/${tag}/text`);
|
|
108546
|
-
return
|
|
108594
|
+
return copyCachedPackage(res);
|
|
108547
108595
|
}
|
|
108548
108596
|
// load and cache
|
|
108549
108597
|
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
|
-
});
|
|
108598
|
+
const pkg = await downloadTextAsync(repopath, sha, pxt.CONFIG_NAME);
|
|
108599
|
+
const current = {
|
|
108600
|
+
files: {}
|
|
108601
|
+
};
|
|
108602
|
+
current.files[pxt.CONFIG_NAME] = pkg;
|
|
108603
|
+
const cfg = JSON.parse(pkg);
|
|
108604
|
+
await pxt.U.promiseMapAll(pxt.allPkgFiles(cfg).slice(1), async (fn) => {
|
|
108605
|
+
current.files[fn] = await downloadTextAsync(repopath, sha, fn);
|
|
108566
108606
|
});
|
|
108567
|
-
|
|
108607
|
+
// cache!
|
|
108608
|
+
this.packages[key] = current;
|
|
108609
|
+
return copyCachedPackage(current);
|
|
108610
|
+
}
|
|
108611
|
+
catch (e) {
|
|
108612
|
+
const fallbackPackage = cachedPackageFromFallback(fallbackPackageFiles);
|
|
108613
|
+
if (fallbackPackage)
|
|
108614
|
+
return fallbackPackage;
|
|
108615
|
+
throw e;
|
|
108616
|
+
}
|
|
108568
108617
|
}
|
|
108569
108618
|
async loadTutorialMarkdown(repopath, tag) {
|
|
108570
108619
|
repopath = normalizeTutorialPath(repopath);
|
|
@@ -108920,7 +108969,7 @@ var pxt;
|
|
|
108920
108969
|
return await github.db.loadConfigAsync(repopath, tag);
|
|
108921
108970
|
}
|
|
108922
108971
|
github.pkgConfigAsync = pkgConfigAsync;
|
|
108923
|
-
async function downloadPackageAsync(repoWithTag, config) {
|
|
108972
|
+
async function downloadPackageAsync(repoWithTag, config, fallbackPackageFiles) {
|
|
108924
108973
|
const p = parseRepoId(repoWithTag);
|
|
108925
108974
|
if (!p) {
|
|
108926
108975
|
pxt.log('Unknown GitHub syntax');
|
|
@@ -108933,9 +108982,17 @@ var pxt;
|
|
|
108933
108982
|
}
|
|
108934
108983
|
// always try to upgrade unbound versions
|
|
108935
108984
|
if (!p.tag) {
|
|
108936
|
-
|
|
108985
|
+
try {
|
|
108986
|
+
p.tag = await github.db.latestVersionAsync(p.slug, config);
|
|
108987
|
+
}
|
|
108988
|
+
catch (e) {
|
|
108989
|
+
const fallbackPackage = cachedPackageFromFallback(fallbackPackageFiles);
|
|
108990
|
+
if (fallbackPackage)
|
|
108991
|
+
return fallbackPackage;
|
|
108992
|
+
throw e;
|
|
108993
|
+
}
|
|
108937
108994
|
}
|
|
108938
|
-
const cached = await github.db.loadPackageAsync(p.fullName, p.tag);
|
|
108995
|
+
const cached = await github.db.loadPackageAsync(p.fullName, p.tag, fallbackPackageFiles);
|
|
108939
108996
|
const dv = upgradedDisablesVariants(config, repoWithTag);
|
|
108940
108997
|
if (dv) {
|
|
108941
108998
|
const cfg = pxt.Package.parseAndValidConfig(cached.files[pxt.CONFIG_NAME]);
|
|
@@ -108960,7 +109017,11 @@ var pxt;
|
|
|
108960
109017
|
return { version, config };
|
|
108961
109018
|
}
|
|
108962
109019
|
github.downloadLatestPackageAsync = downloadLatestPackageAsync;
|
|
108963
|
-
async function cacheProjectDependenciesAsync(cfg) {
|
|
109020
|
+
async function cacheProjectDependenciesAsync(cfg, fallbackPackageFilesById) {
|
|
109021
|
+
await cacheProjectDependenciesCoreAsync(cfg, {}, fallbackPackageFilesById);
|
|
109022
|
+
}
|
|
109023
|
+
github.cacheProjectDependenciesAsync = cacheProjectDependenciesAsync;
|
|
109024
|
+
async function cacheProjectDependenciesCoreAsync(cfg, checked, fallbackPackageFilesById) {
|
|
108964
109025
|
var _a;
|
|
108965
109026
|
const ghExtensions = (_a = Object.keys(cfg.dependencies)) === null || _a === void 0 ? void 0 : _a.filter(dep => isGithubId(cfg.dependencies[dep]));
|
|
108966
109027
|
if (ghExtensions.length) {
|
|
@@ -108968,14 +109029,19 @@ var pxt;
|
|
|
108968
109029
|
// Make sure external packages load before installing header.
|
|
108969
109030
|
await Promise.all(ghExtensions.map(async (ext) => {
|
|
108970
109031
|
const extSrc = cfg.dependencies[ext];
|
|
108971
|
-
|
|
109032
|
+
if (checked[extSrc])
|
|
109033
|
+
return;
|
|
109034
|
+
checked[extSrc] = true;
|
|
109035
|
+
const ghPkg = await downloadPackageAsync(extSrc, pkgConfig, fallbackPackageFilesById === null || fallbackPackageFilesById === void 0 ? void 0 : fallbackPackageFilesById[extSrc]);
|
|
108972
109036
|
if (!ghPkg) {
|
|
108973
109037
|
throw new Error(lf("Cannot load extension {0} from {1}", ext, extSrc));
|
|
108974
109038
|
}
|
|
109039
|
+
const ghPkgCfg = pxt.Package.parseAndValidConfig(ghPkg.files[pxt.CONFIG_NAME]);
|
|
109040
|
+
if (ghPkgCfg)
|
|
109041
|
+
await cacheProjectDependenciesCoreAsync(ghPkgCfg, checked, fallbackPackageFilesById);
|
|
108975
109042
|
}));
|
|
108976
109043
|
}
|
|
108977
109044
|
}
|
|
108978
|
-
github.cacheProjectDependenciesAsync = cacheProjectDependenciesAsync;
|
|
108979
109045
|
let GitRepoStatus;
|
|
108980
109046
|
(function (GitRepoStatus) {
|
|
108981
109047
|
GitRepoStatus[GitRepoStatus["Unknown"] = 0] = "Unknown";
|
|
@@ -115025,7 +115091,10 @@ var pxt;
|
|
|
115025
115091
|
this.config.binaryonly ||
|
|
115026
115092
|
!opts.target.isNative;
|
|
115027
115093
|
if (!noFileEmbed) {
|
|
115028
|
-
const files = await this.filesToBePublishedAsync(true);
|
|
115094
|
+
const files = await this.filesToBePublishedAsync(true, !pxt.appTarget.compile.useUF2);
|
|
115095
|
+
const packagedExtInfo = this.packagedExtensionHexInfo(opts);
|
|
115096
|
+
if (Object.keys(packagedExtInfo).length)
|
|
115097
|
+
files[pxt.PACKAGED_EXT_INFO] = JSON.stringify(packagedExtInfo);
|
|
115029
115098
|
const headerString = JSON.stringify({
|
|
115030
115099
|
name: this.config.name,
|
|
115031
115100
|
comment: this.config.description,
|
|
@@ -115097,25 +115166,75 @@ var pxt;
|
|
|
115097
115166
|
cfg.files = cfg.files.filter(fn => fn !== pxt.HISTORY_FILE);
|
|
115098
115167
|
return cfg;
|
|
115099
115168
|
}
|
|
115100
|
-
filesToBePublishedAsync(allowPrivate = false) {
|
|
115169
|
+
async filesToBePublishedAsync(allowPrivate = false, packExternalExtensions = false) {
|
|
115101
115170
|
const files = {};
|
|
115102
|
-
|
|
115103
|
-
|
|
115104
|
-
|
|
115105
|
-
|
|
115106
|
-
|
|
115107
|
-
|
|
115108
|
-
|
|
115109
|
-
|
|
115110
|
-
|
|
115171
|
+
await this.loadAsync();
|
|
115172
|
+
if (!allowPrivate && !this.config.public)
|
|
115173
|
+
pxt.U.userError('Only packages with "public":true can be published');
|
|
115174
|
+
const cfg = this.prepareConfigToBePublished();
|
|
115175
|
+
files[pxt.CONFIG_NAME] = pxt.Package.stringifyConfig(cfg);
|
|
115176
|
+
for (let f of this.getFiles()) {
|
|
115177
|
+
// already stored
|
|
115178
|
+
if (f === pxt.CONFIG_NAME || f === pxt.HISTORY_FILE)
|
|
115179
|
+
continue;
|
|
115180
|
+
let str = this.readFile(f);
|
|
115181
|
+
if (str == null)
|
|
115182
|
+
pxt.U.userError("referenced file missing: " + f);
|
|
115183
|
+
files[f] = str;
|
|
115184
|
+
}
|
|
115185
|
+
if (packExternalExtensions) {
|
|
115186
|
+
const packagedExtensions = this.packagedExternalExtensions();
|
|
115187
|
+
if (Object.keys(packagedExtensions).length)
|
|
115188
|
+
files[pxt.PACKAGED_EXTENSIONS] = JSON.stringify(packagedExtensions);
|
|
115189
|
+
}
|
|
115190
|
+
return pxt.U.sortObjectFields(files);
|
|
115191
|
+
}
|
|
115192
|
+
packagedExternalExtensions() {
|
|
115193
|
+
const packaged = {};
|
|
115194
|
+
const seen = {};
|
|
115195
|
+
const packDeps = (pkg) => {
|
|
115196
|
+
for (const dep of pkg.resolvedDependencies()) {
|
|
115197
|
+
if (!dep)
|
|
115111
115198
|
continue;
|
|
115112
|
-
|
|
115113
|
-
if (
|
|
115114
|
-
|
|
115115
|
-
|
|
115199
|
+
const seenKey = `${dep.id}:${dep.version()}`;
|
|
115200
|
+
if (seen[seenKey])
|
|
115201
|
+
continue;
|
|
115202
|
+
seen[seenKey] = true;
|
|
115203
|
+
if (dep.verProtocol() === "github" || dep.verProtocol() === "pub") {
|
|
115204
|
+
const depFiles = {};
|
|
115205
|
+
for (const fn of dep.getFiles()) {
|
|
115206
|
+
if (fn === pxt.CONFIG_NAME || fn === pxt.HISTORY_FILE)
|
|
115207
|
+
continue;
|
|
115208
|
+
const content = dep.readFile(fn);
|
|
115209
|
+
if (content != null)
|
|
115210
|
+
depFiles[fn] = content;
|
|
115211
|
+
}
|
|
115212
|
+
depFiles[pxt.CONFIG_NAME] = pxt.Package.stringifyConfig(dep.config);
|
|
115213
|
+
packaged[dep._verspec] = depFiles;
|
|
115214
|
+
if (dep.version() !== dep._verspec)
|
|
115215
|
+
packaged[dep.version()] = depFiles;
|
|
115216
|
+
if (dep.verProtocol() === "pub")
|
|
115217
|
+
packaged[dep.verArgument()] = depFiles;
|
|
115218
|
+
}
|
|
115219
|
+
packDeps(dep);
|
|
115116
115220
|
}
|
|
115117
|
-
|
|
115118
|
-
|
|
115221
|
+
};
|
|
115222
|
+
packDeps(this);
|
|
115223
|
+
return packaged;
|
|
115224
|
+
}
|
|
115225
|
+
packagedExtensionHexInfo(opts) {
|
|
115226
|
+
var _a;
|
|
115227
|
+
const packaged = {};
|
|
115228
|
+
const targets = [opts, ...(opts.otherMultiVariants || [])];
|
|
115229
|
+
for (const target of targets) {
|
|
115230
|
+
const extInfo = target.extinfo;
|
|
115231
|
+
if (!(extInfo === null || extInfo === void 0 ? void 0 : extInfo.sha) || !((_a = extInfo.hexinfo) === null || _a === void 0 ? void 0 : _a.hex))
|
|
115232
|
+
continue;
|
|
115233
|
+
const serialized = pxt.hexloader.stringifyHexInfoForCache(extInfo.hexinfo);
|
|
115234
|
+
if (serialized)
|
|
115235
|
+
packaged[extInfo.sha] = serialized;
|
|
115236
|
+
}
|
|
115237
|
+
return packaged;
|
|
115119
115238
|
}
|
|
115120
115239
|
saveToJsonAsync() {
|
|
115121
115240
|
return this.filesToBePublishedAsync(true)
|
|
@@ -116072,6 +116191,10 @@ var ts;
|
|
|
116072
116191
|
fn.attributes.jsDoc = fn.attributes._untranslatedJsDoc;
|
|
116073
116192
|
if (fn.attributes._untranslatedBlock)
|
|
116074
116193
|
fn.attributes.jsDoc = fn.attributes._untranslatedBlock;
|
|
116194
|
+
if (fn.attributes._untranslatedParamDefl) {
|
|
116195
|
+
fn.attributes.paramDefl = pxtc.U.clone(fn.attributes._untranslatedParamDefl);
|
|
116196
|
+
syncParameterDefaults(fn);
|
|
116197
|
+
}
|
|
116075
116198
|
const lookupLoc = (locSuff, attrKey) => {
|
|
116076
116199
|
var _a, _b;
|
|
116077
116200
|
return loc[fn.qName + locSuff] || ((_a = fn.attributes.locs) === null || _a === void 0 ? void 0 : _a[attrKey])
|
|
@@ -116107,15 +116230,30 @@ var ts;
|
|
|
116107
116230
|
}
|
|
116108
116231
|
const paramsWithLabels = comp.thisParameter ? [comp.thisParameter, ...comp.parameters] : comp.parameters;
|
|
116109
116232
|
for (const param of paramsWithLabels) {
|
|
116110
|
-
if (
|
|
116111
|
-
|
|
116112
|
-
|
|
116113
|
-
|
|
116114
|
-
|
|
116115
|
-
|
|
116233
|
+
if (param.labelLocalizationKey) {
|
|
116234
|
+
const locSuff = param.labelLocalizationKey.slice(fn.qName.length);
|
|
116235
|
+
const paramLabel = lookupLoc(locSuff, langLower + locSuff);
|
|
116236
|
+
if (paramLabel) {
|
|
116237
|
+
setBlockTranslationCacheKey(param.labelLocalizationKey, paramLabel);
|
|
116238
|
+
}
|
|
116239
|
+
else {
|
|
116240
|
+
clearBlockTranslationCacheKey(param.labelLocalizationKey);
|
|
116241
|
+
}
|
|
116116
116242
|
}
|
|
116117
|
-
|
|
116118
|
-
|
|
116243
|
+
const defaultString = pxt.blocks.parameterDefaultToLocalizationString(param.defaultValue, param.type);
|
|
116244
|
+
const defaultLocalizationKey = pxt.blocks.parameterDefaultLocalizationKey(fn.qName, param.actualName);
|
|
116245
|
+
if (defaultLocalizationKey && defaultString !== undefined) {
|
|
116246
|
+
const locSuff = defaultLocalizationKey.slice(fn.qName.length);
|
|
116247
|
+
const paramDefault = lookupLoc(locSuff, langLower + locSuff);
|
|
116248
|
+
if (paramDefault !== undefined) {
|
|
116249
|
+
if (!fn.attributes._untranslatedParamDefl) {
|
|
116250
|
+
fn.attributes._untranslatedParamDefl = pxtc.U.clone(fn.attributes.paramDefl || {});
|
|
116251
|
+
}
|
|
116252
|
+
if (!fn.attributes.paramDefl)
|
|
116253
|
+
fn.attributes.paramDefl = {};
|
|
116254
|
+
fn.attributes.paramDefl[param.actualName] = pxt.blocks.localizationStringToParameterDefault(paramDefault);
|
|
116255
|
+
syncParameterDefaults(fn);
|
|
116256
|
+
}
|
|
116119
116257
|
}
|
|
116120
116258
|
}
|
|
116121
116259
|
}
|
|
@@ -116182,6 +116320,13 @@ var ts;
|
|
|
116182
116320
|
return cleanLocalizations(apis);
|
|
116183
116321
|
}
|
|
116184
116322
|
pxtc.localizeApisAsync = localizeApisAsync;
|
|
116323
|
+
function syncParameterDefaults(fn) {
|
|
116324
|
+
if (!fn.parameters)
|
|
116325
|
+
return;
|
|
116326
|
+
for (const param of fn.parameters) {
|
|
116327
|
+
param.default = fn.attributes.paramDefl && fn.attributes.paramDefl[param.name];
|
|
116328
|
+
}
|
|
116329
|
+
}
|
|
116185
116330
|
function cleanLocalizations(apis) {
|
|
116186
116331
|
pxtc.Util.values(apis.byQName)
|
|
116187
116332
|
.filter(fb => fb.attributes.block && /^{[^:]+:[^}]+}/.test(fb.attributes.block))
|
|
@@ -124727,8 +124872,8 @@ var pxt;
|
|
|
124727
124872
|
loadConfigAsync(repopath, tag) {
|
|
124728
124873
|
return this.loadAsync(repopath, tag, "pxt", (r, t) => this.db.loadConfigAsync(r, t));
|
|
124729
124874
|
}
|
|
124730
|
-
loadPackageAsync(repopath, tag) {
|
|
124731
|
-
return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t));
|
|
124875
|
+
loadPackageAsync(repopath, tag, fallbackPackageFiles) {
|
|
124876
|
+
return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t, fallbackPackageFiles));
|
|
124732
124877
|
}
|
|
124733
124878
|
loadTutorialMarkdown(repopath, tag) {
|
|
124734
124879
|
return this.loadAsync(repopath, tag, "tutorial", (r, t) => this.db.loadTutorialMarkdown(r, t));
|
|
@@ -142580,6 +142725,11 @@ var ts;
|
|
|
142580
142725
|
if (param.labelLocalizationKey && param.label) {
|
|
142581
142726
|
locStrings[param.labelLocalizationKey] = param.label;
|
|
142582
142727
|
}
|
|
142728
|
+
const defaultString = pxt.blocks.parameterDefaultToLocalizationString(param.defaultValue, param.type);
|
|
142729
|
+
const defaultLocalizationKey = pxt.blocks.parameterDefaultLocalizationKey(si.qName, param.actualName);
|
|
142730
|
+
if (defaultLocalizationKey && defaultString !== undefined) {
|
|
142731
|
+
locStrings[defaultLocalizationKey] = defaultString;
|
|
142732
|
+
}
|
|
142583
142733
|
}
|
|
142584
142734
|
if ((_a = comp.handlerArgs) === null || _a === void 0 ? void 0 : _a.length) {
|
|
142585
142735
|
for (const arg of comp.handlerArgs) {
|
|
@@ -164195,8 +164345,8 @@ class FileGithubDb {
|
|
|
164195
164345
|
loadConfigAsync(repopath, tag) {
|
|
164196
164346
|
return this.loadAsync(repopath, tag, "pxt", (r, t) => this.db.loadConfigAsync(r, t));
|
|
164197
164347
|
}
|
|
164198
|
-
loadPackageAsync(repopath, tag) {
|
|
164199
|
-
return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t));
|
|
164348
|
+
loadPackageAsync(repopath, tag, fallbackPackageFiles) {
|
|
164349
|
+
return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t, fallbackPackageFiles));
|
|
164200
164350
|
}
|
|
164201
164351
|
loadTutorialMarkdown(repopath, tag) {
|
|
164202
164352
|
return this.loadAsync(repopath, tag, "tutorial", (r, t) => this.db.loadTutorialMarkdown(r, t));
|
package/built/pxtcompiler.js
CHANGED
|
@@ -38,8 +38,8 @@ var pxt;
|
|
|
38
38
|
loadConfigAsync(repopath, tag) {
|
|
39
39
|
return this.loadAsync(repopath, tag, "pxt", (r, t) => this.db.loadConfigAsync(r, t));
|
|
40
40
|
}
|
|
41
|
-
loadPackageAsync(repopath, tag) {
|
|
42
|
-
return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t));
|
|
41
|
+
loadPackageAsync(repopath, tag, fallbackPackageFiles) {
|
|
42
|
+
return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t, fallbackPackageFiles));
|
|
43
43
|
}
|
|
44
44
|
loadTutorialMarkdown(repopath, tag) {
|
|
45
45
|
return this.loadAsync(repopath, tag, "tutorial", (r, t) => this.db.loadTutorialMarkdown(r, t));
|
|
@@ -17891,6 +17891,11 @@ var ts;
|
|
|
17891
17891
|
if (param.labelLocalizationKey && param.label) {
|
|
17892
17892
|
locStrings[param.labelLocalizationKey] = param.label;
|
|
17893
17893
|
}
|
|
17894
|
+
const defaultString = pxt.blocks.parameterDefaultToLocalizationString(param.defaultValue, param.type);
|
|
17895
|
+
const defaultLocalizationKey = pxt.blocks.parameterDefaultLocalizationKey(si.qName, param.actualName);
|
|
17896
|
+
if (defaultLocalizationKey && defaultString !== undefined) {
|
|
17897
|
+
locStrings[defaultLocalizationKey] = defaultString;
|
|
17898
|
+
}
|
|
17894
17899
|
}
|
|
17895
17900
|
if ((_a = comp.handlerArgs) === null || _a === void 0 ? void 0 : _a.length) {
|
|
17896
17901
|
for (const arg of comp.handlerArgs) {
|
package/built/pxtlib.d.ts
CHANGED
|
@@ -733,6 +733,8 @@ declare namespace pxt {
|
|
|
733
733
|
const TUTORIAL_CODE_STOP = "_onCodeStop.ts";
|
|
734
734
|
const TUTORIAL_INFO_FILE = "tutorial-info-cache.json";
|
|
735
735
|
const TUTORIAL_CUSTOM_TS = "tutorial.custom.ts";
|
|
736
|
+
const PACKAGED_EXTENSIONS = "_packaged-extensions.json";
|
|
737
|
+
const PACKAGED_EXT_INFO = "_packaged-ext-info.json";
|
|
736
738
|
const BREAKPOINT_TABLET = 991;
|
|
737
739
|
const PALETTES_FILE = "_palettes.json";
|
|
738
740
|
const HISTORY_FILE = "_history";
|
|
@@ -786,6 +788,9 @@ declare namespace pxt.blocks {
|
|
|
786
788
|
inBlockDef: boolean;
|
|
787
789
|
localizationKey: string;
|
|
788
790
|
}
|
|
791
|
+
function parameterDefaultLocalizationKey(qName: string, actualName: string): string;
|
|
792
|
+
function parameterDefaultToLocalizationString(defaultValue: string, type?: string): string;
|
|
793
|
+
function localizationStringToParameterDefault(value: string): string;
|
|
789
794
|
const builtinFunctionInfo: pxt.Map<{
|
|
790
795
|
params: string[];
|
|
791
796
|
blockId: string;
|
|
@@ -1159,6 +1164,8 @@ declare namespace pxt.hexloader {
|
|
|
1159
1164
|
let hideLoading: () => void;
|
|
1160
1165
|
function storeWithLimitAsync(host: Host, idxkey: string, newkey: string, newval: string, maxLen?: number): Promise<void>;
|
|
1161
1166
|
function recordGetAsync(host: Host, idxkey: string, newkey: string): Promise<void>;
|
|
1167
|
+
function stringifyHexInfoForCache(hexInfo: pxtc.HexInfo): string;
|
|
1168
|
+
function storeHexInfoCacheEntryAsync(host: Host, sha: string, cachedHexInfo: string): Promise<void>;
|
|
1162
1169
|
function getHexInfoAsync(host: Host, extInfo: pxtc.ExtensionInfo, cloudModule?: any): Promise<pxtc.HexInfo>;
|
|
1163
1170
|
}
|
|
1164
1171
|
declare namespace pxt.crowdin {
|
|
@@ -1467,7 +1474,7 @@ declare namespace pxt.github {
|
|
|
1467
1474
|
interface IGithubDb {
|
|
1468
1475
|
latestVersionAsync(repopath: string, config: PackagesConfig): Promise<string>;
|
|
1469
1476
|
loadConfigAsync(repopath: string, tag: string): Promise<pxt.PackageConfig>;
|
|
1470
|
-
loadPackageAsync(repopath: string, tag: string): Promise<CachedPackage>;
|
|
1477
|
+
loadPackageAsync(repopath: string, tag: string, fallbackPackageFiles?: pxt.Map<string>): Promise<CachedPackage>;
|
|
1471
1478
|
loadTutorialMarkdown(repopath: string, tag?: string): Promise<CachedPackage>;
|
|
1472
1479
|
cacheReposAsync(response: GHTutorialResponse): Promise<void>;
|
|
1473
1480
|
}
|
|
@@ -1480,7 +1487,7 @@ declare namespace pxt.github {
|
|
|
1480
1487
|
private cacheConfig;
|
|
1481
1488
|
loadConfigAsync(repopath: string, tag: string): Promise<pxt.PackageConfig>;
|
|
1482
1489
|
latestVersionAsync(repopath: string, config: PackagesConfig): Promise<string>;
|
|
1483
|
-
loadPackageAsync(repopath: string, tag: string): Promise<CachedPackage>;
|
|
1490
|
+
loadPackageAsync(repopath: string, tag: string, fallbackPackageFiles?: pxt.Map<string>): Promise<CachedPackage>;
|
|
1484
1491
|
private githubLoadPackageAsync;
|
|
1485
1492
|
loadTutorialMarkdown(repopath: string, tag?: string): Promise<GHTutorialRepoInfo>;
|
|
1486
1493
|
cacheReposAsync(resp: GHTutorialResponse): Promise<void>;
|
|
@@ -1525,12 +1532,12 @@ declare namespace pxt.github {
|
|
|
1525
1532
|
function listRefsAsync(repopath: string, namespace?: string, useProxy?: boolean, noCache?: boolean): Promise<string[]>;
|
|
1526
1533
|
function listRefsExtAsync(repopath: string, namespace?: string, useProxy?: boolean, noCache?: boolean): Promise<RefsResult>;
|
|
1527
1534
|
function pkgConfigAsync(repopath: string, tag: string, config: pxt.PackagesConfig): Promise<PackageConfig>;
|
|
1528
|
-
function downloadPackageAsync(repoWithTag: string, config: pxt.PackagesConfig): Promise<CachedPackage>;
|
|
1535
|
+
function downloadPackageAsync(repoWithTag: string, config: pxt.PackagesConfig, fallbackPackageFiles?: pxt.Map<string>): Promise<CachedPackage>;
|
|
1529
1536
|
function downloadLatestPackageAsync(repo: ParsedRepo, useProxy?: boolean, noCache?: boolean): Promise<{
|
|
1530
1537
|
version: string;
|
|
1531
1538
|
config: pxt.PackageConfig;
|
|
1532
1539
|
}>;
|
|
1533
|
-
function cacheProjectDependenciesAsync(cfg: pxt.PackageConfig): Promise<void>;
|
|
1540
|
+
function cacheProjectDependenciesAsync(cfg: pxt.PackageConfig, fallbackPackageFilesById?: pxt.Map<pxt.Map<string>>): Promise<void>;
|
|
1534
1541
|
interface User {
|
|
1535
1542
|
login: string;
|
|
1536
1543
|
id: number;
|
|
@@ -2159,7 +2166,9 @@ declare namespace pxt {
|
|
|
2159
2166
|
resolveBannedCategories(): string[];
|
|
2160
2167
|
getCompileOptionsAsync(target?: pxtc.CompileTarget): Promise<pxtc.CompileOptions>;
|
|
2161
2168
|
private prepareConfigToBePublished;
|
|
2162
|
-
filesToBePublishedAsync(allowPrivate?: boolean): Promise<Map<string>>;
|
|
2169
|
+
filesToBePublishedAsync(allowPrivate?: boolean, packExternalExtensions?: boolean): Promise<Map<string>>;
|
|
2170
|
+
private packagedExternalExtensions;
|
|
2171
|
+
private packagedExtensionHexInfo;
|
|
2163
2172
|
saveToJsonAsync(): Promise<pxt.cpp.HexFile>;
|
|
2164
2173
|
compressToFileAsync(): Promise<Uint8Array>;
|
|
2165
2174
|
computePartDefinitions(parts: string[]): pxt.Map<pxsim.PartDefinition>;
|