@cuecue/core 0.0.43 → 0.0.44
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/dist/index.js +20 -46
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var StateMachine = require('javascript-state-machine');
|
|
6
4
|
var EventEmitter = require('wolfy87-eventemitter');
|
|
7
5
|
var createDebug = require('debug');
|
|
8
6
|
var isArray = require('lodash/isArray');
|
|
9
7
|
var isObject = require('lodash/isObject');
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var StateMachine__default = /*#__PURE__*/_interopDefaultLegacy(StateMachine);
|
|
14
|
-
var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
15
|
-
var createDebug__default = /*#__PURE__*/_interopDefaultLegacy(createDebug);
|
|
16
|
-
var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
|
|
17
|
-
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
18
|
-
|
|
19
|
-
class BasePlugin extends EventEmitter__default["default"] {
|
|
9
|
+
class BasePlugin extends EventEmitter {
|
|
20
10
|
constructor(opts = {}) {
|
|
21
11
|
super();
|
|
22
|
-
this.options = {
|
|
12
|
+
this.options = {
|
|
13
|
+
...opts
|
|
23
14
|
};
|
|
24
15
|
this.onInit = this.onInit.bind(this);
|
|
25
16
|
this.onInitialized = this.onInitialized.bind(this);
|
|
@@ -31,8 +22,8 @@ class BasePlugin extends EventEmitter__default["default"] {
|
|
|
31
22
|
this.onStopped = this.onStopped.bind(this);
|
|
32
23
|
this.onPendingTransition = this.onPendingTransition.bind(this);
|
|
33
24
|
this.onInvalidTransition = this.onInvalidTransition.bind(this);
|
|
34
|
-
this.debug =
|
|
35
|
-
this.state = new
|
|
25
|
+
this.debug = createDebug('cuecue:input');
|
|
26
|
+
this.state = new StateMachine({
|
|
36
27
|
transitions: [{
|
|
37
28
|
name: 'init',
|
|
38
29
|
from: 'none',
|
|
@@ -64,75 +55,59 @@ class BasePlugin extends EventEmitter__default["default"] {
|
|
|
64
55
|
}
|
|
65
56
|
});
|
|
66
57
|
}
|
|
67
|
-
|
|
68
58
|
init() {
|
|
69
59
|
return this.state.init();
|
|
70
60
|
}
|
|
71
|
-
|
|
72
61
|
destroy() {
|
|
73
62
|
return this.state.destroy();
|
|
74
63
|
}
|
|
75
|
-
|
|
76
64
|
async start() {
|
|
77
65
|
if (!this.initialized()) {
|
|
78
66
|
await this.init();
|
|
79
67
|
}
|
|
80
|
-
|
|
81
68
|
return this.state.start();
|
|
82
69
|
}
|
|
83
|
-
|
|
84
70
|
stop() {
|
|
85
71
|
return this.state.stop();
|
|
86
72
|
}
|
|
87
|
-
|
|
88
73
|
started() {
|
|
89
74
|
return this.state.is('started');
|
|
90
75
|
}
|
|
91
|
-
|
|
92
76
|
initialized() {
|
|
93
77
|
return this.state.is('initialized');
|
|
94
78
|
}
|
|
95
|
-
|
|
96
79
|
onInit() {
|
|
97
80
|
this.debug('onInit');
|
|
98
81
|
this.emit('init');
|
|
99
82
|
}
|
|
100
|
-
|
|
101
83
|
onInitialized() {
|
|
102
84
|
this.debug('onInitialized');
|
|
103
85
|
return process.nextTick(() => this.emit('initialized'));
|
|
104
86
|
}
|
|
105
|
-
|
|
106
87
|
onDestroy() {
|
|
107
88
|
this.debug('onDestroy');
|
|
108
89
|
this.emit('destroy');
|
|
109
90
|
}
|
|
110
|
-
|
|
111
91
|
onDestroyed() {
|
|
112
92
|
this.debug('onDestroyed');
|
|
113
93
|
return process.nextTick(() => this.emit('destroyed'));
|
|
114
94
|
}
|
|
115
|
-
|
|
116
95
|
onStart() {
|
|
117
96
|
this.debug('onStart');
|
|
118
97
|
this.emit('start');
|
|
119
98
|
}
|
|
120
|
-
|
|
121
99
|
onStarted() {
|
|
122
100
|
this.debug('onStarted');
|
|
123
101
|
return process.nextTick(() => this.emit('started'));
|
|
124
102
|
}
|
|
125
|
-
|
|
126
103
|
onStop() {
|
|
127
104
|
this.debug('onStop');
|
|
128
105
|
this.emit('stop');
|
|
129
106
|
}
|
|
130
|
-
|
|
131
107
|
onStopped() {
|
|
132
108
|
this.debug('onStopped');
|
|
133
109
|
return process.nextTick(() => this.emit('stopped'));
|
|
134
110
|
}
|
|
135
|
-
|
|
136
111
|
onPendingTransition(transition, from, to) {
|
|
137
112
|
this.debug('Pending transition: %s from: %s to: %s', transition, from, to);
|
|
138
113
|
return new Promise(resolve => {
|
|
@@ -141,76 +116,75 @@ class BasePlugin extends EventEmitter__default["default"] {
|
|
|
141
116
|
}
|
|
142
117
|
});
|
|
143
118
|
}
|
|
144
|
-
|
|
145
119
|
onInvalidTransition(transition, from, to) {
|
|
146
120
|
this.debug('ERROR: Invalid base transition: %s from: %s to: %s state: %s', transition, from, to, this.state.state);
|
|
147
121
|
}
|
|
148
|
-
|
|
149
122
|
}
|
|
150
123
|
|
|
151
124
|
class BaseInput extends BasePlugin {
|
|
125
|
+
command(command, ...args) {
|
|
126
|
+
this.emit('command', command, ...args);
|
|
127
|
+
}
|
|
152
128
|
cue(cue, extraData = null) {
|
|
153
129
|
this.emit('command', 'cue', cue, extraData);
|
|
154
130
|
}
|
|
155
|
-
|
|
156
131
|
interact(data, interactionId = null) {
|
|
157
132
|
this.emit('command', 'interact', data, interactionId);
|
|
158
133
|
}
|
|
159
|
-
|
|
160
134
|
}
|
|
161
135
|
|
|
162
136
|
class BaseOutput extends BasePlugin {}
|
|
163
137
|
|
|
164
138
|
const parseInputId = data => {
|
|
165
|
-
if (
|
|
139
|
+
if (isArray(data)) {
|
|
166
140
|
return data.map(({
|
|
167
141
|
id = null,
|
|
168
142
|
...item
|
|
169
|
-
}) => ({
|
|
143
|
+
}) => ({
|
|
144
|
+
...item,
|
|
170
145
|
...(id !== null ? {
|
|
171
146
|
externalId: id
|
|
172
147
|
} : null)
|
|
173
148
|
}));
|
|
174
149
|
}
|
|
175
|
-
|
|
176
|
-
if (isObject__default["default"](data)) {
|
|
150
|
+
if (isObject(data)) {
|
|
177
151
|
const {
|
|
178
152
|
id = null,
|
|
179
153
|
...props
|
|
180
154
|
} = data;
|
|
181
|
-
return {
|
|
155
|
+
return {
|
|
156
|
+
...props,
|
|
182
157
|
...(id !== null ? {
|
|
183
158
|
externalId: id
|
|
184
159
|
} : null)
|
|
185
160
|
};
|
|
186
161
|
}
|
|
187
|
-
|
|
188
162
|
return null;
|
|
189
163
|
};
|
|
190
164
|
const parseOutputId = data => {
|
|
191
|
-
if (
|
|
165
|
+
if (isArray(data)) {
|
|
192
166
|
return data.map(({
|
|
193
167
|
externalId = null,
|
|
194
168
|
...item
|
|
195
|
-
}) => ({
|
|
169
|
+
}) => ({
|
|
170
|
+
...item,
|
|
196
171
|
...(externalId !== null ? {
|
|
197
172
|
id: externalId
|
|
198
173
|
} : null)
|
|
199
174
|
}));
|
|
200
175
|
}
|
|
201
|
-
|
|
202
|
-
if (isObject__default["default"](data)) {
|
|
176
|
+
if (isObject(data)) {
|
|
203
177
|
const {
|
|
204
178
|
externalId = null,
|
|
205
179
|
...props
|
|
206
180
|
} = data;
|
|
207
|
-
return {
|
|
181
|
+
return {
|
|
182
|
+
...props,
|
|
208
183
|
...(externalId !== null ? {
|
|
209
184
|
id: externalId
|
|
210
185
|
} : null)
|
|
211
186
|
};
|
|
212
187
|
}
|
|
213
|
-
|
|
214
188
|
return null;
|
|
215
189
|
};
|
|
216
190
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuecue/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.44",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -29,17 +29,19 @@
|
|
|
29
29
|
}
|
|
30
30
|
],
|
|
31
31
|
"license": "ISC",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=22"
|
|
34
|
+
},
|
|
32
35
|
"main": "dist/index.js",
|
|
33
36
|
"files": [
|
|
34
37
|
"dist"
|
|
35
38
|
],
|
|
36
39
|
"scripts": {
|
|
37
40
|
"clean": "rm -rf dist",
|
|
38
|
-
"build": "rollup --config ../../rollup.config.
|
|
39
|
-
"
|
|
41
|
+
"build": "rollup --config ../../rollup.config.mjs",
|
|
42
|
+
"prepack": "npm run clean && npm run build"
|
|
40
43
|
},
|
|
41
44
|
"dependencies": {
|
|
42
|
-
"@babel/runtime": "^7.12.5",
|
|
43
45
|
"commander": "^9.4.0",
|
|
44
46
|
"debug": "^4.3.1",
|
|
45
47
|
"javascript-state-machine": "^3.1.0",
|
|
@@ -48,6 +50,5 @@
|
|
|
48
50
|
},
|
|
49
51
|
"publishConfig": {
|
|
50
52
|
"access": "public"
|
|
51
|
-
}
|
|
52
|
-
"gitHead": "59235dd281e2779bf0f964cb069f539ba85a8066"
|
|
53
|
+
}
|
|
53
54
|
}
|