@24i/bigscreen-sdk 1.0.2 → 1.0.3-alpha.2087

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.3-alpha.2087",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -140,6 +140,7 @@
140
140
  display: inline-block;
141
141
  vertical-align: top;
142
142
  width: $value-width;
143
+ word-break: break-word;
143
144
  }
144
145
  }
145
146
  }
@@ -4,6 +4,7 @@ import {
4
4
  ScreenSaverStatus,
5
5
  VolumeRange,
6
6
  } from '@24i/bigscreen-sdk/driver-base';
7
+ import { NetworkConnectionTypeMap } from './constants';
7
8
  import { getPlatformInfo } from './formatUserAgent';
8
9
  import { HisenseVidaaApi } from './types';
9
10
  import { getKeyMap } from './keymap';
@@ -118,7 +119,12 @@ export class DeviceVidaa extends DeviceBase {
118
119
  }
119
120
 
120
121
  async getConnectionType(): Promise<ConnectionType> {
121
- // not supported on Hisense VIDAA platform
122
+ try {
123
+ const netType = window.Hisense_GetNetType();
124
+ return NetworkConnectionTypeMap[netType] || 'unknown';
125
+ } catch (e) {
126
+ console.error('[DeviceVidaa] Failed getConnectionType', e);
127
+ }
122
128
  return 'unknown';
123
129
  }
124
130
 
@@ -6,6 +6,7 @@ export const mockHisenseVidaaApi: HisenseVidaaApi = {
6
6
  Hisense_GetFirmWareVersion: () => 'V0000.01.00Q.L0301',
7
7
  Hisense_Get4KSupportState: () => true,
8
8
  Hisense_GetDeviceID: () => '861003009000001000000641123456789012',
9
+ Hisense_GetNetType: () => 'wireless',
9
10
  };
10
11
 
11
12
  // Key constants are set to random number values
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Mapping connection type from Hisense VIDAA to SDK connection type.
3
+ */
4
+ export const NetworkConnectionTypeMap = {
5
+ wired: 'cable',
6
+ wireless: 'wifi',
7
+ OFF: 'none',
8
+ } as const;
@@ -1,3 +1,5 @@
1
+ export type HisenseNetType = 'OFF' | 'wired' | 'wireless';
2
+
1
3
  export interface HisenseVidaaApi {
2
4
  /**
3
5
  * This interface will retrieve Hisense Unique ID for the device.
@@ -27,6 +29,12 @@ export interface HisenseVidaaApi {
27
29
  * @return a string that represents the TV model name.
28
30
  */
29
31
  Hisense_GetModelName: () => string,
32
+ /**
33
+ * This interface retrieves the network type of the device.
34
+ * @return a string that represents the network type for the device.
35
+ * The one from "OFF", "wired", "wireless".
36
+ */
37
+ Hisense_GetNetType: () => HisenseNetType,
30
38
  }
31
39
 
