pxt-core 13.0.6 → 13.0.8

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
@@ -841,6 +841,9 @@ function gitUploadAsync(opts, uplReqs) {
841
841
  });
842
842
  }
843
843
  async function uploadToGitRepoAsync(opts, uplReqs) {
844
+ if (process.env["PXT_SKIP_GIT_COMMIT"]) {
845
+ return writeFilesToPushAsync(opts, uplReqs);
846
+ }
844
847
  let label = opts.label;
845
848
  if (!label) {
846
849
  console.log('no label; skip release upload');
@@ -941,6 +944,40 @@ async function uploadToGitRepoAsync(opts, uplReqs) {
941
944
  }
942
945
  });
943
946
  }
947
+ async function writeFilesToPushAsync(opts, uplReqs) {
948
+ let label = opts.label;
949
+ if (!label) {
950
+ console.log('no label; skip release upload');
951
+ return Promise.resolve();
952
+ }
953
+ let tid = pxt.appTarget.id;
954
+ if (U.startsWith(label, tid + "/"))
955
+ label = label.slice(tid.length + 1);
956
+ if (!/^v\d/.test(label)) {
957
+ console.log(`label "${label}" is not a version; skipping release upload`);
958
+ return Promise.resolve();
959
+ }
960
+ const releasesDir = path.resolve("tmp/releases");
961
+ const outDir = path.join(releasesDir, "built");
962
+ console.log("writing release files to " + releasesDir);
963
+ nodeutil.mkdirP(outDir);
964
+ const info = await ciBuildInfoAsync();
965
+ const releaseInfo = {
966
+ url: info.commitUrl,
967
+ tag: label
968
+ };
969
+ // this gets read by the github actions workflow
970
+ fs.writeFileSync(path.join(releasesDir, "release.json"), JSON.stringify(releaseInfo, null, 2), { encoding: "utf8" });
971
+ // copy the files into the built directory. the actual push to the git repo will be
972
+ // handled by the github actions workflow
973
+ for (let u of U.values(uplReqs)) {
974
+ let fpath = path.join(outDir, u.filename);
975
+ nodeutil.mkdirP(path.dirname(fpath));
976
+ fs.writeFileSync(fpath, u.content, { encoding: u.encoding });
977
+ }
978
+ // make sure there's always something to commit
979
+ fs.writeFileSync(path.join(outDir, "stamp.txt"), new Date().toString());
980
+ }
944
981
  function uploadedArtFileCdnUrl(fn) {
945
982
  if (!fn || /^(https?|data):/.test(fn))
946
983
  return fn; // nothing to do
package/built/pxt.js CHANGED
@@ -105538,7 +105538,7 @@ int main() {
105538
105538
  let m = /^:10....0[0E]41140E2FB82FA2BB(....)(....)(....)(....)(..)/.exec(ln);
105539
105539
  if (m) {
105540
105540
  metaLen = parseInt(swapBytes(m[1]), 16);
105541
- textLen = parseInt(swapBytes(m[2]), 16);
105541
+ textLen = parseInt(swapBytes(m[2]), 16) + parseInt(swapBytes(m[3]), 16) * 0x10000;
105542
105542
  toGo = metaLen + textLen;
105543
105543
  buf = new Uint8Array(toGo);
105544
105544
  }
@@ -140921,6 +140921,7 @@ var ts;
140921
140921
  addr += 256;
140922
140922
  }
140923
140923
  }
