@24i/bigscreen-sdk 1.0.25 → 1.0.26-alpha.2448

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.25",
3
+ "version": "1.0.26-alpha.2448",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -41,7 +41,7 @@
41
41
  "@24i/appstage-shared-events-manager": "1.0.11",
42
42
  "@24i/appstage-shared-perf-utils": "1.0.11",
43
43
  "@24i/bigscreen-players-engine-base": "1.0.6",
44
- "@24i/smartapps-datalayer": "3.0.10-alpha.1014",
44
+ "@24i/smartapps-datalayer": "3.0.10-alpha.1016",
45
45
  "@sentry/browser": "7.35.0",
46
46
  "@sentry/types": "7.35.0",
47
47
  "@types/gtag.js": "^0.0.13",
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.main = void 0;
5
+ const path = require("path");
6
+ const fs = require("fs");
7
+ const fse = require("fs-extra");
8
+ const chalk = require("chalk");
9
+ const minimist = require("minimist");
10
+ const questions_1 = require("./questionnaire/questions");
11
+ const Settings_1 = require("./settings/Settings");
12
+ async function isDirectoryEmpty(dirPath) {
13
+ const files = await fs.promises.readdir(dirPath);
14
+ return !files.length;
15
+ }
16
+ async function copyTemplateFiles(templateDir, targetDir) {
17
+ return fse.copy(templateDir, targetDir);
18
+ }
19
+ function updatePackageJsonFile(filePath, options) {
20
+ let data = fs.readFileSync(filePath, 'utf8');
21
+ const keywords = options.keywords.map((word) => `"${word}"`).join(', ');
22
+ data = data.replace(/("name": ")(.*)(")/, `$1${options.name}$3`);
23
+ data = data.replace(/("version": ")(.*)(")/, `$1${options.version}$3`);
24
+ data = data.replace(/("description": ")(.*)(")/, `$1${options.description}$3`);
25
+ data = data.replace(/("keywords": \[)(.*)(\])/, `$1${keywords}$3`);
26
+ data = data.replace(/("author": ")(.*)(")/, `$1${options.author}$3`);
27
+ fs.writeFileSync(filePath, data);
28
+ }
29
+ function parseArguments(rawArgv) {
30
+ const argv = minimist(rawArgv.slice(2));
31
+ const dirName = argv._[0];
32
+ if (!dirName) {
33
+ console.error('Error: Missing package name');
34
+ process.exit(1);
35
+ }
36
+ return {
37
+ dirName,
38
+ };
39
+ }
40
+ async function main() {
41
+ const { dirName: destDirName } = parseArguments(process.argv);
42
+ const destDir = path.join(process.cwd(), 'packages/', destDirName);
43
+ if (fs.existsSync(destDir)) {
44
+ console.error(`Error: Target directory "${destDir}" already exists`);
45
+ process.exit(1);
46
+ }
47
+ fs.mkdirSync(destDir, { recursive: true });
48
+ const isDirEmpty = await isDirectoryEmpty(destDir);
49
+ if (!isDirEmpty) {
50
+ console.error(`Error: Target directory "${destDir}" is not empty.`);
51
+ process.exit(1);
52
+ }
53
+ const settings = Object.assign({}, Settings_1.Settings);
54
+ settings.name = `${Settings_1.Settings.name}${destDirName}`.toLowerCase();
55
+ const details = await (0, questions_1.promptPackageDetails)(settings);
56
+ const templateDir = path.join(__dirname, '..', 'templates/typescript');
57
+ await copyTemplateFiles(templateDir, destDir);
58
+ const packageJsonFile = path.join(destDir, 'package.json');
59
+ updatePackageJsonFile(packageJsonFile, details);
60
+ const docsSymlinkTarget = path.join('../../../packages/', destDirName, '/README.md');
61
+ const docsSymlinkPath = path.join(process.cwd(), 'docs/packages/', destDirName, '/README.md');
62
+ await fse.ensureSymlink(docsSymlinkTarget, docsSymlinkPath);
63
+ console.log(`${chalk.green('Success')}, package has been initialized!`);
64
+ }
65
+ exports.main = main;
66
+ //# sourceMappingURL=createPackage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createPackage.js","sourceRoot":"","sources":["../src/createPackage.ts"],"names":[],"mappings":";;;;AAEA,6BAA6B;AAC7B,yBAAyB;AACzB,gCAAgC;AAChC,+BAA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AC;IACrD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,sBAAsB,CAAC,CAAC;IAEvE,MAAM,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC9C,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC3D,qBAAqB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IAGhD,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IACrF,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IAC9F,MAAM,GAAG,CAAC,aAAa,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;IAE5D,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC;AAC5E,CAAC;AA/BD,oBA+BC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const createPackage_1 = require("./createPackage");
4
+ (0, createPackage_1.main)();
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,mDAAuC;AAEvC,IAAA,oBAAI,GAAE,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.promptPackageDetails = void 0;
4
+ const inquirer = require("inquirer");
5
+ async function promptPackageDetails(defaultValues) {
6
+ return inquirer.prompt([
7
+ {
8
+ type: 'input',
9
+ name: 'name',
10
+ message: 'Package name:',
11
+ default: defaultValues.name,
12
+ }, {
13
+ type: 'input',
14
+ name: 'version',
15
+ message: 'Version:',
16
+ default: defaultValues.version,
17
+ }, {
18
+ type: 'input',
19
+ name: 'description',
20
+ message: 'Description:',
21
+ }, {
22
+ type: 'input',
23
+ name: 'keywords',
24
+ message: 'Keywords:',
25
+ filter: (ans) => ans.split(/[\s,]+/),
26
+ }, {
27
+ type: 'input',
28
+ name: 'author',
29
+ message: 'Author:',
30
+ default: defaultValues.author,
31
+ },
32
+ ]);
33
+ }
34
+ exports.promptPackageDetails = promptPackageDetails;
35
+ //# sourceMappingURL=questions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questions.js","sourceRoot":"","sources":["../../src/questionnaire/questions.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AAWrC,KAAK,UAAU,oBAAoB,CAAC,aAA4C;IAC5E,OAAO,QAAQ,CAAC,MAAM,CAAC;QACnB;YACI,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,eAAe;YACxB,OAAO,EAAE,aAAa,CAAC,IAAI;SAC9B,EAAE;YACC,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,UAAU;YACnB,OAAO,EAAE,aAAa,CAAC,OAAO;SACjC,EAAE;YACC,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,cAAc;SAC1B,EAAE;YACC,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,WAAW;YACpB,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC;SACvC,EAAE;YACC,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE,aAAa,CAAC,MAAM;SAChC;KACJ,CAAC,CAAC;AACP,CAAC;AAEQ,oDAAoB"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Settings = void 0;
4
+ const Settings = {
5
+ name: '@24i/smartapps-bigscreen-',
6
+ version: '0.0.1',
7
+ author: '24i',
8
+ };
9
+ exports.Settings = Settings;
10
+ //# sourceMappingURL=Settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Settings.js","sourceRoot":"","sources":["../../src/settings/Settings.ts"],"names":[],"mappings":";;;AAAA,MAAM,QAAQ,GAAG;IACb,IAAI,EAAE,2BAA2B;IACjC,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,KAAK;CAChB,CAAC;AAEO,4BAAQ"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -14,11 +14,13 @@ IFocusable is an interface that should be implemented by anything that can be fo
14
14
  interface IFocusable {
15
15
  focus(options?: FocusOptions): void,
16
16
  hasDom?(element: HTMLElement): boolean,
17
+ hasFocus?(): boolean,
17
18
  }
