@scrypted/server 0.4.3 → 0.4.5

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.

Potentially problematic release.


This version of @scrypted/server might be problematic. Click here for more details.

@@ -13,10 +13,11 @@ const process_1 = __importDefault(require("process"));
13
13
  const mkdirp_1 = __importDefault(require("mkdirp"));
14
14
  const semver_1 = __importDefault(require("semver"));
15
15
  const os_1 = __importDefault(require("os"));
16
+ const rimraf_1 = __importDefault(require("rimraf"));
16
17
  function getPluginNodePath(name) {
17
18
  const pluginVolume = (0, plugin_volume_1.ensurePluginVolume)(name);
18
19
  const nodeMajorVersion = semver_1.default.parse(process_1.default.version).major;
19
- const nodePrefix = path_1.default.join(pluginVolume, `${process_1.default.platform}-${process_1.default.arch}-${nodeMajorVersion}`);
20
+ const nodePrefix = path_1.default.join(pluginVolume, `node${nodeMajorVersion}-${process_1.default.platform}-${process_1.default.arch}`);
20
21
  return nodePrefix;
21
22
  }
22
23
  exports.getPluginNodePath = getPluginNodePath;
@@ -30,35 +31,58 @@ async function installOptionalDependencies(console, packageJson) {
30
31
  }
31
32
  catch (e) {
32
33
  }
33
- const { optionalDependencies } = packageJson;
34
- if (!optionalDependencies)
35
- return;
36
- if (!Object.keys(optionalDependencies).length)
37
- return;
38
- const currentOptionalDependencies = currentPackageJson?.dependencies || {};
39
- if (JSON.stringify(optionalDependencies) === JSON.stringify(currentOptionalDependencies)) {
40
- console.log('native dependencies (up to date).', ...Object.keys(optionalDependencies));
41
- return;
34
+ try {
35
+ const { optionalDependencies } = packageJson;
36
+ if (!optionalDependencies)
37
+ return;
38
+ if (!Object.keys(optionalDependencies).length)
39
+ return;
40
+ const currentOptionalDependencies = currentPackageJson?.dependencies || {};
41
+ if (JSON.stringify(optionalDependencies) === JSON.stringify(currentOptionalDependencies)) {
42
+ console.log('native dependencies (up to date).', ...Object.keys(optionalDependencies));
43
+ return;
44
+ }
45
+ console.log('native dependencies (outdated)', ...Object.keys(optionalDependencies));
46
+ const reduced = Object.assign({}, packageJson);
47
+ reduced.dependencies = reduced.optionalDependencies;
48
+ delete reduced.optionalDependencies;
49
+ delete reduced.devDependencies;
50
+ mkdirp_1.default.sync(nodePrefix);
51
+ fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(reduced));
52
+ let npm = 'npm';
53
+ if (os_1.default.platform() === 'win32')
54
+ npm += '.cmd';
55
+ const cp = child_process_1.default.spawn(npm, ['--prefix', nodePrefix, 'install'], {
56
+ cwd: nodePrefix,
57
+ stdio: 'inherit',
58
+ });
59
+ await (0, events_1.once)(cp, 'exit');
60
+ if (cp.exitCode !== 0)
61
+ throw new Error('npm installation failed with exit code ' + cp.exitCode);
62
+ fs_1.default.writeFileSync(currentInstalledPackageJsonPath, JSON.stringify(reduced));
63
+ console.log('native dependencies installed.');
64
+ }
65
+ finally {
66
+ const pluginVolume = (0, plugin_volume_1.ensurePluginVolume)(packageJson.name);
67
+ for (const de of await fs_1.default.promises.readdir(pluginVolume, {
68
+ withFileTypes: true,
69
+ })) {
70
+ const filePath = path_1.default.join(pluginVolume, de.name);
71
+ if (filePath === nodePrefix)
72
+ continue;
73
+ if (!de.isDirectory())
74
+ return;
75
+ if (de.name.startsWith('linux') || de.name.startsWith('darwin') || de.name.startsWith('win32')
76
+ || de.name.startsWith('python') || de.name.startsWith('node')) {
77
+ console.log('Removing old dependencies:', filePath);
78
+ try {
79
+ rimraf_1.default.sync(filePath);
80
+ }
81
+ catch (e) {
82
+ }
83
+ }
84
+ }
42
85
  }