140924
+ pxtc.saveSourceToUF2 = saveSourceToUF2;
140924
140925
  function hexDump(bytes, startOffset = 0) {
140925
140926
  function toHex(n, len = 8) {
140926
140927
  let r = n.toString(16);
@@ -141310,10 +141311,13 @@ _stored_program: .hex ${res}
141310
141311
  let metablob = pxtc.Util.toUTF8(meta);
141311
141312
  let totallen = metablob.length + binstring.length;
141312
141313
  let res = "\x41\x14\x0E\x2F\xB8\x2F\xA2\xBB";
141314
+ // Binary header as specified in docs/source-embedding.md: 2-byte meta
141315
+ // length, 4-byte text length, 2 reserved bytes, all little endian.
141313
141316
  res += pxtc.U.uint8ArrayToString([
141314
141317
  metablob.length & 0xff, metablob.length >> 8,
141315
- binstring.length & 0xff, binstring.length >> 8,
141316
- 0, 0, 0, 0
141318
+ binstring.length & 0xff, (binstring.length >> 8) & 0xff,
141319
+ (binstring.length >> 16) & 0xff, (binstring.length >> 24) & 0xff,
141320
+ 0, 0
141317
141321
  ]);
141318
141322
  res += metablob;
141319
141323
  res += binstring;
@@ -141321,6 +141325,7 @@ _stored_program: .hex ${res}
141321
141325
  res += "\x00";
141322
141326
  return res;
141323
141327
  }
141328
+ pxtc.packSource = packSource;
141324
141329
  function assembleAndPatch(src, bin, opts, cres) {
141325
141330
  const dummy = opts.extinfo.disabledDeps;
141326
141331
  if (dummy) {
@@ -158222,10 +158227,16 @@ var pxsim;
158222
158227
  // not found, spin a new one
158223
158228
  if (!messageFrame) {
158224
158229
  const url = new URL(simulatorExtension.url);
158225
- if (this.options.parentOrigin)
158226
- url.searchParams.set("parentOrigin", encodeURIComponent(this.options.parentOrigin));
158230
+ // The extension's parent window is this editor, so the origin it
158231
+ // should trust is the editor's own. options.parentOrigin is the
158232
+ // editor's *embedder* origin (controller mode) - the extension's
158233
+ // grandparent - so an extension that validates messages against
158234
+ // it rejects everything the editor sends when the editor is
158235
+ // embedded cross-origin.
158236
+ // searchParams.set() encodes, so don't encode the values here.
158237
+ url.searchParams.set("parentOrigin", window.location.origin);
158227
158238
  if (this.options.userLanguage)
158228
- url.searchParams.set("language", encodeURIComponent(this.options.userLanguage));
158239
+ url.searchParams.set("language", this.options.userLanguage);
158229
158240
  startSimulatorExtension(url.toString(), simulatorExtension.permanent, simulatorExtension.aspectRatio);
158230
158241
  }
158231
158242
  // not running the current run, restart
@@ -165037,6 +165048,9 @@ function gitUploadAsync(opts, uplReqs) {
165037
165048
  });
165038
165049
  }
165039
165050
  async function uploadToGitRepoAsync(opts, uplReqs) {
165051
+ if (process.env["PXT_SKIP_GIT_COMMIT"]) {
165052
+ return writeFilesToPushAsync(opts, uplReqs);
165053
+ }
165040
165054
  let label = opts.label;
165041
165055
  if (!label) {
165042
165056
  console.log('no label; skip release upload');
@@ -165137,6 +165151,40 @@ async function uploadToGitRepoAsync(opts, uplReqs) {
165137
165151
  }
165138
165152
  });
165139
165153
  }
165154
+ async function writeFilesToPushAsync(opts, uplReqs) {
165155
+ let label = opts.label;
165156
+ if (!label) {
165157
+ console.log('no label; skip release upload');
165158
+ return Promise.resolve();
165159
+ }
165160
+ let tid = pxt.appTarget.id;
165161
+ if (U.startsWith(label, tid + "/"))
165162
+ label = label.slice(tid.length + 1);
165163
+ if (!/^v\d/.test(label)) {
165164
+ console.log(`label "${label}" is not a version; skipping release upload`);
165165
+ return Promise.resolve();
165166
+ }
165167
+ const releasesDir = path.resolve("tmp/releases");
165168
+ const outDir = path.join(releasesDir, "built");
165169
+ console.log("writing release files to " + releasesDir);
165170
+ nodeutil.mkdirP(outDir);
165171
+ const info = await ciBuildInfoAsync();
165172
+ const releaseInfo = {
165173
+ url: info.commitUrl,
165174
+ tag: label
165175
+ };
165176
+ // this gets read by the github actions workflow
165177
+ fs.writeFileSync(path.join(releasesDir, "release.json"), JSON.stringify(releaseInfo, null, 2), { encoding: "utf8" });
165178
+ // copy the files into the built directory. the actual push to the git repo will be
165179
+ // handled by the github actions workflow
165180
+ for (let u of U.values(uplReqs)) {
165181
+ let fpath = path.join(outDir, u.filename);
165182
+ nodeutil.mkdirP(path.dirname(fpath));
165183
+ fs.writeFileSync(fpath, u.content, { encoding: u.encoding });
165184
+ }
165185
+ // make sure there's always something to commit
165186
+ fs.writeFileSync(path.join(outDir, "stamp.txt"), new Date().toString());
165187
+ }
165140
165188
  function uploadedArtFileCdnUrl(fn) {
165141
165189
  if (!fn || /^(https?|data):/.test(fn))
165142
165190
  return fn; // nothing to do
@@ -834,6 +834,7 @@ declare namespace ts.pxtc {
834
834
  function hexBytes(bytes: number[]): string;
835
835
  function patchHex(bin: Binary, buf: number[], shortForm: boolean, useuf2: boolean): string[];
836
836
  }
837
+ function saveSourceToUF2(uf2: UF2.BlockFile, bin: Binary): void;
837
838
  function hexDump(bytes: ArrayLike<number>, startOffset?: number): string;
838
839
  function asmline(s: string): string;
839
840
  function firstMethodOffset(): number;
@@ -850,6 +851,7 @@ declare namespace ts.pxtc {
850
851
  buf: number[];
851
852
  thumbFile: assembler.File;
852
853
  };
854
+ function packSource(meta: string, binstring: string): string;
853
855
  function processorEmit(bin: Binary, opts: CompileOptions, cres: CompileResult): void;
854
856
  let validateShim: typeof hexfile.validateShim;
855
857
  }
