pxt-core 8.2.10 → 8.2.11

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
@@ -153007,17 +153007,8 @@ var pxsim;
153007
153007
  this.board.screenshotAsync(this.recordingWidth)
153008
153008
  .then(imageData => {
153009
153009
  // check for duplicate images
153010
- if (this.recordingLastImageData && imageData
153011
- && this.recordingLastImageData.data.byteLength == imageData.data.byteLength) {
153012
- const d0 = this.recordingLastImageData.data;
153013
- const d1 = imageData.data;
153014
- const n = d0.byteLength;
153015
- let i = 0;
153016
- for (i = 0; i < n; ++i)
153017
- if (d0[i] != d1[i])
153018
- break;
153019
- if (i == n) // same, don't send update
153020
- return;
153010
+ if (this.recordingLastImageData && isImageDataEqual(this.recordingLastImageData, imageData)) {
153011
+ return;
153021
153012
  }
153022
153013
  this.recordingLastImageData = imageData;
153023
153014
  Runtime.postMessage({
@@ -153197,6 +153188,28 @@ var pxsim;
153197
153188
  return ts.totalRuntime > elapsed;
153198
153189
  });
153199
153190
  }
153191
+ registerUserInteraction() {
153192
+ this.lastInteractionTime = Date.now();
153193
+ if (this.thumbnailRecordingIntervalRef || this.lastThumbnailTime && this.lastInteractionTime - this.lastThumbnailTime < 1000)
153194
+ return;
153195
+ this.thumbnailFrames = [];
153196
+ this.thumbnailRecordingIntervalRef = setInterval(async () => {
153197
+ const imageData = await this.board.screenshotAsync();
153198
+ if (this.thumbnailFrames.length && isImageDataEqual(imageData, this.thumbnailFrames[this.thumbnailFrames.length - 1])) {
153199
+ return;
153200
+ }
153201
+ this.thumbnailFrames.push(imageData);
153202
+ if (Date.now() - this.lastInteractionTime > 10000 || this.thumbnailFrames.length > 30) {
153203
+ clearInterval(this.thumbnailRecordingIntervalRef);
153204
+ this.thumbnailRecordingIntervalRef = undefined;
153205
+ this.lastThumbnailTime = Date.now();
153206
+ Runtime.postMessage({
153207
+ type: "thumbnail",
153208
+ frames: this.thumbnailFrames
153209
+ });
153210
+ }
153211
+ }, 66);
153212
+ }
153200
153213
  }
153201
153214
  pxsim.Runtime = Runtime;
153202
153215
  class PerfCounter {
@@ -153210,6 +153223,16 @@ var pxsim;
153210
153223
  }
153211
153224
  }
153212
153225
  pxsim.PerfCounter = PerfCounter;
153226
+ function isImageDataEqual(d0, d1) {
153227
+ if (d0.data.byteLength !== d1.data.byteLength)
153228
+ return false;
153229
+ const n = d0.data.byteLength;
153230
+ let i = 0;
153231
+ for (i = 0; i < n; ++i)
153232
+ if (d0.data[i] != d1.data[i])
153233
+ break;
153234
+ return i === n;
153235
+ }
153213
153236
  })(pxsim || (pxsim = {}));
153214
153237
  var pxsim;
