pxt-core 8.4.6 → 8.4.7

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 CHANGED
@@ -97886,7 +97886,6 @@ var pxt;
97886
97886
  this.initialUserPreferences_ = undefined;
97887
97887
  this.initialAuthCheck_ = undefined;
97888
97888
  this.patchQueue = [];
97889
- pxt.Util.assert(!_client);
97890
97889
  // Set global instance.
97891
97890
  _client = this;
97892
97891
  }
@@ -121790,8 +121789,9 @@ var pxt;
121790
121789
  }
121791
121790
  Cloud.getUserId = getUserId;
121792
121791
  function parseScriptId(uri) {
121792
+ var _a;
121793
121793
  const target = pxt.appTarget;
121794
- if (!uri || !target.appTheme || !target.cloud || !target.cloud.sharing)
121794
+ if (!uri || !target.appTheme || !((_a = target.cloud) === null || _a === void 0 ? void 0 : _a.sharing))
121795
121795
  return undefined;
121796
121796
  let domains = ["makecode.com"];
121797
121797
  if (target.appTheme.embedUrl)
@@ -121799,14 +121799,14 @@ var pxt;
121799
121799
  if (target.appTheme.shareUrl)
121800
121800
  domains.push(target.appTheme.shareUrl);
121801
121801
  domains = Util.unique(domains, d => d).map(d => Util.escapeForRegex(Util.stripUrlProtocol(d).replace(/\/$/, '')).toLowerCase());
121802
- const rx = `^((https:\/\/)?(?:${domains.join('|')})\/)?(?:v[0-9]+\/)?(api\/oembed\?url=.*%2F([^&]*)&.*?|([a-z0-9\-_]+))$`;
121803
- const m = new RegExp(rx, 'i').exec(uri.trim());
121804
- const scriptid = m && (!m[1] || domains.indexOf(Util.escapeForRegex(m[1].replace(/https:\/\//, '').replace(/\/$/, '')).toLowerCase()) >= 0) && (m[3] || m[4]) ? (m[3] ? m[3] : m[4]) : null;
121805
- if (!scriptid)
121806
- return undefined;
121807
- if (scriptid[0] == "_" && scriptid.length == 13)
121808
- return scriptid;
121809
- if (scriptid.length == 23 && /^[0-9\-]+$/.test(scriptid) || scriptid.length == 24 && /^S[0-9\-]+$/.test(scriptid))
121802
+ const domainCheck = `(?:(?:https:\/\/)?(?:${domains.join('|')})\/)`;
121803
+ const versionRefCheck = "(?:v[0-9]+\/)";
121804
+ const oembedCheck = "api\/oembed\\?url=.*%2F([^&#]*)&.*";
121805
+ const sharePageCheck = "([a-z0-9\\-_]+)(?:[#?&].*)?";
121806
+ const scriptIdCheck = `^${domainCheck}?${versionRefCheck}?(?:(?:${oembedCheck})|(?:${sharePageCheck}))$`;
121807
+ const m = new RegExp(scriptIdCheck, 'i').exec(uri.trim());
121808
+ const scriptid = (m === null || m === void 0 ? void 0 : m[1] /** oembed res **/) || (m === null || m === void 0 ? void 0 : m[2]) /** share page res **/;
121809
+ if (/^(_.{12}|S?[0-9\-]{23})$/.test(scriptid))
121810
121810
  return scriptid;
121811
121811
  return undefined;
121812
121812
  }
@@ -154645,18 +154645,8 @@ var pxsim;
154645
154645
  }
154646
154646
  }
154647
154647
  postMessageCore(frame, msg) {
154648
- var _a, _b;
154649
- frame.contentWindow.postMessage(msg, frame.dataset['origin']);
154650
- if (pxsim.U.isLocalHostDev() && ((_a = pxt === null || pxt === void 0 ? void 0 : pxt.appTarget) === null || _a === void 0 ? void 0 : _a.id)) {
154651
- // If using the production simulator on local serve, the domain might have been
154652
- // redirected by the CLI server. Also send to the production domain just in case
154653
- try {
154654
- frame.contentWindow.postMessage(msg, `https://trg-${(_b = pxt === null || pxt === void 0 ? void 0 : pxt.appTarget) === null || _b === void 0 ? void 0 : _b.id}.userpxt.io/---simulator`);
154655
- }
154656
- catch (e) {
154657
- // Ignore exceptions if the target origin doesn't match
154658
- }
154659
- }
154648
+ const origin = pxsim.U.isLocalHostDev() ? "*" : frame.dataset["origin"];
154649
+ frame.contentWindow.postMessage(msg, origin);
154660
154650
  }
154661
154651
  createFrame(url) {
154662
154652
  var _a, _b, _c;
package/built/pxtlib.js CHANGED
@@ -200,7 +200,6 @@ var pxt;
200
200
  this.initialUserPreferences_ = undefined;
201
201
  this.initialAuthCheck_ = undefined;
202
202
  this.patchQueue = [];
203
- pxt.Util.assert(!_client);
204
203
  // Set global instance.
205
204
  _client = this;
206
205
  }
@@ -24104,8 +24103,9 @@ var pxt;
24104
24103
  }
24105
24104
  Cloud.getUserId = getUserId;
24106
24105
  function parseScriptId(uri) {
24106
+ var _a;
24107
24107
  const target = pxt.appTarget;
24108
- if (!uri || !target.appTheme || !target.cloud || !target.cloud.sharing)
24108
+ if (!uri || !target.appTheme || !((_a = target.cloud) === null || _a === void 0 ? void 0 : _a.sharing))
24109
24109
  return undefined;
24110
24110
  let domains = ["makecode.com"];
24111
24111
  if (target.appTheme.embedUrl)
@@ -24113,14 +24113,14 @@ var pxt;
24113
24113
  if (target.appTheme.shareUrl)
24114
24114
  domains.push(target.appTheme.shareUrl);
24115
24115
  domains = Util.unique(domains, d => d).map(d => Util.escapeForRegex(Util.stripUrlProtocol(d).replace(/\/$/, '')).toLowerCase());
24116
- const rx = `^((https:\/\/)?(?:${domains.join('|')})\/)?(?:v[0-9]+\/)?(api\/oembed\?url=.*%2F([^&]*)&.*?|([a-z0-9\-_]+))$`;
24117
- const m = new RegExp(rx, 'i').exec(uri.trim());
24118
- const scriptid = m && (!m[1] || domains.indexOf(Util.escapeForRegex(m[1].replace(/https:\/\//, '').replace(/\/$/, '')).toLowerCase()) >= 0) && (m[3] || m[4]) ? (m[3] ? m[3] : m[4]) : null;
24119
- if (!scriptid)
24120
- return undefined;
24121
- if (scriptid[0] == "_" && scriptid.length == 13)
24122
- return scriptid;
24123
- if (scriptid.length == 23 && /^[0-9\-]+$/.test(scriptid) || scriptid.length == 24 && /^S[0-9\-]+$/.test(scriptid))
24116
+ const domainCheck = `(?:(?:https:\/\/)?(?:${domains.join('|')})\/)`;
24117
+ const versionRefCheck = "(?:v[0-9]+\/)";
24118
+ const oembedCheck = "api\/oembed\\?url=.*%2F([^&#]*)&.*";
24119
+ const sharePageCheck = "([a-z0-9\\-_]+)(?:[#?&].*)?";
24120
+ const scriptIdCheck = `^${domainCheck}?${versionRefCheck}?(?:(?:${oembedCheck})|(?:${sharePageCheck}))$`;
24121
+ const m = new RegExp(scriptIdCheck, 'i').exec(uri.trim());
24122
+ const scriptid = (m === null || m === void 0 ? void 0 : m[1] /** oembed res **/) || (m === null || m === void 0 ? void 0 : m[2]) /** share page res **/;
24123
+ if (/^(_.{12}|S?[0-9\-]{23})$/.test(scriptid))
24124
24124
  return scriptid;
24125
24125
  return undefined;
24126
24126
  }
package/built/pxtsim.js CHANGED
@@ -6301,18 +6301,8 @@ var pxsim;
6301
6301
  }
6302
6302
  }
6303
6303
  postMessageCore(frame, msg) {
6304
- var _a, _b;
6305
- frame.contentWindow.postMessage(msg, frame.dataset['origin']);
6306
- if (pxsim.U.isLocalHostDev() && ((_a = pxt === null || pxt === void 0 ? void 0 : pxt.appTarget) === null || _a === void 0 ? void 0 : _a.id)) {
6307
- // If using the production simulator on local serve, the domain might have been
6308
- // redirected by the CLI server. Also send to the production domain just in case
6309
- try {
6310
- frame.contentWindow.postMessage(msg, `https://trg-${(_b = pxt === null || pxt === void 0 ? void 0 : pxt.appTarget) === null || _b === void 0 ? void 0 : _b.id}.userpxt.io/---simulator`);
6311
- }
6312
- catch (e) {
6313
- // Ignore exceptions if the target origin doesn't match
6314
- }
6315
- }
6304
+ const origin = pxsim.U.isLocalHostDev() ? "*" : frame.dataset["origin"];
6305
+ frame.contentWindow.postMessage(msg, origin);
6316
6306
  }
6317
6307
  createFrame(url) {
6318
6308
  var _a, _b, _c;