videojs-mobile-ui 1.1.1 → 1.2.0-alpha.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,15 +1,15 @@
1
- /*! @name videojs-mobile-ui @version 1.1.1 @license MIT */
1
+ /*! @name videojs-mobile-ui @version 1.2.0-alpha.0 @license MIT */
2
2
  'use strict';
3
3
 
4
4
  var videojs = require('video.js');
5
- var window = require('global/window');
5
+ var window = require('@ungap/global-this');
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
9
  var videojs__default = /*#__PURE__*/_interopDefaultLegacy(videojs);
10
10
  var window__default = /*#__PURE__*/_interopDefaultLegacy(window);
11
11
 
12
- var version = "1.1.1";
12
+ var version = "1.2.0-alpha.0";
13
13
 
14
14
  /**
15
15
  * @file touchOverlay.js
@@ -1,2 +1,2 @@
1
- /*! @name videojs-mobile-ui @version 1.1.1 @license MIT */
1
+ /*! @name videojs-mobile-ui @version 1.2.0-alpha.0 @license MIT */
2
2
  @keyframes fadeAndScale{0%,to{opacity:0}25%{opacity:1}}.video-js.vjs-mobile-ui.vjs-has-started:not(.vjs-ad-playing) .vjs-touch-overlay{position:absolute;pointer-events:auto;top:0}.video-js.vjs-mobile-ui .vjs-touch-overlay{display:block;width:100%;height:100%;pointer-events:none}.video-js.vjs-mobile-ui .vjs-touch-overlay.skip{opacity:0;animation:fadeAndScale .8s linear;background-repeat:no-repeat;background-position:80% center;background-size:10%;background-image:url('data:image/svg+xml;utf8,<svg fill="%23FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"/><path d="M0 0h24v24H0z" fill="none"/></svg>')}.video-js.vjs-mobile-ui .vjs-touch-overlay.skip:after{content:attr(data-skip-text);position:absolute;top:60%;left:70%}.video-js.vjs-mobile-ui .vjs-touch-overlay.skip.reverse{background-position:20% center;background-image:url('data:image/svg+xml;utf8,<svg fill="%23FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"/><path d="M0 0h24v24H0z" fill="none"/></svg>')}.video-js.vjs-mobile-ui .vjs-touch-overlay.skip.reverse:after{right:70%;left:unset}.video-js.vjs-mobile-ui .vjs-touch-overlay .vjs-play-control{top:50%;left:50%;transform:translate(-50%,-50%);position:absolute;width:30%;height:80%;pointer-events:none;opacity:0;transition:opacity .3s ease}.video-js.vjs-mobile-ui .vjs-touch-overlay .vjs-play-control .vjs-icon-placeholder::before{content:'';background-size:60%;background-position:center center;background-repeat:no-repeat;background-image:url('data:image/svg+xml;utf8,<svg fill="%23FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/><path d="M0 0h24v24H0z" fill="none"/></svg>')}.video-js.vjs-mobile-ui .vjs-touch-overlay .vjs-play-control.vjs-paused .vjs-icon-placeholder::before{content:'';background-image:url('data:image/svg+xml;utf8,<svg fill="%23FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M8 5v14l11-7z"/><path d="M0 0h24v24H0z" fill="none"/></svg>')}.video-js.vjs-mobile-ui .vjs-touch-overlay .vjs-play-control.vjs-ended .vjs-icon-placeholder::before{content:'';background-image:url('data:image/svg+xml;utf8,<svg fill="%23FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"/></svg>')}.video-js.vjs-mobile-ui .vjs-touch-overlay.show-play-toggle .vjs-play-control{opacity:1;pointer-events:auto}.video-js.vjs-mobile-ui.vjs-mobile-ui-disable-end.vjs-ended .vjs-touch-overlay{display:none}
@@ -1,8 +1,8 @@
1
- /*! @name videojs-mobile-ui @version 1.1.1 @license MIT */
1
+ /*! @name videojs-mobile-ui @version 1.2.0-alpha.0 @license MIT */
2
2
  import videojs from 'video.js';
3
- import window from 'global/window';
3
+ import window from '@ungap/global-this';
4
4
 
5
- var version = "1.1.1";
5
+ var version = "1.2.0-alpha.0";
6
6
 