153215
153238
  (function (pxsim) {
package/built/pxtsim.d.ts CHANGED
@@ -465,6 +465,10 @@ declare namespace pxsim {
465
465
  delay?: number;
466
466
  modalContext?: string;
467
467
  }
468
+ interface SimulatorAutomaticThumbnailMessage extends SimulatorMessage {
469
+ type: "thumbnail";
470
+ frames: ImageData[];
471
+ }
468
472
  interface SimulatorAddExtensionsMessage extends SimulatorMessage {
469
473
  type: "addextensions";
470
474
  /**
@@ -1147,6 +1151,10 @@ declare namespace pxsim {
1147
1151
  perfOffset: number;
1148
1152
  perfElapsed: number;
1149
1153
  perfStack: number;
1154
+ lastInteractionTime: number;
1155
+ lastThumbnailTime: number;
1156
+ thumbnailRecordingIntervalRef: number;
1157
+ thumbnailFrames: ImageData[];
1150
1158
  refCountingDebug: boolean;
1151
1159
  private refObjId;
1152
1160
  overwriteResume: (retPC: number) => void;
@@ -1191,6 +1199,7 @@ declare namespace pxsim {
1191
1199
  pauseScheduled(): void;
1192
1200
  resumeAllPausedScheduled(): void;
1193
1201
  cleanScheduledExpired(): void;
1202
+ registerUserInteraction(): void;
1194
1203
  }
1195
1204
  class PerfCounter {
1196
1205
  name: string;
package/built/pxtsim.js CHANGED
@@ -5758,17 +5758,8 @@ var pxsim;
5758
5758
  this.board.screenshotAsync(this.recordingWidth)
5759
5759
  .then(imageData => {
5760
5760
  // check for duplicate images
5761
- if (this.recordingLastImageData && imageData
5762
- && this.recordingLastImageData.data.byteLength == imageData.data.byteLength) {
5763
- const d0 = this.recordingLastImageData.data;
5764
- const d1 = imageData.data;
5765
- const n = d0.byteLength;
5766
- let i = 0;
5767
- for (i = 0; i < n; ++i)
5768
- if (d0[i] != d1[i])
5769
- break;
5770
- if (i == n) // same, don't send update
5771
- return;
5761
+ if (this.recordingLastImageData && isImageDataEqual(this.recordingLastImageData, imageData)) {
5762
+ return;
5772
5763
  }
5773
5764
  this.recordingLastImageData = imageData;
5774
5765
  Runtime.postMessage({
@@ -5948,6 +5939,28 @@ var pxsim;
5948
5939
  return ts.totalRuntime > elapsed;
5949
5940
  });
5950
5941
  }
5942
+ registerUserInteraction() {
5943
+ this.lastInteractionTime = Date.now();
5944
+ if (this.thumbnailRecordingIntervalRef || this.lastThumbnailTime && this.lastInteractionTime - this.lastThumbnailTime < 1000)
5945
+ return;
5946
+ this.thumbnailFrames = [];
5947
+ this.thumbnailRecordingIntervalRef = setInterval(async () => {
5948
+ const imageData = await this.board.screenshotAsync();
5949
+ if (this.thumbnailFrames.length && isImageDataEqual(imageData, this.thumbnailFrames[this.thumbnailFrames.length - 1])) {
5950
+ return;
5951
+ }
5952
+ this.thumbnailFrames.push(imageData);
5953
+ if (Date.now() - this.lastInteractionTime > 10000 || this.thumbnailFrames.length > 30) {
5954
+ clearInterval(this.thumbnailRecordingIntervalRef);
5955
+ this.thumbnailRecordingIntervalRef = undefined;
5956
+ this.lastThumbnailTime = Date.now();
5957
+ Runtime.postMessage({
5958
+ type: "thumbnail",
5959
+ frames: this.thumbnailFrames
5960
+ });
5961
+ }
5962
+ }, 66);
5963
+ }
5951
5964
  }
5952
5965
  pxsim.Runtime = Runtime;
5953
5966
  class PerfCounter {
@@ -5961,6 +5974,16 @@ var pxsim;
5961
5974
  }
5962
5975
  }
5963
5976
  pxsim.PerfCounter = PerfCounter;
5977
+ function isImageDataEqual(d0, d1) {
5978
+ if (d0.data.byteLength !== d1.data.byteLength)
5979
+ return false;
5980
+ const n = d0.data.byteLength;
5981
+ let i = 0;
5982
+ for (i = 0; i < n; ++i)
5983
+ if (d0.data[i] != d1.data[i])
5984
+ break;
5985
+ return i === n;
5986
+ }
5964
5987
  })(pxsim || (pxsim = {}));
5965
5988
  var pxsim;
5966
5989
  (function (pxsim) {