18
19
  ```
19
20
  - focus is the main function that is called when focusing component/element.
20
21
  - hasDom is optional optimization for components to help Layout components locate the currently
21
22
  focused child.
23
+ - hasFocus is optional check if the component has focus inside or is itself focused.
22
24
 
23
25
  ## Layout components
24
26
  - Vertical: Use it to create focus between elements vertically (up/down)
@@ -329,3 +331,18 @@ outside of the component and not focused.
329
331
  ```ts
330
332
  const refocusAfterHashChange = (focusWrapperOrReference: HTMLElement | Reference<HTMLElement>) => void;
331
333
  ```
334
+
335
+ ## hasFocus
336
+ Test if the element (or element in the reference) has the `activeElement` inside or optionally,
337
+ if the element itself is the `activeElement`.
338
+
339
+ ```ts
340
+ const hasFocus = (elementOrReference: HTMLElement | Reference<HTMLElement>, includeElementItself = false) => boolean;
341
+ ```
342
+
343
+ ## isFocused
344
+ Test if the element (or element in the reference) is the `activeElement`.
345
+
346
+ ```ts
347
+ const isFocused = (elementOrReference: HTMLElement | Reference<HTMLElement>) => boolean;
348
+ ```
@@ -1,4 +1,5 @@
1
1
  export interface IFocusable {
2
2
  focus(options?: FocusOptions): void,
3
3
  hasDom?(element: HTMLElement): boolean,
4
+ hasFocus?(): boolean,
4
5
  }
@@ -0,0 +1,36 @@
1
+ import { Reference, unwrapReference } from '@24i/bigscreen-sdk/jsx';
2
+ import { isElementWrappedBy } from '@24i/bigscreen-sdk/utils/elementUtils';
3
+
4
+ /**
5
+ * Test if the element (or element in the reference) has the `activeElement` inside or optionally,
6
+ * if the element itself is the `activeElement`.
7
+ * @param elementOrReference DOM element or reference to element on which we test focus
8
+ * @param includeElementItself if true, active element is also tested with the provided element.
9
+ * Default is false
10
+ * @returns true if the element has focused element inside or is itself focused
11
+ */
12
+ export const hasFocus = (
13
+ elementOrReference: HTMLElement | Reference<HTMLElement>,
14
+ includeElementItself = false,
15
+ ) => {
16
+ const element = unwrapReference(elementOrReference);
17
+ if (!element) return false;
18
+ return isElementWrappedBy(
19
+ document.activeElement as HTMLElement,
20
+ element,
21
+ includeElementItself,
22
+ );
23
+ };
24
+
25
+ /**
26
+ * Test if the element (or element in the reference) is the `activeElement`.
27
+ * @param elementOrReference DOM element or reference to element on which we test focus
28
+ * @returns true if the element is focused
29
+ */
30
+ export const isFocused = (
31
+ elementOrReference: HTMLElement | Reference<HTMLElement>,
32
+ ) => {
33
+ const element = unwrapReference(elementOrReference);
34
+ if (!element) return false;
35
+ return document.activeElement === element;
36
+ };
@@ -13,3 +13,4 @@ export {
13
13
  } from './candidate';
14
14
  export { focusFirstExisting, preventScrollOnFocus } from './focusFirstExisting';
15
15
  export { refocusAfterHashChange } from './refocusAfterHashChange';
16
+ export { hasFocus, isFocused } from './hasFocus';
@@ -21,6 +21,7 @@ import { generateUuid } from '@24i/bigscreen-sdk/utils/generateUuid';
21
21
  - **[addClass](#addClass)** - safely adds class to reference.
22
22
  - **[debounce](#debounce)** - debounced function is only executed again after a period of not being called, supports leading, trailing (default) and both executions.
23
23
  - **[displayToggler](#displayToggler)** - exports `getDisplayToggler` that allows you to easily show/hide an element with guard preventing unnecessary DOM calls.
24
+ - **[elementUtils](#elementUtils)** - various utils above HTMLElement.
24
25
  - **[forceReflow](#forceReflow)** - To force a DOM reflow on given DOM element.
25
26
  - **[generateUuid](#generateUuid)** - function to get UUIDv4 according to RFC 4122.
26
27
  - **[isMouseUsed](#isMouseUsed)** - **DEPRECATED** moved to `device` package.
@@ -95,6 +96,9 @@ And returns `IDisplayToggler` interface with 4 functions:
95
96
  - `isVisible: () => boolean;` - returns true if the element is visible, false otherwise
96
97
  - `isHidden: () => boolean;` - returns true if the element is hidden, false otherwise
97
98
 
99
+ ### elementUtils
100
+ Various utils for HTMLElement such as visibility tests or element wrapping tests.
101
+
98
102
  ### forceReflow
99
103
  To force a DOM reflow on given DOM element. It can be needed for transitions
100
104
  or other purposes.
@@ -4,6 +4,12 @@ import { SCREEN_WIDTH } from './sizes';
4
4
 
5
5
  const SAFE_TIMEOUT = 100;
6
6
 
7
+ /**
8
+ * Test if the element (or element in the reference) is wrapped visible. This means that the
9
+ * element does not have `display: none` or `visibility: hidden`.
10
+ * @param elementOrReference DOM element or reference to element on which we test wrapping
11
+ * @returns true if element is visible
12
+ */
7
13
  export const isElementVisible = (
8
14
  elementOrReference: HTMLElement | Reference<HTMLElement>,
9
15
  ) => {
@@ -13,10 +19,18 @@ export const isElementVisible = (
13
19
  return style.display !== 'none' && style.visibility !== 'hidden';
14
20
  };
15
21
 
22
+ /**
23
+ * Test if the element (or element in the reference) is wrapped fully visible. This means that the
24
+ * element does not have `display: none` or `visibility: hidden` and exists
25
+ * inside visible DOM tree, which exists in the document.body.
26
+ * @param elementOrReference DOM element or reference to element on which we test wrapping
27
+ * @returns true if element is visible
28
+ */
16
29
  export const isElementFullyVisible = (
17
30
  elementOrReference: HTMLElement | Reference<HTMLElement>,
18
31
  ) => {
19
32
  const element = unwrapReference(elementOrReference);
33
+ if (!element) return false;
20
34
  if (isElementVisible(element)) {
21
35
  let parent = element.parentElement;
22
36
  while (parent) {
@@ -33,6 +47,16 @@ export const isElementFullyVisible = (
33
47
  return false;
34
48
  };
35
49
 
50
+ /**
51
+ * Test if the element (or element in the reference) is wrapped by another element.
52
+ * @param elementOrReference DOM element or reference to element on which we test wrapping
53
+ * @param wrapperElementOrReferenceOrCondition wrapper element or certain condition (utils is
54
+ * running upwards in the DOM tree from first element till some element has some specific condition)
55
+ * @param includesElementItself if true, test will check also provided element itself.
56
+ * This is useful in some cases when we need to include also provided element as wrapper
57
+ * in one run of the util.
58
+ * @returns true if the element is wrapped by provided wrapper
59
+ */
36
60
  export const isElementWrappedBy = (
37
61
  elementOrReference: HTMLElement | Reference<HTMLElement>,
38
62
  wrapperElementOrReferenceOrCondition:
@@ -40,6 +64,7 @@ export const isElementWrappedBy = (
40
64
  includesElementItself = false,
41
65
  ) => {
42
66
  const element = unwrapReference(elementOrReference);
67
+ if (!element) return false;
43
68
  let currentParent = includesElementItself ? element : element.parentElement;
44
69
  let wrapperElement: HTMLElement | null = null;
45
70
  let condition: ((currentWrapper: HTMLElement) => boolean) | null = null;
@@ -16,6 +16,7 @@ export {
16
16
  isElementVisible,
17
17
  isElementFullyVisible,
18
18
  isElementWrappedBy,
19
+ preventDefaultScroll,
19
20
  } from './elementUtils';
20
21
  export { createInterval, createTimeout, runAsync } from './timers';
21
22
  export type { TimedFunction } from './timers';