pxt-core 7.2.24 → 7.2.26
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/pxt.js +33 -9
- package/built/pxtlib.js +33 -9
- package/built/target.js +1 -1
- package/built/web/main.js +1 -1
- package/built/web/pxtapp.js +1 -1
- package/built/web/pxtasseteditor.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/rtlsemantic.css +1 -1
- package/built/web/semantic.css +1 -1
- package/package.json +3 -3
- package/theme/themes/pxt/modules/modal.overrides +2 -1
package/built/pxt.js
CHANGED
|
@@ -97876,6 +97876,10 @@ var pxt;
|
|
|
97876
97876
|
let _client;
|
|
97877
97877
|
function client() { return _client; }
|
|
97878
97878
|
auth.client = client;
|
|
97879
|
+
const PREFERENCES_DEBOUNCE_MS = 5 * 1000;
|
|
97880
|
+
const PREFERENCES_DEBOUNCE_MAX_MS = 30 * 1000;
|
|
97881
|
+
let debouncePreferencesChangedTimeout = 0;
|
|
97882
|
+
let debouncePreferencesChangedStarted = 0;
|
|
97879
97883
|
class AuthClient {
|
|
97880
97884
|
constructor() {
|
|
97881
97885
|
this.initialUserPreferences_ = undefined;
|
|
@@ -98081,15 +98085,28 @@ var pxt;
|
|
|
98081
98085
|
if (!await this.loggedInAsync()) {
|
|
98082
98086
|
return;
|
|
98083
98087
|
}
|
|
98084
|
-
// If the user is logged in, save to cloud
|
|
98085
|
-
|
|
98086
|
-
|
|
98087
|
-
|
|
98088
|
-
|
|
98089
|
-
|
|
98088
|
+
// If the user is logged in, save to cloud, but debounce the api call as this can be called frequently from skillmaps
|
|
98089
|
+
clearTimeout(debouncePreferencesChangedTimeout);
|
|
98090
|
+
const savePrefs = async () => {
|
|
98091
|
+
debouncePreferencesChangedStarted = 0;
|
|
98092
|
+
const result = await this.apiAsync('/api/user/preferences', ops, 'PATCH');
|
|
98093
|
+
if (result.success) {
|
|
98094
|
+
pxt.debug("Updating local user preferences w/ cloud data after result of POST");
|
|
98095
|
+
// Set user profile from returned value so we stay in-sync
|
|
98096
|
+
this.setUserPreferencesAsync(result.resp);
|
|
98097
|
+
}
|
|
98098
|
+
else {
|
|
98099
|
+
pxt.reportError("identity", "update preferences failed", result);
|
|
98100
|
+
}
|
|
98101
|
+
};
|
|
98102
|
+
if (!debouncePreferencesChangedStarted) {
|
|
98103
|
+
debouncePreferencesChangedStarted = pxt.U.now();
|
|
98104
|
+
}
|
|
98105
|
+
if (PREFERENCES_DEBOUNCE_MAX_MS < pxt.U.now() - debouncePreferencesChangedStarted) {
|
|
98106
|
+
await savePrefs();
|
|
98090
98107
|
}
|
|
98091
98108
|
else {
|
|
98092
|
-
|
|
98109
|
+
debouncePreferencesChangedTimeout = setTimeout(savePrefs, PREFERENCES_DEBOUNCE_MS);
|
|
98093
98110
|
}
|
|
98094
98111
|
}
|
|
98095
98112
|
/*protected*/ hasUserId() {
|
|
@@ -105061,6 +105078,7 @@ var pxt;
|
|
|
105061
105078
|
.then(resp => handleResponseAsync(resp));
|
|
105062
105079
|
}
|
|
105063
105080
|
function handleResponseAsync(resp) {
|
|
105081
|
+
var _a, _b, _c;
|
|
105064
105082
|
const code = resp.statusCode;
|
|
105065
105083
|
const errorData = pxt.Util.jsonTryParse(resp.text) || {};
|
|
105066
105084
|
pxt.debug(`upload result: ${code}`);
|
|
@@ -105068,16 +105086,22 @@ var pxt;
|
|
|
105068
105086
|
pxt.log(`create new translation file: ${filename}`);
|
|
105069
105087
|
return uploadAsync("add-file", {});
|
|
105070
105088
|
}
|
|
105071
|
-
else if (code == 404 && errorData.error
|
|
105089
|
+
else if (code == 404 && ((_a = errorData.error) === null || _a === void 0 ? void 0 : _a.code) == 17) {
|
|
105072
105090
|
return createDirectoryAsync(branch, prj, key, filename.replace(/\/[^\/]+$/, ""), incr)
|
|
105073
105091
|
.then(() => startAsync());
|
|
105074
105092
|
}
|
|
105075
|
-
else if (!errorData.success && errorData.error
|
|
105093
|
+
else if (!errorData.success && ((_b = errorData.error) === null || _b === void 0 ? void 0 : _b.code) == 53) {
|
|
105076
105094
|
// file is being updated
|
|
105077
105095
|
pxt.log(`${filename} being updated, waiting 5s and retry...`);
|
|
105078
105096
|
return pxt.U.delay(5000) // wait 5s and try again
|
|
105079
105097
|
.then(() => uploadTranslationAsync(branch, prj, key, filename, data));
|
|
105080
105098
|
}
|
|
105099
|
+
else if (code == 429 && ((_c = errorData.error) === null || _c === void 0 ? void 0 : _c.code) == 55) {
|
|
105100
|
+
// Too many concurrent requests
|
|
105101
|
+
pxt.log(`Maximum concurrent requests reached, waiting 10s and retry...`);
|
|
105102
|
+
return pxt.U.delay(10 * 1000) // wait 10s and try again
|
|
105103
|
+
.then(() => uploadTranslationAsync(branch, prj, key, filename, data));
|
|
105104
|
+
}
|
|
105081
105105
|
else if (code == 200 || errorData.success) {
|
|
105082
105106
|
// something crowdin reports 500 with success=true
|
|
105083
105107
|
return Promise.resolve();
|
package/built/pxtlib.js
CHANGED
|
@@ -190,6 +190,10 @@ var pxt;
|
|
|
190
190
|
let _client;
|
|
191
191
|
function client() { return _client; }
|
|
192
192
|
auth.client = client;
|
|
193
|
+
const PREFERENCES_DEBOUNCE_MS = 5 * 1000;
|
|
194
|
+
const PREFERENCES_DEBOUNCE_MAX_MS = 30 * 1000;
|
|
195
|
+
let debouncePreferencesChangedTimeout = 0;
|
|
196
|
+
let debouncePreferencesChangedStarted = 0;
|
|
193
197
|
class AuthClient {
|
|
194
198
|
constructor() {
|
|
195
199
|
this.initialUserPreferences_ = undefined;
|
|
@@ -395,15 +399,28 @@ var pxt;
|
|
|
395
399
|
if (!await this.loggedInAsync()) {
|
|
396
400
|
return;
|
|
397
401
|
}
|
|
398
|
-
// If the user is logged in, save to cloud
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
402
|
+
// If the user is logged in, save to cloud, but debounce the api call as this can be called frequently from skillmaps
|
|
403
|
+
clearTimeout(debouncePreferencesChangedTimeout);
|
|
404
|
+
const savePrefs = async () => {
|
|
405
|
+
debouncePreferencesChangedStarted = 0;
|
|
406
|
+
const result = await this.apiAsync('/api/user/preferences', ops, 'PATCH');
|
|
407
|
+
if (result.success) {
|
|
408
|
+
pxt.debug("Updating local user preferences w/ cloud data after result of POST");
|
|
409
|
+
// Set user profile from returned value so we stay in-sync
|
|
410
|
+
this.setUserPreferencesAsync(result.resp);
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
pxt.reportError("identity", "update preferences failed", result);
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
if (!debouncePreferencesChangedStarted) {
|
|
417
|
+
debouncePreferencesChangedStarted = pxt.U.now();
|
|
418
|
+
}
|
|
419
|
+
if (PREFERENCES_DEBOUNCE_MAX_MS < pxt.U.now() - debouncePreferencesChangedStarted) {
|
|
420
|
+
await savePrefs();
|
|
404
421
|
}
|
|
405
422
|
else {
|
|
406
|
-
|
|
423
|
+
debouncePreferencesChangedTimeout = setTimeout(savePrefs, PREFERENCES_DEBOUNCE_MS);
|
|
407
424
|
}
|
|
408
425
|
}
|
|
409
426
|
/*protected*/ hasUserId() {
|
|
@@ -7375,6 +7392,7 @@ var pxt;
|
|
|
7375
7392
|
.then(resp => handleResponseAsync(resp));
|
|
7376
7393
|
}
|
|
7377
7394
|
function handleResponseAsync(resp) {
|
|
7395
|
+
var _a, _b, _c;
|
|
7378
7396
|
const code = resp.statusCode;
|
|
7379
7397
|
const errorData = pxt.Util.jsonTryParse(resp.text) || {};
|
|
7380
7398
|
pxt.debug(`upload result: ${code}`);
|
|
@@ -7382,16 +7400,22 @@ var pxt;
|
|
|
7382
7400
|
pxt.log(`create new translation file: ${filename}`);
|
|
7383
7401
|
return uploadAsync("add-file", {});
|
|
7384
7402
|
}
|
|
7385
|
-
else if (code == 404 && errorData.error
|
|
7403
|
+
else if (code == 404 && ((_a = errorData.error) === null || _a === void 0 ? void 0 : _a.code) == 17) {
|
|
7386
7404
|
return createDirectoryAsync(branch, prj, key, filename.replace(/\/[^\/]+$/, ""), incr)
|
|
7387
7405
|
.then(() => startAsync());
|
|
7388
7406
|
}
|
|
7389
|
-
else if (!errorData.success && errorData.error
|
|
7407
|
+
else if (!errorData.success && ((_b = errorData.error) === null || _b === void 0 ? void 0 : _b.code) == 53) {
|
|
7390
7408
|
// file is being updated
|
|
7391
7409
|
pxt.log(`${filename} being updated, waiting 5s and retry...`);
|
|
7392
7410
|
return pxt.U.delay(5000) // wait 5s and try again
|
|
7393
7411
|
.then(() => uploadTranslationAsync(branch, prj, key, filename, data));
|
|
7394
7412
|
}
|
|
7413
|
+
else if (code == 429 && ((_c = errorData.error) === null || _c === void 0 ? void 0 : _c.code) == 55) {
|
|
7414
|
+
// Too many concurrent requests
|
|
7415
|
+
pxt.log(`Maximum concurrent requests reached, waiting 10s and retry...`);
|
|
7416
|
+
return pxt.U.delay(10 * 1000) // wait 10s and try again
|
|
7417
|
+
.then(() => uploadTranslationAsync(branch, prj, key, filename, data));
|
|
7418
|
+
}
|
|
7395
7419
|
else if (code == 200 || errorData.success) {
|
|
7396
7420
|
// something crowdin reports 500 with success=true
|
|
7397
7421
|
return Promise.resolve();
|