@@ -16064,6 +16064,7 @@ var ts;
16064
16064
  addr += 256;
16065
16065
  }
16066
16066
  }
16067
+ pxtc.saveSourceToUF2 = saveSourceToUF2;
16067
16068
  function hexDump(bytes, startOffset = 0) {
16068
16069
  function toHex(n, len = 8) {
16069
16070
  let r = n.toString(16);
@@ -16453,10 +16454,13 @@ _stored_program: .hex ${res}
16453
16454
  let metablob = pxtc.Util.toUTF8(meta);
16454
16455
  let totallen = metablob.length + binstring.length;
16455
16456
  let res = "\x41\x14\x0E\x2F\xB8\x2F\xA2\xBB";
16457
+ // Binary header as specified in docs/source-embedding.md: 2-byte meta
16458
+ // length, 4-byte text length, 2 reserved bytes, all little endian.
16456
16459
  res += pxtc.U.uint8ArrayToString([
16457
16460
  metablob.length & 0xff, metablob.length >> 8,
16458
- binstring.length & 0xff, binstring.length >> 8,
16459
- 0, 0, 0, 0
16461
+ binstring.length & 0xff, (binstring.length >> 8) & 0xff,
16462
+ (binstring.length >> 16) & 0xff, (binstring.length >> 24) & 0xff,
16463
+ 0, 0
16460
16464
  ]);
16461
16465
  res += metablob;
16462
16466
  res += binstring;
@@ -16464,6 +16468,7 @@ _stored_program: .hex ${res}
16464
16468
  res += "\x00";
16465
16469
  return res;
16466
16470
  }
16471
+ pxtc.packSource = packSource;
16467
16472
  function assembleAndPatch(src, bin, opts, cres) {
16468
16473
  const dummy = opts.extinfo.disabledDeps;
16469
16474
  if (dummy) {
package/built/pxtlib.js CHANGED
@@ -7817,7 +7817,7 @@ int main() {
7817
7817
  let m = /^:10....0[0E]41140E2FB82FA2BB(....)(....)(....)(....)(..)/.exec(ln);
7818
7818
  if (m) {
7819
7819
  metaLen = parseInt(swapBytes(m[1]), 16);
7820
- textLen = parseInt(swapBytes(m[2]), 16);
7820
+ textLen = parseInt(swapBytes(m[2]), 16) + parseInt(swapBytes(m[3]), 16) * 0x10000;
7821
7821
  toGo = metaLen + textLen;
7822
7822
  buf = new Uint8Array(toGo);
7823
7823
  }
package/built/pxtsim.js CHANGED
@@ -6721,10 +6721,16 @@ var pxsim;
6721
6721
  // not found, spin a new one
6722
6722
  if (!messageFrame) {
6723
6723
  const url = new URL(simulatorExtension.url);
6724
- if (this.options.parentOrigin)
6725
- url.searchParams.set("parentOrigin", encodeURIComponent(this.options.parentOrigin));
6724
+ // The extension's parent window is this editor, so the origin it
6725
+ // should trust is the editor's own. options.parentOrigin is the
6726
+ // editor's *embedder* origin (controller mode) - the extension's
6727
+ // grandparent - so an extension that validates messages against
6728
+ // it rejects everything the editor sends when the editor is
6729
+ // embedded cross-origin.
6730
+ // searchParams.set() encodes, so don't encode the values here.
6731
+ url.searchParams.set("parentOrigin", window.location.origin);
6726
6732
  if (this.options.userLanguage)
6727
- url.searchParams.set("language", encodeURIComponent(this.options.userLanguage));
6733
+ url.searchParams.set("language", this.options.userLanguage);
6728
6734
  startSimulatorExtension(url.toString(), simulatorExtension.permanent, simulatorExtension.aspectRatio);
6729
6735
  }
6730
6736
  // not running the current run, restart