@companion-module/base 1.13.2 → 1.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/package.json +58 -58
- package/dist/common/json-value.d.ts +0 -33
- package/dist/common/json-value.d.ts.map +0 -1
- package/dist/common/json-value.js +0 -5
- package/dist/common/json-value.js.map +0 -1
- package/dist/common/osc.d.ts +0 -17
- package/dist/common/osc.d.ts.map +0 -1
- package/dist/common/osc.js +0 -7
- package/dist/common/osc.js.map +0 -1
- package/dist/entrypoint.d.ts +0 -11
- package/dist/entrypoint.d.ts.map +0 -1
- package/dist/entrypoint.js +0 -134
- package/dist/entrypoint.js.map +0 -1
- package/dist/helpers/index.d.ts +0 -4
- package/dist/helpers/index.d.ts.map +0 -1
- package/dist/helpers/index.js +0 -10
- package/dist/helpers/index.js.map +0 -1
- package/dist/helpers/tcp.d.ts +0 -31
- package/dist/helpers/tcp.d.ts.map +0 -1
- package/dist/helpers/tcp.js +0 -164
- package/dist/helpers/tcp.js.map +0 -1
- package/dist/helpers/telnet.d.ts +0 -18
- package/dist/helpers/telnet.d.ts.map +0 -1
- package/dist/helpers/telnet.js +0 -169
- package/dist/helpers/telnet.js.map +0 -1
- package/dist/helpers/udp.d.ts +0 -33
- package/dist/helpers/udp.d.ts.map +0 -1
- package/dist/helpers/udp.js +0 -126
- package/dist/helpers/udp.js.map +0 -1
- package/dist/host-api/api.d.ts +0 -383
- package/dist/host-api/api.d.ts.map +0 -1
- package/dist/host-api/api.js +0 -9
- package/dist/host-api/api.js.map +0 -1
- package/dist/host-api/ipc-wrapper.d.ts +0 -37
- package/dist/host-api/ipc-wrapper.d.ts.map +0 -1
- package/dist/host-api/ipc-wrapper.js +0 -128
- package/dist/host-api/ipc-wrapper.js.map +0 -1
- package/dist/host-api/versions.d.ts +0 -12
- package/dist/host-api/versions.d.ts.map +0 -1
- package/dist/host-api/versions.js +0 -5
- package/dist/host-api/versions.js.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -22
- package/dist/index.js.map +0 -1
- package/dist/instance-base.d.ts +0 -12
- package/dist/instance-base.d.ts.map +0 -1
- package/dist/instance-base.js +0 -3
- package/dist/instance-base.js.map +0 -1
- package/dist/internal/actions.d.ts +0 -16
- package/dist/internal/actions.d.ts.map +0 -1
- package/dist/internal/actions.js +0 -207
- package/dist/internal/actions.js.map +0 -1
- package/dist/internal/base.d.ts +0 -11
- package/dist/internal/base.d.ts.map +0 -1
- package/dist/internal/base.js +0 -39
- package/dist/internal/base.js.map +0 -1
- package/dist/internal/feedback.d.ts +0 -20
- package/dist/internal/feedback.d.ts.map +0 -1
- package/dist/internal/feedback.js +0 -307
- package/dist/internal/feedback.js.map +0 -1
- package/dist/internal/upgrade.d.ts +0 -15
- package/dist/internal/upgrade.d.ts.map +0 -1
- package/dist/internal/upgrade.js +0 -174
- package/dist/internal/upgrade.js.map +0 -1
- package/dist/manifest.d.ts +0 -5
- package/dist/manifest.d.ts.map +0 -1
- package/dist/manifest.js +0 -37
- package/dist/manifest.js.map +0 -1
- package/dist/module-api/action.d.ts +0 -100
- package/dist/module-api/action.d.ts.map +0 -1
- package/dist/module-api/action.js +0 -3
- package/dist/module-api/action.js.map +0 -1
- package/dist/module-api/base.d.ts +0 -198
- package/dist/module-api/base.d.ts.map +0 -1
- package/dist/module-api/base.js +0 -486
- package/dist/module-api/base.js.map +0 -1
- package/dist/module-api/common.d.ts +0 -14
- package/dist/module-api/common.d.ts.map +0 -1
- package/dist/module-api/common.js +0 -3
- package/dist/module-api/common.js.map +0 -1
- package/dist/module-api/config.d.ts +0 -12
- package/dist/module-api/config.d.ts.map +0 -1
- package/dist/module-api/config.js +0 -3
- package/dist/module-api/config.js.map +0 -1
- package/dist/module-api/enums.d.ts +0 -31
- package/dist/module-api/enums.d.ts.map +0 -1
- package/dist/module-api/enums.js +0 -37
- package/dist/module-api/enums.js.map +0 -1
- package/dist/module-api/feedback.d.ts +0 -147
- package/dist/module-api/feedback.d.ts.map +0 -1
- package/dist/module-api/feedback.js +0 -3
- package/dist/module-api/feedback.js.map +0 -1
- package/dist/module-api/http.d.ts +0 -17
- package/dist/module-api/http.d.ts.map +0 -1
- package/dist/module-api/http.js +0 -3
- package/dist/module-api/http.js.map +0 -1
- package/dist/module-api/index.d.ts +0 -13
- package/dist/module-api/index.d.ts.map +0 -1
- package/dist/module-api/index.js +0 -15
- package/dist/module-api/index.js.map +0 -1
- package/dist/module-api/input.d.ts +0 -392
- package/dist/module-api/input.d.ts.map +0 -1
- package/dist/module-api/input.js +0 -3
- package/dist/module-api/input.js.map +0 -1
- package/dist/module-api/preset.d.ts +0 -111
- package/dist/module-api/preset.d.ts.map +0 -1
- package/dist/module-api/preset.js +0 -3
- package/dist/module-api/preset.js.map +0 -1
- package/dist/module-api/shared-udp-socket.d.ts +0 -60
- package/dist/module-api/shared-udp-socket.d.ts.map +0 -1
- package/dist/module-api/shared-udp-socket.js +0 -178
- package/dist/module-api/shared-udp-socket.js.map +0 -1
- package/dist/module-api/style.d.ts +0 -20
- package/dist/module-api/style.d.ts.map +0 -1
- package/dist/module-api/style.js +0 -3
- package/dist/module-api/style.js.map +0 -1
- package/dist/module-api/upgrade.d.ts +0 -118
- package/dist/module-api/upgrade.d.ts.map +0 -1
- package/dist/module-api/upgrade.js +0 -95
- package/dist/module-api/upgrade.js.map +0 -1
- package/dist/module-api/variable.d.ts +0 -18
- package/dist/module-api/variable.d.ts.map +0 -1
- package/dist/module-api/variable.js +0 -3
- package/dist/module-api/variable.js.map +0 -1
- package/dist/util.d.ts +0 -97
- package/dist/util.d.ts.map +0 -1
- package/dist/util.js +0 -177
- package/dist/util.js.map +0 -1
- package/generated/manifest.d.ts +0 -133
- package/generated/validate_manifest.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.13.3](https://github.com/bitfocus/companion-module-base/compare/v1.13.2...v1.13.3) (2025-10-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* make `newSecrets` parameter to `saveConfig` optional, if secrets config is not being used [#152](https://github.com/bitfocus/companion-module-base/issues/152) ([ce8397b](https://github.com/bitfocus/companion-module-base/commit/ce8397b6cce4f3e43dc23070e03d27d87d936d93))
|
|
9
|
+
* make CompanionButtonPresetDefinition presetStyle a partial ([#156](https://github.com/bitfocus/companion-module-base/issues/156)) ([c4c8b49](https://github.com/bitfocus/companion-module-base/commit/c4c8b49a3cc6e18ec110661fdf880a8ab2d38063))
|
|
10
|
+
|
|
3
11
|
## [1.13.2](https://github.com/bitfocus/companion-module-base/compare/v1.13.1...v1.13.2) (2025-09-07)
|
|
4
12
|
|
|
5
13
|
|
package/package.json
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
2
|
+
"name": "@companion-module/base",
|
|
3
|
+
"version": "1.13.3",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"typings": "dist/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": "https://github.com/bitfocus/companion-module-base",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "yarn build:ts --watch",
|
|
11
|
+
"build": "yarn build:json-schema && yarn build:ajv-validator && yarn build:ts",
|
|
12
|
+
"build:ts": "tsc -p tsconfig.build.json",
|
|
13
|
+
"build:json-schema": "json2ts --input assets/manifest.schema.json --output generated/manifest.d.ts --additionalProperties=false",
|
|
14
|
+
"build:ajv-validator": "node tools/schema-compile.mjs",
|
|
15
|
+
"docs:html": "typedoc --tsconfig tsconfig.build.json --entryPoints src/index.ts --excludePrivate --theme default --out docs",
|
|
16
|
+
"lint:raw": "eslint",
|
|
17
|
+
"lint": "yarn lint:raw .",
|
|
18
|
+
"unit": "vitest"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": "^18.12 || ^22.8"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"README.md",
|
|
25
|
+
"CHANGELOG.md",
|
|
26
|
+
"dist",
|
|
27
|
+
"generated",
|
|
28
|
+
"assets",
|
|
29
|
+
"lib"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"ajv": "^8.17.1",
|
|
33
|
+
"colord": "^2.9.3",
|
|
34
|
+
"ejson": "^2.2.3",
|
|
35
|
+
"eventemitter3": "^5.0.1",
|
|
36
|
+
"mimic-fn": "^3.1.0",
|
|
37
|
+
"nanoid": "^3.3.11",
|
|
38
|
+
"p-queue": "^6.6.2",
|
|
39
|
+
"p-timeout": "^4.1.0",
|
|
40
|
+
"tslib": "^2.8.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@companion-module/tools": "^2.3.0",
|
|
44
|
+
"@tsconfig/node18": "^18.2.4",
|
|
45
|
+
"@types/ejson": "^2.2.2",
|
|
46
|
+
"@types/lodash-es": "^4.17.12",
|
|
47
|
+
"@types/node": "^18.19.123",
|
|
48
|
+
"eslint": "^9.34.0",
|
|
49
|
+
"json-schema-to-typescript": "^15.0.4",
|
|
50
|
+
"lodash-es": "^4.17.21",
|
|
51
|
+
"prettier": "^3.6.2",
|
|
52
|
+
"typedoc": "^0.27.9",
|
|
53
|
+
"typescript": "~5.7.3",
|
|
54
|
+
"typescript-eslint": "^8.42.0",
|
|
55
|
+
"vitest": "^3.2.4",
|
|
56
|
+
"vitest-mock-extended": "^3.1.0"
|
|
57
|
+
},
|
|
58
|
+
"packageManager": "yarn@4.10.3"
|
|
59
|
+
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
Matches a JSON object.
|
|
3
|
-
|
|
4
|
-
This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
|
|
5
|
-
|
|
6
|
-
@category JSON
|
|
7
|
-
*/
|
|
8
|
-
export type JsonObject = {
|
|
9
|
-
[Key in string]: JsonValue;
|
|
10
|
-
} & {
|
|
11
|
-
[Key in string]?: JsonValue | undefined;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
Matches a JSON array.
|
|
15
|
-
|
|
16
|
-
@category JSON
|
|
17
|
-
*/
|
|
18
|
-
export type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
19
|
-
/**
|
|
20
|
-
Matches any valid JSON primitive value.
|
|
21
|
-
|
|
22
|
-
@category JSON
|
|
23
|
-
*/
|
|
24
|
-
export type JsonPrimitive = string | number | boolean | null;
|
|
25
|
-
/**
|
|
26
|
-
Matches any valid JSON value.
|
|
27
|
-
|
|
28
|
-
@see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
|
|
29
|
-
|
|
30
|
-
@category JSON
|
|
31
|
-
*/
|
|
32
|
-
export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
33
|
-
//# sourceMappingURL=json-value.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json-value.d.ts","sourceRoot":"","sources":["../../src/common/json-value.ts"],"names":[],"mappings":"AAGA;;;;;;EAME;AACF,MAAM,MAAM,UAAU,GAAG;KAAG,GAAG,IAAI,MAAM,GAAG,SAAS;CAAE,GAAG;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS;CAAE,CAAA;AAErG;;;;EAIE;AACF,MAAM,MAAM,SAAS,GAAG,SAAS,EAAE,GAAG,SAAS,SAAS,EAAE,CAAA;AAE1D;;;;EAIE;AACF,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAE5D;;;;;;EAME;AACF,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,CAAA"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copied from https://github.com/sindresorhus/type-fest/blob/main/source/json-value.d.ts
|
|
3
|
-
// Under MIT License - Sindre Sorhus <sindresorhus@gmail.com>
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
//# sourceMappingURL=json-value.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json-value.js","sourceRoot":"","sources":["../../src/common/json-value.ts"],"names":[],"mappings":";AAAA,yFAAyF;AACzF,6DAA6D"}
|
package/dist/common/osc.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Warning: these types are used in various stable apis.
|
|
3
|
-
* BE VERY CAREFUL WHEN MAKING CHANGES
|
|
4
|
-
*/
|
|
5
|
-
export type OSCArgument = number | string | Uint8Array;
|
|
6
|
-
export type OSCMetaArgument = {
|
|
7
|
-
type: 'i' | 'f';
|
|
8
|
-
value: number;
|
|
9
|
-
} | {
|
|
10
|
-
type: 's';
|
|
11
|
-
value: string;
|
|
12
|
-
} | {
|
|
13
|
-
type: 'b';
|
|
14
|
-
value: Uint8Array;
|
|
15
|
-
};
|
|
16
|
-
export type OSCSomeArguments = OSCArgument | Array<OSCArgument> | OSCMetaArgument | Array<OSCMetaArgument>;
|
|
17
|
-
//# sourceMappingURL=osc.d.ts.map
|
package/dist/common/osc.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"osc.d.ts","sourceRoot":"","sources":["../../src/common/osc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAA;AACtD,MAAM,MAAM,eAAe,GACxB;IAAE,IAAI,EAAE,GAAG,GAAG,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAAA;AACnC,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC,CAAA"}
|
package/dist/common/osc.js
DELETED
package/dist/common/osc.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"osc.js","sourceRoot":"","sources":["../../src/common/osc.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
package/dist/entrypoint.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { CompanionStaticUpgradeScript } from './module-api/upgrade.js';
|
|
2
|
-
import type { InstanceBase } from './module-api/base.js';
|
|
3
|
-
export type InstanceConstructor<TConfig, TSecrets> = new (internal: unknown) => InstanceBase<TConfig, TSecrets>;
|
|
4
|
-
/**
|
|
5
|
-
* Setup the module for execution
|
|
6
|
-
* This should be called once per-module, to register the class that should be executed
|
|
7
|
-
* @param factory The class for the module
|
|
8
|
-
* @param upgradeScripts Upgrade scripts
|
|
9
|
-
*/
|
|
10
|
-
export declare function runEntrypoint<TConfig, TSecrets>(factory: InstanceConstructor<TConfig, TSecrets>, upgradeScripts: CompanionStaticUpgradeScript<TConfig, TSecrets>[]): void;
|
|
11
|
-
//# sourceMappingURL=entrypoint.d.ts.map
|
package/dist/entrypoint.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoint.d.ts","sourceRoot":"","sources":["../src/entrypoint.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAA;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAUxD,MAAM,MAAM,mBAAmB,CAAC,OAAO,EAAE,QAAQ,IAAI,KAAK,QAAQ,EAAE,OAAO,KAAK,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AAe/G;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,QAAQ,EAC9C,OAAO,EAAE,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC/C,cAAc,EAAE,4BAA4B,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,GAC/D,IAAI,CAuHN"}
|
package/dist/entrypoint.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runEntrypoint = runEntrypoint;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
/* eslint-disable n/no-process-exit */
|
|
6
|
-
const versions_js_1 = require("./host-api/versions.js");
|
|
7
|
-
const promises_1 = tslib_1.__importDefault(require("fs/promises"));
|
|
8
|
-
const util_js_1 = require("./util.js");
|
|
9
|
-
const ipc_wrapper_js_1 = require("./host-api/ipc-wrapper.js");
|
|
10
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
-
let hasEntrypoint = false;
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
-
let moduleInstance;
|
|
14
|
-
// async function readFileUrl(url: URL): Promise<string> {
|
|
15
|
-
// // Hack to make json files be loadable after being inlined by webpack
|
|
16
|
-
// const prefix = 'application/json;base64,'
|
|
17
|
-
// if (url.pathname.startsWith(prefix)) {
|
|
18
|
-
// const base64 = url.pathname.substring(prefix.length)
|
|
19
|
-
// return Buffer.from(base64, 'base64').toString()
|
|
20
|
-
// }
|
|
21
|
-
// // Fallback to reading from disk
|
|
22
|
-
// const buf = await fs.readFile(url)
|
|
23
|
-
// return buf.toString()
|
|
24
|
-
// }
|
|
25
|
-
/**
|
|
26
|
-
* Setup the module for execution
|
|
27
|
-
* This should be called once per-module, to register the class that should be executed
|
|
28
|
-
* @param factory The class for the module
|
|
29
|
-
* @param upgradeScripts Upgrade scripts
|
|
30
|
-
*/
|
|
31
|
-
function runEntrypoint(factory, upgradeScripts) {
|
|
32
|
-
Promise.resolve()
|
|
33
|
-
.then(async () => {
|
|
34
|
-
// const pkgJsonStr = (await fs.readFile(path.join(__dirname, '../package.json'))).toString()
|
|
35
|
-
// const pkgJson = JSON.parse(pkgJsonStr)
|
|
36
|
-
// if (!pkgJson || pkgJson.name !== '@companion-module/base')
|
|
37
|
-
// throw new Error('Failed to find the package.json for @companion-module/base')
|
|
38
|
-
// if (!pkgJson.version) throw new Error('Missing version field in the package.json for @companion-module/base')
|
|
39
|
-
// Ensure only called once per module
|
|
40
|
-
if (hasEntrypoint)
|
|
41
|
-
throw new Error(`runEntrypoint can only be called once`);
|
|
42
|
-
hasEntrypoint = true;
|
|
43
|
-
// Validate that the upgrade scripts look sane
|
|
44
|
-
if (!upgradeScripts)
|
|
45
|
-
upgradeScripts = [];
|
|
46
|
-
if (!Array.isArray(upgradeScripts))
|
|
47
|
-
throw new Error('upgradeScripts must be an array');
|
|
48
|
-
for (const upgradeScript of upgradeScripts) {
|
|
49
|
-
if (typeof upgradeScript !== 'function')
|
|
50
|
-
throw new Error('upgradeScripts must be an array of functions');
|
|
51
|
-
}
|
|
52
|
-
const manifestPath = process.env.MODULE_MANIFEST;
|
|
53
|
-
if (!manifestPath)
|
|
54
|
-
throw new Error('Module initialise is missing MODULE_MANIFEST');
|
|
55
|
-
// check manifest api field against apiVersion
|
|
56
|
-
const manifestBlob = await promises_1.default.readFile(manifestPath);
|
|
57
|
-
const manifestJson = JSON.parse(manifestBlob.toString());
|
|
58
|
-
if (manifestJson.runtime?.api !== versions_js_1.HostApiNodeJsIpc)
|
|
59
|
-
throw new Error(`Module manifest 'api' mismatch`);
|
|
60
|
-
if (!manifestJson.runtime.apiVersion)
|
|
61
|
-
throw new Error(`Module manifest 'apiVersion' missing`);
|
|
62
|
-
let apiVersion = manifestJson.runtime.apiVersion;
|
|
63
|
-
if (apiVersion === '0.0.0') {
|
|
64
|
-
// It looks like the module is in dev mode. lets attempt to load the package.json from this module instead
|
|
65
|
-
try {
|
|
66
|
-
const baseJsonStr = await promises_1.default.readFile(path_1.default.join(__dirname, '../package.json'));
|
|
67
|
-
const baseJson = JSON.parse(baseJsonStr.toString());
|
|
68
|
-
if (baseJson.name === '@companion-module/base') {
|
|
69
|
-
apiVersion = baseJson.version;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (_e) {
|
|
73
|
-
throw new Error('Failed to determine module api version');
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (!process.send)
|
|
77
|
-
throw new Error('Module is not being run with ipc');
|
|
78
|
-
console.log(`Starting up module class: ${factory.name}`);
|
|
79
|
-
const connectionId = process.env.CONNECTION_ID;
|
|
80
|
-
if (typeof connectionId !== 'string' || !connectionId)
|
|
81
|
-
throw new Error('Module initialise is missing CONNECTION_ID');
|
|
82
|
-
const verificationToken = process.env.VERIFICATION_TOKEN;
|
|
83
|
-
if (typeof verificationToken !== 'string' || !verificationToken)
|
|
84
|
-
throw new Error('Module initialise is missing VERIFICATION_TOKEN');
|
|
85
|
-
// Allow the DSN to be provided as an env variable
|
|
86
|
-
// const sentryDsn = process.env.SENTRY_DSN
|
|
87
|
-
// const sentryUserId = process.env.SENTRY_USERID
|
|
88
|
-
// const sentryCompanionVersion = process.env.SENTRY_COMPANION_VERSION
|
|
89
|
-
// if (sentryDsn && sentryUserId && sentryDsn.substring(0, 8) == 'https://') {
|
|
90
|
-
// console.log('Sentry enabled')
|
|
91
|
-
// init({
|
|
92
|
-
// dsn: sentryDsn,
|
|
93
|
-
// release: `${manifestJson.name}@${manifestJson.version}`,
|
|
94
|
-
// beforeSend(event) {
|
|
95
|
-
// if (event.exception) {
|
|
96
|
-
// console.log('sentry', 'error', event.exception)
|
|
97
|
-
// }
|
|
98
|
-
// return event
|
|
99
|
-
// },
|
|
100
|
-
// })
|
|
101
|
-
// {
|
|
102
|
-
// const scope = getCurrentScope()
|
|
103
|
-
// scope.setUser({ id: sentryUserId })
|
|
104
|
-
// scope.setTag('companion', sentryCompanionVersion)
|
|
105
|
-
// }
|
|
106
|
-
// } else {
|
|
107
|
-
// console.log('Sentry disabled')
|
|
108
|
-
// }
|
|
109
|
-
const ipcWrapper = new ipc_wrapper_js_1.IpcWrapper({}, (msg) => {
|
|
110
|
-
process.send(msg);
|
|
111
|
-
}, 5000);
|
|
112
|
-
process.once('message', (msg) => {
|
|
113
|
-
ipcWrapper.receivedMessage(msg);
|
|
114
|
-
});
|
|
115
|
-
moduleInstance = new factory((0, util_js_1.literal)({
|
|
116
|
-
id: connectionId,
|
|
117
|
-
upgradeScripts,
|
|
118
|
-
_isInstanceBaseProps: true,
|
|
119
|
-
}));
|
|
120
|
-
ipcWrapper.sendWithCb('register', { apiVersion, connectionId, verificationToken }).then(() => {
|
|
121
|
-
console.log(`Module-host accepted registration`);
|
|
122
|
-
}, (err) => {
|
|
123
|
-
console.error('Module registration failed', err);
|
|
124
|
-
// Kill the process
|
|
125
|
-
process.exit(11);
|
|
126
|
-
});
|
|
127
|
-
})
|
|
128
|
-
.catch((e) => {
|
|
129
|
-
console.error(`Failed to startup module:`);
|
|
130
|
-
console.error(e.stack || e.message);
|
|
131
|
-
process.exit(1);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
//# sourceMappingURL=entrypoint.js.map
|
package/dist/entrypoint.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoint.js","sourceRoot":"","sources":["../src/entrypoint.ts"],"names":[],"mappings":";;AAoCA,sCA0HC;;AA9JD,sCAAsC;AACtC,wDAAyG;AACzG,mEAA4B;AAI5B,uCAAmC;AAEnC,8DAAsD;AACtD,wDAAuB;AAEvB,IAAI,aAAa,GAAG,KAAK,CAAA;AACzB,6DAA6D;AAC7D,IAAI,cAAkD,CAAA;AAItD,0DAA0D;AAC1D,yEAAyE;AACzE,6CAA6C;AAC7C,0CAA0C;AAC1C,yDAAyD;AACzD,oDAAoD;AACpD,KAAK;AAEL,oCAAoC;AACpC,sCAAsC;AACtC,yBAAyB;AACzB,IAAI;AAEJ;;;;;GAKG;AACH,SAAgB,aAAa,CAC5B,OAA+C,EAC/C,cAAiE;IAEjE,OAAO,CAAC,OAAO,EAAE;SACf,IAAI,CAAC,KAAK,IAAI,EAAE;QAChB,6FAA6F;QAC7F,yCAAyC;QACzC,6DAA6D;QAC7D,iFAAiF;QACjF,gHAAgH;QAEhH,qCAAqC;QACrC,IAAI,aAAa;YAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;QAC3E,aAAa,GAAG,IAAI,CAAA;QAEpB,8CAA8C;QAC9C,IAAI,CAAC,cAAc;YAAE,cAAc,GAAG,EAAE,C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AA;QAChC,CAAC,CAAC,CAAA;QAEF,cAAc,GAAG,IAAI,OAAO,CAC3B,IAAA,iBAAO,EAAuC;YAC7C,EAAE,EAAE,YAAY;YAChB,cAAc;YACd,oBAAoB,EAAE,IAAI;SAC1B,CAAC,CACF,CAAA;QAED,UAAU,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC,CAAC,IAAI,CACtF,GAAG,EAAE;YACJ,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAA;QACjD,CAAC,EACD,CAAC,GAAG,EAAE,EAAE;YACP,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAA;YAEhD,mBAAmB;YACnB,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACjB,CAAC,CACD,CAAA;IACF,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC1C,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,CAAC,CAAA;QACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/helpers/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACnF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/helpers/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UDPHelper = exports.TelnetHelper = exports.TCPHelper = void 0;
|
|
4
|
-
var tcp_js_1 = require("./tcp.js");
|
|
5
|
-
Object.defineProperty(exports, "TCPHelper", { enumerable: true, get: function () { return tcp_js_1.TCPHelper; } });
|
|
6
|
-
var telnet_js_1 = require("./telnet.js");
|
|
7
|
-
Object.defineProperty(exports, "TelnetHelper", { enumerable: true, get: function () { return telnet_js_1.TelnetHelper; } });
|
|
8
|
-
var udp_js_1 = require("./udp.js");
|
|
9
|
-
Object.defineProperty(exports, "UDPHelper", { enumerable: true, get: function () { return udp_js_1.UDPHelper; } });
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;AAAA,mCAAuE;AAA9D,mGAAA,SAAS,OAAA;AAClB,yCAAmF;AAA1E,yGAAA,YAAY,OAAA;AACrB,mCAAuE;AAA9D,mGAAA,SAAS,OAAA"}
|
package/dist/helpers/tcp.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import net from 'net';
|
|
2
|
-
import { EventEmitter } from 'eventemitter3';
|
|
3
|
-
import { InstanceStatus } from '../module-api/enums.js';
|
|
4
|
-
type TCPStatuses = InstanceStatus.Ok | InstanceStatus.Connecting | InstanceStatus.Disconnected | InstanceStatus.UnknownError;
|
|
5
|
-
export interface TCPHelperEvents {
|
|
6
|
-
error: [err: Error];
|
|
7
|
-
data: [msg: Buffer];
|
|
8
|
-
connect: [];
|
|
9
|
-
end: [];
|
|
10
|
-
drain: [];
|
|
11
|
-
status_change: [status: TCPStatuses, message: string | undefined];
|
|
12
|
-
}
|
|
13
|
-
export interface TCPHelperOptions {
|
|
14
|
-
/** default 2000 */
|
|
15
|
-
reconnect_interval?: number;
|
|
16
|
-
/** default true */
|
|
17
|
-
reconnect?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export declare class TCPHelper extends EventEmitter<TCPHelperEvents> {
|
|
20
|
-
#private;
|
|
21
|
-
readonly _socket: net.Socket;
|
|
22
|
-
get isConnected(): boolean;
|
|
23
|
-
get isConnecting(): boolean;
|
|
24
|
-
get isDestroyed(): boolean;
|
|
25
|
-
constructor(host: string, port: number, options?: TCPHelperOptions);
|
|
26
|
-
connect(): boolean;
|
|
27
|
-
send(message: string | Buffer): Promise<boolean>;
|
|
28
|
-
destroy(): void;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=tcp.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tcp.d.ts","sourceRoot":"","sources":["../../src/helpers/tcp.ts"],"names":[],"mappings":"AAiBA,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEvD,KAAK,WAAW,GACb,cAAc,CAAC,EAAE,GACjB,cAAc,CAAC,UAAU,GACzB,cAAc,CAAC,YAAY,GAC3B,cAAc,CAAC,YAAY,CAAA;AAE9B,MAAM,WAAW,eAAe;IAE/B,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAEnB,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAGnB,OAAO,EAAE,EAAE,CAAA;IAEX,GAAG,EAAE,EAAE,CAAA;IAEP,KAAK,EAAE,EAAE,CAAA;IAGT,aAAa,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CACjE;AAED,MAAM,WAAW,gBAAgB;IAChC,mBAAmB;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,mBAAmB;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,qBAAa,SAAU,SAAQ,YAAY,CAAC,eAAe,CAAC;;IAG3D,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAA;IAU5B,IAAI,WAAW,IAAI,OAAO,CAEzB;IACD,IAAI,YAAY,IAAI,OAAO,CAE1B;IACD,IAAI,WAAW,IAAI,OAAO,CAEzB;gBAEW,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB;IA+DlE,OAAO,IAAI,OAAO;IAQZ,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA+BtD,OAAO,IAAI,IAAI;CAsCf"}
|
package/dist/helpers/tcp.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* This file is part of the Companion project
|
|
4
|
-
* Copyright (c) 2018 Bitfocus AS
|
|
5
|
-
* Authors: William Viker <william@bitfocus.io>, Håkon Nessjøen <haakon@bitfocus.io>
|
|
6
|
-
*
|
|
7
|
-
* This program is free software.
|
|
8
|
-
* You should have received a copy of the MIT licence as well as the Bitfocus
|
|
9
|
-
* Individual Contributor License Agreement for companion along with
|
|
10
|
-
* this program.
|
|
11
|
-
*
|
|
12
|
-
* You can be released from the requirements of the license by purchasing
|
|
13
|
-
* a commercial license. Buying such a license is mandatory as soon as you
|
|
14
|
-
* develop commercial activities involving the Companion software without
|
|
15
|
-
* disclosing the source code of your own applications.
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.TCPHelper = void 0;
|
|
20
|
-
const tslib_1 = require("tslib");
|
|
21
|
-
const net_1 = tslib_1.__importDefault(require("net"));
|
|
22
|
-
const eventemitter3_1 = require("eventemitter3");
|
|
23
|
-
const enums_js_1 = require("../module-api/enums.js");
|
|
24
|
-
class TCPHelper extends eventemitter3_1.EventEmitter {
|
|
25
|
-
#host;
|
|
26
|
-
#port;
|
|
27
|
-
_socket;
|
|
28
|
-
#options;
|
|
29
|
-
#connected = false;
|
|
30
|
-
#connecting = false;
|
|
31
|
-
#destroyed = false;
|
|
32
|
-
#lastStatus;
|
|
33
|
-
#reconnectTimer;
|
|
34
|
-
#missingErrorHandlerTimer;
|
|
35
|
-
get isConnected() {
|
|
36
|
-
return this.#connected;
|
|
37
|
-
}
|
|
38
|
-
get isConnecting() {
|
|
39
|
-
return this.#connecting;
|
|
40
|
-
}
|
|
41
|
-
get isDestroyed() {
|
|
42
|
-
return this.#destroyed;
|
|
43
|
-
}
|
|
44
|
-
constructor(host, port, options) {
|
|
45
|
-
super();
|
|
46
|
-
this.#host = host;
|
|
47
|
-
this.#port = port;
|
|
48
|
-
this.#options = {
|
|
49
|
-
reconnect_interval: 2000,
|
|
50
|
-
reconnect: true,
|
|
51
|
-
...options,
|
|
52
|
-
};
|
|
53
|
-
this._socket = new net_1.default.Socket();
|
|
54
|
-
this._socket.setKeepAlive(true);
|
|
55
|
-
this._socket.setNoDelay(true);
|
|
56
|
-
this._socket.on('error', (err) => {
|
|
57
|
-
this.#connecting = false;
|
|
58
|
-
this.#connected = false;
|
|
59
|
-
if (this.#options.reconnect) {
|
|
60
|
-
this.#queueReconnect();
|
|
61
|
-
}
|
|
62
|
-
this.#new_status(enums_js_1.InstanceStatus.UnknownError, err.message);
|
|
63
|
-
this.emit('error', err);
|
|
64
|
-
});
|
|
65
|
-
this._socket.on('ready', () => {
|
|
66
|
-
this.#connected = true;
|
|
67
|
-
this.#connecting = false;
|
|
68
|
-
this.#new_status(enums_js_1.InstanceStatus.Ok);
|
|
69
|
-
this.emit('connect');
|
|
70
|
-
});
|
|
71
|
-
this._socket.on('end', () => {
|
|
72
|
-
this.#connected = false;
|
|
73
|
-
this.#new_status(enums_js_1.InstanceStatus.Disconnected);
|
|
74
|
-
if (!this.#connecting && this.#options.reconnect) {
|
|
75
|
-
this.#queueReconnect();
|
|
76
|
-
}
|
|
77
|
-
this.emit('end');
|
|
78
|
-
});
|
|
79
|
-
this._socket.on('data', (data) => this.emit('data', data));
|
|
80
|
-
this._socket.on('drain', () => this.emit('drain'));
|
|
81
|
-
// Let caller install event handlers first
|
|
82
|
-
setImmediate(() => {
|
|
83
|
-
if (!this.#destroyed)
|
|
84
|
-
this.connect();
|
|
85
|
-
});
|
|
86
|
-
this.#missingErrorHandlerTimer = setTimeout(() => {
|
|
87
|
-
this.#missingErrorHandlerTimer = undefined;
|
|
88
|
-
if (!this.#destroyed && !this.listenerCount('error')) {
|
|
89
|
-
// The socket is active and has no listeners. Log an error for the module devs!
|
|
90
|
-
console.error(`Danger: TCP client for ${this.#host}:${this.#port} is missing an error handler!`);
|
|
91
|
-
}
|
|
92
|
-
}, 5000);
|
|
93
|
-
}
|
|
94
|
-
connect() {
|
|
95
|
-
if (this.#destroyed)
|
|
96
|
-
throw new Error('Cannot connect destroyed socket');
|
|
97
|
-
if (this.#connecting)
|
|
98
|
-
return false;
|
|
99
|
-
this.#connecting = true;
|
|
100
|
-
this._socket.connect(this.#port, this.#host);
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
async send(message) {
|
|
104
|
-
if (this.#destroyed || this._socket.destroyed)
|
|
105
|
-
throw new Error('Cannot write to destroyed socket');
|
|
106
|
-
if (!message || !message.length)
|
|
107
|
-
throw new Error('No message to send');
|
|
108
|
-
if (!this.#connected) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
return new Promise((resolve, reject) => {
|
|
113
|
-
this._socket.write(message, (error) => {
|
|
114
|
-
if (error) {
|
|
115
|
-
reject(error);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
resolve(true);
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
this.#connected = false;
|
|
124
|
-
const error2 = error instanceof Error ? error : new Error(`${error}`);
|
|
125
|
-
// Unhandeled socket error
|
|
126
|
-
this.#new_status(enums_js_1.InstanceStatus.UnknownError, error2.message);
|
|
127
|
-
this.emit('error', error2);
|
|
128
|
-
throw error2;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
destroy() {
|
|
132
|
-
this.#destroyed = true;
|
|
133
|
-
if (this.#reconnectTimer !== undefined) {
|
|
134
|
-
clearTimeout(this.#reconnectTimer);
|
|
135
|
-
this.#reconnectTimer = undefined;
|
|
136
|
-
}
|
|
137
|
-
if (this.#missingErrorHandlerTimer !== undefined) {
|
|
138
|
-
clearTimeout(this.#missingErrorHandlerTimer);
|
|
139
|
-
this.#missingErrorHandlerTimer = undefined;
|
|
140
|
-
}
|
|
141
|
-
this._socket.removeAllListeners();
|
|
142
|
-
this.removeAllListeners();
|
|
143
|
-
this._socket.destroy();
|
|
144
|
-
}
|
|
145
|
-
#queueReconnect() {
|
|
146
|
-
if (this.#reconnectTimer !== undefined) {
|
|
147
|
-
clearTimeout(this.#reconnectTimer);
|
|
148
|
-
}
|
|
149
|
-
this.#reconnectTimer = setTimeout(() => {
|
|
150
|
-
this.#reconnectTimer = undefined;
|
|
151
|
-
this.#new_status(enums_js_1.InstanceStatus.Connecting);
|
|
152
|
-
this.connect();
|
|
153
|
-
}, this.#options.reconnect_interval);
|
|
154
|
-
}
|
|
155
|
-
// Private function
|
|
156
|
-
#new_status(status, message) {
|
|
157
|
-
if (this.#lastStatus != status) {
|
|
158
|
-
this.#lastStatus = status;
|
|
159
|
-
this.emit('status_change', status, message);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
exports.TCPHelper = TCPHelper;
|
|
164
|
-
//# sourceMappingURL=tcp.js.map
|
package/dist/helpers/tcp.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tcp.js","sourceRoot":"","sources":["../../src/helpers/tcp.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;AAEH,sDAAqB;AACrB,iDAA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EAAE;YACtC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAA;YAEhC,IAAI,CAAC,WAAW,CAAC,yBAAc,CAAC,UAAU,CAAC,CAAA;YAE3C,IAAI,CAAC,OAAO,EAAE,CAAA;QACf,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAA;IACrC,CAAC;IAED,mBAAmB;IACnB,WAAW,CAAC,MAAmB,EAAE,OAAgB;QAChD,IAAI,IAAI,CAAC,WAAW,IAAI,MAAM,EAAE,CAAC;YAChC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAA;YACzB,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAC5C,CAAC;IACF,CAAC;CACD;AAnKD,8BAmKC"}
|
package/dist/helpers/telnet.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import EventEmitter from 'eventemitter3';
|
|
2
|
-
import { TCPHelperEvents, TCPHelperOptions } from './tcp.js';
|
|
3
|
-
export interface TelnetHelperEvents extends TCPHelperEvents {
|
|
4
|
-
sb: [Buffer];
|
|
5
|
-
iac: [string, number];
|
|
6
|
-
}
|
|
7
|
-
export type TelnetHelperOptions = TCPHelperOptions;
|
|
8
|
-
export declare class TelnetHelper extends EventEmitter<TelnetHelperEvents> {
|
|
9
|
-
#private;
|
|
10
|
-
get isConnected(): boolean;
|
|
11
|
-
get isConnecting(): boolean;
|
|
12
|
-
get isDestroyed(): boolean;
|
|
13
|
-
constructor(host: string, port: number, options?: TelnetHelperOptions);
|
|
14
|
-
connect(): boolean;
|
|
15
|
-
send(message: string | Buffer): Promise<boolean>;
|
|
16
|
-
destroy(): void;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=telnet.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"telnet.d.ts","sourceRoot":"","sources":["../../src/helpers/telnet.ts"],"names":[],"mappings":"AAiBA,OAAO,YAAY,MAAM,eAAe,CAAA;AAExC,OAAO,EAAa,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAYvE,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IAC1D,EAAE,EAAE,CAAC,MAAM,CAAC,CAAA;IACZ,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACrB;AACD,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAA;AAElD,qBAAa,YAAa,SAAQ,YAAY,CAAC,kBAAkB,CAAC;;IAKjE,IAAI,WAAW,IAAI,OAAO,CAEzB;IACD,IAAI,YAAY,IAAI,OAAO,CAE1B;IACD,IAAI,WAAW,IAAI,OAAO,CAEzB;gBAEW,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB;IA4BrE,OAAO,IAAI,OAAO;IAGZ,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAItD,OAAO,IAAI,IAAI;CAWf"}
|