quake2ts 0.0.519 → 0.0.520

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.
@@ -10179,33 +10179,68 @@ var DemoPlaybackController = class {
10179
10179
  });
10180
10180
  }
10181
10181
  }
10182
- async playRangeWithTracking(start, end, tracker) {
10182
+ async playRangeWithTracking(start, end, tracker, options = {}) {
10183
10183
  this.tracker = tracker;
10184
10184
  tracker.startTracking();
10185
- return new Promise((resolve, reject) => {
10186
- const originalComplete = this.callbacks?.onPlaybackComplete;
10187
- const originalError = this.callbacks?.onPlaybackError;
10188
- const cleanup = () => {
10189
- this.setCallbacks({ ...this.callbacks, onPlaybackComplete: originalComplete, onPlaybackError: originalError });
10185
+ const startFrame = start.type === "frame" ? start.frame : this.timeToFrame(start.seconds);
10186
+ const endFrame = end.type === "frame" ? end.frame : this.timeToFrame(end.seconds);
10187
+ if (options.fastForward) {
10188
+ try {
10189
+ this.playFrom(start);
10190
+ this.transitionState(
10191
+ 1
10192
+ /* Playing */
10193
+ );
10194
+ const CHUNK_SIZE = 100;
10195
+ const processChunk = async () => {
10196
+ if (this.state !== 1) {
10197
+ throw new Error("Playback stopped unexpectedly during fast forward");
10198
+ }
10199
+ let count = 0;
10200
+ while (count < CHUNK_SIZE) {
10201
+ if (this.currentFrameIndex >= endFrame || !this.processNextFrame()) {
10202
+ const log = tracker.stopTracking();
10203
+ this.tracker = null;
10204
+ if (this.callbacks?.onPlaybackComplete) this.callbacks.onPlaybackComplete();
10205
+ return log;
10206
+ }
10207
+ count++;
10208
+ }
10209
+ await new Promise((resolve) => setTimeout(resolve, 0));
10210
+ return processChunk();
10211
+ };
10212
+ return await processChunk();
10213
+ } catch (e) {
10214
+ tracker.stopTracking();
10190
10215
  this.tracker = null;
10191
- };
10192
- this.setCallbacks({
10193
- ...this.callbacks,
10194
- onPlaybackComplete: () => {
10195
- const log = tracker.stopTracking();
10196
- if (originalComplete) originalComplete();
10197
- cleanup();
10198
- resolve(log);
10199
- },
10200
- onPlaybackError: (err2) => {
10201
- tracker.stopTracking();
10202
- if (originalError) originalError(err2);
10203
- cleanup();
10204
- reject(err2);
10205
- }
10216
+ throw e;
10217
+ }
10218
+ } else {
10219
+ return new Promise((resolve, reject) => {
10220
+ const originalComplete = this.callbacks?.onPlaybackComplete;
10221
+ const originalError = this.callbacks?.onPlaybackError;
10222
+ const cleanup = () => {
10223
+ this.setCallbacks({ ...this.callbacks, onPlaybackComplete: originalComplete, onPlaybackError: originalError });
10224
+ this.tracker = null;
10225
+ };
10226
+ this.setCallbacks({
10227
+ ...this.callbacks,
10228
+ onPlaybackComplete: () => {
10229
+ const log = tracker.stopTracking();
10230
+ if (originalComplete) originalComplete();
10231
+ cleanup();
10232
+ resolve(log);
10233
+ },
10234
+ onPlaybackError: (err2) => {
10235
+ tracker.stopTracking();
10236
+ if (originalError) originalError(err2);
10237
+ cleanup();
10238
+ reject(err2);
10239
+ }
10240
+ });
10241
+ this.playRange(start, end);
10206
10242
  });
10207
- this.playRange(start, end);
10208
- });
10243
+ }
10209
10244
  }
10210
10245
  };
10211
10246
  var DemoRecorder = class {