@24i/bigscreen-sdk 1.0.8-alpha.2177 → 1.0.8-alpha.2180

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.8-alpha.2177",
3
+ "version": "1.0.8-alpha.2180",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -143,6 +143,7 @@ export class PlayerUI extends Component<Props>
143
143
  }
144
144
  if (!this.seeking.isAutomaticallySeekingForward) {
145
145
  this.seeking.startAutomaticSeekForward();
146
+ this.disableHiding();
146
147
  return true;
147
148
  }
148
149
  return false;
@@ -155,6 +156,7 @@ export class PlayerUI extends Component<Props>
155
156
  }
156
157
  if (!this.seeking.isAutomaticallySeekingBackward) {
157
158
  this.seeking.startAutomaticSeekBackward();
159
+ this.disableHiding();
158
160
  return true;
159
161
  }
160
162
  return false;
@@ -0,0 +1,47 @@
1
+ import { HOUR_IN_MS, MINUTE_IN_MS } from '@24i/bigscreen-sdk/utils';
2
+ import * as TwentyFourIMediaTimeApi from '../services/24iMediaTimeApi';
3
+
4
+ type ParamOptions = TwentyFourIMediaTimeApi.ParamOptions;
5
+
6
+ const defaultOptions: ParamOptions = {
7
+ timeoutInMs: 30000,
8
+ retryConfig: {
9
+ retry: 2,
10
+ },
11
+ };
12
+
13
+ /**
14
+ * Returns a tring in ISO format followed by +/-hh:mm suffix for timezone offset.
15
+ * @param resp Time api response.
16
+ * @returns ISO string with timezone data.
17
+ */
18
+ const getIsoDateString = (resp: TwentyFourIMediaTimeApi.ServiceDataResponse): string => {
19
+ let datetime = new Date(resp.timestamp + resp.timezone_offset).toISOString();
20
+ const offset = resp.timezone_offset / HOUR_IN_MS;
21
+ if (offset) {
22
+ const sign = offset > 0 ? '+' : '-';
23
+ const hours = Math.abs(offset);
24
+ const minutes = Math.floor((resp.timezone_offset % HOUR_IN_MS) / MINUTE_IN_MS);
25
+ // eslint-disable-next-line no-magic-numbers
26
+ const timeString = sign + `0${hours}`.slice(-2) + ':' + `0${minutes}`.slice(-2);
27
+ datetime = datetime.replace('Z', timeString);
28
+ }
29
+ return datetime;
30
+ };
31
+
32
+ /**
33
+ * Wrapper over "TwentyFourIMediaTimeApi.getTime" method requesting the current time
34
+ * from timekeeping server. Transforms the result to ISO string with timezone offset data
35
+ * included.
36
+ *
37
+ * @param options Options object
38
+ */
39
+ export const getTime = async (options: ParamOptions = {}) => {
40
+ const opts = { ...defaultOptions, ...options };
41
+ const resp = await TwentyFourIMediaTimeApi.getTime(opts);
42
+
43
+ if ('timestamp' in resp && 'timezone_offset' in resp && 'in_dst' in resp) {
44
+ return { datetime: getIsoDateString(resp) };
45
+ }
46
+ return null;
47
+ };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Package "24iMediaTimeApi" provides a single function to obtain the current time
3
+ * adjusted by local timezone and daylight savings time for use in time package,
4
+ * from 24i time API at https://time.24imedia.tv/
5
+ */
6
+ import {
7
+ xhrSendRetry, type RetryConfig, type XhrResponse,
8
+ } from '@24i/bigscreen-sdk/utils/xhr';
9
+
10
+ const API_URL = 'https://time.24imedia.tv/';
11
+
12
+ export type Options = {
13
+ /** The request timeout in milliseconds. The value 0 for no timeout */
14
+ timeoutInMs: number,
15
+ /** Retry configuration */
16
+ retryConfig: RetryConfig,
17
+ };
18
+ export type ParamOptions = Partial<Options>;
19
+
20
+ export type ServiceDataResponse = {
21
+ /** Is dailight savings time */
22
+ in_dst: boolean,
23
+ /** Current time in GMT, in milliseconds */
24
+ timestamp: number,
25
+ /** Timezeone offset in milliseconds */
26
+ timezone_offset: number,
27
+ };
28
+
29
+ /**
30
+ * Request the current time based on public IP of request.
31
+ *
32
+ * @param options Options object
33
+ */
34
+ export async function getTime(options?: ParamOptions): Promise<ServiceDataResponse> {
35
+ try {
36
+ const resp = (await xhrSendRetry(API_URL, options)) as XhrResponse;
37
+ const data: any = resp.dataJson || {};
38
+ return data as ServiceDataResponse;
39
+ } catch (e) {
40
+ console.error('[24iMediaTimeApi] Failed to get time', e);
41
+ throw e;
42
+ }
43
+ }
@@ -0,0 +1,6 @@
1
+ export {
2
+ Options,
3
+ ParamOptions,
4
+ ServiceDataResponse,
5
+ getTime,
6
+ } from './24iMediaTimeApi';
@@ -9,6 +9,7 @@ const trimWithEllipsis = (
9
9
  if (!row.textContent) {
10
10
  return;
11
11
  }
12
+ const { visibility } = row.style;
12
13
  row.style.visibility = 'hidden';
13
14
  const lineHeightString = window.getComputedStyle(row, null).getPropertyValue('line-height');
14
15
  const lineHeight = parseInt(lineHeightString, 10);
@@ -27,6 +28,7 @@ const trimWithEllipsis = (
27
28
  } while (numberOfLines <= requestedNumberOfLines
28
29
  && currentPosition < originalTextContent.length);
29
30
  row.textContent = stringBuffer.substring(0, stringBuffer.length - 1) + ellipsis;
31
+
30
32
  } else {
31
33
  let currentPosition = originalTextContent.length - 1;
32
34
  do {
@@ -39,7 +41,7 @@ const trimWithEllipsis = (
39
41
  row.textContent = `${ellipsis}${stringBuffer.substring(1)}`;
40
42
  }
41
43
  }
42
- row.style.visibility = '';
44
+ row.style.visibility = visibility;
43
45
  };
44
46
 
45
47
  export const trimWithLeadingEllipsis = (