@scrypted/server 0.7.91 → 0.7.93

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.
Files changed (185) hide show
  1. package/package.json +1 -1
  2. package/src/services/addresses.ts +2 -0
  3. package/dist/asynciterable-utils.d.ts +0 -2
  4. package/dist/asynciterable-utils.js +0 -24
  5. package/dist/asynciterable-utils.js.map +0 -1
  6. package/dist/cert.d.ts +0 -6
  7. package/dist/cert.js +0 -75
  8. package/dist/cert.js.map +0 -1
  9. package/dist/collection.d.ts +0 -1
  10. package/dist/collection.js +0 -16
  11. package/dist/collection.js.map +0 -1
  12. package/dist/db-types.d.ts +0 -38
  13. package/dist/db-types.js +0 -45
  14. package/dist/db-types.js.map +0 -1
  15. package/dist/event-registry.d.ts +0 -19
  16. package/dist/event-registry.js +0 -92
  17. package/dist/event-registry.js.map +0 -1
  18. package/dist/http-interfaces.d.ts +0 -3
  19. package/dist/http-interfaces.js +0 -73
  20. package/dist/http-interfaces.js.map +0 -1
  21. package/dist/infer-defaults.d.ts +0 -11
  22. package/dist/infer-defaults.js +0 -119
  23. package/dist/infer-defaults.js.map +0 -1
  24. package/dist/io.d.ts +0 -22
  25. package/dist/io.js +0 -3
  26. package/dist/io.js.map +0 -1
  27. package/dist/level.d.ts +0 -110
  28. package/dist/level.js +0 -135
  29. package/dist/level.js.map +0 -1
  30. package/dist/listen-zero.d.ts +0 -13
  31. package/dist/listen-zero.js +0 -48
  32. package/dist/listen-zero.js.map +0 -1
  33. package/dist/logger.d.ts +0 -29
  34. package/dist/logger.js +0 -78
  35. package/dist/logger.js.map +0 -1
  36. package/dist/media-helpers.d.ts +0 -5
  37. package/dist/media-helpers.js +0 -89
  38. package/dist/media-helpers.js.map +0 -1
  39. package/dist/mixin/mixin-cycle.d.ts +0 -3
  40. package/dist/mixin/mixin-cycle.js +0 -32
  41. package/dist/mixin/mixin-cycle.js.map +0 -1
  42. package/dist/plugin/acl.d.ts +0 -16
  43. package/dist/plugin/acl.js +0 -83
  44. package/dist/plugin/acl.js.map +0 -1
  45. package/dist/plugin/descriptor.d.ts +0 -22
  46. package/dist/plugin/descriptor.js +0 -35
  47. package/dist/plugin/descriptor.js.map +0 -1
  48. package/dist/plugin/media.d.ts +0 -71
  49. package/dist/plugin/media.js +0 -420
  50. package/dist/plugin/media.js.map +0 -1
  51. package/dist/plugin/mediaobject.d.ts +0 -10
  52. package/dist/plugin/mediaobject.js +0 -26
  53. package/dist/plugin/mediaobject.js.map +0 -1
  54. package/dist/plugin/plugin-api.d.ts +0 -106
  55. package/dist/plugin/plugin-api.js +0 -120
  56. package/dist/plugin/plugin-api.js.map +0 -1
  57. package/dist/plugin/plugin-console.d.ts +0 -28
  58. package/dist/plugin/plugin-console.js +0 -291
  59. package/dist/plugin/plugin-console.js.map +0 -1
  60. package/dist/plugin/plugin-debug.d.ts +0 -4
  61. package/dist/plugin/plugin-debug.js +0 -3
  62. package/dist/plugin/plugin-debug.js.map +0 -1
  63. package/dist/plugin/plugin-device.d.ts +0 -54
  64. package/dist/plugin/plugin-device.js +0 -413
  65. package/dist/plugin/plugin-device.js.map +0 -1
  66. package/dist/plugin/plugin-error.d.ts +0 -2
  67. package/dist/plugin/plugin-error.js +0 -7
  68. package/dist/plugin/plugin-error.js.map +0 -1
  69. package/dist/plugin/plugin-host-api.d.ts +0 -43
  70. package/dist/plugin/plugin-host-api.js +0 -177
  71. package/dist/plugin/plugin-host-api.js.map +0 -1
  72. package/dist/plugin/plugin-host.d.ts +0 -45
  73. package/dist/plugin/plugin-host.js +0 -398
  74. package/dist/plugin/plugin-host.js.map +0 -1
  75. package/dist/plugin/plugin-http.d.ts +0 -18
  76. package/dist/plugin/plugin-http.js +0 -120
  77. package/dist/plugin/plugin-http.js.map +0 -1
  78. package/dist/plugin/plugin-lazy-remote.d.ts +0 -31
  79. package/dist/plugin/plugin-lazy-remote.js +0 -75
  80. package/dist/plugin/plugin-lazy-remote.js.map +0 -1
  81. package/dist/plugin/plugin-npm-dependencies.d.ts +0 -8
  82. package/dist/plugin/plugin-npm-dependencies.js +0 -103
  83. package/dist/plugin/plugin-npm-dependencies.js.map +0 -1
  84. package/dist/plugin/plugin-remote-stats.d.ts +0 -8
  85. package/dist/plugin/plugin-remote-stats.js +0 -30
  86. package/dist/plugin/plugin-remote-stats.js.map +0 -1
  87. package/dist/plugin/plugin-remote-websocket.d.ts +0 -29
  88. package/dist/plugin/plugin-remote-websocket.js +0 -152
  89. package/dist/plugin/plugin-remote-websocket.js.map +0 -1
  90. package/dist/plugin/plugin-remote-worker.d.ts +0 -5
  91. package/dist/plugin/plugin-remote-worker.js +0 -348
  92. package/dist/plugin/plugin-remote-worker.js.map +0 -1
  93. package/dist/plugin/plugin-remote.d.ts +0 -75
  94. package/dist/plugin/plugin-remote.js +0 -598
  95. package/dist/plugin/plugin-remote.js.map +0 -1
  96. package/dist/plugin/plugin-repl.d.ts +0 -2
  97. package/dist/plugin/plugin-repl.js +0 -74
  98. package/dist/plugin/plugin-repl.js.map +0 -1
  99. package/dist/plugin/plugin-state-check.d.ts +0 -1
  100. package/dist/plugin/plugin-state-check.js +0 -27
  101. package/dist/plugin/plugin-state-check.js.map +0 -1
  102. package/dist/plugin/plugin-volume.d.ts +0 -3
  103. package/dist/plugin/plugin-volume.js +0 -31
  104. package/dist/plugin/plugin-volume.js.map +0 -1
  105. package/dist/plugin/runtime/child-process-worker.d.ts +0 -20
  106. package/dist/plugin/runtime/child-process-worker.js +0 -42
  107. package/dist/plugin/runtime/child-process-worker.js.map +0 -1
  108. package/dist/plugin/runtime/node-fork-worker.d.ts +0 -9
  109. package/dist/plugin/runtime/node-fork-worker.js +0 -67
  110. package/dist/plugin/runtime/node-fork-worker.js.map +0 -1
  111. package/dist/plugin/runtime/node-thread-worker.d.ts +0 -20
  112. package/dist/plugin/runtime/node-thread-worker.js +0 -73
  113. package/dist/plugin/runtime/node-thread-worker.js.map +0 -1
  114. package/dist/plugin/runtime/python-worker.d.ts +0 -10
  115. package/dist/plugin/runtime/python-worker.js +0 -91
  116. package/dist/plugin/runtime/python-worker.js.map +0 -1
  117. package/dist/plugin/runtime/runtime-worker.d.ts +0 -26
  118. package/dist/plugin/runtime/runtime-worker.js +0 -3
  119. package/dist/plugin/runtime/runtime-worker.js.map +0 -1
  120. package/dist/plugin/socket-serializer.d.ts +0 -5
  121. package/dist/plugin/socket-serializer.js +0 -17
  122. package/dist/plugin/socket-serializer.js.map +0 -1
  123. package/dist/plugin/system.d.ts +0 -39
  124. package/dist/plugin/system.js +0 -216
  125. package/dist/plugin/system.js.map +0 -1
  126. package/dist/rpc-buffer-serializer.d.ts +0 -11
  127. package/dist/rpc-buffer-serializer.js +0 -30
  128. package/dist/rpc-buffer-serializer.js.map +0 -1
  129. package/dist/rpc-serializer.d.ts +0 -24
  130. package/dist/rpc-serializer.js +0 -144
  131. package/dist/rpc-serializer.js.map +0 -1
  132. package/dist/rpc.d.ts +0 -147
  133. package/dist/rpc.js +0 -689
  134. package/dist/rpc.js.map +0 -1
  135. package/dist/runtime.d.ts +0 -103
  136. package/dist/runtime.js +0 -815
  137. package/dist/runtime.js.map +0 -1
  138. package/dist/scrypted-main-exports.d.ts +0 -6
  139. package/dist/scrypted-main-exports.js +0 -57
  140. package/dist/scrypted-main-exports.js.map +0 -1
  141. package/dist/scrypted-main.d.ts +0 -1
  142. package/dist/scrypted-main.js +0 -8
  143. package/dist/scrypted-main.js.map +0 -1
  144. package/dist/scrypted-plugin-main.d.ts +0 -2
  145. package/dist/scrypted-plugin-main.js +0 -43
  146. package/dist/scrypted-plugin-main.js.map +0 -1
  147. package/dist/scrypted-server-main.d.ts +0 -6
  148. package/dist/scrypted-server-main.js +0 -559
  149. package/dist/scrypted-server-main.js.map +0 -1
  150. package/dist/server-settings.d.ts +0 -5
  151. package/dist/server-settings.js +0 -91
  152. package/dist/server-settings.js.map +0 -1
  153. package/dist/services/addresses.d.ts +0 -7
  154. package/dist/services/addresses.js +0 -41
  155. package/dist/services/addresses.js.map +0 -1
  156. package/dist/services/alerts.d.ts +0 -9
  157. package/dist/services/alerts.js +0 -27
  158. package/dist/services/alerts.js.map +0 -1
  159. package/dist/services/cors.d.ts +0 -18
  160. package/dist/services/cors.js +0 -18
  161. package/dist/services/cors.js.map +0 -1
  162. package/dist/services/info.d.ts +0 -5
  163. package/dist/services/info.js +0 -18
  164. package/dist/services/info.js.map +0 -1
  165. package/dist/services/plugin.d.ts +0 -46
  166. package/dist/services/plugin.js +0 -172
  167. package/dist/services/plugin.js.map +0 -1
  168. package/dist/services/service-control.d.ts +0 -8
  169. package/dist/services/service-control.js +0 -39
  170. package/dist/services/service-control.js.map +0 -1
  171. package/dist/services/users.d.ts +0 -19
  172. package/dist/services/users.js +0 -75
  173. package/dist/services/users.js.map +0 -1
  174. package/dist/sleep.d.ts +0 -1
  175. package/dist/sleep.js +0 -8
  176. package/dist/sleep.js.map +0 -1
  177. package/dist/state.d.ts +0 -39
  178. package/dist/state.js +0 -247
  179. package/dist/state.js.map +0 -1
  180. package/dist/threading.d.ts +0 -3
  181. package/dist/threading.js +0 -93
  182. package/dist/threading.js.map +0 -1
  183. package/dist/usertoken.d.ts +0 -11
  184. package/dist/usertoken.js +0 -52
  185. package/dist/usertoken.js.map +0 -1