7
7
  /**
8
8
  * @file touchOverlay.js
@@ -1,15 +1,16 @@
1
- /*! @name videojs-mobile-ui @version 1.1.1 @license MIT */
1
+ /*! @name videojs-mobile-ui @version 1.2.0-alpha.0 @license MIT */
2
2
  (function (global, factory) {
3
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('video.js')) :
4
- typeof define === 'function' && define.amd ? define(['video.js'], factory) :
5
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.videojsMobileUi = factory(global.videojs));
6
- })(this, (function (videojs) { 'use strict';
3
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('video.js'), require('@ungap/global-this')) :
4
+ typeof define === 'function' && define.amd ? define(['video.js', '@ungap/global-this'], factory) :
5
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.videojsMobileUi = factory(global.videojs, global.window));
6
+ })(this, (function (videojs, window) { 'use strict';
7
7
 
8
8
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
9
 
10
10
  var videojs__default = /*#__PURE__*/_interopDefaultLegacy(videojs);
11
+ var window__default = /*#__PURE__*/_interopDefaultLegacy(window);
11
12
 
12
- var version = "1.1.1";
13
+ var version = "1.2.0-alpha.0";
13
14
 
14
15
  /**
15
16
  * @file touchOverlay.js
@@ -85,7 +86,7 @@
85
86
  // Remove and readd class to trigger animation
86
87
  this.setAttribute('data-skip-text', `${increment} ${this.localize('seconds')}`);
87
88
  this.removeClass('skip');
88
- window.requestAnimationFrame(() => {
89
+ window__default["default"].requestAnimationFrame(() => {
89
90
  this.addClass('skip');
90
91
  });
91
92
  }, this.tapTimeout);
@@ -161,7 +162,7 @@
161
162
  disabled: false
162
163
  }
163
164
  };
164
- const screen = window.screen;
165
+ const screen = window__default["default"].screen;
165
166
 
166
167
  /**
167
168
  * Gets 'portrait' or 'lanscape' from the two orientation APIs
@@ -178,8 +179,8 @@
178
179
  }
179
180
 
180
181
  // iOS only supports window.orientation
181
- if (typeof window.orientation === 'number') {
182
- if (window.orientation === 0 || window.orientation === 180) {
182
+ if (typeof window__default["default"].orientation === 'number') {
183
+ if (window__default["default"].orientation === 0 || window__default["default"].orientation === 180) {
183
184
  return 'portrait';
184
185
  }
185
186
  return 'landscape';
@@ -233,9 +234,9 @@
233
234
  };
234
235
  if (options.fullscreen.enterOnRotate || options.fullscreen.exitOnRotate) {
235
236
  if (videojs__default["default"].browser.IS_IOS) {
236
- window.addEventListener('orientationchange', rotationHandler);
237
+ window__default["default"].addEventListener('orientationchange', rotationHandler);
237
238
  player.on('dispose', () => {
238
- window.removeEventListener('orientationchange', rotationHandler);
239
+ window__default["default"].removeEventListener('orientationchange', rotationHandler);
239
240
  });
240
241
  } else if (screen.orientation) {
241
242
  // addEventListener('orientationchange') is not a user interaction on Android
@@ -1,2 +1,2 @@
1
- /*! @name videojs-mobile-ui @version 1.1.1 @license MIT */
2
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("video.js")):"function"==typeof define&&define.amd?define(["video.js"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).videojsMobileUi=t(e.videojs)}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);const o=n.default.getComponent("Component"),i=n.default.dom||n.default;o.registerComponent("TouchOverlay",class extends o{constructor(e,t){super(e,t),this.seekSeconds=t.seekSeconds,this.tapTimeout=t.tapTimeout,this.taps=0,this.addChild("playToggle",{}),e.on(["playing","userinactive"],(e=>{this.removeClass("show-play-toggle")})),0===this.player_.options_.inactivityTimeout&&(this.player_.options_.inactivityTimeout=5e3),this.handleTaps_=n.default.fn.debounce((e=>{const t=(this.taps-1)*this.seekSeconds;if(this.taps=0,t<1)return;const n=this.el_.getBoundingClientRect(),o=e.changedTouches[0].clientX-n.left;if(o<.4*n.width)this.player_.currentTime(Math.max(0,this.player_.currentTime()-t)),this.addClass("reverse");else{if(!(o>n.width-.4*n.width))return;this.player_.currentTime(Math.min(this.player_.duration(),this.player_.currentTime()+t)),this.removeClass("reverse")}this.removeClass("show-play-toggle"),this.setAttribute("data-skip-text",`${t} ${this.localize("seconds")}`),this.removeClass("skip"),window.requestAnimationFrame((()=>{this.addClass("skip")}))}),this.tapTimeout),this.enable()}createEl(){return i.createEl("div",{className:"vjs-touch-overlay",tabIndex:-1})}handleTap(e){e.target===this.el_&&(e.preventDefault(),this.taps+=1,1===this.taps&&(this.removeClass("skip"),this.toggleClass("show-play-toggle")),this.handleTaps_(e))}enable(){this.firstTapCaptured=!1,this.on("touchend",this.handleTap)}disable(){this.off("touchend",this.handleTap)}});const s={fullscreen:{enterOnRotate:!0,exitOnRotate:!0,lockOnRotate:!0,lockToLandscapeOnEnter:!1,disabled:!1},touchControls:{seekSeconds:10,tapTimeout:300,disableOnEnd:!1,disabled:!1}},a=window.screen,r=()=>{if(a){const e=((a.orientation||{}).type||a.mozOrientation||a.msOrientation||"").split("-")[0];if("landscape"===e||"portrait"===e)return e}return"number"==typeof window.orientation?0===window.orientation||180===window.orientation?"portrait":"landscape":"portrait"},l=function(e={}){(e.forceForTesting||n.default.browser.IS_ANDROID||n.default.browser.IS_IOS)&&this.ready((()=>{((e,t)=>{if(e.addClass("vjs-mobile-ui"),!t.touchControls.disabled){(t.touchControls.disableOnEnd||"function"==typeof e.endscreen)&&e.addClass("vjs-mobile-ui-disable-end");const n=e.children_.indexOf(e.getChild("ControlBar"));e.touchOverlay=e.addChild("TouchOverlay",t.touchControls,n)}if(t.fullscreen.disabled)return;let o=!1;const i=()=>{const i=r();"landscape"===i&&t.fullscreen.enterOnRotate?!1===e.paused()&&(e.requestFullscreen(),(t.fullscreen.lockOnRotate||t.fullscreen.lockToLandscapeOnEnter)&&a.orientation&&a.orientation.lock&&a.orientation.lock("landscape").then((()=>{o=!0})).catch((e=>{n.default.log("Browser refused orientation lock:",e)}))):"portrait"===i&&t.fullscreen.exitOnRotate&&!o&&e.isFullscreen()&&e.exitFullscreen()};(t.fullscreen.enterOnRotate||t.fullscreen.exitOnRotate)&&(n.default.browser.IS_IOS?(window.addEventListener("orientationchange",i),e.on("dispose",(()=>{window.removeEventListener("orientationchange",i)}))):a.orientation&&(a.orientation.onchange=i,e.on("dispose",(()=>{a.orientation.onchange=null})))),e.on("fullscreenchange",(i=>{e.isFullscreen()&&t.fullscreen.lockToLandscapeOnEnter&&"portrait"===r()?a.orientation.lock("landscape").then((()=>{o=!0})).catch((e=>{n.default.log("Browser refused orientation lock:",e)})):!e.isFullscreen()&&o&&(a.orientation.unlock(),o=!1)})),e.on("ended",(e=>{!0===o&&(a.orientation.unlock(),o=!1)}))})(this,n.default.obj.merge(s,e))}))};return n.default.registerPlugin("mobileUi",l),l.VERSION="1.1.1",l}));
1
+ /*! @name videojs-mobile-ui @version 1.2.0-alpha.0 @license MIT */
2
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("video.js"),require("@ungap/global-this")):"function"==typeof define&&define.amd?define(["video.js","@ungap/global-this"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).videojsMobileUi=t(e.videojs,e.window)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(e),i=n(t);const s=o.default.getComponent("Component"),a=o.default.dom||o.default;s.registerComponent("TouchOverlay",class extends s{constructor(e,t){super(e,t),this.seekSeconds=t.seekSeconds,this.tapTimeout=t.tapTimeout,this.taps=0,this.addChild("playToggle",{}),e.on(["playing","userinactive"],(e=>{this.removeClass("show-play-toggle")})),0===this.player_.options_.inactivityTimeout&&(this.player_.options_.inactivityTimeout=5e3),this.handleTaps_=o.default.fn.debounce((e=>{const t=(this.taps-1)*this.seekSeconds;if(this.taps=0,t<1)return;const n=this.el_.getBoundingClientRect(),o=e.changedTouches[0].clientX-n.left;if(o<.4*n.width)this.player_.currentTime(Math.max(0,this.player_.currentTime()-t)),this.addClass("reverse");else{if(!(o>n.width-.4*n.width))return;this.player_.currentTime(Math.min(this.player_.duration(),this.player_.currentTime()+t)),this.removeClass("reverse")}this.removeClass("show-play-toggle"),this.setAttribute("data-skip-text",`${t} ${this.localize("seconds")}`),this.removeClass("skip"),i.default.requestAnimationFrame((()=>{this.addClass("skip")}))}),this.tapTimeout),this.enable()}createEl(){return a.createEl("div",{className:"vjs-touch-overlay",tabIndex:-1})}handleTap(e){e.target===this.el_&&(e.preventDefault(),this.taps+=1,1===this.taps&&(this.removeClass("skip"),this.toggleClass("show-play-toggle")),this.handleTaps_(e))}enable(){this.firstTapCaptured=!1,this.on("touchend",this.handleTap)}disable(){this.off("touchend",this.handleTap)}});const l={fullscreen:{enterOnRotate:!0,exitOnRotate:!0,lockOnRotate:!0,lockToLandscapeOnEnter:!1,disabled:!1},touchControls:{seekSeconds:10,tapTimeout:300,disableOnEnd:!1,disabled:!1}},r=i.default.screen,d=()=>{if(r){const e=((r.orientation||{}).type||r.mozOrientation||r.msOrientation||"").split("-")[0];if("landscape"===e||"portrait"===e)return e}return"number"==typeof i.default.orientation?0===i.default.orientation||180===i.default.orientation?"portrait":"landscape":"portrait"},u=function(e={}){(e.forceForTesting||o.default.browser.IS_ANDROID||o.default.browser.IS_IOS)&&this.ready((()=>{((e,t)=>{if(e.addClass("vjs-mobile-ui"),!t.touchControls.disabled){(t.touchControls.disableOnEnd||"function"==typeof e.endscreen)&&e.addClass("vjs-mobile-ui-disable-end");const n=e.children_.indexOf(e.getChild("ControlBar"));e.touchOverlay=e.addChild("TouchOverlay",t.touchControls,n)}if(t.fullscreen.disabled)return;let n=!1;const s=()=>{const i=d();"landscape"===i&&t.fullscreen.enterOnRotate?!1===e.paused()&&(e.requestFullscreen(),(t.fullscreen.lockOnRotate||t.fullscreen.lockToLandscapeOnEnter)&&r.orientation&&r.orientation.lock&&r.orientation.lock("landscape").then((()=>{n=!0})).catch((e=>{o.default.log("Browser refused orientation lock:",e)}))):"portrait"===i&&t.fullscreen.exitOnRotate&&!n&&e.isFullscreen()&&e.exitFullscreen()};(t.fullscreen.enterOnRotate||t.fullscreen.exitOnRotate)&&(o.default.browser.IS_IOS?(i.default.addEventListener("orientationchange",s),e.on("dispose",(()=>{i.default.removeEventListener("orientationchange",s)}))):r.orientation&&(r.orientation.onchange=s,e.on("dispose",(()=>{r.orientation.onchange=null})))),e.on("fullscreenchange",(i=>{e.isFullscreen()&&t.fullscreen.lockToLandscapeOnEnter&&"portrait"===d()?r.orientation.lock("landscape").then((()=>{n=!0})).catch((e=>{o.default.log("Browser refused orientation lock:",e)})):!e.isFullscreen()&&n&&(r.orientation.unlock(),n=!1)})),e.on("ended",(e=>{!0===n&&(r.orientation.unlock(),n=!1)}))})(this,o.default.obj.merge(l,e))}))};return o.default.registerPlugin("mobileUi",u),u.VERSION="1.2.0-alpha.0",u}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "videojs-mobile-ui",
3
- "version": "1.1.1",
3
+ "version": "1.2.0-alpha.0",
4
4
  "description": "Mobile tap controls and fullscreen on rotate for Video.js",
