motion-master-client 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/package.json +17 -2
- package/src/index.js +29 -0
- package/src/index.js.map +1 -0
- package/src/lib/cia402.d.ts +182 -0
- package/src/lib/cia402.js +392 -0
- package/src/lib/cia402.js.map +1 -0
- package/src/lib/config-file.d.ts +13 -0
- package/src/lib/config-file.js +50 -0
- package/src/lib/config-file.js.map +1 -0
- package/src/lib/device-log-line.d.ts +5 -0
- package/src/lib/device-log-line.js +3 -0
- package/src/lib/device-log-line.js.map +1 -0
- package/src/lib/device-parameter.d.ts +56 -0
- package/src/lib/device-parameter.js +39 -0
- package/src/lib/device-parameter.js.map +1 -0
- package/src/lib/device.d.ts +9 -0
- package/src/lib/device.js +3 -0
- package/src/lib/device.js.map +1 -0
- package/src/lib/hardware-description.d.ts +41 -0
- package/src/lib/hardware-description.js +94 -0
- package/src/lib/hardware-description.js.map +1 -0
- package/src/lib/logger.d.ts +1 -0
- package/src/lib/logger.js +8 -0
- package/src/lib/logger.js.map +1 -0
- package/src/lib/monitoring-config.d.ts +6 -0
- package/src/lib/monitoring-config.js +3 -0
- package/src/lib/monitoring-config.js.map +1 -0
- package/src/lib/{monitoring-entry.ts → monitoring-entry.d.ts} +4 -5
- package/src/lib/monitoring-entry.js +3 -0
- package/src/lib/monitoring-entry.js.map +1 -0
- package/src/lib/motion-master-client.d.ts +56 -0
- package/src/lib/motion-master-client.js +167 -0
- package/src/lib/motion-master-client.js.map +1 -0
- package/src/lib/motion-master-pub-sub-client.d.ts +17 -0
- package/src/lib/motion-master-pub-sub-client.js +73 -0
- package/src/lib/motion-master-pub-sub-client.js.map +1 -0
- package/src/lib/motion-master-pub-sub-socket.d.ts +34 -0
- package/src/lib/motion-master-pub-sub-socket.js +3 -0
- package/src/lib/motion-master-pub-sub-socket.js.map +1 -0
- package/src/lib/motion-master-pub-sub-web-socket.d.ts +14 -0
- package/src/lib/motion-master-pub-sub-web-socket.js +67 -0
- package/src/lib/motion-master-pub-sub-web-socket.js.map +1 -0
- package/src/lib/motion-master-pub-sub-worker-socket.d.ts +14 -0
- package/src/lib/motion-master-pub-sub-worker-socket.js +42 -0
- package/src/lib/motion-master-pub-sub-worker-socket.js.map +1 -0
- package/src/lib/motion-master-req-res-client.d.ts +947 -0
- package/src/lib/motion-master-req-res-client.js +1735 -0
- package/src/lib/motion-master-req-res-client.js.map +1 -0
- package/src/lib/motion-master-req-res-socket.d.ts +52 -0
- package/src/lib/motion-master-req-res-socket.js +3 -0
- package/src/lib/motion-master-req-res-socket.js.map +1 -0
- package/src/lib/motion-master-req-res-web-socket.d.ts +24 -0
- package/src/lib/motion-master-req-res-web-socket.js +99 -0
- package/src/lib/motion-master-req-res-web-socket.js.map +1 -0
- package/src/lib/motion-master-req-res-worker-socket.d.ts +20 -0
- package/src/lib/motion-master-req-res-worker-socket.js +69 -0
- package/src/lib/motion-master-req-res-worker-socket.js.map +1 -0
- package/src/lib/operators.d.ts +20 -0
- package/src/lib/operators.js +85 -0
- package/src/lib/operators.js.map +1 -0
- package/src/lib/options.d.ts +10 -0
- package/src/lib/options.js +14 -0
- package/src/lib/options.js.map +1 -0
- package/src/lib/parameter.d.ts +72 -0
- package/src/lib/parameter.js +119 -0
- package/src/lib/parameter.js.map +1 -0
- package/src/lib/product-id-range.d.ts +7 -0
- package/src/lib/product-id-range.js +12 -0
- package/src/lib/product-id-range.js.map +1 -0
- package/src/lib/request-status-resolver.d.ts +4 -0
- package/src/lib/request-status-resolver.js +345 -0
- package/src/lib/request-status-resolver.js.map +1 -0
- package/src/lib/system-log-line.d.ts +9 -0
- package/src/lib/system-log-line.js +3 -0
- package/src/lib/system-log-line.js.map +1 -0
- package/src/lib/{types.ts → types.d.ts} +149 -81
- package/src/lib/types.js +29 -0
- package/src/lib/types.js.map +1 -0
- package/src/lib/urls.d.ts +3 -0
- package/src/lib/urls.js +10 -0
- package/src/lib/urls.js.map +1 -0
- package/src/lib/util.d.ts +42 -0
- package/src/lib/util.js +326 -0
- package/src/lib/util.js.map +1 -0
- package/.babelrc +0 -3
- package/.eslintrc.json +0 -18
- package/jest.config.ts +0 -16
- package/motion-master.proto +0 -1822
- package/project.json +0 -45
- package/src/lib/cia402.spec.ts +0 -77
- package/src/lib/cia402.ts +0 -414
- package/src/lib/config-file.spec.ts +0 -114
- package/src/lib/config-file.ts +0 -63
- package/src/lib/device-log-line.ts +0 -5
- package/src/lib/device-parameter.spec.ts +0 -85
- package/src/lib/device-parameter.ts +0 -79
- package/src/lib/device.ts +0 -10
- package/src/lib/hardware-description.spec.ts +0 -253
- package/src/lib/hardware-description.ts +0 -129
- package/src/lib/logger.ts +0 -5
- package/src/lib/monitoring-config.ts +0 -6
- package/src/lib/motion-master-client.ts +0 -250
- package/src/lib/motion-master-pub-sub-client.ts +0 -100
- package/src/lib/motion-master-pub-sub-socket.ts +0 -40
- package/src/lib/motion-master-pub-sub-web-socket.ts +0 -78
- package/src/lib/motion-master-pub-sub-worker-socket.ts +0 -51
- package/src/lib/motion-master-req-res-client.spec.ts +0 -740
- package/src/lib/motion-master-req-res-client.ts +0 -2206
- package/src/lib/motion-master-req-res-socket.ts +0 -62
- package/src/lib/motion-master-req-res-web-socket.ts +0 -124
- package/src/lib/motion-master-req-res-worker-socket.ts +0 -87
- package/src/lib/operators.ts +0 -110
- package/src/lib/options.ts +0 -12
- package/src/lib/parameter.spec.ts +0 -160
- package/src/lib/parameter.ts +0 -170
- package/src/lib/product-id-range.ts +0 -8
- package/src/lib/request-status-resolver.ts +0 -403
- package/src/lib/system-log-line.ts +0 -9
- package/src/lib/urls.ts +0 -6
- package/src/lib/util.ts +0 -317
- package/tsconfig.json +0 -23
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -20
- package/typedoc.json +0 -10
- /package/src/{index.ts → index.d.ts} +0 -0
package/src/lib/util.ts
DELETED
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import { inRange } from "lodash";
|
|
2
|
-
import { DeviceLogLine } from "./device-log-line";
|
|
3
|
-
import { Parameter, ParameterIndexSubindex } from "./parameter";
|
|
4
|
-
import { SystemLogLine } from "./system-log-line";
|
|
5
|
-
import { DeviceRef, DeviceRefObj, IMotionMasterMessage, MotionMasterMessage, ParameterAddressValue, ParameterTypeValue, ParameterTypeValueKey, ParameterValueType, ValueType } from "./types";
|
|
6
|
-
|
|
7
|
-
export function getParameterTypeValueDefault(key: ParameterTypeValueKey) {
|
|
8
|
-
if (key === 'floatValue' || key === 'intValue' || key === 'uintValue') {
|
|
9
|
-
return 0;
|
|
10
|
-
} else if (key === 'rawValue') {
|
|
11
|
-
return Uint8Array.from([]);
|
|
12
|
-
} else if (key === 'stringValue') {
|
|
13
|
-
return '';
|
|
14
|
-
} else {
|
|
15
|
-
return 0;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function getParameterTypeValue(parameter: MotionMasterMessage.Status.DeviceParameterValues.IParameterValue): ParameterTypeValueKey | undefined {
|
|
20
|
-
return (MotionMasterMessage.Status.DeviceParameterValues.ParameterValue.create(parameter)).typeValue;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function getParameterValue(parameter: MotionMasterMessage.Status.DeviceParameterValues.IParameterValue): ParameterValueType {
|
|
24
|
-
const key = getParameterTypeValue(parameter);
|
|
25
|
-
if (key && key in parameter) {
|
|
26
|
-
return parameter[key] ?? getParameterTypeValueDefault(key);
|
|
27
|
-
}
|
|
28
|
-
return 0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function makeDeviceRefObj(deviceRef: DeviceRef): DeviceRefObj {
|
|
32
|
-
if (typeof deviceRef === 'number') {
|
|
33
|
-
if (deviceRef <= 0xFFFF) {
|
|
34
|
-
return { devicePosition: deviceRef };
|
|
35
|
-
} else {
|
|
36
|
-
return { deviceAddress: deviceRef };
|
|
37
|
-
}
|
|
38
|
-
} else {
|
|
39
|
-
return { deviceSerialNumber: deviceRef };
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// TODO: Write unit tests.
|
|
44
|
-
export function parseSystemLogLine(line: string): SystemLogLine | undefined {
|
|
45
|
-
const re = /(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\.\d{1,3})\s\((.+)\)\s\[(.+)\](.+:\d+)(.+?)\|(.*)/s;
|
|
46
|
-
const result = re.exec(line);
|
|
47
|
-
if (result) {
|
|
48
|
-
return {
|
|
49
|
-
line,
|
|
50
|
-
date: new Date(result[1]),
|
|
51
|
-
uptime: result[2].trim(),
|
|
52
|
-
id: result[3].trim(),
|
|
53
|
-
file: result[4].trim(),
|
|
54
|
-
level: result[5].trim(),
|
|
55
|
-
message: result[6],
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// TODO: Write unit tests.
|
|
62
|
-
export function parseSystemLogContent(content: string): SystemLogLine[] {
|
|
63
|
-
const re = /(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\.\d{1,3}.+?)(?=\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\.\d{1,3}|$)/gs;
|
|
64
|
-
return content.split(re)
|
|
65
|
-
.filter((l) => l !== '')
|
|
66
|
-
.map((v) => parseSystemLogLine(v))
|
|
67
|
-
.filter((l): l is SystemLogLine => l !== undefined);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function parseDeviceLog(line: string): DeviceLogLine | undefined {
|
|
71
|
-
const re = /^(\d{2}:\d{2}:\d{2}\.\d+)\s(.*)\|(.*)$/gm;
|
|
72
|
-
const result = re.exec(line);
|
|
73
|
-
if (result) {
|
|
74
|
-
return {
|
|
75
|
-
time: result[1].trim(),
|
|
76
|
-
level: result[2].trim(),
|
|
77
|
-
message: result[3].trim(),
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function parseDeviceLogContent(content: string): DeviceLogLine[] {
|
|
84
|
-
return content.split('\n')
|
|
85
|
-
.map((v) => parseDeviceLog(v))
|
|
86
|
-
.filter((l): l is DeviceLogLine => l !== undefined);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function mapParameterTypeValueToObject(type: keyof ParameterTypeValue, value: number | string): ParameterTypeValue {
|
|
90
|
-
const p: ParameterTypeValue = {};
|
|
91
|
-
if (type === 'floatValue') {
|
|
92
|
-
p['floatValue'] = typeof value === 'number' ? value : parseFloat(value);
|
|
93
|
-
} else if (type === 'intValue') {
|
|
94
|
-
p['intValue'] = typeof value === 'number' ? value : parseInt(value, 10);
|
|
95
|
-
} else if (type === 'rawValue') {
|
|
96
|
-
if (typeof value === 'number') {
|
|
97
|
-
p['rawValue'] = Uint8Array.from([value]);
|
|
98
|
-
} else {
|
|
99
|
-
let bytes: number[] = [];
|
|
100
|
-
if (value.startsWith('0x')) {
|
|
101
|
-
bytes = value.slice(2).match(/.{1,2}/g)?.map((h) => parseInt(h, 16)) ?? [];
|
|
102
|
-
} else {
|
|
103
|
-
bytes = value.split(',').map((c) => c.trim()).map((c) => parseInt(c, 10));
|
|
104
|
-
}
|
|
105
|
-
p['rawValue'] = Uint8Array.from(bytes);
|
|
106
|
-
}
|
|
107
|
-
} else if (type === 'stringValue') {
|
|
108
|
-
p['stringValue'] = typeof value === 'string' ? value : value.toString();
|
|
109
|
-
} else if (type === 'uintValue') {
|
|
110
|
-
p['uintValue'] = typeof value === 'number' ? value : parseInt(value, 10);
|
|
111
|
-
}
|
|
112
|
-
return p;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Using bytes fixes: ERROR TypeError: Cannot freeze array buffer views with elements in NgRx
|
|
116
|
-
export function createPlainObjectFromMotionMasterMessage(motionMasterMessage: MotionMasterMessage) {
|
|
117
|
-
return MotionMasterMessage.toObject(motionMasterMessage, {
|
|
118
|
-
bytes: Array, // Valid values are `Array`
|
|
119
|
-
defaults: true, // Also sets default values on the resulting object
|
|
120
|
-
arrays: true, // Sets empty arrays for missing repeated fields even if `defaults=false`
|
|
121
|
-
objects: true, // Sets empty objects for missing map fields even if `defaults=false`
|
|
122
|
-
oneofs: true, // Includes virtual oneof properties set to the present field's name, if any
|
|
123
|
-
json: true, // Performs additional JSON compatibility conversions, i.e. NaN and Infinity to strings
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export function convertMotionMasterMessageToLoggerContext(motionMasterMessage: IMotionMasterMessage, namespace = 'reqResMessage') {
|
|
128
|
-
let type;
|
|
129
|
-
let name;
|
|
130
|
-
|
|
131
|
-
if (motionMasterMessage.request) {
|
|
132
|
-
type = 'request';
|
|
133
|
-
name = Object.keys(motionMasterMessage.request).join();
|
|
134
|
-
} else if (motionMasterMessage.status) {
|
|
135
|
-
type = 'status';
|
|
136
|
-
name = Object.keys(motionMasterMessage.status).join();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return { namespace, motionMasterMessage, type, name };
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export function decodeTextContent(content: Uint8Array): string {
|
|
143
|
-
const decoder = new TextDecoder();
|
|
144
|
-
const buffer = Uint8Array.from(content);
|
|
145
|
-
return decoder.decode(buffer);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export function isRxPdoIndex(index: number): boolean {
|
|
149
|
-
return inRange(index, 0x1600, 0x1800);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export function isTxPdoIndex(index: number): boolean {
|
|
153
|
-
return inRange(index, 0x1A00, 0x1C00);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export function filterRxPdoParameters<T extends ParameterIndexSubindex>(parameters: T[], excludeSubIndex000 = false): T[] {
|
|
157
|
-
return parameters.filter((p) => isRxPdoIndex(p.index) && (excludeSubIndex000 ? p.subindex > 0 : true)); // RxPDOs: Index area 0x1600 to 0x17FF
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export function filterTxPdoParameters<T extends ParameterIndexSubindex>(parameters: T[], excludeSubIndex000 = false): T[] {
|
|
161
|
-
return parameters.filter((p) => isTxPdoIndex(p.index) && (excludeSubIndex000 ? p.subindex > 0 : true)); // TxPDOs: Index area 0x1A00 to 0x1BFF
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export function fillPdoParametersWithMappingEntries(parameters: Parameter[], entriesPerPdo = 10): Parameter[] {
|
|
165
|
-
const output: Parameter[] = [];
|
|
166
|
-
let i = 0;
|
|
167
|
-
while (i < parameters.length) {
|
|
168
|
-
if (parameters[i].subindex === 0) {
|
|
169
|
-
let j = i;
|
|
170
|
-
while (parameters[j] && (parameters[j].index === parameters[i].index)) {
|
|
171
|
-
output.push(parameters[j]);
|
|
172
|
-
j++;
|
|
173
|
-
}
|
|
174
|
-
let d = j - i;
|
|
175
|
-
while (d <= entriesPerPdo) {
|
|
176
|
-
output.push({
|
|
177
|
-
index: parameters[i].index,
|
|
178
|
-
subindex: d,
|
|
179
|
-
name: parameters[i].name,
|
|
180
|
-
uintValue: 0,
|
|
181
|
-
value: 0,
|
|
182
|
-
valueType: ValueType.UNSIGNED32,
|
|
183
|
-
group: parameters[i].group,
|
|
184
|
-
typeValueKey: "uintValue",
|
|
185
|
-
readAccess: true,
|
|
186
|
-
writeAccess: true,
|
|
187
|
-
});
|
|
188
|
-
d++;
|
|
189
|
-
}
|
|
190
|
-
i = j;
|
|
191
|
-
} else {
|
|
192
|
-
i++;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return output;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export function mapParameterToPdoSubItemValue(parameter: Parameter): number {
|
|
199
|
-
const { index, subindex } = parameter;
|
|
200
|
-
if (parameter.valueType && parameter.valueType < ValueType.VISIBLE_STRING) {
|
|
201
|
-
const buffer = new ArrayBuffer(4);
|
|
202
|
-
const view = new DataView(buffer);
|
|
203
|
-
const bitSize = mapValueTypeToBitSize(parameter.valueType);
|
|
204
|
-
view.setUint16(0, index);
|
|
205
|
-
view.setUint8(2, subindex);
|
|
206
|
-
view.setUint8(3, bitSize);
|
|
207
|
-
return view.getUint32(0);
|
|
208
|
-
}
|
|
209
|
-
return 0;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export function mapValueTypeToBitSize(valueType: ValueType): number {
|
|
213
|
-
switch (valueType) {
|
|
214
|
-
case ValueType.UNSPECIFIED:
|
|
215
|
-
return 0;
|
|
216
|
-
case ValueType.BOOLEAN:
|
|
217
|
-
return 1;
|
|
218
|
-
case ValueType.INTEGER8:
|
|
219
|
-
case ValueType.UNSIGNED8:
|
|
220
|
-
return 8;
|
|
221
|
-
case ValueType.INTEGER16:
|
|
222
|
-
case ValueType.UNSIGNED16:
|
|
223
|
-
return 16;
|
|
224
|
-
case ValueType.INTEGER32:
|
|
225
|
-
case ValueType.UNSIGNED32:
|
|
226
|
-
case ValueType.REAL32:
|
|
227
|
-
return 32;
|
|
228
|
-
}
|
|
229
|
-
throw new Error(`Non-numeric value type "${valueType}" (data types with variable length) cannot be mapped to bit size. You will have to get this info from ESI.`);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export const valueTypeToParameterTypeValueKeyMap = new Map<ValueType, keyof Required<ParameterTypeValue>>([
|
|
233
|
-
[ValueType.BOOLEAN, 'uintValue'],
|
|
234
|
-
[ValueType.INTEGER8, 'intValue'],
|
|
235
|
-
[ValueType.INTEGER16, 'intValue'],
|
|
236
|
-
[ValueType.INTEGER32, 'intValue'],
|
|
237
|
-
[ValueType.UNSIGNED8, 'uintValue'],
|
|
238
|
-
[ValueType.UNSIGNED16, 'uintValue'],
|
|
239
|
-
[ValueType.UNSIGNED32, 'uintValue'],
|
|
240
|
-
[ValueType.REAL32, 'floatValue'],
|
|
241
|
-
[ValueType.VISIBLE_STRING, 'stringValue'],
|
|
242
|
-
[ValueType.OCTET_STRING, 'rawValue'],
|
|
243
|
-
[ValueType.UNICODE_STRING, 'stringValue'],
|
|
244
|
-
]);
|
|
245
|
-
|
|
246
|
-
export function isValidDeviceRefObj(obj: DeviceRefObj): boolean {
|
|
247
|
-
return Number.isFinite(Number(obj.deviceAddress))
|
|
248
|
-
|| (typeof obj.devicePosition === 'number' && obj.devicePosition >= 0)
|
|
249
|
-
|| typeof obj.deviceSerialNumber === 'string';
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
export function createPdoParameterValues(parameters: Array<{ index: number, subindex: number, typeValue?: ParameterTypeValueKey }>, values: Array<ParameterValueType>) {
|
|
253
|
-
const output = parameters.map((parameter, i, arr) => {
|
|
254
|
-
const { index, subindex, typeValue } = parameter;
|
|
255
|
-
let value = values[i];
|
|
256
|
-
if (subindex === 0) {
|
|
257
|
-
value = arr.reduce((n, p, j) => (p.index === index && p.subindex > 0 && values[j]) ? n + 1 : n, 0);
|
|
258
|
-
}
|
|
259
|
-
return [index, subindex, value, typeValue];
|
|
260
|
-
}) as ParameterAddressValue[];
|
|
261
|
-
|
|
262
|
-
for (let i = 0; i < output.length - 1; i++) {
|
|
263
|
-
const [, subindex1, value1] = output[i];
|
|
264
|
-
if (subindex1 > 0 && value1 === 0) {
|
|
265
|
-
let j = i + 1;
|
|
266
|
-
let [, subindex2, value2] = output[j];
|
|
267
|
-
while (subindex2 > subindex1 && output[j]) {
|
|
268
|
-
if (typeof value2 === 'number' && value2 > 0) {
|
|
269
|
-
output[i][2] = value2;
|
|
270
|
-
output[j][2] = 0;
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
if (output[++j]) {
|
|
274
|
-
[, subindex2, value2] = output[j];
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return output;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
export function resolveAfter(ms: number, value?: unknown) {
|
|
284
|
-
return new Promise(function (resolve) {
|
|
285
|
-
setTimeout(resolve.bind(null, value), ms);
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
export function convertRgbToLedColor(value: number) {
|
|
290
|
-
const r = (value >> 16) & 0xFF;
|
|
291
|
-
const g = (value >> 8) & 0xFF;
|
|
292
|
-
const b = value & 0xFF;
|
|
293
|
-
const ledColorValue = (g << 16) | (r << 8) | b;
|
|
294
|
-
return ledColorValue;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export function createRandomColor(brightness: number) {
|
|
298
|
-
function randomChannel(brightness: number) {
|
|
299
|
-
const r = 255 - brightness;
|
|
300
|
-
const n = 0 | ((Math.random() * r) + brightness);
|
|
301
|
-
const s = n.toString(16);
|
|
302
|
-
return (s.length == 1) ? '0' + s : s;
|
|
303
|
-
}
|
|
304
|
-
return '#' + randomChannel(brightness) + randomChannel(brightness) + randomChannel(brightness);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
export const emptyAppBase64 = 'UEsDBBQACAAIABBye08AAAAAAAAAAAAAAAANACAAYXBwX2VtcHR5LmJpblVUDQAHMHfeXTB33l0wd95ddXgLAAEE6AMAAAToAwAAAwBQSwcIAAAAAAIAAAAAAAAAUEsBAhQDFAAIAAgAEHJ7TwAAAAACAAAAAAAAAA0AIAAAAAAAAAAAAKSBAAAAAGFwcF9lbXB0eS5iaW5VVA0ABzB33l0wd95dMHfeXXV4CwABBOgDAAAE6AMAAFBLBQYAAAAAAQABAFsAAABdAAAAAAA=';
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
export function getMapKeyByValue<K, V>(map: Map<K, V>, searchValue: V): K | undefined {
|
|
311
|
-
for (let [key, value] of map.entries()) {
|
|
312
|
-
if (value === searchValue) {
|
|
313
|
-
return key;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
return;
|
|
317
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"forceConsistentCasingInFileNames": true,
|
|
6
|
-
"strict": true,
|
|
7
|
-
"noImplicitOverride": true,
|
|
8
|
-
"noPropertyAccessFromIndexSignature": true,
|
|
9
|
-
"noImplicitReturns": true,
|
|
10
|
-
"noFallthroughCasesInSwitch": true,
|
|
11
|
-
"allowJs": true
|
|
12
|
-
},
|
|
13
|
-
"files": [],
|
|
14
|
-
"include": [],
|
|
15
|
-
"references": [
|
|
16
|
-
{
|
|
17
|
-
"path": "./tsconfig.lib.json"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"path": "./tsconfig.spec.json"
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
}
|
package/tsconfig.lib.json
DELETED
package/tsconfig.spec.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"types": ["jest", "node"]
|
|
7
|
-
},
|
|
8
|
-
"include": [
|
|
9
|
-
"**/*.test.ts",
|
|
10
|
-
"**/*.spec.ts",
|
|
11
|
-
"**/*.test.tsx",
|
|
12
|
-
"**/*.spec.tsx",
|
|
13
|
-
"**/*.test.js",
|
|
14
|
-
"**/*.spec.js",
|
|
15
|
-
"**/*.test.jsx",
|
|
16
|
-
"**/*.spec.jsx",
|
|
17
|
-
"**/*.d.ts",
|
|
18
|
-
"jest.config.ts"
|
|
19
|
-
]
|
|
20
|
-
}
|
package/typedoc.json
DELETED
|
File without changes
|