@mattebox/player-spatial-nav 0.1.1 → 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.
- package/dist/cdn/mattebox-player-spatial-nav.min.js +1 -1
- package/dist/component.js +3 -3
- package/dist/es2015/component.js +3 -4
- package/dist/es2015/host.js +1 -2
- package/dist/es2015/index.js +1 -2
- package/dist/es2015/keys.js +1 -2
- package/dist/es2015/navigate.js +1 -2
- package/dist/es2015/spatial-nav.js +2 -3
- package/package.json +3 -3
|
@@ -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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PLAYER, findPlayer } from "./host.js";
|
|
2
|
-
|
|
2
|
+
// src/component.ts
|
|
3
3
|
var Component = class extends HTMLElement {
|
|
4
4
|
constructor() {
|
|
5
5
|
super();
|
|
@@ -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() {
|
|
@@ -36,5 +36,4 @@ var Component = class extends HTMLElement {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
//#endregion
|
|
40
39
|
export { Component };
|
package/dist/es2015/host.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/host.ts
|
|
2
2
|
const PLAYER = "mattebox-player";
|
|
3
3
|
/** The parent, or the host of the shadow root `node` sits in, or null at the document. */
|
|
4
4
|
function above(node) {
|
|
@@ -15,5 +15,4 @@ function findPlayer(node) {
|
|
|
15
15
|
}
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
-
//#endregion
|
|
19
18
|
export { PLAYER, above, findPlayer };
|
package/dist/es2015/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MbxSpatialNav } from "./spatial-nav.js";
|
|
2
|
-
|
|
2
|
+
// src/index.ts
|
|
3
3
|
/**
|
|
4
4
|
* @mattebox/player-spatial-nav: <mbx-spatial-nav>, the remote control for the player
|
|
5
5
|
* on a TV. Importing this module registers the element; that is the
|
|
@@ -8,5 +8,4 @@ import { MbxSpatialNav } from "./spatial-nav.js";
|
|
|
8
8
|
*/
|
|
9
9
|
const SPATIAL_NAV = "mbx-spatial-nav";
|
|
10
10
|
if (customElements.get("mbx-spatial-nav") === void 0) customElements.define(SPATIAL_NAV, MbxSpatialNav);
|
|
11
|
-
//#endregion
|
|
12
11
|
export { MbxSpatialNav, SPATIAL_NAV };
|
package/dist/es2015/keys.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/keys.ts
|
|
2
2
|
/**
|
|
3
3
|
* The keys of a TV remote, as the standard `KeyboardEvent.key` names the
|
|
4
4
|
* player reads. Tizen and webOS report several remote keys by `keyCode`
|
|
@@ -38,5 +38,4 @@ function keyOf(event) {
|
|
|
38
38
|
function isBack(key) {
|
|
39
39
|
return key === "GoBack" || key === "BrowserBack" || key === "Escape";
|
|
40
40
|
}
|
|
41
|
-
//#endregion
|
|
42
41
|
export { isBack, keyOf };
|
package/dist/es2015/navigate.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { above } from "./host.js";
|
|
2
1
|
import { Component } from "./component.js";
|
|
2
|
+
import { above } from "./host.js";
|
|
3
3
|
import { isBack, keyOf } from "./keys.js";
|
|
4
4
|
import { DIRECTIONS, OPPOSITE, candidates, nearest } from "./navigate.js";
|
|
5
|
-
|
|
5
|
+
// src/spatial-nav.ts
|
|
6
6
|
/**
|
|
7
7
|
* <mbx-spatial-nav>: the remote control for the player on a TV. Placed
|
|
8
8
|
* inside the player, it renders nothing, and it moves focus between the
|
|
@@ -179,5 +179,4 @@ var MbxSpatialNav = class extends Component {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
|
-
//#endregion
|
|
183
182
|
export { MbxSpatialNav };
|
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
|
}
|