image-to-pixel 3.0.1 → 3.2.0

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.
@@ -1,4 +1,4 @@
1
- /*! image-to-pixel v3.0.1 | MIT | https://github.com/Tezumie/Image-to-Pixel */
1
+ /*! image-to-pixel v3.2.0 | MIT | https://github.com/Tezumie/Image-to-Pixel */
2
2
  var ImageToPixel = (() => {
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
@@ -5251,19 +5251,23 @@ void main() {
5251
5251
  await videoReady(video);
5252
5252
  const wasPaused = video.paused;
5253
5253
  video.pause();
5254
- const times = frameTimes({ duration: video.duration, ...opts });
5255
- for (let i = 0; i < times.length; i++) {
5256
- if (opts.signal && opts.signal.aborted) throw new DOMException("Aborted", "AbortError");
5257
- await seekTo(video, times[i]);
5258
- await opts.onFrame({ index: i, time: times[i], total: times.length });
5254
+ const times = Array.isArray(opts.times) ? opts.times.filter((t) => Number.isFinite(t)).slice(0, opts.maxFrames ?? Infinity) : frameTimes({ duration: video.duration, ...opts });
5255
+ try {
5256
+ for (let i = 0; i < times.length; i++) {
5257
+ if (opts.signal?.aborted) throw new DOMException("Aborted", "AbortError");
5258
+ await seekTo(video, times[i]);
5259
+ if (opts.signal?.aborted) throw new DOMException("Aborted", "AbortError");
5260
+ await opts.onFrame({ index: i, time: times[i], total: times.length });
5261
+ }
5262
+ } finally {
5263
+ if (!wasPaused) video.play().catch(() => {
5264
+ });
5259
5265
  }
5260
- if (!wasPaused) video.play().catch(() => {
5261
- });
5262
5266
  return times.length;
5263
5267
  }
5264
5268
 
5265
5269
  // lib/index.js
5266
- var VERSION2 = true ? "3.0.1" : "dev";
5270
+ var VERSION2 = true ? "3.2.0" : "dev";
5267
5271
  return __toCommonJS(index_exports);
5268
5272
  })();
5269
5273
  /*! Bundled license information: