@mattebox/player-spatial-nav 0.1.2 → 0.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 +1 @@
|
|
|
1
|
-
var matteboxPlayerSpatialNav=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){let t=e.parentNode;return t===null?e instanceof ShadowRoot?e.host:null:t}function n(e){let n=e;for(;n!==null;){if(n instanceof HTMLElement&&n.localName===`mattebox-player`)return n;n=t(n)}return null}var r=class extends HTMLElement{constructor(){super(),this.player=null,this.offs=[],this.epoch=0}connectedCallback(){let e=n(this);if(e===null)return;this.epoch+=1;let t=this.epoch,r=()=>{t===this.epoch&&this.isConnected&&(customElements.upgrade(e),`
|
|
1
|
+
var matteboxPlayerSpatialNav=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){let t=e.parentNode;return t===null?e instanceof ShadowRoot?e.host:null:t}function n(e){let n=e;for(;n!==null;){if(n instanceof HTMLElement&&n.localName===`mattebox-player`)return n;n=t(n)}return null}var r=class extends HTMLElement{constructor(){super(),this.player=null,this.offs=[],this.epoch=0}connectedCallback(){let e=n(this);if(e===null)return;this.epoch+=1;let t=this.epoch,r=()=>{t===this.epoch&&this.isConnected&&(customElements.upgrade(e),`media`in e&&(this.player=e,this.attach(this.player)))};`media`in e?r():customElements.whenDefined(`mattebox-player`).then(r)}disconnectedCallback(){this.epoch+=1;for(let e of this.offs)e();this.offs=[],this.player=null}on(e,t,n,r){e.addEventListener(t,n,r),this.offs.push(()=>{e.removeEventListener(t,n,r)})}};let i={10009:`GoBack`,461:`GoBack`,10252:`MediaPlayPause`,415:`MediaPlay`,19:`MediaPause`,413:`MediaStop`,417:`MediaFastForward`,412:`MediaRewind`},a={13:`Enter`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`};function o(e){var t;let n=i[e.keyCode];return n===void 0?e.key!==``&&e.key!==`Unidentified`||(t=a[e.keyCode])==null?e.key:t:n}function s(e){return e===`GoBack`||e===`BrowserBack`||e===`Escape`}let c={ArrowUp:`up`,ArrowDown:`down`,ArrowLeft:`left`,ArrowRight:`right`},l={up:`down`,down:`up`,left:`right`,right:`left`};function u(e){return e instanceof HTMLElement?e instanceof HTMLButtonElement?!e.disabled:e.getAttribute(`role`)===`slider`||e.hasAttribute(`tabindex`)&&e.tabIndex>=0:!1}function d(e){let t=[],n=r=>{var i,a;r!==e&&u(r)&&r.getClientRects().length>0&&t.push(r);let o=r instanceof HTMLSlotElement?r.assignedElements({flatten:!0}):[...(i=(a=r.shadowRoot)==null?void 0:a.children)==null?[]:i,...r.shadowRoot?[]:r.children];for(let e of o)n(e)};return n(e),t}function f(e,t,n,r){return Math.max(0,n-t,e-r)}function p(e,t,n){let r=n===`left`||n===`right`,i=null,a=[2,0,0];for(let o of t){let t=o.getBoundingClientRect(),s;if(s=n===`right`?t.left-e.right:n===`left`?e.left-t.right:n===`down`?t.top-e.bottom:e.top-t.bottom,s<-1)continue;let c=r?f(e.top,e.bottom,t.top,t.bottom):f(e.left,e.right,t.left,t.right),l=c===0?0:1;if(r&&l===1)continue;let u=[l,Math.max(0,s),c];m(u,a)&&(i=o,a=u)}return i}function m(e,t){for(let i=0;i<e.length;i+=1){var n,r;let a=(n=e[i])==null?0:n,o=(r=t[i])==null?0:r;if(a!==o)return a<o}return!1}var h=class extends r{constructor(){super(),this.last=null,this.move=null,this.pointed=null,this.resting=!1,this.sending=null}attach(e){this.on(e,`keydown`,t=>this.key(e,t),{capture:!0}),this.on(e,`pointermove`,t=>{this.resting=!0;let n=d(e),r=t.composedPath().find(e=>n.includes(e));r!==void 0&&(this.pointed=r)}),this.on(e,`focusin`,()=>{let t=this.focused(e);t!==null&&(this.last=t)})}focused(e){var n;let r=document.activeElement;for(;(r==null||(n=r.shadowRoot)==null?void 0:n.activeElement)!=null;)r=r.shadowRoot.activeElement;if(!(r instanceof HTMLElement)||r===e)return null;for(let n=r;n!==null;n=t(n))if(n===e)return r;return null}inOpen(e,n){for(let r=n;r!==null&&r!==e;r=t(r))if(r instanceof HTMLElement&&r.hasAttribute(`open`))return!0;return!1}start(e){var t,n,r;let i=d(e);for(let e of[this.pointed,this.last])if(e!==null&&i.includes(e))return e;let a=e.querySelector((t=this.getAttribute(`initial`))==null?`mbx-play-button`:t);return(n=(r=i.find(e=>{var t;return(a==null?void 0:a.contains(e))||(a==null||(t=a.shadowRoot)==null?void 0:t.contains(e))}))==null?i[0]:r)==null?null:n}key(e,t){if(t===this.sending||t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey)return;let n=o(t),r=c[n];if(r===void 0&&n!==`Enter`){s(n)?this.back(e,t):n!==t.key&&this.again(t,n);return}let i=this.focused(e);if(i===null||this.resting||e.hasAttribute(`idle`)){this.resting=!1;let n=this.start(e);if(n===null)return;t.preventDefault(),n.focus();return}if(this.inOpen(e,i))return;if(r===void 0){if(i instanceof HTMLButtonElement&&n===t.key||i.getAttribute(`role`)===`slider`)return;t.preventDefault(),i.click();return}if(i.getAttribute(`role`)===`slider`&&(r===`left`||r===`right`)){n!==t.key&&this.again(t,n);return}let a=d(e).filter(e=>e!==i),u=this.move,f=u!==null&&u.to===i&&u.direction===l[r]&&a.includes(u.from)?u.from:p(i.getBoundingClientRect(),a,r);t.preventDefault(),f===null?this.dispatchEvent(new CustomEvent(`navigateout`,{detail:r,bubbles:!0,composed:!0})):(this.move={from:i,to:f,direction:r},f.focus())}back(e,t){let n=this.focused(e);if(n===null)return;let r=new KeyboardEvent(`keydown`,{key:`Escape`,bubbles:!0,composed:!0,cancelable:!0});t.stopPropagation(),t.preventDefault(),this.send(n,r)&&n.blur()}again(e,t){let n=e.composedPath()[0];n!==void 0&&(e.stopPropagation(),e.preventDefault(),this.send(n,new KeyboardEvent(`keydown`,{key:t,bubbles:!0,composed:!0,cancelable:!0})))}send(e,t){this.sending=t;try{return e.dispatchEvent(t)}finally{this.sending=null}}};let g=`mbx-spatial-nav`;return customElements.get(`mbx-spatial-nav`)===void 0&&customElements.define(g,h),e.MbxSpatialNav=h,e.SPATIAL_NAV=g,e})({});
|
package/dist/component.js
CHANGED
|
@@ -15,14 +15,14 @@ export class Component extends HTMLElement {
|
|
|
15
15
|
const attach = () => {
|
|
16
16
|
if (epoch !== this.epoch || !this.isConnected)
|
|
17
17
|
return;
|
|
18
|
-
// Defined, and this instance upgraded: `
|
|
18
|
+
// Defined, and this instance upgraded: `media` is on the prototype.
|
|
19
19
|
customElements.upgrade(found);
|
|
20
|
-
if (!('
|
|
20
|
+
if (!('media' in found))
|
|
21
21
|
return;
|
|
22
22
|
this.player = found;
|
|
23
23
|
this.attach(this.player);
|
|
24
24
|
};
|
|
25
|
-
if ('
|
|
25
|
+
if ('media' in found)
|
|
26
26
|
attach();
|
|
27
27
|
else
|
|
28
28
|
void customElements.whenDefined(PLAYER).then(attach);
|
package/dist/es2015/component.js
CHANGED
|
@@ -15,11 +15,11 @@ var Component = class extends HTMLElement {
|
|
|
15
15
|
const attach = () => {
|
|
16
16
|
if (epoch !== this.epoch || !this.isConnected) return;
|
|
17
17
|
customElements.upgrade(found);
|
|
18
|
-
if (!("
|
|
18
|
+
if (!("media" in found)) return;
|
|
19
19
|
this.player = found;
|
|
20
20
|
this.attach(this.player);
|
|
21
21
|
};
|
|
22
|
-
if ("
|
|
22
|
+
if ("media" in found) attach();
|
|
23
23
|
else customElements.whenDefined(PLAYER).then(attach);
|
|
24
24
|
}
|
|
25
25
|
disconnectedCallback() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mattebox/player-spatial-nav",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "<mbx-spatial-nav>: remote control navigation for <mattebox-player> on Tizen, webOS and other TV browsers.",
|
|
5
5
|
"author": "Josep Boix Requesens",
|
|
6
6
|
"repository": {
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"release:ci": "semantic-release"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@mattebox/player": ">=0.
|
|
53
|
+
"@mattebox/player": ">=0.15.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@mattebox/player-core": "^0.
|
|
56
|
+
"@mattebox/player-core": "^0.9.0"
|
|
57
57
|
}
|
|
58
58
|
}
|