pxt-arcade 2.0.25 → 2.0.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/editor.js CHANGED
@@ -285,26 +285,31 @@ var pxt;
285
285
  node.textContent = "Sprite.z";
286
286
  }
287
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;
288
+ const performOldEnumShimUpgrade = (variableType, blockType) => {
289
+ const variableKinds = pxt.U.toArray(dom.querySelectorAll(`variable[type=${variableType}]`));
290
+ if (variableKinds.length) {
291
+ pxt.U.toArray(dom.querySelectorAll(`block[type=${blockType}]>field[name=MEMBER]`))
292
+ .concat(pxt.U.toArray(dom.querySelectorAll(`shadow[type=${blockType}]>field[name=MEMBER]`)))
293
+ .forEach(node => {
294
+ const value = node.textContent;
295
+ if (!/^\d/.test(value)) {
296
+ // The correct numerical value will be in the variables
297
+ for (const kind of variableKinds) {
298
+ const match = /^\d+(.*)/.exec(kind.textContent);
299
+ if ((match === null || match === void 0 ? void 0 : match[1]) === value) {
300
+ node.textContent = kind.textContent;
301
+ break;
302
+ }
303
303
  }
304
304
  }
305
- }
306
- });
307
- }
305
+ });
306
+ }
307
+ };
308
+ // The kind field used by the legacy animation editor switched to including the numerical
309
+ // enum value in the field (e.g. Walking -> 0Walking)
310
+ performOldEnumShimUpgrade("ActionKind", "action_enum_shim");
311
+ // same for SpriteKindLegacy
312
+ performOldEnumShimUpgrade("SpriteKindLegacy", "spritetype");
308
313
  }
309
314
  // Added the "use system keyboard" options to the ask for number and ask for string blocks
310
315
  if (pxt.semver.strcmp(pkgTargetVersion || "0.0.0", "2.0.18") < 0) {