diff --git a/server/.gitignore b/server/.gitignore index 941c10066..58a4a9c39 100644 --- a/server/.gitignore +++ b/server/.gitignore @@ -10,4 +10,3 @@ scrypted.db.bak .update .venv py -electron/bin diff --git a/server/.npmignore b/server/.npmignore index 1d4a8cf86..559c1c63e 100644 --- a/server/.npmignore +++ b/server/.npmignore @@ -13,4 +13,3 @@ __pycache__ tsconfig.json test scripts -electron/bin diff --git a/server/bin/electron-get.d.ts b/server/bin/electron-get.d.ts deleted file mode 100644 index bed401e0a..000000000 --- a/server/bin/electron-get.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare declare const version: string; -export declare async function installElectron(): Promise; -export declare const electronBin: string; diff --git a/server/bin/electron-get.js b/server/bin/electron-get.js deleted file mode 100644 index 84e1516cb..000000000 --- a/server/bin/electron-get.js +++ /dev/null @@ -1,49 +0,0 @@ -const path = require('path'); -const extract = require('extract-zip'); -const { download } = require('@electron/get'); -const fs = require('fs'); - -const version = '31.4.0'; -const binDir = path.join(__dirname, '..', 'electron', 'bin'); -const versionedBinDir = path.join(binDir, process.platform, version); -const tmpDir = path.join(versionedBinDir, 'tmp'); -const targetDir = path.join(versionedBinDir, 'target'); - -let electronBin; -switch (process.platform) { - case 'mas': - case 'darwin': - electronBin = 'Electron.app/Contents/MacOS/Electron'; - break; - case 'freebsd': - case 'openbsd': - case 'linux': - electronBin = 'electron'; - break; - case 'win32': - electronBin = 'electron.exe'; - break; - default: - console.warn('Electron builds are not available on platform: ' + process.platform); -} - -module.exports.version = version; -module.exports.electronBin = electronBin ? path.join(targetDir, electronBin) : undefined; - -function extractFile(zipPath) { - return extract(zipPath, { dir: tmpDir }); -} - -module.exports.installElectron = function installElectron() { - return download(version).then(async zipPath => { - console.log('electron zip', zipPath); - if (fs.existsSync(targetDir)) { - console.log('electron already downloaded', targetDir); - return; - } - fs.rmSync(binDir, { recursive: true, force: true }); - await extractFile(zipPath); - fs.renameSync(tmpDir, targetDir); - console.log('electron downloaded', targetDir); - }); -} diff --git a/server/bin/postinstall b/server/bin/postinstall index f0d6d2dee..b4da79678 100644 --- a/server/bin/postinstall +++ b/server/bin/postinstall @@ -4,5 +4,3 @@ if (!process.env.SCRYPTED_PYTHON_PATH) { require('./packaged-python').installScryptedServerRequirements(); } - -require('./electron-get').installElectron(); diff --git a/server/electron/electron-plugin.html b/server/electron/electron-plugin.html deleted file mode 100644 index e574d0dee..000000000 --- a/server/electron/electron-plugin.html +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/server/package-lock.json b/server/package-lock.json index 856d4299f..ee9515310 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -10,7 +10,6 @@ "hasInstallScript": true, "license": "ISC", "dependencies": { - "@electron/get": "^3.1.0", "@mapbox/node-pre-gyp": "^1.0.11", "@scrypted/ffmpeg-static": "^6.1.0-build1", "@scrypted/node-pty": "^1.0.18", @@ -57,36 +56,7 @@ "@types/semver": "^7.5.8", "@types/source-map-support": "^0.5.10", "@types/whatwg-mimetype": "^3.0.2", - "@types/ws": "^8.5.12", - "electron": "^31.4.0" - } - }, - "node_modules/@electron/get": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@electron/get/-/get-3.1.0.tgz", - "integrity": "sha512-F+nKc0xW+kVbBRhFzaMgPy3KwmuNTYX1fx6+FxxoSnNgwYX6LD7AKBTWkU0MQ6IBoe7dz069CNkR673sPAgkCQ==", - "dependencies": { - "debug": "^4.1.1", - "env-paths": "^2.2.0", - "fs-extra": "^8.1.0", - "got": "^11.8.5", - "progress": "^2.0.3", - "semver": "^6.2.0", - "sumchecker": "^3.0.1" - }, - "engines": { - "node": ">=14" - }, - "optionalDependencies": { - "global-agent": "^3.0.0" - } - }, - "node_modules/@electron/get/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "bin": { - "semver": "bin/semver.js" + "@types/ws": "^8.5.12" } }, "node_modules/@emnapi/runtime": { @@ -656,28 +626,6 @@ "resolved": "https://registry.npmjs.org/@scrypted/types/-/types-0.3.51.tgz", "integrity": "sha512-jOqkUxyDxG2vtlw6yUVXzxLvmR0AZRvPFImI13vgsuF9Q1j5YutM/MNEshWZZinDWEaFLNFlz3QUF55Scol0Lg==" }, - "node_modules/@sindresorhus/is": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", - "integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/is?sponsor=1" - } - }, - "node_modules/@szmarczak/http-timer": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", - "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==", - "dependencies": { - "defer-to-connect": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/@types/adm-zip": { "version": "0.5.5", "resolved": "https://registry.npmjs.org/@types/adm-zip/-/adm-zip-0.5.5.tgz", @@ -697,17 +645,6 @@ "@types/node": "*" } }, - "node_modules/@types/cacheable-request": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz", - "integrity": "sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==", - "dependencies": { - "@types/http-cache-semantics": "*", - "@types/keyv": "^3.1.4", - "@types/node": "*", - "@types/responselike": "^1.0.0" - } - }, "node_modules/@types/connect": { "version": "3.4.35", "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", @@ -781,19 +718,6 @@ "@types/node": "*" } }, - "node_modules/@types/http-cache-semantics": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz", - "integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==" - }, - "node_modules/@types/keyv": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", - "integrity": "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/lodash": { "version": "4.17.7", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.7.tgz", @@ -841,14 +765,6 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==", "dev": true }, - "node_modules/@types/responselike": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz", - "integrity": "sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/semver": { "version": "7.5.8", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", @@ -1145,12 +1061,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, - "node_modules/boolean": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/boolean/-/boolean-3.2.0.tgz", - "integrity": "sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==", - "optional": true - }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1356,31 +1266,6 @@ "node": ">=8" } }, - "node_modules/cacheable-lookup": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", - "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==", - "engines": { - "node": ">=10.6.0" - } - }, - "node_modules/cacheable-request": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.4.tgz", - "integrity": "sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg==", - "dependencies": { - "clone-response": "^1.0.2", - "get-stream": "^5.1.0", - "http-cache-semantics": "^4.0.0", - "keyv": "^4.0.0", - "lowercase-keys": "^2.0.0", - "normalize-url": "^6.0.1", - "responselike": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", @@ -1433,17 +1318,6 @@ "node": ">=6" } }, - "node_modules/clone-response": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz", - "integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==", - "dependencies": { - "mimic-response": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/color": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", @@ -1603,31 +1477,6 @@ } } }, - "node_modules/decompress-response": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", - "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", - "dependencies": { - "mimic-response": "^3.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/decompress-response/node_modules/mimic-response": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", @@ -1636,48 +1485,6 @@ "node": ">=4.0.0" } }, - "node_modules/defer-to-connect": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", - "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", - "engines": { - "node": ">=10" - } - }, - "node_modules/define-data-property": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", - "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", - "optional": true, - "dependencies": { - "es-define-property": "^1.0.0", - "es-errors": "^1.3.0", - "gopd": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/define-properties": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", - "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", - "optional": true, - "dependencies": { - "define-data-property": "^1.0.1", - "has-property-descriptors": "^1.0.0", - "object-keys": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -1708,12 +1515,6 @@ "node": ">=8" } }, - "node_modules/detect-node": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz", - "integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==", - "optional": true - }, "node_modules/dotenv": { "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", @@ -1735,63 +1536,6 @@ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, - "node_modules/electron": { - "version": "31.4.0", - "resolved": "https://registry.npmjs.org/electron/-/electron-31.4.0.tgz", - "integrity": "sha512-YTwKoAA+nrJMlI1TTHnIXLYWoQLKnhbkz0qxZcI7Hadcy0UaFMFs9xzwvH2MnrRpVJy7RKo49kVGuvSdRl8zMA==", - "dev": true, - "hasInstallScript": true, - "dependencies": { - "@electron/get": "^2.0.0", - "@types/node": "^20.9.0", - "extract-zip": "^2.0.1" - }, - "bin": { - "electron": "cli.js" - }, - "engines": { - "node": ">= 12.20.55" - } - }, - "node_modules/electron/node_modules/@electron/get": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@electron/get/-/get-2.0.3.tgz", - "integrity": "sha512-Qkzpg2s9GnVV2I2BjRksUi43U5e6+zaQMcjoJy0C+C5oxaKl+fmckGDQFtRpZpZV0NQekuZZ+tGz7EA9TVnQtQ==", - "dev": true, - "dependencies": { - "debug": "^4.1.1", - "env-paths": "^2.2.0", - "fs-extra": "^8.1.0", - "got": "^11.8.5", - "progress": "^2.0.3", - "semver": "^6.2.0", - "sumchecker": "^3.0.1" - }, - "engines": { - "node": ">=12" - }, - "optionalDependencies": { - "global-agent": "^3.0.0" - } - }, - "node_modules/electron/node_modules/@types/node": { - "version": "20.16.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.1.tgz", - "integrity": "sha512-zJDo7wEadFtSyNz5QITDfRcrhqDvQI1xQNQ0VoizPjM/dVAODqqIUWbJPkvsxmTI0MYRGRikcdjMPhOssnPejQ==", - "dev": true, - "dependencies": { - "undici-types": "~6.19.2" - } - }, - "node_modules/electron/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -1895,18 +1639,6 @@ "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==" }, - "node_modules/es-define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", - "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", - "optional": true, - "dependencies": { - "get-intrinsic": "^1.2.4" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/es-errors": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", @@ -1915,29 +1647,11 @@ "node": ">= 0.4" } }, - "node_modules/es6-error": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", - "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", - "optional": true - }, "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" }, - "node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "optional": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", @@ -2144,19 +1858,6 @@ "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" }, - "node_modules/fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, "node_modules/fs-minipass": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", @@ -2267,92 +1968,11 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/global-agent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/global-agent/-/global-agent-3.0.0.tgz", - "integrity": "sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q==", - "optional": true, - "dependencies": { - "boolean": "^3.0.1", - "es6-error": "^4.1.1", - "matcher": "^3.0.0", - "roarr": "^2.15.3", - "semver": "^7.3.2", - "serialize-error": "^7.0.1" - }, - "engines": { - "node": ">=10.0" - } - }, - "node_modules/globalthis": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", - "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==", - "optional": true, - "dependencies": { - "define-properties": "^1.2.1", - "gopd": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/gopd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", - "optional": true, - "dependencies": { - "get-intrinsic": "^1.1.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/got": { - "version": "11.8.6", - "resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz", - "integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==", - "dependencies": { - "@sindresorhus/is": "^4.0.0", - "@szmarczak/http-timer": "^4.0.5", - "@types/cacheable-request": "^6.0.1", - "@types/responselike": "^1.0.0", - "cacheable-lookup": "^5.0.3", - "cacheable-request": "^7.0.2", - "decompress-response": "^6.0.0", - "http2-wrapper": "^1.0.0-beta.5.2", - "lowercase-keys": "^2.0.0", - "p-cancelable": "^2.0.0", - "responselike": "^2.0.0" - }, - "engines": { - "node": ">=10.19.0" - }, - "funding": { - "url": "https://github.com/sindresorhus/got?sponsor=1" - } - }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" }, - "node_modules/has-property-descriptors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", - "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", - "optional": true, - "dependencies": { - "es-define-property": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/has-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", @@ -2448,18 +2068,6 @@ "node": ">= 14" } }, - "node_modules/http2-wrapper": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", - "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", - "dependencies": { - "quick-lru": "^5.1.1", - "resolve-alpn": "^1.0.0" - }, - "engines": { - "node": ">=10.19.0" - } - }, "node_modules/https-proxy-agent": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", @@ -2627,33 +2235,6 @@ "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==" }, - "node_modules/json-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==" - }, - "node_modules/json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", - "optional": true - }, - "node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/keyv": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", - "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", - "dependencies": { - "json-buffer": "3.0.1" - } - }, "node_modules/level": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/level/-/level-8.0.1.tgz", @@ -2696,14 +2277,6 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, - "node_modules/lowercase-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", - "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", - "engines": { - "node": ">=8" - } - }, "node_modules/lru-cache": { "version": "10.2.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", @@ -2755,18 +2328,6 @@ "node": "^16.14.0 || >=18.0.0" } }, - "node_modules/matcher": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/matcher/-/matcher-3.0.0.tgz", - "integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==", - "optional": true, - "dependencies": { - "escape-string-regexp": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -2807,14 +2368,6 @@ "node": ">= 0.6" } }, - "node_modules/mimic-response": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", - "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", - "engines": { - "node": ">=4" - } - }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -3222,17 +2775,6 @@ "node": ">=6" } }, - "node_modules/normalize-url": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", - "integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/npmlog": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", @@ -3260,15 +2802,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "optional": true, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", @@ -3288,14 +2821,6 @@ "wrappy": "1" } }, - "node_modules/p-cancelable": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", - "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==", - "engines": { - "node": ">=8" - } - }, "node_modules/p-map": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz", @@ -3393,14 +2918,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/promise-retry": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-2.0.1.tgz", @@ -3476,17 +2993,6 @@ } ] }, - "node_modules/quick-lru": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", - "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -3536,22 +3042,6 @@ "node": ">= 6" } }, - "node_modules/resolve-alpn": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", - "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==" - }, - "node_modules/responselike": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz", - "integrity": "sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==", - "dependencies": { - "lowercase-keys": "^2.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", @@ -3574,23 +3064,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/roarr": { - "version": "2.15.4", - "resolved": "https://registry.npmjs.org/roarr/-/roarr-2.15.4.tgz", - "integrity": "sha512-CHhPh+UNHD2GTXNYhPWLnU8ONHdI+5DI+4EYIAOaiD63rHeYlZvyh8P+in5999TTSFgUYuKUAjzRI4mdh/p+2A==", - "optional": true, - "dependencies": { - "boolean": "^3.0.1", - "detect-node": "^2.0.4", - "globalthis": "^1.0.1", - "json-stringify-safe": "^5.0.1", - "semver-compare": "^1.0.0", - "sprintf-js": "^1.1.2" - }, - "engines": { - "node": ">=8.0" - } - }, "node_modules/router": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/router/-/router-1.3.8.tgz", @@ -3683,12 +3156,6 @@ "node": ">=10" } }, - "node_modules/semver-compare": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", - "integrity": "sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==", - "optional": true - }, "node_modules/send": { "version": "0.18.0", "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", @@ -3741,21 +3208,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, - "node_modules/serialize-error": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz", - "integrity": "sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw==", - "optional": true, - "dependencies": { - "type-fest": "^0.13.1" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/serve-static": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", @@ -4016,17 +3468,6 @@ "node": ">=0.10.0" } }, - "node_modules/sumchecker": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz", - "integrity": "sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg==", - "dependencies": { - "debug": "^4.1.0" - }, - "engines": { - "node": ">= 8.0" - } - }, "node_modules/tar": { "version": "7.4.3", "resolved": "https://registry.npmjs.org/tar/-/tar-7.4.3.tgz", @@ -4183,18 +3624,6 @@ "node": "*" } }, - "node_modules/type-fest": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", - "integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==", - "optional": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -4246,14 +3675,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/unix-crypt-td-js": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/unix-crypt-td-js/-/unix-crypt-td-js-1.1.4.tgz", diff --git a/server/package.json b/server/package.json index 4c383620e..d61781eea 100644 --- a/server/package.json +++ b/server/package.json @@ -3,7 +3,6 @@ "version": "0.115.36", "description": "", "dependencies": { - "@electron/get": "^3.1.0", "@mapbox/node-pre-gyp": "^1.0.11", "@scrypted/ffmpeg-static": "^6.1.0-build1", "@scrypted/node-pty": "^1.0.18", @@ -47,8 +46,7 @@ "@types/semver": "^7.5.8", "@types/source-map-support": "^0.5.10", "@types/whatwg-mimetype": "^3.0.2", - "@types/ws": "^8.5.12", - "electron": "^31.4.0" + "@types/ws": "^8.5.12" }, "bin": { "scrypted-serve": "bin/scrypted-serve" diff --git a/server/src/plugin/runtime/electron-worker.ts b/server/src/plugin/runtime/electron-worker.ts deleted file mode 100644 index 58a17637d..000000000 --- a/server/src/plugin/runtime/electron-worker.ts +++ /dev/null @@ -1,158 +0,0 @@ -import fs from 'fs'; -import path from 'path'; -import child_process from 'child_process'; -import net from "net"; -import { RpcMessage, RpcPeer } from "../../rpc"; -import { SidebandSocketSerializer } from "../socket-serializer"; -import { ChildProcessWorker } from "./child-process-worker"; -import { RuntimeWorkerOptions } from "./runtime-worker"; -import type { ScryptedRuntime } from '../../runtime'; -import { electronBin } from '../../../bin/electron-get'; - -export class ElectronForkWorker extends ChildProcessWorker { - static allocatedDisplays = new Set(); - allocatedDisplay: number; - - constructor(_mainFilename: string, pluginId: string, options: RuntimeWorkerOptions, runtime: ScryptedRuntime, mode: 'default' | 'webgl' | 'webgpu') { - super(pluginId, options); - - const { env } = options; - - fs.chmodSync(electronBin, 0o755); - const enabledFeatures = ['SharedArrayBuffer', 'VaapiVideoDecodeLinuxGL']; - const args = [ - electronBin, - '--disable-features=BlockInsecurePrivateNetworkRequests,PrivateNetworkAccessSendPreflights', - ]; - - if (mode !== 'default') { - args.push( - '--ignore-gpu-blocklist', - '--use-gl=angle', - '--use-angle=gl-egl', - ); - } - - if (process.platform === 'linux') { - // crappy but should work. - for (let i = 50; i < 100; i++) { - if (!ElectronForkWorker.allocatedDisplays.has(i)) { - this.allocatedDisplay = i; - break; - } - } - - if (!this.allocatedDisplay) - throw new Error('unable to allocate DISPLAY for xvfb-run'); - - ElectronForkWorker.allocatedDisplays.add(this.allocatedDisplay); - - // requires xvfb-run as electron does not support the chrome --headless flag. - // dummy up a DISPLAY env variable. this value numerical because of the way it is. - args.unshift('xvfb-run', '-n', this.allocatedDisplay.toString()); - // https://github.com/gpuweb/gpuweb/wiki/Implementation-Status#chromium-chrome-edge-etc - args.push( - '--no-sandbox', - ); - - if (mode === 'webgpu') { - args.push( - '--enable-unsafe-webgpu', - '--disable-vulkan-surface', - ); - enabledFeatures.push('Vulkan'); - } - } - args.push( - `--enable-features=${enabledFeatures.join(",")}`, - ) - - if (process.platform === 'darwin') { - // Electron plist must be modified with this to hide dock icon before start. app.dock.hide flashes the dock before program starts. - // LSUIElement - // 1 - } - - if (options?.pluginDebug) { - args.push(`--remote-debugging-port=${options?.pluginDebug.inspectPort}`); - } - - args.push( - path.join(__dirname, 'electron', 'electron-plugin-remote.js'), - '--', 'child', this.pluginId); - - const bin = args.shift(); - this.worker = child_process.spawn(bin, args, { - stdio: ['pipe', 'pipe', 'pipe', 'ipc'], - env: Object.assign({}, process.env, env), - serialization: 'advanced', - }); - - this.worker.on('exit', () => { - }); - - if (options?.pluginDebug?.waitDebug) { - options.pluginDebug.waitDebug.catch(() => { }); - options.pluginDebug.waitDebug = Promise.resolve(undefined); - } - - this.worker.send({ - pluginId, - options: { - ...options, - pluginDebug: options?.pluginDebug ? { - ...options.pluginDebug, - // dont want to send/serialize this. - waitDebug: null, - } : undefined, - }, - }); - - this.setupWorker(); - } - - kill(): void { - if (this.worker) { - ElectronForkWorker.allocatedDisplays.delete(this.allocatedDisplay); - this.worker.disconnect(); - } - super.kill(); - } - - setupRpcPeer(peer: RpcPeer): void { - this.worker.on('message', (message, sendHandle) => { - if ((message as any).type && sendHandle) { - peer.handleMessage(message as any, { - sendHandle, - }); - } - else if (sendHandle) { - this.emit('rpc', message, sendHandle); - } - else { - peer.handleMessage(message as any); - } - }); - peer.transportSafeArgumentTypes.add(Buffer.name); - peer.transportSafeArgumentTypes.add(Uint8Array.name); - peer.addSerializer(net.Socket, net.Socket.name, new SidebandSocketSerializer()); - } - - send(message: RpcMessage, reject?: (e: Error) => void, serializationContext?: any): void { - try { - if (!this.worker) - throw new Error('fork worker has been killed'); - this.worker.send(message, serializationContext?.sendHandle, e => { - if (e && reject) - reject(e); - }); - } - catch (e) { - reject?.(e); - } - } - - get pid() { - return this.worker?.pid; - } -} diff --git a/server/src/plugin/runtime/electron/electron-plugin-preload.ts b/server/src/plugin/runtime/electron/electron-plugin-preload.ts deleted file mode 100644 index abac48482..000000000 --- a/server/src/plugin/runtime/electron/electron-plugin-preload.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { startPluginRemote } from "../../plugin-remote-worker"; -import { ipcRenderer } from 'electron'; -// import { bufferWrapUint8Array } from "./buffer-wrap"; -// import { setNpmExecFunctionElectron } from "./set-npm-exec"; -import { PassThrough } from "stream"; -import { Console } from "console"; -import type { RuntimeWorkerOptions } from "../runtime-worker"; -import { pipeWorkerConsole } from "../../plugin-console"; - -// setNpmExecFunctionElectron(); - -ipcRenderer.on('scrypted-init', (e, initMessage: { pluginId: string, options: RuntimeWorkerOptions }) => { - const { pluginId, options } = initMessage; - - for (const [k, v] of Object.entries(options.env || {})) { - process.env[k] = v?.toString(); - } - - const originalConsole = console; - const stdout = new PassThrough(); - const stderr = new PassThrough(); - pipeWorkerConsole({ stdout, stderr }, originalConsole); - stdout.on('data', d => { - ipcRenderer.send('scrypted-stdout', d); - }); - stderr.on('data', d => { - ipcRenderer.send('scrypted-stderr', d); - }); - const pluginConsole = new Console(stdout, stderr); - (globalThis as any).foo = 3; - global.console = pluginConsole; - (global as any).ss = originalConsole; - - const peer = startPluginRemote('', pluginId, (message, reject, serializationContext) => { - try { - ipcRenderer.send('scrypted', message); - } - catch (e) { - reject?.(e); - } - }, { - sourceURL(filename) { - return `scrypted-electron://${filename}`; - } - }); - - // const evalLocal = peer.evalLocal.bind(peer); - // peer.evalLocal = (script, filename, params) => { - // // at some point vscode or chromes source map pathing got confused by - // // file paths and no longer mapped them. by using a custom protocol, - // // the source map paths get properly resolved. - // return evalLocal(script, `scrypted-electron://${filename}`, params); - // } - - peer.transportSafeArgumentTypes.add(Buffer.name); - peer.transportSafeArgumentTypes.add(Uint8Array.name); - - // const deserialize = peer.deserialize; - // peer.deserialize = (value, deserializationContext) => { - // const ret = deserialize.call(peer, value, deserializationContext); - // if (ret instanceof Uint8Array) - // return bufferWrapUint8Array(ret); - // return ret; - // } - - ipcRenderer.on('scrypted', (_, data) => { - peer.handleMessage(data); - }) -}); - diff --git a/server/src/plugin/runtime/electron/electron-plugin-remote.ts b/server/src/plugin/runtime/electron/electron-plugin-remote.ts deleted file mode 100644 index 9aef33e50..000000000 --- a/server/src/plugin/runtime/electron/electron-plugin-remote.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { app, BrowserWindow } from 'electron'; -import path from 'path'; -import { Deferred } from '../../../deferred'; -import { RuntimeWorkerOptions } from '../runtime-worker'; - -if (process.platform === 'darwin') { - // Electron plist must be modified with this to hide dock icon before start. app.dock.hide flashes the dock before program starts. - // LSUIElement - // 1 - app.dock.hide(); -} - -let win: BrowserWindow; -const winQueue: any[] = []; - -const createWindow = (firstMessage: { plugindId: string, options: RuntimeWorkerOptions }) => { - const message: { plugindId: string, options: RuntimeWorkerOptions } = firstMessage; - - win = new BrowserWindow({ - width: 800, - height: 600, - show: false, - webPreferences: { - backgroundThrottling: false, - preload: path.join(__dirname, 'electron-plugin-preload.js'), - nodeIntegration: true, - webSecurity: false, - allowRunningInsecureContent: true, - } - }); - win.webContents.send('scrypted-init', message); - - // win.loadURL('https://webglsamples.org/aquarium/aquarium.html'); - console.log(__dirname); - const html = path.join(__dirname, '../../../../electron', 'electron-plugin.html'); - win.loadFile(html); - win.webContents.openDevTools(); - - win.webContents.ipc.on('scrypted', (e, message) => { - process.send(message); - }); - win.webContents.ipc.on('scrypted-stdout', (e, message) => { - process.stdout.write(message); - }); - win.webContents.ipc.on('scrypted-stderr', (e, message) => { - process.stderr.write(message); - }); - - while (winQueue.length) { - processMessage(winQueue.shift()); - } - - function kill() { - process.exit(); - } - - win.webContents.on('destroyed', kill); - win.webContents.on('plugin-crashed', kill); - win.on('close', kill); -} - -const firstMessage = new Deferred; -function processMessage(message: any) { - win.webContents.send('scrypted', message); -} - -process.on('message', (message) => { - if (!firstMessage.finished) { - firstMessage.resolve(message); - return; - } - - if (win) - processMessage(message); - else - winQueue.push(message); -}); - -process.on('disconnect', () => { - console.error('peer host disconnected, exiting.'); - process.exit(1); -}); - -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') app.quit() -}) - -app.whenReady().then(async () => { - const message: { plugindId: string, options: RuntimeWorkerOptions } = await firstMessage.promise; - createWindow(message) -}); diff --git a/server/src/plugin/runtime/runtime-host.ts b/server/src/plugin/runtime/runtime-host.ts index 81c493b5b..e19e544f5 100644 --- a/server/src/plugin/runtime/runtime-host.ts +++ b/server/src/plugin/runtime/runtime-host.ts @@ -1,6 +1,5 @@ import type { ScryptedRuntime } from "../../runtime"; import { CustomRuntimeWorker } from "./custom-worker"; -import { ElectronForkWorker } from "./electron-worker"; import { NodeForkWorker } from "./node-fork-worker"; import { PythonRuntimeWorker } from "./python-worker"; import type { RuntimeWorker, RuntimeWorkerOptions } from "./runtime-worker"; @@ -14,12 +13,5 @@ export function getBuiltinRuntimeHosts() { pluginHosts.set('python', (_, pluginId, options) => new PythonRuntimeWorker(pluginId, options)); pluginHosts.set('node', (mainFilename, pluginId, options) => new NodeForkWorker(mainFilename, pluginId, options)); - // safe - pluginHosts.set('electron', (mainFilename, pluginId, options, runtime) => new ElectronForkWorker(mainFilename, pluginId, options, runtime, 'default')); - // mostly safe - pluginHosts.set('electron-webgl', (mainFilename, pluginId, options, runtime) => new ElectronForkWorker(mainFilename, pluginId, options, runtime, 'webgl')); - // there be dragons - pluginHosts.set('electron-webgpu', (mainFilename, pluginId, options, runtime) => new ElectronForkWorker(mainFilename, pluginId, options, runtime, 'webgpu')); - return pluginHosts; }