jassub 1.1.11 → 1.1.13

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/dist/jassub.es.js CHANGED
@@ -1,19 +1,5 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
3
  var __publicField = (obj, key, value) => {
18
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
19
5
  return value;
@@ -22,10 +8,10 @@ if (!("requestVideoFrameCallback" in HTMLVideoElement.prototype) && "getVideoPla
22
8
  HTMLVideoElement.prototype._rvfcpolyfillmap = {};
23
9
  HTMLVideoElement.prototype.requestVideoFrameCallback = function(callback) {
24
10
  const quality = this.getVideoPlaybackQuality();
25
- const baseline = this.mozPresentedFrames || quality.totalVideoFrames - quality.droppedVideoFrames;
11
+ const baseline = this.mozPresentedFrames || this.mozPaintedFrames || quality.totalVideoFrames - quality.droppedVideoFrames;
26
12
  const check = (old, now2) => {
27
13
  const newquality = this.getVideoPlaybackQuality();
28
- const presentedFrames = this.mozPresentedFrames || newquality.totalVideoFrames - newquality.droppedVideoFrames;
14
+ const presentedFrames = this.mozPresentedFrames || this.mozPaintedFrames || newquality.totalVideoFrames - newquality.droppedVideoFrames;
29
15
  if (presentedFrames > baseline) {
30
16
  const processingDuration = this.mozFrameDelay || newquality.totalFrameDelay - quality.totalFrameDelay || 0;
31
17
  const timediff = now2 - old;
@@ -119,6 +105,9 @@ const _JASSUB = class extends EventTarget {
119
105
  });
120
106
  if (_offscreenRender === true)
121
107
  this.sendMessage("offscreenCanvas", null, [this._canvasctrl]);
108
+ this._boundResize = this.resize.bind(this);
109
+ this._boundTimeUpdate = this._timeupdate.bind(this);
110
+ this._boundSetRate = this.setRate.bind(this);
122
111
  this.setVideo(options.video);
123
112
  if (this._onDemandRender) {
124
113
  this.busy = false;
@@ -172,7 +161,7 @@ const _JASSUB = class extends EventTarget {
172
161
  let videoSize = null;
173
162
  if ((!width || !height) && this._video) {
174
163
  videoSize = this._getVideoPosition();
175
- const newsize = this._computeCanvasSize(videoSize.width || 0 * (window.devicePixelRatio || 1), videoSize.height || 0 * (window.devicePixelRatio || 1));
164
+ const newsize = this._computeCanvasSize((videoSize.width || 0) * (window.devicePixelRatio || 1), (videoSize.height || 0) * (window.devicePixelRatio || 1));
176
165
  width = newsize.width;
177
166
  height = newsize.height;
178
167
  top = videoSize.y - (this._canvasParent.getBoundingClientRect().top - this._video.getBoundingClientRect().top);
@@ -255,16 +244,16 @@ const _JASSUB = class extends EventTarget {
255
244
  this._video = video;
256
245
  if (this._onDemandRender !== true) {
257
246
  this._playstate = video.paused;
258
- video.addEventListener("timeupdate", this._timeupdate.bind(this), false);
259
- video.addEventListener("progress", this._timeupdate.bind(this), false);
260
- video.addEventListener("waiting", this._timeupdate.bind(this), false);
261
- video.addEventListener("seeking", this._timeupdate.bind(this), false);
262
- video.addEventListener("playing", this._timeupdate.bind(this), false);
263
- video.addEventListener("ratechange", this.setRate.bind(this), false);
247
+ video.addEventListener("timeupdate", this._boundTimeUpdate, false);
248
+ video.addEventListener("progress", this._boundTimeUpdate, false);
249
+ video.addEventListener("waiting", this._boundTimeUpdate, false);
250
+ video.addEventListener("seeking", this._boundTimeUpdate, false);
251
+ video.addEventListener("playing", this._boundTimeUpdate, false);
252
+ video.addEventListener("ratechange", this._boundSetRate, false);
264
253
  }
265
254
  if (video.videoWidth > 0)
266
255
  this.resize();
267
- video.addEventListener("resize", this.resize.bind(this));
256
+ video.addEventListener("resize", this._boundResize);
268
257
  if (typeof ResizeObserver !== "undefined") {
269
258
  if (!this._ro)
270
259
  this._ro = new ResizeObserver(() => this.resize());
@@ -347,9 +336,11 @@ const _JASSUB = class extends EventTarget {
347
336
  }
348
337
  }
349
338
  _getLocalFont({ font }) {
339
+ var _a, _b;
350
340
  try {
351
- if ("request" in navigator.permissions) {
352
- navigator.permissions.request({ name: "local-fonts" }).then((permission) => {
341
+ const query = ((_a = navigator == null ? void 0 : navigator.permissions) == null ? void 0 : _a.request) || ((_b = navigator == null ? void 0 : navigator.permissions) == null ? void 0 : _b.query);
342
+ if (query) {
343
+ query({ name: "local-fonts" }).then((permission) => {
353
344
  if (permission.state === "granted") {
354
345
  this._sendLocalFont(font);
355
346
  }
@@ -410,14 +401,16 @@ const _JASSUB = class extends EventTarget {
410
401
  }
411
402
  sendMessage(target, data = {}, transferable) {
412
403
  if (transferable) {
413
- this._worker.postMessage(__spreadValues({
404
+ this._worker.postMessage({
414
405
  target,
415
- transferable
416
- }, data), [...transferable]);
406
+ transferable,
407
+ ...data
408
+ }, [...transferable]);
417
409
  } else {
418
- this._worker.postMessage(__spreadValues({
419
- target
420
- }, data));
410
+ this._worker.postMessage({
411
+ target,
412
+ ...data
413
+ });
421
414
  }
422
415
  }
423
416
  _fetchFromWorker(workerOptions, callback) {
@@ -463,13 +456,13 @@ const _JASSUB = class extends EventTarget {
463
456
  if (this._video) {
464
457
  if (this._ro)
465
458
  this._ro.unobserve(this._video);
466
- this._video.removeEventListener("timeupdate", this._timeupdate);
467
- this._video.removeEventListener("progress", this._timeupdate);
468
- this._video.removeEventListener("waiting", this._timeupdate);
469
- this._video.removeEventListener("seeking", this._timeupdate);
470
- this._video.removeEventListener("playing", this._timeupdate);
471
- this._video.removeEventListener("ratechange", this.setRate);
472
- this._video.removeEventListener("resize", this.resize);
459
+ this._video.removeEventListener("timeupdate", this._boundTimeUpdate);
460
+ this._video.removeEventListener("progress", this._boundTimeUpdate);
461
+ this._video.removeEventListener("waiting", this._boundTimeUpdate);
462
+ this._video.removeEventListener("seeking", this._boundTimeUpdate);
463
+ this._video.removeEventListener("playing", this._boundTimeUpdate);
464
+ this._video.removeEventListener("ratechange", this._boundSetRate);
465
+ this._video.removeEventListener("resize", this._boundResize);
473
466
  }
474
467
  }
475
468
  destroy(err) {