pxt-core 13.1.7 → 13.1.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/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
  }
@@ -140923,6 +140923,7 @@ var ts;
140923
140923
  addr += 256;
140924
140924
  }
140925
140925
  }
140926
+ pxtc.saveSourceToUF2 = saveSourceToUF2;
140926
140927
  function hexDump(bytes, startOffset = 0) {
140927
140928
  function toHex(n, len = 8) {
140928
140929
  let r = n.toString(16);
@@ -141312,10 +141313,13 @@ _stored_program: .hex ${res}
141312
141313
  let metablob = pxtc.Util.toUTF8(meta);
141313
141314
  let totallen = metablob.length + binstring.length;
141314
141315
  let res = "\x41\x14\x0E\x2F\xB8\x2F\xA2\xBB";
141316
+ // Binary header as specified in docs/source-embedding.md: 2-byte meta
141317
+ // length, 4-byte text length, 2 reserved bytes, all little endian.
141315
141318
  res += pxtc.U.uint8ArrayToString([
141316
141319
  metablob.length & 0xff, metablob.length >> 8,
141317
- binstring.length & 0xff, binstring.length >> 8,
141318
- 0, 0, 0, 0
141320
+ binstring.length & 0xff, (binstring.length >> 8) & 0xff,
141321
+ (binstring.length >> 16) & 0xff, (binstring.length >> 24) & 0xff,
141322
+ 0, 0
141319
141323
  ]);
141320
141324
  res += metablob;
141321
141325
  res += binstring;
@@ -141323,6 +141327,7 @@ _stored_program: .hex ${res}
141323
141327
  res += "\x00";
141324
141328
  return res;
141325
141329
  }
141330
+ pxtc.packSource = packSource;
141326
141331
  function assembleAndPatch(src, bin, opts, cres) {
141327
141332
  const dummy = opts.extinfo.disabledDeps;
141328
141333
  if (dummy) {
@@ -158224,10 +158229,16 @@ var pxsim;
158224
158229
  // not found, spin a new one
158225
158230
  if (!messageFrame) {
158226
158231
  const url = new URL(simulatorExtension.url);
158227
- if (this.options.parentOrigin)
158228
- url.searchParams.set("parentOrigin", encodeURIComponent(this.options.parentOrigin));
158232
+ // The extension's parent window is this editor, so the origin it
158233
+ // should trust is the editor's own. options.parentOrigin is the
158234
+ // editor's *embedder* origin (controller mode) - the extension's
158235
+ // grandparent - so an extension that validates messages against
158236
+ // it rejects everything the editor sends when the editor is
158237
+ // embedded cross-origin.
158238
+ // searchParams.set() encodes, so don't encode the values here.
158239
+ url.searchParams.set("parentOrigin", window.location.origin);
158229
158240
  if (this.options.userLanguage)
158230
- url.searchParams.set("language", encodeURIComponent(this.options.userLanguage));
158241
+ url.searchParams.set("language", this.options.userLanguage);
158231
158242
  startSimulatorExtension(url.toString(), simulatorExtension.permanent, simulatorExtension.aspectRatio);
158232
158243
  }
158233
158244
  // not running the current run, restart
@@ -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