32
40
  export type HisenseVidaaKeys = {
@@ -1,6 +1,7 @@
1
1
  import { Component, createRef } from '@24i/bigscreen-sdk/jsx';
2
2
  import { device } from '@24i/bigscreen-sdk/device';
3
3
  import { stopEvent } from '@24i/bigscreen-sdk/utils/stopEvent';
4
+ import { getDisplayToggler, DISPLAY_NONE } from '@24i/bigscreen-sdk/utils/displayToggler';
4
5
  import { service } from './service';
5
6
  import {
6
7
  Props,
@@ -25,6 +26,16 @@ export class MenuAndContentContainer<T extends string = string>
25
26
  */
26
27
  listensToMouse = false;
27
28
 
29
+ /**
30
+ * Element for triggering menu by mouse event.
31
+ */
32
+ mouseTriggerElement = createRef<HTMLDivElement>();
33
+
34
+ /**
35
+ * DisplayToggler for {@link mouseTriggerElement}.
36
+ */
37
+ mouseTriggerElementDisplayToggler = getDisplayToggler(this.mouseTriggerElement, true);
38
+
28
39
  /**
29
40
  * Adds event listeners:
30
41
  * - keydown to {@link Props.elementForEvents elementForEvents}
@@ -58,10 +69,12 @@ export class MenuAndContentContainer<T extends string = string>
58
69
  onVisibilityChange = (visible: boolean) => {
59
70
  if (visible) {
60
71
  this.menu.current!.focus();
72
+ if (this.listensToMouse) this.mouseTriggerElementDisplayToggler.hide();
61
73
  service.triggerEvent('visibilitychange', true);
62
74
  } else {
63
75
  const { router: { current: router } } = this.props;
64
76
  router!.focus();
77
+ if (this.listensToMouse) this.mouseTriggerElementDisplayToggler.show();
65
78
  service.triggerEvent('visibilitychange', false);
66
79
  }
67
80
  };
@@ -88,14 +101,10 @@ export class MenuAndContentContainer<T extends string = string>
88
101
  * @param event mouse event
89
102
  */
90
103
  onMouseMove = (event: MouseEvent) => {
91
- const { Menu } = this.props;
92
104
  const menu = this.menu.current!;
93
105
  if (this.isMenuAvailable() && !menu.isOpen()) {
94
- const { clientX, clientY } = event;
95
- if (Menu.shouldOpenMenuWithMouse({ clientX, clientY })) {
96
- menu.open();
97
- stopEvent(event);
98
- }
106
+ menu.open();
107
+ stopEvent(event);
99
108
  }
100
109
  };
101
110
 
@@ -127,8 +136,8 @@ export class MenuAndContentContainer<T extends string = string>
127
136
  addMouseListener() {
128
137
  if (!this.listensToMouse) {
129
138
  this.listensToMouse = true;
130
- const { elementForEvents } = this.props;
131
- elementForEvents.current!.addEventListener('mousemove', this.onMouseMove);
139
+ if (!this.menu.current!.isOpen()) this.mouseTriggerElementDisplayToggler.show();
140
+ this.mouseTriggerElement.current!.addEventListener('mousemove', this.onMouseMove);
132
141
  }
133
142
  }
134
143
 
@@ -138,8 +147,8 @@ export class MenuAndContentContainer<T extends string = string>
138
147
  removeMouseListener() {
139
148
  if (this.listensToMouse) {
140
149
  this.listensToMouse = false;
141
- const { elementForEvents } = this.props;
142
- elementForEvents.current!.removeEventListener('mousemove', this.onMouseMove);
150
+ if (!this.menu.current!.isOpen()) this.mouseTriggerElementDisplayToggler.hide();
151
+ this.mouseTriggerElement.current!.removeEventListener('mousemove', this.onMouseMove);
143
152
  }
144
153
  }
145
154
 
@@ -155,12 +164,18 @@ export class MenuAndContentContainer<T extends string = string>
155
164
  const { children, items, Menu } = this.props;
156
165
  return (
157
166
  <>
158
- <Menu
159
- ref={this.menu}
160
- items={items}
161
- onVisibilityChange={this.onVisibilityChange}
162
- contentContainer={this}
163
- />
167
+ <div className="menu-container">
168
+ <Menu
169
+ ref={this.menu}
170
+ items={items}
171
+ onVisibilityChange={this.onVisibilityChange}
172
+ contentContainer={this}
173
+ />
174
+ <div
175
+ ref={this.mouseTriggerElement}
176
+ className={`menu-mouse-trigger ${DISPLAY_NONE}`}
177
+ />
178
+ </div>
164
179
  {children}
165
180
  </>
166
181
  );
@@ -119,13 +119,6 @@ export interface Menu<
119
119
  updateItems(items: MenuItem<T>[]): void,
120
120
  }
121
121
 
122
- /**
123
- * Function for deciding whether to open menu based on mouse position.
124
- */
125
- type MouseMenuOpenResolver = (
126
- ({ clientX, clientY }: { clientX: number, clientY: number }) => boolean
127
- );
128
-
129
122
  /**
130
123
  * Function for deciding whether to open menu based on pressed key.
131
124
  */
@@ -145,7 +138,6 @@ type KeyboardMenuCloseResolver = (
145
138
  */
146
139
  export interface MenuComponent<T extends string = string, P extends MenuProps<T> = MenuProps<T>> {
147
140
  new (props: P): Menu<T, P>,
148
- shouldOpenMenuWithMouse: MouseMenuOpenResolver,
149
141
  shouldOpenMenu: KeyboardMenuOpenResolver,
150
142
  shouldCloseMenu: KeyboardMenuCloseResolver,
151
143
  }
@@ -1,4 +1,4 @@
1
- .menu-container {
1
+ .menu-container .side-menu {
2
2
  position: absolute;
3
3
  top: 0;
4
4
  left: 0;
@@ -220,7 +220,7 @@ export class SideMenu extends Component<Props> implements ISideMenu {
220
220
  render() {
221
221
  const { items } = this.props;
222
222
  return (
223
- <div ref={this.visualController.div} className={`menu-container ${DISPLAY_NONE}`}>
223
+ <div ref={this.visualController.div} className={`side-menu ${DISPLAY_NONE}`}>
224
224
  <div
225
225
  ref={this.visualController.overlay}
226
226
  className={`overlay ${animated ? DISPLAY_NONE : ''}`}
@@ -2,7 +2,7 @@
2
2
  @import '@24i/bigscreen-sdk/sass-utils/transition';
3
3
  @import '@24i/bigscreen-sdk/sass-utils/prefix-property';
4
4
 
5
- .menu-container {
5
+ .menu-container .side-menu {
6
6
  @include transform(translate3d(0, 0, 0));
7
7
  @include transition(prefix-property(transform), 300ms);
8
8
 
@@ -1,6 +1,6 @@
1
1
  @import '@24i/bigscreen-sdk/sass-utils/transform';
2
2
 
3
- [dir=rtl] .menu-container {
3
+ [dir=rtl] .menu-container .side-menu {
4
4
  left: auto;
5
5
  right: 0;
6
6
 
@@ -189,11 +189,7 @@ export class PlayerUI extends Component<Props>
189
189
  }
190
190
 
191
191
  canHideAutomatically() {
192
- return (
193
- this.isPlaying()
194
- && !this.seeking.isSeeking()
195
- && !this.isHidingDisabled
196
- );
192
+ return !this.isHidingDisabled;
197
193
  }
198
194
 
199
195
  isPlaying() {