43
- console.log('native dependencies (outdated)', ...Object.keys(optionalDependencies));
44
- const reduced = Object.assign({}, packageJson);
45
- reduced.dependencies = reduced.optionalDependencies;
46
- delete reduced.optionalDependencies;
47
- delete reduced.devDependencies;
48
- mkdirp_1.default.sync(nodePrefix);
49
- fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(reduced));
50
- let npm = 'npm';
51
- if (os_1.default.platform() === 'win32')
52
- npm += '.cmd';
53
- const cp = child_process_1.default.spawn(npm, ['--prefix', nodePrefix, 'install'], {
54
- cwd: nodePrefix,
55
- stdio: 'inherit',
56
- });
57
- await (0, events_1.once)(cp, 'exit');
58
- if (cp.exitCode !== 0)
59
- throw new Error('npm installation failed with exit code ' + cp.exitCode);
60
- fs_1.default.writeFileSync(currentInstalledPackageJsonPath, JSON.stringify(reduced));
61
- console.log('native dependencies installed.');
62
86
  }
63
87
  exports.installOptionalDependencies = installOptionalDependencies;
64
88
  //# sourceMappingURL=plugin-npm-dependencies.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-npm-dependencies.js","sourceRoot":"","sources":["../../src/plugin/plugin-npm-dependencies.ts"],"names":[],"mappings":";;;;;;AAAA,mDAAqD;AACrD,4CAAoB;AACpB,kEAA0C;AAC1C,gDAAwB;AACxB,mCAA8B;AAC9B,sDAA8B;AAC9B,oDAA4B;AAC5B,oDAA4B;AAC5B,4CAAoB;AAEpB,SAAgB,iBAAiB,CAAC,IAAY;IAC1C,MAAM,YAAY,GAAG,IAAA,kCAAkB,EAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,gBAAgB,GAAG,gBAAM,CAAC,KAAK,CAAC,iBAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;IAC7D,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,iBAAO,CAAC,QAAQ,IAAI,iBAAO,CAAC,IAAI,IAAI,gBAAgB,EAAE,CAAC,CAAC;IACtG,OAAO,UAAU,CAAC;AACtB,CAAC;AALD,8CAKC;AAEM,KAAK,UAAU,2BAA2B,CAAC,OAAgB,EAAE,WAAgB;IAChF,MAAM,UAAU,GAAG,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAC9D,MAAM,+BAA+B,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,wBAAwB,CAA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AAC,UAAU,CAAC,OAAO,CAAC;mBACvF,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;gBAC/D,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,QAAQ,CAAC,CAAC;gBACpD,IAAI;oBACA,gBAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBACzB;gBACD,OAAO,CAAC,EAAE;iBACT;aACJ;SACJ;KACJ;AACL,CAAC;AAvED,kEAuEC"}
@@ -36,7 +36,7 @@ class PythonRuntimeWorker extends child_process_worker_1.ChildProcessWorker {
36
36
  }
37
37
  }
38
38
  }
