@scrypted/server 0.7.19 → 0.7.21

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.

@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- const { spawn } = require('child_process');
3
2
  const path = require('path');
4
3
  const mainPath = path.join(__dirname, '../dist/scrypted-main.js');
5
- spawn('node', ['--expose-gc', mainPath], { stdio: 'inherit' });
4
+ require(mainPath);
@@ -0,0 +1,52 @@
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
+ const v8_1 = __importDefault(require("v8"));
7
+ const vm_1 = __importDefault(require("vm"));
8
+ const process_1 = __importDefault(require("process"));
9
+ const semver_1 = __importDefault(require("semver"));
10
+ const rpc_1 = require("./rpc");
11
+ const plugin_error_1 = require("./plugin/plugin-error");
12
+ function start(mainFilename) {
13
+ if (!global.gc) {
14
+ v8_1.default.setFlagsFromString('--expose_gc');
15
+ global.gc = vm_1.default.runInNewContext("gc");
16
+ }
17
+ if (!semver_1.default.gte(process_1.default.version, '16.0.0')) {
18
+ throw new Error('"node" version out of date. Please update node to v16 or higher.');
19
+ }
20
+ // Node 17 changes the dns resolution order to return the record order.
21
+ // This causes issues with clients that are on "IPv6" networks that are
22
+ // actually busted and fail to connect to npm's IPv6 address.
23
+ // The workaround is to favor IPv4.
24
+ process_1.default.env['NODE_OPTIONS'] = '--dns-result-order=ipv4first';
25
+ (0, rpc_1.startPeriodicGarbageCollection)();
26
+ if (process_1.default.argv[2] === 'child' || process_1.default.argv[2] === 'child-thread') {
27
+ // plugins should never crash. this handler will be removed, and then readded
28
+ // after the plugin source map is retrieved.
29
+ process_1.default.on('uncaughtException', e => {
30
+ console.error('uncaughtException', e);
31
+ });
32
+ process_1.default.on('unhandledRejection', e => {
33
+ console.error('unhandledRejection', e);
34
+ });
35
+ const start = require('./scrypted-plugin-main').default;
36
+ start(mainFilename);
37
+ }
38
+ else {
39
+ // unhandled rejections are allowed if they are from a rpc/plugin call.
40
+ process_1.default.on('unhandledRejection', error => {
41
+ if (error?.constructor !== rpc_1.RPCResultError && error?.constructor !== plugin_error_1.PluginError) {
42
+ console.error('wtf', error);
43
+ throw error;
44
+ }
45
+ console.warn('unhandled rejection of RPC Result', error);
46
+ });
47
+ const start = require('./scrypted-server-main').default;
48
+ start(mainFilename);
49
+ }
50
+ }
51
+ exports.default = start;
52
+ //# sourceMappingURL=scrypted-main-exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrypted-main-exports.js","sourceRoot":"","sources":["../src/scrypted-main-exports.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,4CAAoB;AACpB,sDAA8B;AAC9B,oDAA4B;AAC5B,+BAAuE;AACvE,wDAAoD;AAEpD,SAAS,KAAK,CAAC,YAAoB;IAC/B,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;QACZ,YAAE,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAA;QACpC,MAAM,CAAC,EAAE,GAAG,YAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;KACxC;IAED,IAAI,CAAC,gBAAM,CAAC,GAAG,CAAC,iBAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;QACxC,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAA;KACtF;IAED,uEAAuE;IACvE,uEAAuE;IACvE,6DAA6D;IAC7D,mCAAmC;IACnC,iBAAO,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,8BAA8B,CAAC;IAE7D,IAAA,oCAA8B,GAAE,CAAC;IAEjC,IAAI,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,IAAI,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,cAAc,EAAE;QACnE,6EAA6E;QAC7E,4CAA4C;QAC5C,iBAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,CAAC,EAAE;YAChC,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QACH,iBAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,CAAC,EAAE;YACjC,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC,OAAO,CAAC;QACxD,KAAK,CAAC,YAAY,CAAC,CAAC;KACvB;SACI;QACD,uEAAuE;QACvE,iBAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,CAAC,EAAE;YACrC,IAAI,KAAK,EAAE,WAAW,KAAK,oBAAc,IAAI,KAAK,EAAE,WAAW,KAAK,0BAAW,EAAE;gBAC7E,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAC5B,MAAM,KAAK,CAAC;aACf;YACD,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC,OAAO,CAAC;QACxD,KAAK,CAAC,YAAY,CAAC,CAAC;KACvB;AACL,CAAC;AAED,kBAAe,KAAK,CAAC"}
@@ -3,47 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const v8_1 = __importDefault(require("v8"));
7
- const vm_1 = __importDefault(require("vm"));
8
- const process_1 = __importDefault(require("process"));
9
- const semver_1 = __importDefault(require("semver"));
10
- const rpc_1 = require("./rpc");
11
- const plugin_error_1 = require("./plugin/plugin-error");
12
- if (!global.gc) {
13
- v8_1.default.setFlagsFromString('--expose_gc');
14
- global.gc = vm_1.default.runInNewContext("gc");
15
- }
16
- if (!semver_1.default.gte(process_1.default.version, '16.0.0')) {
17
- throw new Error('"node" version out of date. Please update node to v16 or higher.');
18
- }
19
- // Node 17 changes the dns resolution order to return the record order.
20
- // This causes issues with clients that are on "IPv6" networks that are
21
- // actually busted and fail to connect to npm's IPv6 address.
22
- // The workaround is to favor IPv4.
23
- process_1.default.env['NODE_OPTIONS'] = '--dns-result-order=ipv4first';
24
- (0, rpc_1.startPeriodicGarbageCollection)();
25
- if (process_1.default.argv[2] === 'child' || process_1.default.argv[2] === 'child-thread') {
26
- // plugins should never crash. this handler will be removed, and then readded
27
- // after the plugin source map is retrieved.
28
- process_1.default.on('uncaughtException', e => {
29
- console.error('uncaughtException', e);
30
- });
31
- process_1.default.on('unhandledRejection', e => {
32
- console.error('unhandledRejection', e);
33
- });
34
- const start = require('./scrypted-plugin-main').default;
35
- start(__filename);
36
- }
37
- else {
38
- // unhandled rejections are allowed if they are from a rpc/plugin call.
39
- process_1.default.on('unhandledRejection', error => {
40
- if (error?.constructor !== rpc_1.RPCResultError && error?.constructor !== plugin_error_1.PluginError) {
41
- console.error('wtf', error);
42
- throw error;
43
- }
44
- console.warn('unhandled rejection of RPC Result', error);
45
- });
46
- const start = require('./scrypted-server-main').default;
47
- start(__filename);
48
- }
6
+ const scrypted_main_exports_1 = __importDefault(require("./scrypted-main-exports"));
7
+ (0, scrypted_main_exports_1.default)(__filename);
49
8
  //# sourceMappingURL=scrypted-main.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scrypted-main.js","sourceRoot":"","sources":["../src/scrypted-main.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,4CAAoB;AACpB,sDAA8B;AAC9B,oDAA4B;AAC5B,+BAAuE;AACvE,wDAAoD;AAEpD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;IACZ,YAAE,CAAC,kBAAkB,CAAC,aAAa,CAAC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I,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC,OAAO,CAAC;IACxD,KAAK,CAAC,UAAU,CAAC,CAAC;CACrB"}
