pxt-arcade 2.0.12 → 2.0.13

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/editor.js CHANGED
@@ -89,6 +89,10 @@ var pxt;
89
89
  const usedVariables = pxt.U.toArray(statementsRoot.querySelectorAll("block[type=variables_get]"));
90
90
  paramValues.forEach(value => {
91
91
  let oldVariableName = "";
92
+ const handlerVarShadow = getShadow(value, "variables_get_reporter");
93
+ if (!handlerVarShadow) {
94
+ return;
95
+ }
92
96
  const connectedVarBlock = getChildBlock(value, "variables_get");
93
97
  if (connectedVarBlock) {
94
98
  // A variable is connected to the shadow variable reporter; use the name for
@@ -97,7 +101,6 @@ var pxt;
97
101
  oldVariableName = connectedVarField.textContent;
98
102
  value.removeChild(connectedVarBlock);
99
103
  }
100
- const handlerVarShadow = getShadow(value, "variables_get_reporter");
101
104
  const handlerVarField = getField(handlerVarShadow, "VAR");
102
105
  const argReporterName = handlerVarField.textContent;
103
106
  oldVariableName = oldVariableName || argReporterName;
@@ -274,6 +277,35 @@ var pxt;
274
277
  .forEach(node => node.setAttribute("name", "height"));
275
278
  }
276
279
  }
280
+ if (pxt.semver.strcmp(pkgTargetVersion || "0.0.0", "1.0.0") < 0) {
281
+ // At some point Sprite.z switched from being a getter/setter to a property
282
+ pxt.U.toArray(dom.querySelectorAll("block[type=Sprite_blockCombine_set]>field[name=property]"))
283
+ .forEach(node => {
284
+ if (node.textContent.trim() === "Sprite.z@set") {
285
+ node.textContent = "Sprite.z";
286
+ }
287
+ });
288
+ // The kind field used by the legacy animation editor switched to including the numerical
289
+ // enum value in the field (e.g. Walking -> 0Walking)
290
+ const actionKinds = pxt.U.toArray(dom.querySelectorAll("variable[type=ActionKind]"));
291
+ if (actionKinds.length) {
292
+ pxt.U.toArray(dom.querySelectorAll("block[type=action_enum_shim]>field[name=MEMBER]"))
293
+ .concat(pxt.U.toArray(dom.querySelectorAll("shadow[type=action_enum_shim]>field[name=MEMBER]")))
294
+ .forEach(node => {
295
+ const value = node.textContent;
296
+ if (!/^\d/.test(value)) {
297
+ // The correct numerical value will be in the variables
298
+ for (const kind of actionKinds) {
299
+ const match = /^\d+(.*)/.exec(kind.textContent);
300
+ if ((match === null || match === void 0 ? void 0 : match[1]) === value) {
301
+ node.textContent = kind.textContent;
302
+ break;
303
+ }
304
+ }
305
+ }
306
+ });
307
+ }
308
+ }
277
309
  }
278
310
  function swapFieldIfNotMatching(eventRoot, fieldAName, fieldBName, fieldAShouldStartWith) {
279
311
  const fieldA = eventRoot.querySelector(`field[name=${fieldAName}]`);