39
- const pythonPath = os_1.default.platform() === 'win32' ? 'py.exe' : 'python3';
39
+ const pythonPath = process.env.SCRYPTED_PYTHON_PATH || (os_1.default.platform() === 'win32' ? 'py.exe' : 'python3');
40
40
  this.worker = child_process_1.default.spawn(pythonPath, args, {
41
41
  // stdin, stdout, stderr, peer in, peer out
42
42
  stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe'],
@@ -1 +1 @@
1
- {"version":3,"file":"python-worker.js","sourceRoot":"","sources":["../../../src/plugin/runtime/python-worker.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA0C;AAC1C,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AAIxB,yDAAiE;AACjE,iEAA4D;AAG5D,MAAa,mBAAoB,SAAQ,yCAAkB;IACvD,UAAU,CAA+C;IAEzD,YAAY,QAAgB,EAAE,OAA6B;QACvD,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAEzB,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QACrC,MAAM,IAAI,GAAa;YACnB,IAAI;SACP,CAAC;QACF,IAAI,WAAW,EAAE;YACb,IAAI,CAAC,IAAI,CACL,IAAI,EACJ,SAAS,EACT,UAAU,EACV,WAAW,WAAW,CAAC,WA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AC,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC,CAAC;SACtE;QACD,OAAO,CAAC,EAAE;YACN,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;SACf;IACL,CAAC;CACJ;AA9ED,kDA8EC"}
@@ -10,6 +10,11 @@ const plugin_error_1 = require("./plugin/plugin-error");
10
10
  if (!semver_1.default.gte(process_1.default.version, '16.0.0')) {
11
11
  throw new Error('"node" version out of date. Please update node to v16 or higher.');
12
12
  }
13
+ // Node 17 changes the dns resolution order to return the record order.
14
+ // This causes issues with clients that are on "IPv6" networks that are
15
+ // actually busted and fail to connect to npm's IPv6 address.
16
+ // The workaround is to favor IPv4.
17
+ process_1.default.env['NODE_OPTIONS'] = '--dns-result-order=ipv4first';
13
18
  (0, rpc_1.startPeriodicGarbageCollection)();
14
19
  if (process_1.default.argv[2] === 'child' || process_1.default.argv[2] === 'child-thread') {
15
20
  // plugins should never crash. this handler will be removed, and then readded
@@ -1 +1 @@
1
- {"version":3,"file":"scrypted-main.js","sourceRoot":"","sources":["../src/scrypted-main.ts"],"names":[],"mappings":";;;;;AAAA,sDAA8B;AAC9B,oDAA4B;AAC5B,+BAAuE;AACvE,wDAAoD;AAEpD,IAAI,CAAC,gBAAM,CAAC,GAAG,CAAC,iBAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;IACxC,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAA;CACtF;AAED,IAAA,oCAA8B,GAAE,CAAC;AAEjC,IAAI,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,IAAI,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,cAAc,EAAE;IACnE,6EAA6E;IAC7E,4CAA4C;IAC5C,iBAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,CAAC,EAAE;QAChC,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IACH,iBA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EAAE;QAChC,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IACH,iBAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,CAAC,EAAE;QACjC,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACrC;KACI;IACD,uEAAuE;IACvE,iBAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,CAAC,EAAE;QACrC,IAAI,KAAK,EAAE,WAAW,KAAK,oBAAc,IAAI,KAAK,EAAE,WAAW,KAAK,0BAAW,EAAE;YAC7E,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAC5B,MAAM,KAAK,CAAC;SACf;QACD,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACrC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrypted/server",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "",
5
5
  "dependencies": {
6
6
  "@ffmpeg-installer/ffmpeg": "^1.1.0",
@@ -4,7 +4,7 @@ import asyncio
4
4
  import base64
5
5
  import gc
6
6
  import json
7
- import mimetypes
7
+ import sys
8
8
  import os
9
9
  import platform
10
10
  import shutil
@@ -274,14 +274,15 @@ class PluginRemote:
274
274
  zip = zipfile.ZipFile(zipPath)
275
275
 
276
276
  plugin_volume = os.environ.get('SCRYPTED_PLUGIN_VOLUME')
277
- python_prefix = os.path.join(plugin_volume, 'python-%s-%s' % (platform.system(), platform.machine()))
278
- if not os.path.exists(python_prefix):
279
- os.makedirs(python_prefix)
280
277
 
281
278
  python_version = 'python%s' % str(
282
279
  sys.version_info[0])+"."+str(sys.version_info[1])
283
280
  print('python version:', python_version)
284
281
 
282
+ python_prefix = os.path.join(plugin_volume, 'python%s-%s-%s' % (python_version, platform.system(), platform.machine()))
283
+ if not os.path.exists(python_prefix):
284
+ os.makedirs(python_prefix)
285
+
285
286
  if 'requirements.txt' in zip.namelist():
286
287
  requirements = zip.open('requirements.txt').read()
287
288
  str_requirements = requirements.decode('utf8')
@@ -7,11 +7,12 @@ import process from 'process';
7
7
  import mkdirp from "mkdirp";
8
8
  import semver from 'semver';
9
9
  import os from 'os';
10
+ import rimraf from "rimraf";
10
11
 
11
12
  export function getPluginNodePath(name: string) {
12
13
  const pluginVolume = ensurePluginVolume(name);
13
14
  const nodeMajorVersion = semver.parse(process.version).major;
14
- const nodePrefix = path.join(pluginVolume, `${process.platform}-${process.arch}-${nodeMajorVersion}`);
15
+ const nodePrefix = path.join(pluginVolume, `node${nodeMajorVersion}-${process.platform}-${process.arch}`);
15
16
  return nodePrefix;
16
17
  }
17
18
 
@@ -27,40 +28,63 @@ export async function installOptionalDependencies(console: Console, packageJson:
27
28
  catch (e) {
28
29
  }
29
30
 
30
- const { optionalDependencies } = packageJson;
31
- if (!optionalDependencies)
32
- return;
33
- if (!Object.keys(optionalDependencies).length)
34
- return;
35
- const currentOptionalDependencies = currentPackageJson?.dependencies || {};
31
+ try {
32
+ const { optionalDependencies } = packageJson;
33
+ if (!optionalDependencies)
34
+ return;
35
+ if (!Object.keys(optionalDependencies).length)
36
+ return;
37
+ const currentOptionalDependencies = currentPackageJson?.dependencies || {};
36
38
 
37
- if (JSON.stringify(optionalDependencies) === JSON.stringify(currentOptionalDependencies)) {
38
- console.log('native dependencies (up to date).', ...Object.keys(optionalDependencies));
39
- return;
40
- }
39
+ if (JSON.stringify(optionalDependencies) === JSON.stringify(currentOptionalDependencies)) {
40
+ console.log('native dependencies (up to date).', ...Object.keys(optionalDependencies));
41
+ return;
42
+ }
41
43
 
42
- console.log('native dependencies (outdated)', ...Object.keys(optionalDependencies));
44
+ console.log('native dependencies (outdated)', ...Object.keys(optionalDependencies));
43
45
 
44
- const reduced = Object.assign({}, packageJson);
45
- reduced.dependencies = reduced.optionalDependencies;
46
- delete reduced.optionalDependencies;
47
- delete reduced.devDependencies;
46
+ const reduced = Object.assign({}, packageJson);
47
+ reduced.dependencies = reduced.optionalDependencies;
48
+ delete reduced.optionalDependencies;
49
+ delete reduced.devDependencies;
48
50
 
49
- mkdirp.sync(nodePrefix);
50
- fs.writeFileSync(packageJsonPath, JSON.stringify(reduced));
51
+ mkdirp.sync(nodePrefix);
52
+ fs.writeFileSync(packageJsonPath, JSON.stringify(reduced));
51
53
 
52
- let npm = 'npm';
53
- if (os.platform() === 'win32')
54
- npm += '.cmd';
55
- const cp = child_process.spawn(npm, ['--prefix', nodePrefix, 'install'], {
56
- cwd: nodePrefix,
57
- stdio: 'inherit',
58
- });
54
+ let npm = 'npm';
55
+ if (os.platform() === 'win32')
56
+ npm += '.cmd';
57
+ const cp = child_process.spawn(npm, ['--prefix', nodePrefix, 'install'], {
58
+ cwd: nodePrefix,
59
+ stdio: 'inherit',
60
+ });
59
61
 
60
- await once(cp, 'exit');
61
- if (cp.exitCode !== 0)
62
- throw new Error('npm installation failed with exit code ' + cp.exitCode);
62
+ await once(cp, 'exit');
63
+ if (cp.exitCode !== 0)
64
+ throw new Error('npm installation failed with exit code ' + cp.exitCode);
63
65
 
64
- fs.writeFileSync(currentInstalledPackageJsonPath, JSON.stringify(reduced));
65
- console.log('native dependencies installed.');
66
+ fs.writeFileSync(currentInstalledPackageJsonPath, JSON.stringify(reduced));
67
+ console.log('native dependencies installed.');
68
+ }
69
+ finally {
70
+ const pluginVolume = ensurePluginVolume(packageJson.name);
71
+ for (const de of await fs.promises.readdir(pluginVolume, {
72
+ withFileTypes: true,
73
+ })) {
74
+ const filePath = path.join(pluginVolume, de.name);
75
+ if (filePath === nodePrefix)
76
+ continue;
77
+ if (!de.isDirectory())
78
+ return;
79
+ if (de.name.startsWith('linux') || de.name.startsWith('darwin') || de.name.startsWith('win32')
80
+ || de.name.startsWith('python') || de.name.startsWith('node')) {
81
+ console.log('Removing old dependencies:', filePath);
82
+ try {
83
+ rimraf.sync(filePath);
84
+ }
85
+ catch (e) {
86
+ }
87
+ }
88
+ }
89
+ }
66
90
  }
@@ -47,7 +47,7 @@ export class PythonRuntimeWorker extends ChildProcessWorker {
47
47
  }
48
48
  }
49
49
 
50
- const pythonPath = os.platform() === 'win32' ? 'py.exe' : 'python3';
50
+ const pythonPath = process.env.SCRYPTED_PYTHON_PATH || (os.platform() === 'win32' ? 'py.exe' : 'python3');
51
51
 
52
52
  this.worker = child_process.spawn(pythonPath, args, {
53
53
  // stdin, stdout, stderr, peer in, peer out
@@ -7,6 +7,12 @@ if (!semver.gte(process.version, '16.0.0')) {
7
7
  throw new Error('"node" version out of date. Please update node to v16 or higher.')
8
8
  }
9
9
 
10
+ // Node 17 changes the dns resolution order to return the record order.
11
+ // This causes issues with clients that are on "IPv6" networks that are
12
+ // actually busted and fail to connect to npm's IPv6 address.
13
+ // The workaround is to favor IPv4.
14
+ process.env['NODE_OPTIONS'] = '--dns-result-order=ipv4first';
15
+
10
16
  startPeriodicGarbageCollection();
11
17
 
12
18
  if (process.argv[2] === 'child' || process.argv[2] === 'child-thread') {