pxt-core 9.1.3 → 9.1.6

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 CHANGED
@@ -1567,7 +1567,7 @@ function getGalleryUrl(props) {
1567
1567
  return typeof props === "string" ? props : props.url;
1568
1568
  }
1569
1569
  function replaceStaticImagesInJsonBlob(cfg, staticAssetHandler) {
1570
- return pxt.replaceStringsInJsonBlob(cfg, /^\.?\/static\/.+\.(png|gif|jpeg|jpg|svg|mp4)$/i, staticAssetHandler);
1570
+ return pxt.replaceStringsInJsonBlob(cfg, /^\.?\/static\/.+\.(png|gif|jpeg|jpg|svg|mp4|ico)$/i, staticAssetHandler);
1571
1571
  }
1572
1572
  function saveThemeJson(cfg, localDir, packaged) {
1573
1573
  var _a, _b, _c;
@@ -2077,7 +2077,7 @@ async function buildTargetCoreAsync(options = {}) {
2077
2077
  if (pxt.appTarget.cacheusedblocksdirs)
2078
2078
  cfg.tutorialInfo = await internalCacheUsedBlocksAsync();
2079
2079
  await forEachBundledPkgAsync(async (pkg, dirname) => {
2080
- var _a, _b;
2080
+ var _a, _b, _c;
2081
2081
  pxt.log(`building bundled ${dirname}`);
2082
2082
  let isPrj = /prj$/.test(dirname);
2083
2083
  const isHw = /hw---/.test(dirname);
@@ -2111,12 +2111,12 @@ async function buildTargetCoreAsync(options = {}) {
2111
2111
  }
2112
2112
  }
2113
2113
  // For the projects, we need to save the base HEX file to the offline HEX cache
2114
- if (isPrj && pxt.appTarget.compile && pxt.appTarget.compile.hasHex) {
2114
+ if (isPrj && ((_a = pxt.appTarget.compile) === null || _a === void 0 ? void 0 : _a.hasHex)) {
2115
2115
  if (!pkgOptions) {
2116
2116
  pxt.debug(`Failed to extract native image for project ${dirname}`);
2117
2117
  return;
2118
2118
  }
2119
- const hexFileExtInfo = [pkgOptions.extinfo, ...(((_a = pkgOptions.otherMultiVariants) === null || _a === void 0 ? void 0 : _a.map(el => el.extinfo)) || [])];
2119
+ const hexFileExtInfo = [pkgOptions.extinfo, ...(((_b = pkgOptions.otherMultiVariants) === null || _b === void 0 ? void 0 : _b.map(el => el.extinfo)) || [])];
2120
2120
  for (const extinfo of hexFileExtInfo) {
2121
2121
  // Place the base HEX image in the hex cache if necessary
2122
2122
  let sha = extinfo.sha;
@@ -2137,24 +2137,25 @@ async function buildTargetCoreAsync(options = {}) {
2137
2137
  // We want to cache a hex file for each of the native packages in case they are added to a project.
2138
2138
  // This won't cover the whole matrix, but handles the common case of projects that add one extra
2139
2139
  // extension in the offline app.
2140
- const allDeps = pkg.sortedDeps(true).map(dep => path.resolve(path.join(dirname, dep.verArgument())))
2140
+ const allDeps = pkg.sortedDeps(true)
2141
+ .map(dep => path.resolve(path.join(dirname, dep.verArgument())))
2141
2142
  .map(dep => path.resolve(dep).replace(/---.*/, "")); // keep path format (/ vs \\) consistent, trim --- suffix to avoid duplicate imports.
2142
2143
  const config = nodeutil.readPkgConfig(dirname);
2143
2144
  const host = pkg.host();
2144
2145
  const pkgsToBuildWith = packageDirs.filter(dirname => !allDeps.some(el => el.indexOf(dirname.replace(/---.*/, "")) !== -1));
2145
- pxt.log(`Dependencies of pkg: ${allDeps}`);
2146
- pxt.log(`Attemping to bundle necessary hexfiles to compile with: ${pkgsToBuildWith}`);
2146
+ pxt.log(`Dependencies of base pkgs: ${allDeps.map(el => path.basename(el)).join(", ")}`);
2147
2147
  for (const extraPackage of pkgsToBuildWith) {
2148
+ const extraPathBaseName = path.basename(extraPackage);
2148
2149
  process.chdir(path.join(rootDir, dirname));
2149
- const deps = Object.assign(Object.assign({}, config.dependencies), { extra: "file:" + path.relative(path.resolve("."), extraPackage) });
2150
+ const deps = Object.assign(Object.assign({}, config.dependencies), { [extraPathBaseName]: "file:" + path.relative(path.resolve("."), extraPackage) });
2150
2151
  host.fileOverrides["pxt.json"] = JSON.stringify(Object.assign(Object.assign({}, config), { dependencies: deps }));
2151
- pxt.log(`Building hex cache for ${pkg.config.name} with dependencies:`);
2152
+ pxt.log(`Building hex cache for ${extraPathBaseName} with dependencies:`);
2152
2153
  console.dir(deps);
2153
2154
  mainPkg = new pxt.MainPackage(host);
2154
2155
  try {
2155
2156
  const extraRes = await testForBuildTargetAsync(true, null);
2156
2157
  if (extraRes) {
2157
- const hexFileExtInfo = [extraRes.options.extinfo, ...(((_b = extraRes.options.otherMultiVariants) === null || _b === void 0 ? void 0 : _b.map(el => el.extinfo)) || [])];
2158
+ const hexFileExtInfo = [extraRes.options.extinfo, ...(((_c = extraRes.options.otherMultiVariants) === null || _c === void 0 ? void 0 : _c.map(el => el.extinfo)) || [])];
2158
2159
  for (const extinfo of hexFileExtInfo) {
2159
2160
  // Place the base HEX image in the hex cache if necessary
2160
2161
  let sha = extinfo.sha;
@@ -2165,7 +2166,7 @@ async function buildTargetCoreAsync(options = {}) {
2165
2166
  }
2166
2167
  else {
2167
2168
  nodeutil.writeFileSync(hexFile, hex.join(os.EOL));
2168
- pxt.debug(`created native image in offline cache for project ${dirname}: ${hexFile}`);
2169
+ pxt.log(`created native image in offline cache for project ${dirname}: ${hexFile}`);
2169
2170
  }
2170
2171
  }
2171
2172
  }
package/built/pxt.js CHANGED
@@ -162219,7 +162219,7 @@ function getGalleryUrl(props) {
162219
162219
  return typeof props === "string" ? props : props.url;
162220
162220
  }
162221
162221
  function replaceStaticImagesInJsonBlob(cfg, staticAssetHandler) {
162222
- return pxt.replaceStringsInJsonBlob(cfg, /^\.?\/static\/.+\.(png|gif|jpeg|jpg|svg|mp4)$/i, staticAssetHandler);
162222
+ return pxt.replaceStringsInJsonBlob(cfg, /^\.?\/static\/.+\.(png|gif|jpeg|jpg|svg|mp4|ico)$/i, staticAssetHandler);
162223
162223
  }
162224
162224
  function saveThemeJson(cfg, localDir, packaged) {
162225
162225
  var _a, _b, _c;
@@ -162729,7 +162729,7 @@ async function buildTargetCoreAsync(options = {}) {
162729
162729
  if (pxt.appTarget.cacheusedblocksdirs)
162730
162730
  cfg.tutorialInfo = await internalCacheUsedBlocksAsync();
162731
162731
  await forEachBundledPkgAsync(async (pkg, dirname) => {
162732
- var _a, _b;
162732
+ var _a, _b, _c;
162733
162733
  pxt.log(`building bundled ${dirname}`);
162734
162734
  let isPrj = /prj$/.test(dirname);
162735
162735
  const isHw = /hw---/.test(dirname);
@@ -162763,12 +162763,12 @@ async function buildTargetCoreAsync(options = {}) {
162763
162763
  }
162764
162764
  }
162765
162765
  // For the projects, we need to save the base HEX file to the offline HEX cache
162766
- if (isPrj && pxt.appTarget.compile && pxt.appTarget.compile.hasHex) {
162766
+ if (isPrj && ((_a = pxt.appTarget.compile) === null || _a === void 0 ? void 0 : _a.hasHex)) {
162767
162767
  if (!pkgOptions) {
162768
162768
  pxt.debug(`Failed to extract native image for project ${dirname}`);
162769
162769
  return;
162770
162770
  }
162771
- const hexFileExtInfo = [pkgOptions.extinfo, ...(((_a = pkgOptions.otherMultiVariants) === null || _a === void 0 ? void 0 : _a.map(el => el.extinfo)) || [])];
162771
+ const hexFileExtInfo = [pkgOptions.extinfo, ...(((_b = pkgOptions.otherMultiVariants) === null || _b === void 0 ? void 0 : _b.map(el => el.extinfo)) || [])];
162772
162772
  for (const extinfo of hexFileExtInfo) {
162773
162773
  // Place the base HEX image in the hex cache if necessary
162774
162774
  let sha = extinfo.sha;
@@ -162789,24 +162789,25 @@ async function buildTargetCoreAsync(options = {}) {
162789
162789
  // We want to cache a hex file for each of the native packages in case they are added to a project.
162790
162790
  // This won't cover the whole matrix, but handles the common case of projects that add one extra
162791
162791
  // extension in the offline app.
162792
- const allDeps = pkg.sortedDeps(true).map(dep => path.resolve(path.join(dirname, dep.verArgument())))
162792
+ const allDeps = pkg.sortedDeps(true)
162793
+ .map(dep => path.resolve(path.join(dirname, dep.verArgument())))
162793
162794
  .map(dep => path.resolve(dep).replace(/---.*/, "")); // keep path format (/ vs \\) consistent, trim --- suffix to avoid duplicate imports.
162794
162795
  const config = nodeutil.readPkgConfig(dirname);
162795
162796
  const host = pkg.host();
162796
162797
  const pkgsToBuildWith = packageDirs.filter(dirname => !allDeps.some(el => el.indexOf(dirname.replace(/---.*/, "")) !== -1));
162797
- pxt.log(`Dependencies of pkg: ${allDeps}`);
162798
- pxt.log(`Attemping to bundle necessary hexfiles to compile with: ${pkgsToBuildWith}`);
162798
+ pxt.log(`Dependencies of base pkgs: ${allDeps.map(el => path.basename(el)).join(", ")}`);
162799
162799
  for (const extraPackage of pkgsToBuildWith) {
162800
+ const extraPathBaseName = path.basename(extraPackage);
162800
162801
  process.chdir(path.join(rootDir, dirname));
162801
- const deps = Object.assign(Object.assign({}, config.dependencies), { extra: "file:" + path.relative(path.resolve("."), extraPackage) });
162802
+ const deps = Object.assign(Object.assign({}, config.dependencies), { [extraPathBaseName]: "file:" + path.relative(path.resolve("."), extraPackage) });
162802
162803
  host.fileOverrides["pxt.json"] = JSON.stringify(Object.assign(Object.assign({}, config), { dependencies: deps }));
162803
- pxt.log(`Building hex cache for ${pkg.config.name} with dependencies:`);
162804
+ pxt.log(`Building hex cache for ${extraPathBaseName} with dependencies:`);
162804
162805
  console.dir(deps);
162805
162806
  mainPkg = new pxt.MainPackage(host);
162806
162807
  try {
162807
162808
  const extraRes = await testForBuildTargetAsync(true, null);
162808
162809
  if (extraRes) {
162809
- const hexFileExtInfo = [extraRes.options.extinfo, ...(((_b = extraRes.options.otherMultiVariants) === null || _b === void 0 ? void 0 : _b.map(el => el.extinfo)) || [])];
162810
+ const hexFileExtInfo = [extraRes.options.extinfo, ...(((_c = extraRes.options.otherMultiVariants) === null || _c === void 0 ? void 0 : _c.map(el => el.extinfo)) || [])];
162810
162811
  for (const extinfo of hexFileExtInfo) {
162811
162812
  // Place the base HEX image in the hex cache if necessary
162812
162813
  let sha = extinfo.sha;
@@ -162817,7 +162818,7 @@ async function buildTargetCoreAsync(options = {}) {
162817
162818
  }
162818
162819
  else {
162819
162820
  nodeutil.writeFileSync(hexFile, hex.join(os.EOL));
162820
- pxt.debug(`created native image in offline cache for project ${dirname}: ${hexFile}`);
162821
+ pxt.log(`created native image in offline cache for project ${dirname}: ${hexFile}`);
162821
162822
  }
162822
162823
  }
162823
162824
  }
@@ -13666,11 +13666,11 @@ var pxtblockly;
13666
13666
  }
13667
13667
  promptAndRenameKind(ws, Object.assign(Object.assign({}, this.opts), { toRename }), lf("Rename '{0}':", oldName), newName => {
13668
13668
  // Update the values of all existing field instances
13669
- const allFields = pxtblockly.getAllFields(ws, field => field instanceof FieldKind);
13669
+ const allFields = pxtblockly.getAllFields(ws, field => field instanceof FieldKind
13670
+ && field.getValue() === oldName
13671
+ && field.opts.name === this.opts.name);
13670
13672
  for (const field of allFields) {
13671
- if (field.ref.getValue() === oldName) {
13672
- field.ref.setValue(newName);
13673
- }
13673
+ field.ref.setValue(newName);
13674
13674
  }
13675
13675
  });
13676
13676
  }
@@ -13682,7 +13682,9 @@ var pxtblockly;
13682
13682
  Blockly.alert(lf("The built-in {0} '{1}' cannot be deleted.", this.opts.memberName, varName));
13683
13683
  return;
13684
13684
  }
13685
- const uses = pxtblockly.getAllFields(ws, field => field instanceof FieldKind && field.getValue() === varName);
13685
+ const uses = pxtblockly.getAllFields(ws, field => field instanceof FieldKind
13686
+ && field.getValue() === varName
13687
+ && field.opts.name === this.opts.name);
13686
13688
  if (uses.length > 1) {
13687
13689
  Blockly.confirm(lf("Delete {0} uses of the \"{1}\" {2}?", uses.length, varName, this.opts.memberName), response => {
13688
13690
  if (!response)
@@ -10104,11 +10104,11 @@ var pxtblockly;
10104
10104
  }
10105
10105
  promptAndRenameKind(ws, Object.assign(Object.assign({}, this.opts), { toRename }), lf("Rename '{0}':", oldName), newName => {
10106
10106
  // Update the values of all existing field instances
10107
- const allFields = pxtblockly.getAllFields(ws, field => field instanceof FieldKind);
10107
+ const allFields = pxtblockly.getAllFields(ws, field => field instanceof FieldKind
10108
+ && field.getValue() === oldName
10109
+ && field.opts.name === this.opts.name);
10108
10110
  for (const field of allFields) {
10109
- if (field.ref.getValue() === oldName) {
10110
- field.ref.setValue(newName);
10111
- }
10111
+ field.ref.setValue(newName);
10112
10112
  }
10113
10113
  });
10114
10114
  }
@@ -10120,7 +10120,9 @@ var pxtblockly;
10120
10120
  Blockly.alert(lf("The built-in {0} '{1}' cannot be deleted.", this.opts.memberName, varName));
10121
10121
  return;
10122
10122
  }
10123
- const uses = pxtblockly.getAllFields(ws, field => field instanceof FieldKind && field.getValue() === varName);
10123
+ const uses = pxtblockly.getAllFields(ws, field => field instanceof FieldKind
10124
+ && field.getValue() === varName
10125
+ && field.opts.name === this.opts.name);
10124
10126
  if (uses.length > 1) {
10125
10127
  Blockly.confirm(lf("Delete {0} uses of the \"{1}\" {2}?", uses.length, varName, this.opts.memberName), response => {
10126
10128
  if (!response)