@24i/bigscreen-sdk 1.0.26-alpha.2448 → 1.0.26
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 +1 -1
- package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoDetail.tsx +2 -1
- package/packages/focus/src/hasFocus.ts +2 -2
- package/packages/sdk-installer/dist/index.js +5 -0
- package/packages/sdk-installer/dist/sdkInstaller.js +38 -0
- package/packages/sdk-installer/dist/services/clean.js +11 -0
- package/packages/sdk-installer/dist/services/download.js +55 -0
- package/packages/sdk-installer/dist/services/index.js +11 -0
- package/packages/sdk-installer/dist/services/install.js +24 -0
- package/packages/sdk-installer/dist/services/unzip.js +12 -0
- package/packages/sdk-installer/dist/types/index.d.ts +1 -0
- package/packages/sdk-installer/dist/types/sdkInstaller.d.ts +7 -0
- package/packages/sdk-installer/dist/types/services/clean.d.ts +2 -0
- package/packages/sdk-installer/dist/types/services/download.d.ts +2 -0
- package/packages/sdk-installer/dist/types/services/index.d.ts +4 -0
- package/packages/sdk-installer/dist/types/services/install.d.ts +2 -0
- package/packages/sdk-installer/dist/types/services/unzip.d.ts +2 -0
- package/packages/toast/src/ToastService.tsx +16 -5
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createRef, Component } from '@24i/bigscreen-sdk/jsx';
|
|
2
|
+
import { hasFocus } from '@24i/bigscreen-sdk/focus';
|
|
2
3
|
import { ScrollText } from '@24i/bigscreen-sdk/scroll-text';
|
|
3
4
|
import { map } from '@24i/bigscreen-sdk/perf-utils/array';
|
|
4
5
|
import { ITechnicalInfoProvider, TechnicalInfoData } from './ITechnicalInfoProvider';
|
|
@@ -38,7 +39,7 @@ class TechnicalInfoDetail extends Component<Props> {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
hasFocus() {
|
|
41
|
-
return this.wrapRef
|
|
42
|
+
return hasFocus(this.wrapRef);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
renderInfoData(data: TechnicalInfoData) {
|
|
@@ -6,12 +6,12 @@ import { isElementWrappedBy } from '@24i/bigscreen-sdk/utils/elementUtils';
|
|
|
6
6
|
* if the element itself is the `activeElement`.
|
|
7
7
|
* @param elementOrReference DOM element or reference to element on which we test focus
|
|
8
8
|
* @param includeElementItself if true, active element is also tested with the provided element.
|
|
9
|
-
* Default is
|
|
9
|
+
* Default is true
|
|
10
10
|
* @returns true if the element has focused element inside or is itself focused
|
|
11
11
|
*/
|
|
12
12
|
export const hasFocus = (
|
|
13
13
|
elementOrReference: HTMLElement | Reference<HTMLElement>,
|
|
14
|
-
includeElementItself =
|
|
14
|
+
includeElementItself = true,
|
|
15
15
|
) => {
|
|
16
16
|
const element = unwrapReference(elementOrReference);
|
|
17
17
|
if (!element) return false;
|
|
@@ -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';
|
|
@@ -34,11 +34,22 @@ export class ToastService<T extends MinimalToastProps> extends Component<Props<T
|
|
|
34
34
|
this.serviceContinue();
|
|
35
35
|
},
|
|
36
36
|
} as T);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
|
|
38
|
+
// Check if toast element with the same message already exists in stack
|
|
39
|
+
const elementExists = this.toastElementBuffer.find((item) => {
|
|
40
|
+
const { message: newMessage } = toastElement.props;
|
|
41
|
+
const { message } = item.props;
|
|
42
|
+
|
|
43
|
+
return message === newMessage;
|
|
44
|
+
}) !== undefined;
|
|
45
|
+
|
|
46
|
+
if (!elementExists) {
|
|
47
|
+
if (!this.isShowingToast) {
|
|
48
|
+
this.appendMount(toastElement, this.rootDivRef);
|
|
49
|
+
this.isShowingToast = true;
|
|
50
|
+
} else {
|
|
51
|
+
this.toastElementBuffer.push(toastElement);
|
|
52
|
+
}
|
|
42
53
|
}
|
|
43
54
|
}
|
|
44
55
|
|