5
5
  "main": "dist/videojs-mobile-ui.cjs.js",
6
6
  "module": "dist/videojs-mobile-ui.es.js",
@@ -67,9 +67,6 @@
67
67
  "*.js": "vjsstandard --fix",
68
68
  "README.md": "doctoc --notitle"
69
69
  },
70
- "dependencies": {
71
- "global": "^4.4.0"
72
- },
73
70
  "peerDependencies": {
74
71
  "video.js": "^8"
75
72
  },
@@ -82,7 +79,7 @@
82
79
  "postcss": "^8.2.13",
83
80
  "postcss-cli": "^8.3.1",
84
81
  "rollup": "^2.46.0",
85
- "sinon": "^15.0.0",
82
+ "sinon": "^16.0.0",
86
83
  "video.js": "^8.0.0",
87
84
  "videojs-generate-karma-config": "~8.0.0",
88
85
  "videojs-generate-postcss-config": "~3.0.0",
@@ -90,5 +87,8 @@
90
87
  "videojs-generator-verify": "^4.1.0",
91
88
  "videojs-languages": "^2.0.0",
92
89
  "videojs-standard": "^9.0.1"
90
+ },
91
+ "dependencies": {
92
+ "@ungap/global-this": "^0.4.4"
93
93
  }
94
94
  }