1
+ {"version":3,"file":"scrypted-main.js","sourceRoot":"","sources":["../src/scrypted-main.ts"],"names":[],"mappings":";;;;;AAAA,oFAA4C;AAE5C,IAAA,+BAAK,EAAC,UAAU,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrypted/server",
3
- "version": "0.7.19",
3
+ "version": "0.7.21",
4
4
  "description": "",
5
5
  "dependencies": {
6
6
  "@mapbox/node-pre-gyp": "^1.0.10",
@@ -60,7 +60,7 @@
60
60
  "bin": {
61
61
  "scrypted-serve": "bin/scrypted-serve"
62
62
  },
63
- "main": "dist/scrypted-main.js",
63
+ "main": "dist/scrypted-main-exports.js",
64
64
  "scripts": {
65
65
  "preserve": "npm run build",
66
66
  "serve": "node --expose-gc dist/scrypted-main.js",
@@ -0,0 +1,54 @@
1
+ import v8 from 'v8';
2
+ import vm from 'vm';
3
+ import process from 'process';
4
+ import semver from 'semver';
5
+ import { RPCResultError, startPeriodicGarbageCollection } from './rpc';
6
+ import { PluginError } from './plugin/plugin-error';
7
+
8
+ function start(mainFilename: string) {
9
+ if (!global.gc) {
10
+ v8.setFlagsFromString('--expose_gc')
11
+ global.gc = vm.runInNewContext("gc");
12
+ }
13
+
14
+ if (!semver.gte(process.version, '16.0.0')) {
15
+ throw new Error('"node" version out of date. Please update node to v16 or higher.')
16
+ }
17
+
18
+ // Node 17 changes the dns resolution order to return the record order.
19
+ // This causes issues with clients that are on "IPv6" networks that are
20
+ // actually busted and fail to connect to npm's IPv6 address.
21
+ // The workaround is to favor IPv4.
22
+ process.env['NODE_OPTIONS'] = '--dns-result-order=ipv4first';
23
+
24
+ startPeriodicGarbageCollection();
25
+
26
+ if (process.argv[2] === 'child' || process.argv[2] === 'child-thread') {
27
+ // plugins should never crash. this handler will be removed, and then readded
28
+ // after the plugin source map is retrieved.
29
+ process.on('uncaughtException', e => {
30
+ console.error('uncaughtException', e);
31
+ });
32
+ process.on('unhandledRejection', e => {
33
+ console.error('unhandledRejection', e);
34
+ });
35
+
36
+ const start = require('./scrypted-plugin-main').default;
37
+ start(mainFilename);
38
+ }
39
+ else {
40
+ // unhandled rejections are allowed if they are from a rpc/plugin call.
41
+ process.on('unhandledRejection', error => {
42
+ if (error?.constructor !== RPCResultError && error?.constructor !== PluginError) {
43
+ console.error('wtf', error);
44
+ throw error;
45
+ }
46
+ console.warn('unhandled rejection of RPC Result', error);
47
+ });
48
+
49
+ const start = require('./scrypted-server-main').default;
50
+ start(mainFilename);
51
+ }
52
+ }
53
+
54
+ export default start;
@@ -1,50 +1,3 @@
1
- import v8 from 'v8';
2
- import vm from 'vm';
3
- import process from 'process';
4
- import semver from 'semver';
5
- import { RPCResultError, startPeriodicGarbageCollection } from './rpc';
6
- import { PluginError } from './plugin/plugin-error';
1
+ import start from './scrypted-main-exports';
7
2
 
8
- if (!global.gc) {
9
- v8.setFlagsFromString('--expose_gc')
10
- global.gc = vm.runInNewContext("gc");
11
- }
12
-
13
- if (!semver.gte(process.version, '16.0.0')) {
14
- throw new Error('"node" version out of date. Please update node to v16 or higher.')
15
- }
16
-
17
- // Node 17 changes the dns resolution order to return the record order.
18
- // This causes issues with clients that are on "IPv6" networks that are
19
- // actually busted and fail to connect to npm's IPv6 address.
20
- // The workaround is to favor IPv4.
21
- process.env['NODE_OPTIONS'] = '--dns-result-order=ipv4first';
22
-
23
- startPeriodicGarbageCollection();
24
-
25
- if (process.argv[2] === 'child' || process.argv[2] === 'child-thread') {
26
- // plugins should never crash. this handler will be removed, and then readded
27
- // after the plugin source map is retrieved.
28
- process.on('uncaughtException', e => {
29
- console.error('uncaughtException', e);
30
- });
31
- process.on('unhandledRejection', e => {
32
- console.error('unhandledRejection', e);
33
- });
34
-
35
- const start = require('./scrypted-plugin-main').default;
36
- start(__filename);
37
- }
38
- else {
39
- // unhandled rejections are allowed if they are from a rpc/plugin call.
40
- process.on('unhandledRejection', error => {
41
- if (error?.constructor !== RPCResultError && error?.constructor !== PluginError) {
42
- console.error('wtf', error);
43
- throw error;
44
- }
45
- console.warn('unhandled rejection of RPC Result', error);
46
- });
47
-
48
- const start = require('./scrypted-server-main').default;
49
- start(__filename);
50
- }
3
+ start(__filename);