@24i/bigscreen-sdk 1.0.28 → 1.0.29-alpha.2487

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.28",
3
+ "version": "1.0.29-alpha.2487",
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",
44
+ "@24i/smartapps-datalayer": "3.0.11-alpha.1017",
45
45
  "@sentry/browser": "7.35.0",
46
46
  "@sentry/types": "7.35.0",
47
47
  "@types/gtag.js": "^0.0.14",
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sdkInstaller = void 0;
4
+ var sdkInstaller_1 = require("./sdkInstaller");
5
+ Object.defineProperty(exports, "sdkInstaller", { enumerable: true, get: function () { return sdkInstaller_1.sdkInstaller; } });
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sdkInstaller = void 0;
4
+ const path_1 = require("path");
5
+ const url_1 = require("url");
6
+ const services_1 = require("./services");
7
+ const log = (message) => process.stdout.write(message);
8
+ const sdkInstaller = async ({ zipPath, installPath, enableLogs }) => {
9
+ const logger = enableLogs ? log : () => false;
10
+ const pathsToDelete = [];
11
+ let usedInstallPath;
12
+ try {
13
+ const parsedZipPath = (0, path_1.parse)(zipPath);
14
+ const parsedZipUrl = (0, url_1.parse)(zipPath);
15
+ if (!parsedZipUrl.protocol) {
16
+ throw new Error('Installation from local packages is not supported yet.');
17
+ }
18
+ logger('Downloading...');
19
+ const downloadedFilePath = `${process.cwd()}/${parsedZipPath.base}`;
20
+ pathsToDelete.push(downloadedFilePath);
21
+ await (0, services_1.download)(zipPath, downloadedFilePath);
22
+ logger('\rUnpacking...');
23
+ const unzippedDirPath = `${process.cwd()}/${parsedZipPath.name}`;
24
+ pathsToDelete.push(unzippedDirPath);
25
+ (0, services_1.unzip)(downloadedFilePath);
26
+ logger('\rInstalling...');
27
+ usedInstallPath = (0, services_1.install)(unzippedDirPath, installPath);
28
+ }
29
+ catch (e) {
30
+ (0, services_1.clean)(pathsToDelete);
31
+ throw e;
32
+ }
33
+ logger('\rCleaning...');
34
+ (0, services_1.clean)(pathsToDelete);
35
+ logger(`\rInstalled to ${usedInstallPath}\n`);
36
+ return usedInstallPath;
37
+ };
38
+ exports.sdkInstaller = sdkInstaller;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clean = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const deleteFileOrDirectory = (path) => {
6
+ (0, child_process_1.spawnSync)('rm', ['-r', path]);
7
+ };
8
+ const clean = (pathsToBeDeleted) => {
9
+ pathsToBeDeleted.forEach(deleteFileOrDirectory);
10
+ };
11
+ exports.clean = clean;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.download = void 0;
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const url = require("url");
7
+ const http = require("http");
8
+ const https = require("https");
9
+ const createDirPathIfDoesntExist = async (dirPath) => {
10
+ if (!fs.existsSync(dirPath)) {
11
+ fs.mkdirSync(dirPath, { recursive: true });
12
+ }
13
+ };
14
+ const getNetworkProtocolAdapter = (requestedUrl) => {
15
+ const { protocol } = url.parse(requestedUrl);
16
+ switch (protocol) {
17
+ case 'http:': return http;
18
+ case 'https:': return https;
19
+ default: throw new Error(`${protocol} protocol is not supported`);
20
+ }
21
+ };
22
+ const getResponseError = (response) => {
23
+ const HTTP_RESPONSE_STATUS_CODE_OK = 200;
24
+ const { statusCode, headers } = response;
25
+ const contentType = headers['content-type'];
26
+ if (statusCode !== HTTP_RESPONSE_STATUS_CODE_OK) {
27
+ return new Error(`Request Failed. Status Code: ${statusCode}`);
28
+ }
29
+ if (!contentType) {
30
+ return new Error('Missing Content-Type: expected application/zip');
31
+ }
32
+ if (!/^application\/zip/.test(contentType)) {
33
+ return new Error(`Wrong Content-Type: expected application/zip, received ${contentType}`);
34
+ }
35
+ return null;
36
+ };
37
+ const download = async (fromUrl, toFilePath) => {
38
+ const toDirPath = path.parse(toFilePath).dir;
39
+ await createDirPathIfDoesntExist(toDirPath);
40
+ return new Promise((resolve, reject) => {
41
+ const request = getNetworkProtocolAdapter(fromUrl).get(fromUrl, (response) => {
42
+ const error = getResponseError(response);
43
+ if (error) {
44
+ reject(error);
45
+ return;
46
+ }
47
+ const file = fs.createWriteStream(toFilePath);
48
+ file.on('error', reject);
49
+ file.on('finish', resolve);
50
+ response.pipe(file);
51
+ });
52
+ request.on('error', reject);
53
+ });
54
+ };
55
+ exports.download = download;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clean = exports.install = exports.unzip = exports.download = void 0;
4
+ var download_1 = require("./download");
5
+ Object.defineProperty(exports, "download", { enumerable: true, get: function () { return download_1.download; } });
6
+ var unzip_1 = require("./unzip");
7
+ Object.defineProperty(exports, "unzip", { enumerable: true, get: function () { return unzip_1.unzip; } });
8
+ var install_1 = require("./install");
9
+ Object.defineProperty(exports, "install", { enumerable: true, get: function () { return install_1.install; } });
10
+ var clean_1 = require("./clean");
11
+ Object.defineProperty(exports, "clean", { enumerable: true, get: function () { return clean_1.clean; } });
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.install = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const getInstalledPathFromOutput = (output) => {
6
+ var _a;
7
+ const prefix = 'INSTALL_PATH=';
8
+ const installedPathRow = output
9
+ .split('\n')
10
+ .map((outputRow) => outputRow.trim())
11
+ .filter((trimmedOutputRow) => trimmedOutputRow.startsWith(prefix));
12
+ return ((_a = installedPathRow[0]) === null || _a === void 0 ? void 0 : _a.replace(prefix, '')) || '';
13
+ };
14
+ const install = (installerDirPath, installToPath) => {
15
+ const installationScriptPath = `${installerDirPath}/install.js`;
16
+ const installationCommandWithoutCustomPath = `node ${installationScriptPath}`;
17
+ const installationCmdToBeUsed = installToPath
18
+ ? `${installationCommandWithoutCustomPath} ${installToPath}`
19
+ : installationCommandWithoutCustomPath;
20
+ const execOptions = { maxBuffer: 5242880 };
21
+ const installationScriptOutput = (0, child_process_1.execSync)(installationCmdToBeUsed, execOptions).toString();
22
+ return getInstalledPathFromOutput(installationScriptOutput);
23
+ };
24
+ exports.install = install;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unzip = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const unzip = (filePath) => {
6
+ const spawnOptions = { maxBuffer: 5242880 };
7
+ const unzipProcess = (0, child_process_1.spawnSync)('unzip', ['-n', filePath], spawnOptions);
8
+ if (unzipProcess.stderr.length) {
9
+ throw new Error(unzipProcess.stderr.toString());
10
+ }
11
+ };
12
+ exports.unzip = unzip;
@@ -0,0 +1 @@
1
+ export { sdkInstaller } from './sdkInstaller';
@@ -0,0 +1,7 @@
1
+ declare type SdkInstallerOptions = {
2
+ zipPath: string;
3
+ installPath?: string;
4
+ enableLogs?: boolean;
5
+ };
6
+ declare const sdkInstaller: ({ zipPath, installPath, enableLogs }: SdkInstallerOptions) => Promise<string>;
7
+ export { sdkInstaller };
@@ -0,0 +1,2 @@
1
+ declare const clean: (pathsToBeDeleted: string[]) => void;
2
+ export { clean };
@@ -0,0 +1,2 @@
1
+ declare const download: (fromUrl: string, toFilePath: string) => Promise<void>;
2
+ export { download };
@@ -0,0 +1,4 @@
1
+ export { download } from './download';
2
+ export { unzip } from './unzip';
3
+ export { install } from './install';
4
+ export { clean } from './clean';
@@ -0,0 +1,2 @@
1
+ declare const install: (installerDirPath: string, installToPath?: string | undefined) => string;
2
+ export { install };
@@ -0,0 +1,2 @@
1
+ declare const unzip: (filePath: string) => void;
2
+ export { unzip };