@@ -7,5 +7,13 @@ const config = generate(options);
7
7
 
8
8
  // Add additonal builds/customization here!
9
9
 
10
+ config.settings.globals.browser['@ungap/global-this'] = 'window';
11
+ config.settings.globals.module['@ungap/global-this'] = 'window';
12
+ config.settings.externals.browser.push('@ungap/global-this');
13
+ config.settings.externals.module.push('@ungap/global-this');
14
+
15
+ // eslint-disable-next-line no-console
16
+ console.log(JSON.stringify(config.settings, null, 2));
17
+
10
18
  // export the builds to rollup
11
19
  export default Object.values(config.builds);
package/src/plugin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import videojs from 'video.js';
2
2
  import {version as VERSION} from '../package.json';
3
3
  import './touchOverlay.js';
4
- import window from 'global/window';
4
+ import window from '@ungap/global-this';
5
5
 
6
6
  // Default options for the plugin.
7
7
  const defaults = {
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import videojs from 'video.js';
7
- import window from 'global/window';
7
+ import window from '@ungap/global-this';
8
8
 
9
9
  const Component = videojs.getComponent('Component');
10
10
  const dom = videojs.dom || videojs;
@@ -1,5 +1,4 @@
1
- import document from 'global/document';
2
- import window from 'global/window';
1
+ import window from '@ungap/global-this';
3
2
 
4
3
  import QUnit from 'qunit';
5
4
  import sinon from 'sinon';
@@ -26,8 +25,8 @@ QUnit.module('videojs-mobile-ui', {
26
25
  // with the actual timer methods!
27
26
  this.clock = sinon.useFakeTimers();
28
27
 
29
- this.fixture = document.getElementById('qunit-fixture');
30
- this.video = document.createElement('video');
28
+ this.fixture = window.document.getElementById('qunit-fixture');
29
+ this.video = window.document.createElement('video');
31
30
  this.fixture.appendChild(this.video);
32
31
  this.player = videojs(this.video);
33
32
  },
@@ -84,7 +83,7 @@ QUnit.test('iOS event listeners', function(assert) {
84
83
 
85
84
  const oldBrowser = videojs.browser;
86
85
 
87
- videojs.browser = videojs.mergeOptions(videojs.browser, {
86
+ videojs.browser = videojs.obj.merge(videojs.browser, {
88
87
  IS_IOS: true,
89
88
  IS_ANDROID: false
90
89
  });
@@ -124,7 +123,7 @@ QUnit[testOrSkip]('Android event listeners', function(assert) {
124
123
 
125
124
  const oldBrowser = videojs.browser;
126
125
 
127
- videojs.browser = videojs.mergeOptions(videojs.browser, {
126
+ videojs.browser = videojs.obj.merge(videojs.browser, {
128
127
  IS_IOS: false,
129
128
  IS_ANDROID: true
130
129
  });
@@ -156,7 +155,7 @@ QUnit[testOrSkip]('Android event listeners skipped if disabled', function(assert
156
155
 
157
156
  const oldBrowser = videojs.browser;
158
157
 
159
- videojs.browser = videojs.mergeOptions(videojs.browser, {
158
+ videojs.browser = videojs.obj.merge(videojs.browser, {
160
159
  IS_IOS: false,
161
160
  IS_ANDROID: true
162
161
  });