@camera.ui/go2rtc 0.0.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ All notable changes to this project will be documented in this file.
2
+
3
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
+
6
+ ## [1.0.0] - 2019-08-06
7
+
8
+ - Initial Release
package/LICENSE.md ADDED
File without changes
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # @camera.ui/go2rtc
@@ -0,0 +1 @@
1
+ export declare const go2rtcPath: () => string;
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.go2rtcPath = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const os_1 = __importDefault(require("os"));
9
+ const platform = os_1.default.platform();
10
+ const go2rtcBinaryPath = path_1.default.resolve(__dirname, 'binary');
11
+ const go2rtcFile = 'go2rtc' + (platform === 'win32' ? '.exe' : '');
12
+ const go2rtcPath = () => path_1.default.resolve(go2rtcBinaryPath, go2rtcFile);
13
+ exports.go2rtcPath = go2rtcPath;
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AAEpB,MAAM,QAAQ,GAAG,YAAE,CAAC,QAAQ,EAAE,CAAC;AAE/B,MAAM,gBAAgB,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC3D,MAAM,UAAU,GAAG,QAAQ,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAE5D,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,cAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;AAA9D,QAAA,UAAU,cAAoD"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const os_1 = __importDefault(require("os"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const promises_1 = require("stream/promises");
11
+ const axios_1 = __importDefault(require("axios"));
12
+ const unzipper_1 = __importDefault(require("unzipper"));
13
+ const _1 = require(".");
14
+ const binaries = {
15
+ darwin: {
16
+ amd64: 'go2rtc_mac_amd64.zip',
17
+ arm64: 'go2rtc_mac_arm64.zip',
18
+ },
19
+ linux: {
20
+ amd64: 'go2rtc_linux_amd64',
21
+ arm: 'go2rtc_linux_arm',
22
+ armv6: 'go2rtc_linux_armv6',
23
+ arm64: 'go2rtc_linux_arm64',
24
+ i386: 'go2rtc_linux_i386',
25
+ mipsel: 'go2rtc_linux_mipsel',
26
+ },
27
+ win32: {
28
+ amd64: 'go2rtc_win64.zip',
29
+ arm64: 'go2rtc_win_arm64.zip',
30
+ i386: 'go2rtc_win32.zip',
31
+ },
32
+ };
33
+ const GO2RTC_VERSION = 'v1.8.4';
34
+ const arch = os_1.default.arch();
35
+ const platform = os_1.default.platform();
36
+ const releasesUrl = 'https://api.github.com/repos/AlexxIT/go2rtc/releases';
37
+ const filename = binaries[platform]?.[arch];
38
+ const go2rtcBinaryPath = path_1.default.resolve(__dirname, 'binary');
39
+ const go2rtcFilePath = path_1.default.resolve(go2rtcBinaryPath, filename);
40
+ const go2rtcExtractedFilePath = (0, _1.go2rtcPath)();
41
+ const isZipUrl = (url) => {
42
+ const pathArray = new URL(url).pathname.split('/');
43
+ const fileName = pathArray[pathArray.length - 1];
44
+ return fileName !== undefined && path_1.default.extname(fileName) === '.zip';
45
+ };
46
+ const downloadFile = async (url) => {
47
+ console.log(`Downloading Go2Rtc ${GO2RTC_VERSION} to ${go2rtcFilePath}...`);
48
+ const { data } = await axios_1.default.get(url, {
49
+ onDownloadProgress: (progressEvent) => {
50
+ if (process.env.CI || !progressEvent.total) {
51
+ return;
52
+ }
53
+ const percent = Math.round((progressEvent.loaded / progressEvent.total) * 100) + '%';
54
+ process.stdout.write('\r' + percent);
55
+ if (progressEvent.loaded === progressEvent.total) {
56
+ process.stdout.write('\r');
57
+ }
58
+ },
59
+ timeout: 30 * 1000, // 30s
60
+ maxRedirects: 3,
61
+ responseType: 'stream',
62
+ });
63
+ await fs_extra_1.default.ensureDir(go2rtcBinaryPath);
64
+ const streams = [data, fs_extra_1.default.createWriteStream(go2rtcFilePath)];
65
+ await (0, promises_1.pipeline)(streams);
66
+ if (isZipUrl(url)) {
67
+ console.log(`Extracting ${go2rtcFilePath} to ${go2rtcExtractedFilePath}...`);
68
+ const directory = await unzipper_1.default.Open.file(go2rtcFilePath);
69
+ await new Promise((resolve, reject) => {
70
+ directory.files[0].stream().pipe(fs_extra_1.default.createWriteStream(go2rtcExtractedFilePath)).on('error', reject).on('finish', resolve);
71
+ });
72
+ console.log(`Removing ${go2rtcFilePath}...`);
73
+ await fs_extra_1.default.remove(go2rtcFilePath);
74
+ }
75
+ };
76
+ const getReleaseAssets = async (version) => {
77
+ const response = await axios_1.default.get(`${releasesUrl}/tags/${version}`);
78
+ const assets = response.data.assets.map((asset) => asset.browser_download_url);
79
+ const files = assets.map((asset) => asset.split(`${version}/`)[1]);
80
+ return {
81
+ assets,
82
+ files,
83
+ };
84
+ };
85
+ const downloadGo2Rtc = async () => {
86
+ const release = await getReleaseAssets(GO2RTC_VERSION);
87
+ if (!filename || !release.assets.find((r) => r.endsWith(filename))) {
88
+ throw new Error(`No go2rtc binary found for architecture (${platform} / ${arch})`);
89
+ }
90
+ const downloadUrl = release.assets.find((r) => r.endsWith(filename));
91
+ await downloadFile(downloadUrl);
92
+ if (platform === 'linux' || platform === 'darwin') {
93
+ console.log(`Making ${go2rtcExtractedFilePath} executable...`);
94
+ fs_extra_1.default.chmodSync(go2rtcExtractedFilePath, 0o755);
95
+ }
96
+ console.log('Done!');
97
+ };
98
+ downloadGo2Rtc();
99
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":";;;;;;AAEA,4CAAoB;AACpB,wDAA0B;AAC1B,gDAAwB;AACxB,8CAA2C;AAC3C,kDAAkD;AAClD,wDAAgC;AAEhC,wBAA+B;AAQ/B,MAAM,QAAQ,GAAoB;IAChC,MAAM,EAAE;QACN,KAAK,EAAE,sBAAsB;QAC7B,KAAK,EAAE,sBAAsB;KAC9B;IACD,KAAK,EAAE;QACL,KAAK,EAAE,oBAAoB;QAC3B,GAAG,EAAE,kBAAkB;QACvB,KAAK,EAAE,oBAAoB;QAC3B,KAAK,EAAE,oBAAoB;QAC3B,IAAI,EAAE,mBAAmB;QACzB,MAAM,EAAE,qBAAqB;KAC9B;IACD,KAAK,EAAE;QACL,KAAK,EAAE,kBAAkB;QACzB,KAAK,EAAE,sBAAsB;QAC7B,IAAI,EAAE,kBAAkB;KACzB;CACF,CAAC;AAEF,MAAM,cAAc,GAAG,QAAQ,CAAC;AAChC,MAAM,IAAI,GAAG,YAAE,CAAC,IAAI,EAAU,CAAC;AAC/B,MAAM,QAAQ,GAAG,YAAE,CAAC,QAAQ,EAAE,CAAC;AAC/B,MAAM,WAAW,GAAG,sDAAsD,CAAC;AAC3E,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AAE5C,MAAM,gBA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4
+ "description": "camera.ui go2rtc",
5
+ "author": "seydx (https://github.com/seydx/camera.ui)",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "default": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "build": "rimraf dist && tsc",
16
+ "format": "prettier --write 'src/' --ignore-unknown --no-error-on-unmatched-pattern",
17
+ "install": "node dist/install.js",
18
+ "lint": "eslint --fix --ext .js,.ts .",
19
+ "update": "updates --update ./",
20
+ "install-updates": "npm i --save",
21
+ "prepublishOnly": "npm run lint && npm run format && npm run build"
22
+ },
23
+ "dependencies": {
24
+ "axios": "^1.6.2",
25
+ "fs-extra": "11.2.0",
26
+ "unzipper": "^0.10.14"
27
+ },
28
+ "devDependencies": {
29
+ "@rushstack/eslint-patch": "^1.6.1",
30
+ "@types/node": "^20.10.5",
31
+ "@types/ws": "^8.5.10",
32
+ "@typescript-eslint/eslint-plugin": "^6.15.0",
33
+ "@typescript-eslint/parser": "^6.15.0",
34
+ "concurrently": "^8.2.2",
35
+ "eslint": "^8.56.0",
36
+ "eslint-config-prettier": "^9.1.0",
37
+ "eslint-plugin-prettier": "^5.1.2",
38
+ "prettier": "^3.1.1",
39
+ "rimraf": "^5.0.5",
40
+ "typescript": "^5.3.3",
41
+ "updates": "^15.1.1"
42
+ },
43
+ "bugs": {
44
+ "url": "https://github.com/seydx/camera.ui/issues"
45
+ },
46
+ "engines": {
47
+ "camera.ui": ">=3.0.0-alpha.0",
48
+ "node": ">=18.12.0"
49
+ },
50
+ "homepage": "https://github.com/seydx/camera.ui#readme",
51
+ "keywords": [
52
+ "camera.ui"
53
+ ],
54
+ "license": "MIT",
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "git+https://github.com/seydx/camera.ui.git"
58
+ }
59
+ }