@24i/bigscreen-sdk 0.9.9-alpha.2148 → 0.9.9-alpha.2150
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/__mocks__/@24i/bigscreen-sdk/animations.ts +2 -0
- package/package.json +1 -1
- package/packages/animations/src/__mocks__/JSAnimations.ts +30 -0
- package/packages/conviva/src/__mocks__/ConvivaMock.ts +36 -0
- package/packages/developer-tools/src/DeveloperConsole/utils/formatTime.ts +13 -0
- package/packages/developer-tools/src/DeveloperConsole/utils/index.ts +3 -0
- package/packages/developer-tools/src/DeveloperConsole/utils/stringify.ts +10 -0
- package/packages/developer-tools/src/DeveloperConsole/utils/styles.ts +24 -0
- package/packages/developer-tools/src/EnvironmentSelection/utils/format.ts +4 -0
- package/packages/developer-tools/src/TechnicalInfo/__mocks__/Device.ts +51 -0
- package/packages/developer-tools/src/TechnicalInfo/__mocks__/Player.ts +7 -0
- package/packages/developer-tools/src/TechnicalInfo/__mocks__/Storage.ts +9 -0
- package/packages/developer-tools/src/TechnicalInfo/utils/eme01bSupport.ts +58 -0
- package/packages/developer-tools/src/TechnicalInfo/utils/emeSupport.ts +80 -0
- package/packages/developer-tools/src/TechnicalInfo/utils/formatTimezone.ts +15 -0
- package/packages/developer-tools/src/TechnicalInfo/utils/mseSupport.ts +14 -0
- package/packages/developer-tools/src/utils/reload.ts +6 -0
- package/packages/driver-base/src/__mocks__/DeviceBase.ts +100 -0
- package/packages/driver-base/src/__mocks__/keyMap.ts +41 -0
- package/packages/driver-entone/src/__mocks__/entone.ts +177 -0
- package/packages/driver-hbbtv/src/__mocks__/hbbtv.ts +17 -0
- package/packages/driver-kreatv/src/__mocks__/toi2.ts +76 -0
- package/packages/driver-kreatv/src/__mocks__/toi3.ts +43 -0
- package/packages/driver-saphi/src/__mocks__/SmartTvA_API.ts +11 -0
- package/packages/driver-saphi/src/__mocks__/userAgent.ts +4 -0
- package/packages/driver-tizen/src/__mocks__/tizen.ts +35 -0
- package/packages/driver-webos/src/__mocks__/webos.ts +172 -0
- package/packages/driver-xbox/src/__mocks__/Windows.ts +94 -0
- package/packages/gallup/src/__mocks__/SpringStreams.js +18 -0
- package/packages/input/__mocks__/MockKeyboard.ts +40 -0
- package/packages/keyboard/src/utils/caret.ts +48 -0
- package/packages/keyboard/src/utils/generateFocusMatrixFromStringMatrix.ts +12 -0
- package/packages/keyboard/src/utils/input.ts +40 -0
- package/packages/list/utils/index.ts +1 -0
- package/packages/logger/src/__mocks__/LoggerBase.ts +13 -0
- package/packages/logger/src/utils/deviceInfo.ts +25 -0
- package/packages/logger/src/utils/index.ts +1 -0
- package/packages/utils/README.md +336 -0
- package/packages/utils/src/addClass.ts +9 -0
- package/packages/utils/src/counter.ts +47 -0
- package/packages/utils/src/debounce.ts +54 -0
- package/packages/utils/src/displayToggler.scss +3 -0
- package/packages/utils/src/displayToggler.ts +38 -0
- package/packages/utils/src/elementUtils.ts +58 -0
- package/packages/utils/src/generateUuid.ts +19 -0
- package/packages/utils/src/index.ts +35 -0
- package/packages/utils/src/memoryInfo.ts +21 -0
- package/packages/utils/src/nTimes.ts +9 -0
- package/packages/utils/src/noop.ts +1 -0
- package/packages/utils/src/offsetPosition.ts +56 -0
- package/packages/utils/src/removeClass.ts +9 -0
- package/packages/utils/src/scaledImage.ts +21 -0
- package/packages/utils/src/stopEvent.ts +10 -0
- package/packages/utils/src/timeConstants.ts +11 -0
- package/packages/utils/src/timers/createInterval.ts +19 -0
- package/packages/utils/src/timers/createTimeout.ts +22 -0
- package/packages/utils/src/timers/index.ts +4 -0
- package/packages/utils/src/timers/runAsync.ts +3 -0
- package/packages/utils/src/timers/types.ts +9 -0
- package/packages/utils/src/wait.ts +1 -0
- package/packages/utils/src/xhr/__mocks__/xhr.ts +29 -0
- package/packages/utils/src/xhr/index.ts +11 -0
- package/packages/utils/src/xhr/xhrSend.ts +139 -0
- package/packages/utils/src/xhr/xhrSendRetry.ts +77 -0
- package/packages/volume-control/src/__mocks__/VolumeControlUIMock.tsx +18 -0
- package/utils/create-export-maps/index.ts +3 -0
- package/utils/create-export-maps/src/__tests__/createExportMaps.spec.ts +50 -0
- package/utils/create-export-maps/src/createExportMaps.ts +61 -0
- package/utils/create-package/README.md +40 -0
- package/utils/create-package/src/createPackage.ts +72 -0
- package/utils/create-package/src/index.ts +3 -0
- package/utils/create-package/src/questionnaire/questions.ts +19 -0
- package/utils/create-package/src/settings/Settings.ts +5 -0
- package/utils/create-package/src/types.ts +4 -0
- package/utils/create-package/templates/typescript/README.md +9 -0
- package/utils/create-package/templates/typescript/exports.json +6 -0
- package/utils/create-package/templates/typescript/src/index.ts +0 -0
- package/utils/run-scripts/index.ts +3 -0
- package/utils/run-scripts/src/__tests__/runScripts.spec.ts +45 -0
- package/utils/run-scripts/src/runScripts.ts +20 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import packageJson from '../../../package.json';
|
|
4
|
+
|
|
5
|
+
const packagesPath = resolve('./packages');
|
|
6
|
+
|
|
7
|
+
const allExports: Record<string, string> = {};
|
|
8
|
+
|
|
9
|
+
type ExportsDefinition = {
|
|
10
|
+
name: string,
|
|
11
|
+
entryPoints: Record<string, string>,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const handleExport = ({ name, entryPoints }: ExportsDefinition) => {
|
|
15
|
+
let hasRootExport = false;
|
|
16
|
+
Object.entries(entryPoints).forEach(([exportAlias, exportPath]) => {
|
|
17
|
+
if (exportAlias === '/') {
|
|
18
|
+
hasRootExport = true;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const parsedAlias = `/${exportAlias}`;
|
|
22
|
+
allExports[`${name}${parsedAlias}`] = `${name}/${exportPath}`;
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Typescript resolves aliases from top. Root export would overtake any other pathed export.
|
|
26
|
+
* Therefore root export has to be last in the generated list.
|
|
27
|
+
*/
|
|
28
|
+
if (hasRootExport) {
|
|
29
|
+
allExports[name] = `${name}/${entryPoints['/']}`;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const loadAllExports = () => {
|
|
34
|
+
const fileNames = fs.readdirSync(packagesPath);
|
|
35
|
+
fileNames.forEach((fileName) => {
|
|
36
|
+
const packagePath = resolve(packagesPath, fileName);
|
|
37
|
+
const isDirectory = fs.lstatSync(packagePath).isDirectory();
|
|
38
|
+
if (isDirectory) {
|
|
39
|
+
const exportsPath = resolve(packagePath, 'exports.json');
|
|
40
|
+
if (fs.existsSync(exportsPath)) {
|
|
41
|
+
// eslint-disable-next-line import/no-dynamic-require, global-require
|
|
42
|
+
const exports = require(exportsPath);
|
|
43
|
+
handleExport(exports);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const createPackageJsonMapping = () => {
|
|
50
|
+
const exports: Record<string, string> = {};
|
|
51
|
+
Object.entries(allExports).forEach(([exportAlias, exportPath]) => {
|
|
52
|
+
exports[`./${exportAlias}`] = `./packages/${exportPath}`;
|
|
53
|
+
});
|
|
54
|
+
(packageJson.exports as Record<string, string>) = exports;
|
|
55
|
+
fs.writeFileSync(resolve('./package.json'), JSON.stringify(packageJson, null, 4));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const createExportMaps = () => {
|
|
59
|
+
loadAllExports();
|
|
60
|
+
createPackageJsonMapping();
|
|
61
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: README
|
|
3
|
+
title: Create Package
|
|
4
|
+
hide_title: true
|
|
5
|
+
sidebar_label: Create Package
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Package Initializer
|
|
9
|
+
An initializer for packages in `SmartApps BIGscreen SDK` monorepo helps to set up
|
|
10
|
+
folder structure with basic config files like eslint, tsconfig etc.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
Originally designed as [npm initializer](https://docs.npmjs.com/cli/init#description),
|
|
14
|
+
now degraded to the local script without any ambition to be published.
|
|
15
|
+
|
|
16
|
+
Go to SmartApps BIGscreen SDK monorepo root folder and type:
|
|
17
|
+
```
|
|
18
|
+
$ npm run create-package -- <my-package-name>
|
|
19
|
+
```
|
|
20
|
+
You will be prompted for basic package information.
|
|
21
|
+
|
|
22
|
+
## What it does
|
|
23
|
+
1. Create folder `./packages/<my-package-name>`
|
|
24
|
+
2. Guide you through a questionnaire to setup the project
|
|
25
|
+
* e.g. auto-suggested 24i package name in form: `@24i/smartapps-bigscreenen-<my-package-name>`
|
|
26
|
+
3. Copy the template files (src, tsconfig, eslintrc, jest.config, readme, etc.)
|
|
27
|
+
4. Generate package.json with all the project details
|
|
28
|
+
5. Create symlink in docs `./docs/packages/<my-package-name>/README.md`
|
|
29
|
+
|
|
30
|
+
## Motivation
|
|
31
|
+
Every time that I start a new package inside SmartApps BIGscreen SDK monorepo, I hate
|
|
32
|
+
to go to other project folder, copy files like eslintrc, tsconfig, create folder
|
|
33
|
+
structure, etc.
|
|
34
|
+
|
|
35
|
+
With this in mind, the motivation to build this package started as a DRY (Do not
|
|
36
|
+
repeat yourself) thing.
|
|
37
|
+
|
|
38
|
+
This package is intended to automate the initialization of new packages and with
|
|
39
|
+
this have a new folder with everything ready to work. Behind this, also to ensure
|
|
40
|
+
we are using the unified setup for each package inside SmartApps BIGscreen SDK monorepo.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import * as fse from 'fs-extra';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import minimist from 'minimist';
|
|
8
|
+
import { promptPackageDetails } from './questionnaire/questions';
|
|
9
|
+
import { Settings } from './settings/Settings';
|
|
10
|
+
import { IPackageOptions } from './types';
|
|
11
|
+
|
|
12
|
+
async function isDirectoryEmpty(dirPath: string) {
|
|
13
|
+
const files = await fs.promises.readdir(dirPath);
|
|
14
|
+
return !files.length;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function copyTemplateFiles(templateDir: string, targetDir: string) {
|
|
18
|
+
return fse.copy(templateDir, targetDir);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function updateExportsJsonFile(filePath: string, options: IPackageOptions) {
|
|
22
|
+
let data = fs.readFileSync(filePath, 'utf8');
|
|
23
|
+
data = data.replace(/("name": ")(.*)(")/, `$1${options.name}$3`);
|
|
24
|
+
fs.writeFileSync(filePath, data);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function parseArguments(rawArgv: Array<string>) {
|
|
28
|
+
const argv = minimist(rawArgv.slice(2));
|
|
29
|
+
const dirName = argv._[0];
|
|
30
|
+
|
|
31
|
+
if (!dirName) {
|
|
32
|
+
console.error('Error: Missing package name');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
dirName,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function main() {
|
|
42
|
+
const { dirName: destDirName } = parseArguments(process.argv);
|
|
43
|
+
const destDir = path.join(process.cwd(), 'packages/', destDirName);
|
|
44
|
+
if (fs.existsSync(destDir)) {
|
|
45
|
+
console.error(`Error: Target directory "${destDir}" already exists`);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
49
|
+
|
|
50
|
+
const isDirEmpty = await isDirectoryEmpty(destDir);
|
|
51
|
+
if (!isDirEmpty) {
|
|
52
|
+
console.error(`Error: Target directory "${destDir}" is not empty.`);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const settings = { ...Settings };
|
|
57
|
+
settings.name = `${Settings.name}${destDirName}`.toLowerCase();
|
|
58
|
+
|
|
59
|
+
const details = await promptPackageDetails(settings);
|
|
60
|
+
const templateDir = path.join(__dirname, '..', 'templates/typescript');
|
|
61
|
+
|
|
62
|
+
await copyTemplateFiles(templateDir, destDir);
|
|
63
|
+
const exportsJsonFile = path.join(destDir, 'exports.json');
|
|
64
|
+
updateExportsJsonFile(exportsJsonFile, details);
|
|
65
|
+
|
|
66
|
+
// create symlink in docs to README.md
|
|
67
|
+
const docsSymlinkTarget = path.join('../../../packages/', destDirName, '/README.md');
|
|
68
|
+
const docsSymlinkPath = path.join(process.cwd(), 'docs/packages/', destDirName, '/README.md');
|
|
69
|
+
await fse.ensureSymlink(docsSymlinkTarget, docsSymlinkPath);
|
|
70
|
+
|
|
71
|
+
console.log(`${chalk.green('Success')}, package has been initialized!`);
|
|
72
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as inquirer from 'inquirer';
|
|
2
|
+
|
|
3
|
+
interface IPromptPackageDetailsDefaults {
|
|
4
|
+
/** Package name */
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async function promptPackageDetails(defaultValues: IPromptPackageDetailsDefaults) {
|
|
9
|
+
return inquirer.prompt([
|
|
10
|
+
{
|
|
11
|
+
type: 'input',
|
|
12
|
+
name: 'name',
|
|
13
|
+
message: 'Package name:',
|
|
14
|
+
default: defaultValues.name,
|
|
15
|
+
},
|
|
16
|
+
]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { promptPackageDetails };
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { runScripts } from '../runScripts';
|
|
3
|
+
|
|
4
|
+
jest.mock('../../../../package.json', () => ({
|
|
5
|
+
scripts: {
|
|
6
|
+
'scripts:prepare:create-export-maps': 'ts-node ./utils/create-export-maps/index.ts',
|
|
7
|
+
'scripts:run:test2': 'ts-node ./utils/test2.ts',
|
|
8
|
+
'scripts:run:test1': 'ts-node ./utils/test1.ts',
|
|
9
|
+
},
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
jest.mock('child_process', () => ({
|
|
13
|
+
execSync: jest.fn(),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
describe('runScripts', () => {
|
|
17
|
+
const argvBackup = process.argv;
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
jest.clearAllMocks();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterAll(() => {
|
|
24
|
+
process.argv = argvBackup;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should not run anything if no script found', () => {
|
|
28
|
+
process.argv = ['node', 'run-scripts/index.ts', 'build:.+'];
|
|
29
|
+
runScripts();
|
|
30
|
+
expect(execSync).not.toHaveBeenCalled();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should run found script', () => {
|
|
34
|
+
process.argv = ['node', 'run-scripts/index.ts', 'prepare:.+'];
|
|
35
|
+
runScripts();
|
|
36
|
+
expect(execSync).toHaveBeenCalledWith('npm run scripts:prepare:create-export-maps');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should run found scripts in order they are in package.json', () => {
|
|
40
|
+
process.argv = ['node', 'run-scripts/index.ts', 'run:.+'];
|
|
41
|
+
runScripts();
|
|
42
|
+
expect(execSync).toHaveBeenNthCalledWith(1, 'npm run scripts:run:test2');
|
|
43
|
+
expect(execSync).toHaveBeenNthCalledWith(2, 'npm run scripts:run:test1');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { scripts } from '../../../package.json';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Runs all npm scripts from package.json that match given regexp.
|
|
6
|
+
* RegExp is passed as the 1st param.
|
|
7
|
+
*/
|
|
8
|
+
export const runScripts = () => {
|
|
9
|
+
const matcher = new RegExp(process.argv[2] ?? '');
|
|
10
|
+
const scriptsToRun = Object.keys(scripts).filter((script) => script.match(matcher));
|
|
11
|
+
scriptsToRun.forEach((script) => {
|
|
12
|
+
console.log(`Running npm run ${script}`);
|
|
13
|
+
try {
|
|
14
|
+
execSync(`npm run ${script}`);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
console.error((e as Error).message);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
};
|