@@ -1,74 +0,0 @@
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.createREPLServer = void 0;
7
- const listen_zero_1 = require("../listen-zero");
8
- const net_1 = require("net");
9
- const events_1 = require("events");
10
- const repl_1 = __importDefault(require("repl"));
11
- async function createREPLServer(scrypted, params, plugin) {
12
- const { deviceManager, systemManager } = scrypted;
13
- const server = new net_1.Server(async (socket) => {
14
- let [filter] = await (0, events_1.once)(socket, 'data');
15
- filter = filter.toString().trim();
16
- if (filter === 'undefined')
17
- filter = undefined;
18
- const chain = [];
19
- const nativeIds = deviceManager.nativeIds;
20
- const reversed = new Map();
21
- for (const nativeId of nativeIds.keys()) {
22
- reversed.set(nativeIds.get(nativeId).id, nativeId);
23
- }
24
- while (filter) {
25
- const { id } = nativeIds.get(filter);
26
- const d = await systemManager.getDeviceById(id);
27
- chain.push(filter);
28
- filter = reversed.get(d.providerId);
29
- }
30
- chain.reverse();
31
- let device = plugin;
32
- for (const c of chain) {
33
- device = await device.getDevice(c);
34
- }
35
- const realDevice = systemManager.getDeviceById(device.id);
36
- const ctx = Object.assign(params, {
37
- device,
38
- realDevice,
39
- sdk: scrypted,
40
- });
41
- delete ctx.console;
42
- delete ctx.window;
43
- delete ctx.WebSocket;
44
- delete ctx.pluginHostAPI;
45
- delete ctx.log;
46
- delete ctx.pluginRuntimeAPI;
47
- const replFilter = new Set(['require', 'localStorage', 'exports', '__filename', 'log']);
48
- const replVariables = Object.keys(ctx).filter(key => !replFilter.has(key));
49
- const welcome = `JavaScript REPL variables:\n${replVariables.map(key => ' ' + key).join('\n')}\n\n`;
50
- socket.write(welcome);
51
- const r = repl_1.default.start({
52
- terminal: true,
53
- input: socket,
54
- output: socket,
55
- // writer(this: REPLServer, obj: any) {
56
- // const ret = util.inspect(obj, {
57
- // colors: true,
58
- // });
59
- // return ret;//.replaceAll('\n', '\r\n');
60
- // },
61
- preview: false,
62
- });
63
- Object.assign(r.context, ctx);
64
- const cleanup = () => {
65
- r.close();
66
- };
67
- socket.on('close', cleanup);
68
- socket.on('error', cleanup);
69
- socket.on('end', cleanup);
70
- });
71
- return (0, listen_zero_1.listenZero)(server);
72
- }
73
- exports.createREPLServer = createREPLServer;
74
- //# sourceMappingURL=plugin-repl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-repl.js","sourceRoot":"","sources":["../../src/plugin/plugin-repl.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA4C;AAC5C,6BAA6B;AAC7B,mCAA8B;AAC9B,gDAAwB;AAGjB,KAAK,UAAU,gBAAgB,CAAC,QAAwB,EAAE,MAAW,EAAE,MA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AM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IACH,OAAO,IAAA,wBAAU,EAAC,MAAM,CAAC,CAAC;AAC9B,CAAC;AAxED,4CAwEC"}
@@ -1 +0,0 @@
1
- export declare function checkProperty(key: string, value: any): void;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkProperty = void 0;
4
- const types_1 = require("@scrypted/types");
5
- const rpc_1 = require("../rpc");
6
- const descriptor_1 = require("./descriptor");
7
- function checkProperty(key, value) {
8
- if (key === types_1.ScryptedInterfaceProperty.id)
9
- throw new Error("id is read only");
10
- if (key === types_1.ScryptedInterfaceProperty.nativeId)
11
- throw new Error("nativeId is read only");
12
- if (key === types_1.ScryptedInterfaceProperty.mixins)
13
- throw new Error("mixins is read only");
14
- if (key === types_1.ScryptedInterfaceProperty.interfaces)
15
- throw new Error("interfaces is a read only post-mixin computed property, use providedInterfaces");
16
- if (rpc_1.RpcPeer.isRpcProxy(value))
17
- throw new Error('value must be a primitive type');
18
- const iface = descriptor_1.propertyInterfaces[key.toString()];
19
- if (iface === types_1.ScryptedInterface.ScryptedDevice) {
20
- // only allow info to be set, since that doesn't actually change the descriptor
21
- // or the provided* properties (room, interfaces, name, type).
22
- if (key !== types_1.ScryptedInterfaceProperty.info)
23
- throw new Error(`${key.toString()} can not be set. Use DeviceManager.onDevicesChanges or DeviceManager.onDeviceDiscovered to update the device description.`);
24
- }
25
- }
26
- exports.checkProperty = checkProperty;
27
- //# sourceMappingURL=plugin-state-check.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-state-check.js","sourceRoot":"","sources":["../../src/plugin/plugin-state-check.ts"],"names":[],"mappings":";;;AAAA,2CAA+E;AAC/E,gCAAiC;AACjC,6CAAkD;AAElD,SAAgB,aAAa,CAAC,GAAW,EAAE,KAAU;IACjD,IAAI,GAAG,KAAK,iCAAyB,CAAC,EAAE;QACpC,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,IAAI,GAAG,KAAK,iCAAyB,CAAC,QAAQ;QAC1C,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC7C,IAAI,GAAG,KAAK,iCAAyB,CAAC,MAAM;QACxC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC3C,IAAI,GAAG,KAAK,iCAAyB,CAAC,UAAU;QAC5C,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACtG,IAAI,aAAO,CAAC,UAAU,CAAC,KAAK,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IACrD,MAAM,KAAK,GAAG,+BAAkB,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjD,IAAI,KAAK,KAAK,yBAAiB,CAAC,cAAc,EAAE;QAC5C,+EAA+E;QAC/E,8DAA8D;QAC9D,IAAI,GAAG,KAAK,iCAAyB,CAAC,IAAI;YACtC,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,2HAA2H,CAAC,CAAC;KACrK;AACL,CAAC;AAlBD,sCAkBC"}
@@ -1,3 +0,0 @@
1
- export declare function getScryptedVolume(): string;
2
- export declare function getPluginVolume(pluginId: string): string;
3
- export declare function ensurePluginVolume(pluginId: string): string;
@@ -1,31 +0,0 @@
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.ensurePluginVolume = exports.getPluginVolume = exports.getScryptedVolume = void 0;
7
- const os_1 = __importDefault(require("os"));
8
- const path_1 = __importDefault(require("path"));
9
- const mkdirp_1 = __importDefault(require("mkdirp"));
10
- function getScryptedVolume() {
11
- const volumeDir = process.env.SCRYPTED_VOLUME || path_1.default.join(os_1.default.homedir(), '.scrypted', 'volume');
12
- return volumeDir;
13
- }
14
- exports.getScryptedVolume = getScryptedVolume;
15
- function getPluginVolume(pluginId) {
16
- const volume = getScryptedVolume();
17
- const pluginVolume = path_1.default.join(volume, 'plugins', pluginId);
18
- return pluginVolume;
19
- }
20
- exports.getPluginVolume = getPluginVolume;
21
- function ensurePluginVolume(pluginId) {
22
- const pluginVolume = getPluginVolume(pluginId);
23
- try {
24
- mkdirp_1.default.sync(pluginVolume);
25
- }
26
- catch (e) {
27
- }
28
- return pluginVolume;
29
- }
30
- exports.ensurePluginVolume = ensurePluginVolume;
31
- //# sourceMappingURL=plugin-volume.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-volume.js","sourceRoot":"","sources":["../../src/plugin/plugin-volume.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,oDAA4B;AAE5B,SAAgB,iBAAiB;IAC7B,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IAChG,OAAO,SAAS,CAAC;AACrB,CAAC;AAHD,8CAGC;AAED,SAAgB,eAAe,CAAC,QAAgB;IAC5C,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;IACnC,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC5D,OAAO,YAAY,CAAC;AACxB,CAAC;AAJD,0CAIC;AAED,SAAgB,kBAAkB,CAAC,QAAgB;IAC/C,MAAM,YAAY,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC/C,IAAI;QACA,gBAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;KAC7B;IACD,OAAO,CAAC,EAAE;KACT;IACD,OAAO,YAAY,CAAC;AACxB,CAAC;AARD,gDAQC"}
@@ -1,20 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { EventEmitter } from "ws";
5
- import { RuntimeWorker, RuntimeWorkerOptions } from "./runtime-worker";
6
- import child_process from 'child_process';
7
- import { RpcMessage, RpcPeer } from "../../rpc";
8
- export declare abstract class ChildProcessWorker extends EventEmitter implements RuntimeWorker {
9
- pluginId: string;
10
- worker: child_process.ChildProcess;
11
- constructor(pluginId: string, options: RuntimeWorkerOptions);
12
- setupWorker(): void;
13
- get pid(): number;
14
- get stdout(): import("stream").Readable;
15
- get stderr(): import("stream").Readable;
16
- get killed(): boolean;
17
- kill(): void;
18
- abstract send(message: RpcMessage, reject?: (e: Error) => void): void;
19
- abstract setupRpcPeer(peer: RpcPeer): void;
20
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChildProcessWorker = void 0;
4
- const ws_1 = require("ws");
5
- class ChildProcessWorker extends ws_1.EventEmitter {
6
- pluginId;
7
- worker;
8
- constructor(pluginId, options) {
9
- super();
10
- this.pluginId = pluginId;
11
- }
12
- setupWorker() {
13
- this.worker.on('close', () => this.emit('close'));
14
- this.worker.on('disconnect', () => this.emit('disconnect'));
15
- this.worker.on('exit', (code, signal) => this.emit('exit', code, signal));
16
- this.worker.on('close', () => this.emit('close'));
17
- this.worker.on('error', e => this.emit('error', e));
18
- }
19
- get pid() {
20
- return this.worker.pid;
21
- }
22
- get stdout() {
23
- return this.worker.stdout;
24
- }
25
- get stderr() {
26
- return this.worker.stderr;
27
- }
28
- get killed() {
29
- return this.worker.killed;
30
- }
31
- kill() {
32
- if (!this.worker)
33
- return;
34
- this.worker.kill('SIGKILL');
35
- this.worker.removeAllListeners();
36
- this.worker.stdout.removeAllListeners();
37
- this.worker.stderr.removeAllListeners();
38
- this.worker = undefined;
39
- }
40
- }
41
- exports.ChildProcessWorker = ChildProcessWorker;
42
- //# sourceMappingURL=child-process-worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"child-process-worker.js","sourceRoot":"","sources":["../../../src/plugin/runtime/child-process-worker.ts"],"names":[],"mappings":";;;AAAA,2BAAkC;AAKlC,MAAsB,kBAAmB,SAAQ,iBAAY;IAGtC;IAFnB,MAAM,CAA6B;IAEnC,YAAmB,QAAgB,EAAE,OAA6B;QAC9D,KAAK,EAAE,CAAC;QADO,aAAQ,GAAR,QAAQ,CAAQ;IAEnC,CAAC;IAED,WAAW;QACP,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QAC1E,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;IAC3B,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,IAAI;QACA,IAAI,CAAC,IAAI,CAAC,MAAM;YACZ,OAAO;QACX,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC5B,CAAC;CAIJ;AA3CD,gDA2CC"}
@@ -1,9 +0,0 @@
1
- import { RuntimeWorkerOptions as RuntimeWorkerOptions } from "./runtime-worker";
2
- import { RpcMessage, RpcPeer } from "../../rpc";
3
- import { ChildProcessWorker } from "./child-process-worker";
4
- export declare class NodeForkWorker extends ChildProcessWorker {
5
- constructor(mainFilename: string, pluginId: string, options: RuntimeWorkerOptions);
6
- setupRpcPeer(peer: RpcPeer): void;
7
- send(message: RpcMessage, reject?: (e: Error) => void, serializationContext?: any): void;
8
- get pid(): number;
9
- }
@@ -1,67 +0,0 @@
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.NodeForkWorker = void 0;
7
- const child_process_1 = __importDefault(require("child_process"));
8
- const path_1 = __importDefault(require("path"));
9
- const child_process_worker_1 = require("./child-process-worker");
10
- const plugin_npm_dependencies_1 = require("../plugin-npm-dependencies");
11
- const socket_serializer_1 = require("../socket-serializer");
12
- const net_1 = __importDefault(require("net"));
13
- class NodeForkWorker extends child_process_worker_1.ChildProcessWorker {
14
- constructor(mainFilename, pluginId, options) {
15
- super(pluginId, options);
16
- const { env, pluginDebug } = options;
17
- const execArgv = process.execArgv.slice();
18
- if (pluginDebug) {
19
- execArgv.push(`--inspect=0.0.0.0:${pluginDebug.inspectPort}`);
20
- }
21
- this.worker = child_process_1.default.fork(mainFilename, ['child', this.pluginId], {
22
- stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
23
- env: Object.assign({}, process.env, env, {
24
- NODE_PATH: path_1.default.join((0, plugin_npm_dependencies_1.getPluginNodePath)(this.pluginId), 'node_modules'),
25
- }),
26
- serialization: 'advanced',
27
- execArgv,
28
- });
29
- this.setupWorker();
30
- }
31
- setupRpcPeer(peer) {
32
- this.worker.on('message', (message, sendHandle) => {
33
- if (message.type && sendHandle) {
34
- peer.handleMessage(message, {
35
- sendHandle,
36
- });
37
- }
38
- else if (sendHandle) {
39
- this.emit('rpc', message, sendHandle);
40
- }
41
- else {
42
- peer.handleMessage(message);
43
- }
44
- });
45
- peer.transportSafeArgumentTypes.add(Buffer.name);
46
- peer.transportSafeArgumentTypes.add(Uint8Array.name);
47
- peer.addSerializer(net_1.default.Socket, net_1.default.Socket.name, new socket_serializer_1.SidebandSocketSerializer());
48
- }
49
- send(message, reject, serializationContext) {
50
- try {
51
- if (!this.worker)
52
- throw new Error('fork worker has been killed');
53
- this.worker.send(message, serializationContext?.sendHandle, e => {
54
- if (e && reject)
55
- reject(e);
56
- });
57
- }
58
- catch (e) {
59
- reject?.(e);
60
- }
61
- }
62
- get pid() {
63
- return this.worker?.pid;
64
- }
65
- }
66
- exports.NodeForkWorker = NodeForkWorker;
67
- //# sourceMappingURL=node-fork-worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-fork-worker.js","sourceRoot":"","sources":["../../../src/plugin/runtime/node-fork-worker.ts"],"names":[],"mappings":";;;;;;AACA,kEAA0C;AAC1C,gDAAwB;AAExB,iEAA4D;AAC5D,wEAA+D;AAC/D,4DAAgE;AAChE,8CAAsB;AAEtB,MAAa,cAAe,SAAQ,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CAAC;aACtC;QACL,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,aAAa,CAAC,aAAG,CAAC,MAAM,EAAE,aAAG,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,4CAAwB,EAAE,CAAC,CAAC;IACpF,CAAC;IAED,IAAI,CAAC,OAAmB,EAAE,MAA2B,EAAE,oBAA0B;QAC7E,IAAI;YACA,IAAI,CAAC,IAAI,CAAC,MAAM;gBACZ,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;YACnD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE;gBAC5D,IAAI,CAAC,IAAI,MAAM;oBACX,MAAM,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;SACN;QACD,OAAO,CAAC,EAAE;YACN,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;SACf;IACL,CAAC;IAED,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC;IAC5B,CAAC;CACJ;AA5DD,wCA4DC"}
@@ -1,20 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { EventEmitter } from "ws";
5
- import { RpcMessage, RpcPeer } from "../../rpc";
6
- import { RuntimeWorker, RuntimeWorkerOptions } from "./runtime-worker";
7
- import worker_threads from "worker_threads";
8
- export declare class NodeThreadWorker extends EventEmitter implements RuntimeWorker {
9
- pluginId: string;
10
- terminated: boolean;
11
- worker: worker_threads.Worker;
12
- constructor(mainFilename: string, pluginId: string, options: RuntimeWorkerOptions);
13
- get pid(): number;
14
- get stdout(): import("stream").Readable;
15
- get stderr(): import("stream").Readable;
16
- get killed(): boolean;
17
- kill(): void;
18
- send(message: RpcMessage, reject?: (e: Error) => void): void;
19
- setupRpcPeer(peer: RpcPeer): void;
20
- }
@@ -1,73 +0,0 @@
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.NodeThreadWorker = void 0;
7
- const ws_1 = require("ws");
8
- const worker_threads_1 = __importDefault(require("worker_threads"));
9
- const path_1 = __importDefault(require("path"));
10
- const plugin_npm_dependencies_1 = require("../plugin-npm-dependencies");
11
- const v8_1 = __importDefault(require("v8"));
12
- class NodeThreadWorker extends ws_1.EventEmitter {
13
- pluginId;
14
- terminated;
15
- worker;
16
- constructor(mainFilename, pluginId, options) {
17
- super();
18
- this.pluginId = pluginId;
19
- const { env } = options;
20
- this.worker = new worker_threads_1.default.Worker(mainFilename, {
21
- argv: ['child-thread', this.pluginId],
22
- env: Object.assign({}, process.env, env, {
23
- NODE_PATH: path_1.default.join((0, plugin_npm_dependencies_1.getPluginNodePath)(this.pluginId), 'node_modules'),
24
- }),
25
- });
26
- this.worker.on('exit', () => {
27
- this.terminated = true;
28
- this.emit('exit');
29
- });
30
- this.worker.on('error', e => {
31
- this.emit('error', e);
32
- });
33
- this.worker.on('messageerror', e => {
34
- this.emit('error', e);
35
- });
36
- }
37
- get pid() {
38
- return this.worker.threadId;
39
- }
40
- get stdout() {
41
- return this.worker.stdout;
42
- }
43
- get stderr() {
44
- return this.worker.stderr;
45
- }
46
- get killed() {
47
- return this.terminated;
48
- }
49
- kill() {
50
- if (!this.worker)
51
- return;
52
- this.worker.terminate();
53
- this.worker.removeAllListeners();
54
- this.worker.stdout.removeAllListeners();
55
- this.worker.stderr.removeAllListeners();
56
- this.worker = undefined;
57
- }
58
- send(message, reject) {
59
- try {
60
- if (!this.worker)
61
- throw new Error('thread worker has been killed');
62
- this.worker.postMessage(v8_1.default.serialize(message));
63
- }
64
- catch (e) {
65
- reject?.(e);
66
- }
67
- }
68
- setupRpcPeer(peer) {
69
- this.worker.on('message', message => peer.handleMessage(v8_1.default.deserialize(message)));
70
- }
71
- }
72
- exports.NodeThreadWorker = NodeThreadWorker;
73
- //# sourceMappingURL=node-thread-worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-thread-worker.js","sourceRoot":"","sources":["../../../src/plugin/runtime/node-thread-worker.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAkC;AAGlC,oEAA4C;AAC5C,gDAAwB;AACxB,wEAA+D;AAC/D,4CAAoB;AAEpB,MAAa,gBAAiB,SAAQ,iBAAY;IAIL;IAHzC,UAAU,CAAU;IACpB,MAAM,CAAwB;IAE9B,YAAY,YAAoB,EAAS,QAAgB,EAAE,OAA6B;QACpF,KAAK,EAAE,CAAC;QAD6B,aAAQ,GAAR,QAAQ,CAAQ;QAErD,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;QAExB,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAc,CAAC,MAAM,CAAC,YAAY,EAAE;YAClD,IAAI,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC;YACrC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE;gBACrC,SAAS,EAAE,cAAI,CAAC,IAAI,CAAC,IAAA,2CAAiB,EAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;aACzE,CAAC;SACL,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;YACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;YACxB,IAAI,CAA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C,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,YAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC;CACJ;AAnED,4CAmEC"}
@@ -1,10 +0,0 @@
1
- import { RpcMessage, RpcPeer } from "../../rpc";
2
- import { createRpcDuplexSerializer } from '../../rpc-serializer';
3
- import { ChildProcessWorker } from "./child-process-worker";
4
- import { RuntimeWorkerOptions } from "./runtime-worker";
5
- export declare class PythonRuntimeWorker extends ChildProcessWorker {
6
- serializer: ReturnType<typeof createRpcDuplexSerializer>;
7
- constructor(pluginId: string, options: RuntimeWorkerOptions);
8
- setupRpcPeer(peer: RpcPeer): void;
9
- send(message: RpcMessage, reject?: (e: Error) => void, serializationContext?: any): void;
10
- }
@@ -1,91 +0,0 @@
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.PythonRuntimeWorker = void 0;
7
- const child_process_1 = __importDefault(require("child_process"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const os_1 = __importDefault(require("os"));
10
- const path_1 = __importDefault(require("path"));
11
- const rpc_serializer_1 = require("../../rpc-serializer");
12
- const child_process_worker_1 = require("./child-process-worker");
13
- class PythonRuntimeWorker extends child_process_worker_1.ChildProcessWorker {
14
- serializer;
15
- constructor(pluginId, options) {
16
- super(pluginId, options);
17
- const { env, pluginDebug } = options;
18
- const args = [
19
- '-u',
20
- ];
21
- if (pluginDebug) {
22
- args.push('-m', 'debugpy', '--listen', `0.0.0.0:${pluginDebug.inspectPort}`, '--wait-for-client');
23
- }
24
- args.push(path_1.default.join(__dirname, '../../../python', 'plugin_remote.py'));
25
- const gstEnv = {};
26
- // hack to fix gst plugin search path on mac...
27
- if (os_1.default.platform() === 'darwin') {
28
- const gstPaths = [
29
- '/opt/homebrew/lib/gstreamer-1.0',
30
- '/usr/local/lib/gstreamer-1.0',
31
- ];
32
- for (const gstPath of gstPaths) {
33
- // search for common plugins.
34
- if (fs_1.default.existsSync(path_1.default.join(gstPath, 'libgstx264.dylib'))
35
- || fs_1.default.existsSync(path_1.default.join(gstPath, 'libgstlibav.dylib'))
36
- || fs_1.default.existsSync(path_1.default.join(gstPath, 'libgstvideotestsrc.dylib'))) {
37
- gstEnv['GST_PLUGIN_PATH'] = gstPath;
38
- break;
39
- }
40
- }
41
- }
42
- let pythonPath = process.env.SCRYPTED_PYTHON_PATH;
43
- if (os_1.default.platform() === 'win32') {
44
- pythonPath ||= 'py.exe';
45
- if (process.env.SCRYPTED_WINDOWS_PYTHON_VERSION)
46
- args.unshift(process.env.SCRYPTED_WINDOWS_PYTHON_VERSION);
47
- }
48
- else {
49
- pythonPath ||= 'python3';
50
- }
51
- args.push(this.pluginId);
52
- const types = require.resolve('@scrypted/types');
53
- const PYTHONPATH = types.substring(0, types.indexOf('types') + 'types'.length);
54
- this.worker = child_process_1.default.spawn(pythonPath, args, {
55
- // stdin, stdout, stderr, peer in, peer out
56
- stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe'],
57
- env: Object.assign({
58
- PYTHONUNBUFFERED: '1',
59
- PYTHONPATH,
60
- }, gstEnv, process.env, env),
61
- });
62
- this.setupWorker();
63
- }
64
- setupRpcPeer(peer) {
65
- const peerin = this.worker.stdio[3];
66
- const peerout = this.worker.stdio[4];
67
- const serializer = this.serializer = (0, rpc_serializer_1.createRpcDuplexSerializer)(peerin);
68
- serializer.setupRpcPeer(peer);
69
- peerout.on('data', data => serializer.onData(data));
70
- peerin.on('error', e => {
71
- this.emit('error', e);
72
- serializer.onDisconnected();
73
- });
74
- peerout.on('error', e => {
75
- this.emit('error', e);
76
- serializer.onDisconnected();
77
- });
78
- }
79
- send(message, reject, serializationContext) {
80
- try {
81
- if (!this.worker)
82
- throw new Error('python worker has been killed');
83
- this.serializer.sendMessage(message, reject, serializationContext);
84
- }
85
- catch (e) {
86
- reject?.(e);
87
- }
88
- }
89
- }
90
- exports.PythonRuntimeWorker = PythonRuntimeWorker;
91
- //# sourceMappingURL=python-worker.js.map
@@ -1 +0,0 @@
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;AAGxB,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,WAAW,EAAE,EACpC,mBAAmB,CACtB,CAAA;SACJ;QACD,IAAI,CAAC,IAAI,CACL,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,CAC9D,CAAA;QAED,MAAM,MAAM,GAAsB,EAAE,CAAC;QACrC,+CAA+C;QAC/C,IAAI,YAAE,CAAC,QAAQ,EAAE,KAAK,QAAQ,EAAE;YAC5B,MAAM,QAAQ,GAAG;gBACb,iCAAiC;gBACjC,8BAA8B;aACjC,CAAC;YACF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;gBAC5B,6BAA6B;gBAC7B,IAAI,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;uBAClD,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;uBACtD,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a,CAAC;QAChD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAa,CAAC;QAEjD,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,GAAG,IAAA,0CAAyB,EAAC,MAAM,CAAC,CAAC;QACvE,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACpD,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACtB,UAAU,CAAC,cAAc,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;YACpB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;YACrB,UAAU,CAAC,cAAc,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC;IACP,CAAC;IAED,IAAI,CAAC,OAAmB,EAAE,MAA2B,EAAE,oBAA0B;QAC7E,IAAI;YACA,IAAI,CAAC,IAAI,CAAC,MAAM;gBACZ,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;YACrD,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC,CAAC;SACtE;QACD,OAAO,CAAC,EAAE;YACN,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;SACf;IACL,CAAC;CACJ;AA9FD,kDA8FC"}
@@ -1,26 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { RpcMessage, RpcPeer } from "../../rpc";
5
- import { PluginDebug } from "../plugin-debug";
6
- import { Readable } from "stream";
7
- import net from "net";
8
- export interface RuntimeWorkerOptions {
9
- pluginDebug: PluginDebug;
10
- env: any;
11
- }
12
- export interface RuntimeWorker {
13
- pid: number;
14
- stdout: Readable;
15
- stderr: Readable;
16
- killed: boolean;
17
- kill(): void;
18
- on(event: 'rpc', listener: (message: any, sendHandle: net.Socket) => void): this;
19
- on(event: 'error', listener: (err: Error) => void): this;
20
- on(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
21
- on(event: 'disconnect', listener: () => void): this;
22
- on(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
23
- once(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
24
- send(message: RpcMessage, reject?: (e: Error) => void, serializationContext?: any): void;
25
- setupRpcPeer(peer: RpcPeer): void;
26
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=runtime-worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-worker.js","sourceRoot":"","sources":["../../../src/plugin/runtime/runtime-worker.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- import { RpcSerializer } from "../rpc";
2
- export declare class SidebandSocketSerializer implements RpcSerializer {
3
- serialize(value: any, serializationContext?: any): void;
4
- deserialize(serialized: any, serializationContext?: any): any;
5
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SidebandSocketSerializer = void 0;
4
- class SidebandSocketSerializer {
5
- serialize(value, serializationContext) {
6
- if (!serializationContext)
7
- throw new Error('socket serialization context unavailable');
8
- serializationContext.sendHandle = value;
9
- }
10
- deserialize(serialized, serializationContext) {
11
- if (!serializationContext)
12
- throw new Error('socket deserialization context unavailable');
13
- return serializationContext.sendHandle;
14
- }
15
- }
16
- exports.SidebandSocketSerializer = SidebandSocketSerializer;
17
- //# sourceMappingURL=socket-serializer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"socket-serializer.js","sourceRoot":"","sources":["../../src/plugin/socket-serializer.ts"],"names":[],"mappings":";;;AAEA,MAAa,wBAAwB;IACjC,SAAS,CAAC,KAAU,EAAE,oBAA0B;QAC5C,IAAI,CAAC,oBAAoB;YACrB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAChE,oBAAoB,CAAC,UAAU,GAAG,KAAK,CAAC;IAC5C,CAAC;IAED,WAAW,CAAC,UAAe,EAAE,oBAA0B;QACnD,IAAI,CAAC,oBAAoB;YACrB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAClE,OAAO,oBAAoB,CAAC,UAAU,CAAC;IAC3C,CAAC;CACJ;AAZD,4DAYC"}
@@ -1,39 +0,0 @@
1
- import { EventListener, EventListenerOptions, EventListenerRegister, Logger, ScryptedDevice, ScryptedInterfaceDescriptor, ScryptedNativeId, SystemDeviceState, SystemManager } from "@scrypted/types";
2
- import { EventRegistry } from "../event-registry";
3
- import { getPropertyInterfaces } from "./descriptor";
4
- import { PluginAPI } from "./plugin-api";
5
- export declare class SystemManagerImpl implements SystemManager {
6
- api: PluginAPI;
7
- state: {
8
- [id: string]: {
9
- [property: string]: SystemDeviceState;
10
- };
11
- };
12
- deviceProxies: {
13
- [id: string]: ScryptedDevice;
14
- };
15
- log: Logger;
16
- events: EventRegistry;
17
- typesVersion: string;
18
- descriptors: {
19
- [scryptedInterface: string]: ScryptedInterfaceDescriptor;
20
- };
21
- propertyInterfaces: ReturnType<typeof getPropertyInterfaces>;
22
- getDeviceState(id: string): {
23
- [property: string]: SystemDeviceState;
24
- };
25
- getSystemState(): {
26
- [id: string]: {
27
- [property: string]: SystemDeviceState;
28
- };
29
- };
30
- getDeviceById(idOrPluginId: string, nativeId?: ScryptedNativeId): any;
31
- getDeviceByName(name: string): any;
32
- listen(callback: EventListener): EventListenerRegister;
33
- listenDevice(id: string, options: string | EventListenerOptions, callback: EventListener): EventListenerRegister;
34
- removeDevice(id: string): Promise<void>;
35
- getComponent(id: string): Promise<any>;
36
- setScryptedInterfaceDescriptors(typesVersion: string, descriptors: {
37
- [scryptedInterface: string]: ScryptedInterfaceDescriptor;
38
- }): Promise<void>;
39
- }