-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
57 lines (50 loc) · 1.92 KB
/
index.js
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
const { InstanceBase, runEntrypoint, InstanceStatus, CompanionActionDefinitions, CompanionVariableDefinition } = require('@companion-module/base');
const { getPlaydeckConfigFields, PlaydeckConfig } = require('./src/PlaydeckConfig');
const UpgradeScripts = require('./src/upgrades');
const { PlaydeckFeedbacks } = require('./src/PlaydeckFeedbacks');
const { PlaydeckVersion } = require('./src/PlaydeckVersion');
const { PlaydeckActions } = require('./src/PlaydeckActions');
const { PlaydeckPresets } = require('./src/PlaydeckPresets');
const { PlaydeckState } = require('./src/PlaydeckState');
const { PlaydeckConnectionManager } = require('./src/PlaydeckConnections/PlaydeckConnectionManager');
class PlaydeckInstance extends InstanceBase {
/** @type { PlaydeckConfig } */
config;
/** @type { PlaydeckVersion } */
version;
/** @type { PlaydeckState } */
state;
/** @type { CompanionVariableDefinition[] } */
variableDefinitions = [];
/** @type { CompanionActionDefinitions } */
actionDefinitions = {};
constructor(internal) {
super(internal);
}
async init(config) {
this.config = config;
this.version = new PlaydeckVersion(this.config.version);
this.state = new PlaydeckState(this);
this.updateStatus(InstanceStatus.Connecting);
this.connectionManager = new PlaydeckConnectionManager(this);
this.actions = new PlaydeckActions(this);
this.feedbacks = new PlaydeckFeedbacks(this);
this.presets = new PlaydeckPresets(this);
}
// When module gets deleted
async destroy() {
this.log('debug', 'Playdeck Instance: destroying...');
this.connectionManager.destroy();
}
async configUpdated(config) {
this.log('debug', 'Playdeck Instance: Updating config...');
this.destroy();
this.config = config;
this.init(config);
}
getConfigFields() {
return getPlaydeckConfigFields();
}
}
runEntrypoint(PlaydeckInstance, UpgradeScripts);
module.exports = PlaydeckInstance;