@sebbo2002/vestaboard2mqtt 3.0.0-develop.2 → 4.0.0-develop.1
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/bin/start.cjs +9 -0
- package/dist/bin/start.cjs.map +1 -0
- package/dist/bin/start.d.ts +0 -1
- package/dist/bin/start.js +1 -6
- package/dist/bin/start.js.map +1 -1
- package/dist/chunk-TNWD7XIG.js +8 -0
- package/dist/chunk-TNWD7XIG.js.map +1 -0
- package/dist/lib/index.cjs +8 -0
- package/dist/lib/index.cjs.map +1 -0
- package/dist/lib/index.d.cts +18 -0
- package/dist/lib/index.d.ts +3 -1
- package/dist/lib/index.js +1 -148
- package/dist/lib/index.js.map +1 -1
- package/package.json +21 -15
- package/dist/lib/cache.d.ts +0 -21
- package/dist/lib/cache.js +0 -108
- package/dist/lib/cache.js.map +0 -1
- package/dist/lib/config.d.ts +0 -30
- package/dist/lib/config.js +0 -63
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/message.d.ts +0 -29
- package/dist/lib/message.js +0 -252
- package/dist/lib/message.js.map +0 -1
- package/dist/lib/page.d.ts +0 -10
- package/dist/lib/page.js +0 -3
- package/dist/lib/page.js.map +0 -1
- package/dist/lib/pages/calendar.d.ts +0 -21
- package/dist/lib/pages/calendar.js +0 -130
- package/dist/lib/pages/calendar.js.map +0 -1
- package/dist/lib/pages/index.d.ts +0 -3
- package/dist/lib/pages/index.js +0 -10
- package/dist/lib/pages/index.js.map +0 -1
- package/dist/lib/pages/message.d.ts +0 -8
- package/dist/lib/pages/message.js +0 -32
- package/dist/lib/pages/message.js.map +0 -1
- package/dist/lib/pages/today.d.ts +0 -13
- package/dist/lib/pages/today.js +0 -86
- package/dist/lib/pages/today.js.map +0 -1
package/dist/lib/index.js
CHANGED
|
@@ -1,149 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import mqtt from 'async-mqtt';
|
|
11
|
-
import Config from './config.js';
|
|
12
|
-
import Cache from './cache.js';
|
|
13
|
-
import Message from './message.js';
|
|
14
|
-
import pages from './pages/index.js';
|
|
15
|
-
import { Vesta } from 'vestaboard-api';
|
|
16
|
-
export default class Vestaboard2MQTT {
|
|
17
|
-
static run() {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
yield Config.load();
|
|
20
|
-
return new Vestaboard2MQTT();
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
constructor() {
|
|
24
|
-
this.pageConfig = new Cache('page-config');
|
|
25
|
-
this.board = new Vesta({
|
|
26
|
-
apiKey: Config.board.key,
|
|
27
|
-
apiSecret: Config.board.secret
|
|
28
|
-
});
|
|
29
|
-
this.mqtt = mqtt.connect(Config.mqtt.url, {
|
|
30
|
-
will: {
|
|
31
|
-
topic: Config.mqtt.prefix + '/status',
|
|
32
|
-
payload: 'offline',
|
|
33
|
-
qos: 0,
|
|
34
|
-
retain: true
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
this.mqtt.on('connect', () => {
|
|
38
|
-
this.mqtt.publish(Config.mqtt.prefix + '/status', 'online', {
|
|
39
|
-
retain: true
|
|
40
|
-
});
|
|
41
|
-
this.setupBrokerSubscriptions().catch(error => {
|
|
42
|
-
console.error(new Error(`Unable to setup mqtt subscriptions: ${error.stack}`));
|
|
43
|
-
process.exit(1);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
this.mqtt.on('message', (topic, message) => {
|
|
47
|
-
this.handleMessage(topic, message.toString()).catch(error => {
|
|
48
|
-
this.debug(`Unable to handle message: ${error.stack}`);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
setupBrokerSubscriptions() {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
if (!this.mqtt) {
|
|
55
|
-
throw new Error('Unable to setup subscriptions: client not set.');
|
|
56
|
-
}
|
|
57
|
-
yield this.mqtt.subscribe(Config.mqtt.prefix + '/#');
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
debug(message) {
|
|
61
|
-
const msg = String(message);
|
|
62
|
-
this.mqtt.publish(Config.mqtt.prefix + '/debug', msg);
|
|
63
|
-
console.log(msg);
|
|
64
|
-
}
|
|
65
|
-
handleMessage(topic, payload) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
if ([Config.mqtt.prefix + '/debug', Config.mqtt.prefix + '/status'].includes(topic)) {
|
|
68
|
-
// just ignore my own events
|
|
69
|
-
}
|
|
70
|
-
else if (topic === Config.mqtt.prefix + '/disabled') {
|
|
71
|
-
const value = ['1', 'true', 'TRUE'].includes(payload);
|
|
72
|
-
yield Config.updateDisabled(value);
|
|
73
|
-
if (!value) {
|
|
74
|
-
this.debug('Board not disabled anymore, update with latest message');
|
|
75
|
-
yield this.updateCurrentMessage();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else if (Object.keys(pages).map(id => Config.mqtt.prefix + '/' + id).includes(topic)) {
|
|
79
|
-
const page = pages[topic.substr(Config.mqtt.prefix.length + 1)];
|
|
80
|
-
yield this.renderMessage(page, payload);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
const page = Object.entries(pages)
|
|
84
|
-
.find(([id]) => topic.startsWith(Config.mqtt.prefix + '/' + id + '/'));
|
|
85
|
-
if (!page) {
|
|
86
|
-
this.debug(`Unknown topic ${topic}, I'm sorry`);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const key = topic.substr((Config.mqtt.prefix + '/' + page[0] + '/').length);
|
|
90
|
-
const cache = yield this.pageConfig.get(page[0]);
|
|
91
|
-
const config = page[1].parseConfig(key, payload, cache || {});
|
|
92
|
-
const newConfig = Object.assign(cache || {}, config);
|
|
93
|
-
yield this.pageConfig.set(page[0], newConfig);
|
|
94
|
-
yield this.updateCurrentMessage();
|
|
95
|
-
this.debug(`Update config for page module ${page[0]}: ${JSON.stringify(newConfig, null, ' ')}`);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
updateCurrentMessage() {
|
|
100
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
if (this.currentMessage) {
|
|
102
|
-
yield this.renderMessage(this.currentMessage.page, this.currentMessage.payload);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
renderMessage(page, payload) {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
this.currentMessage = {
|
|
109
|
-
page,
|
|
110
|
-
payload
|
|
111
|
-
};
|
|
112
|
-
const pageEntry = Object.entries(pages).find(([, pageInstance]) => pageInstance === page);
|
|
113
|
-
if (Config.board.disabled || !pageEntry) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
const parsePayload = yield page.parsePayload(payload);
|
|
117
|
-
const config = yield this.pageConfig.get(pageEntry[0]);
|
|
118
|
-
const response = yield page.render(parsePayload, config || {});
|
|
119
|
-
if (response.message) {
|
|
120
|
-
yield this.sendMessage(response.message);
|
|
121
|
-
}
|
|
122
|
-
if (this.currentTimer) {
|
|
123
|
-
clearTimeout(this.currentTimer);
|
|
124
|
-
delete this.currentTimer;
|
|
125
|
-
}
|
|
126
|
-
if (response.validTill) {
|
|
127
|
-
this.debug(`Set timer for ${response.validTill.toString()} to update message`);
|
|
128
|
-
this.currentTimer = setTimeout(() => {
|
|
129
|
-
this.debug('Here I am again, updating the message now…');
|
|
130
|
-
this.renderMessage(page, payload).catch(error => {
|
|
131
|
-
this.debug(`Unable to update page: ${error}`);
|
|
132
|
-
});
|
|
133
|
-
}, response.validTill.getTime() - new Date().getTime());
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
sendMessage(message = new Message()) {
|
|
138
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
const charArray = message.export();
|
|
140
|
-
if (!this.subscriptionIds) {
|
|
141
|
-
const subscriptions = yield this.board.getSubscriptions();
|
|
142
|
-
this.subscriptionIds = subscriptions.map(i => i._id);
|
|
143
|
-
}
|
|
144
|
-
this.debug('Sending Message:\n\n' + message.toString());
|
|
145
|
-
yield Promise.all(this.subscriptionIds.map(id => this.board.postMessage(id, charArray)));
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
1
|
+
import{a}from"../chunk-TNWD7XIG.js";export{a as default};
|
|
149
2
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -14,20 +14,20 @@
|
|
|
14
14
|
"description": "Small script to connect a Vestaboard with my home automation via MQTT.",
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@qiwi/semantic-release-gh-pages-plugin": "^5.2.5",
|
|
17
|
-
"@sebbo2002/semantic-release-docker": "^
|
|
18
|
-
"@semantic-release/changelog": "^6.0.
|
|
17
|
+
"@sebbo2002/semantic-release-docker": "^3.0.0",
|
|
18
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
19
19
|
"@semantic-release/exec": "^6.0.3",
|
|
20
20
|
"@semantic-release/git": "^10.0.1",
|
|
21
|
-
"@semantic-release/npm": "^
|
|
21
|
+
"@semantic-release/npm": "^10.0.3",
|
|
22
22
|
"@types/mocha": "^10.0.1",
|
|
23
|
-
"@types/node": "^
|
|
23
|
+
"@types/node": "^20.2.5",
|
|
24
24
|
"@types/node-fetch": "^3.0.3",
|
|
25
25
|
"@types/ws": "^8.5.4",
|
|
26
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
27
|
-
"@typescript-eslint/parser": "^5.
|
|
28
|
-
"c8": "^7.
|
|
29
|
-
"eslint": "^8.
|
|
30
|
-
"eslint-plugin-jsonc": "^2.
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
|
27
|
+
"@typescript-eslint/parser": "^5.59.8",
|
|
28
|
+
"c8": "^7.14.0",
|
|
29
|
+
"eslint": "^8.41.0",
|
|
30
|
+
"eslint-plugin-jsonc": "^2.8.0",
|
|
31
31
|
"esm": "^3.2.25",
|
|
32
32
|
"license-checker": "^25.0.1",
|
|
33
33
|
"mocha": "^10.2.0",
|
|
@@ -35,25 +35,31 @@
|
|
|
35
35
|
"semantic-release-license": "^1.0.3",
|
|
36
36
|
"source-map-support": "^0.5.21",
|
|
37
37
|
"ts-node": "^10.8.2",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
38
|
+
"tsup": "^6.7.0",
|
|
39
|
+
"typedoc": "^0.24.8",
|
|
40
|
+
"typescript": "^5.1.3"
|
|
40
41
|
},
|
|
41
42
|
"engines": {
|
|
42
|
-
"node": "^
|
|
43
|
+
"node": "^16.0.0 || >=18.0.0"
|
|
44
|
+
},
|
|
45
|
+
"exports": {
|
|
46
|
+
"import": "./dist/lib/index.js",
|
|
47
|
+
"require": "./dist/lib/index.cjs"
|
|
43
48
|
},
|
|
44
|
-
"exports": "./dist/index.js",
|
|
45
49
|
"files": [
|
|
46
50
|
"/dist"
|
|
47
51
|
],
|
|
48
52
|
"homepage": "https://github.com/sebbo2002/vestaboard2mqtt#readme",
|
|
49
53
|
"license": "MIT",
|
|
54
|
+
"main": "./dist/lib/index.cjs",
|
|
55
|
+
"module": "./dist/lib/index.js",
|
|
50
56
|
"name": "@sebbo2002/vestaboard2mqtt",
|
|
51
57
|
"repository": {
|
|
52
58
|
"type": "git",
|
|
53
59
|
"url": "git+https://github.com/sebbo2002/vestaboard2mqtt.git"
|
|
54
60
|
},
|
|
55
61
|
"scripts": {
|
|
56
|
-
"build": "
|
|
62
|
+
"build": "tsup && cp ./dist/lib/index.d.ts ./dist/lib/index.d.cts",
|
|
57
63
|
"build-all": "./.github/workflows/build.sh",
|
|
58
64
|
"coverage": "c8 mocha",
|
|
59
65
|
"develop": "ts-node ./src/bin/start.ts",
|
|
@@ -63,5 +69,5 @@
|
|
|
63
69
|
"test": "mocha"
|
|
64
70
|
},
|
|
65
71
|
"type": "module",
|
|
66
|
-
"version": "
|
|
72
|
+
"version": "4.0.0-develop.1"
|
|
67
73
|
}
|
package/dist/lib/cache.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
type CacheItem = CacheItemObject | CacheValue;
|
|
2
|
-
type CacheItemObject = {
|
|
3
|
-
updated: number;
|
|
4
|
-
value: CacheValue;
|
|
5
|
-
};
|
|
6
|
-
type CacheValue = unknown;
|
|
7
|
-
export default class Cache {
|
|
8
|
-
private static readonly file;
|
|
9
|
-
private readonly namespace;
|
|
10
|
-
private static currentFetch?;
|
|
11
|
-
private static currentData?;
|
|
12
|
-
constructor(namespace: string);
|
|
13
|
-
static fetch(): Promise<void>;
|
|
14
|
-
static fetchFromFile(): Promise<void>;
|
|
15
|
-
static isCacheItemObject(obj: CacheItem): obj is CacheItemObject;
|
|
16
|
-
get<T>(key: string, maxAge?: number): Promise<T | null>;
|
|
17
|
-
set(key: string, value: unknown): Promise<void>;
|
|
18
|
-
delete(key: string): Promise<void>;
|
|
19
|
-
static save(): Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
package/dist/lib/cache.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { join } from 'path';
|
|
11
|
-
import { existsSync } from 'fs';
|
|
12
|
-
import { promises } from 'fs';
|
|
13
|
-
// as node@12 has no 'fs/promises'
|
|
14
|
-
const { readFile, writeFile } = promises;
|
|
15
|
-
export default class Cache {
|
|
16
|
-
constructor(namespace) {
|
|
17
|
-
this.namespace = namespace;
|
|
18
|
-
}
|
|
19
|
-
static fetch() {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
if (this.currentFetch) {
|
|
22
|
-
return this.currentFetch;
|
|
23
|
-
}
|
|
24
|
-
const fetch = this.fetchFromFile();
|
|
25
|
-
this.currentFetch = fetch;
|
|
26
|
-
return fetch;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
static fetchFromFile() {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
if (!existsSync(this.file)) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
const content = yield readFile(this.file, { encoding: 'utf8' });
|
|
36
|
-
this.currentData = JSON.parse(content);
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
console.warn(`Unable to parse cache file: ${error}`);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
static isCacheItemObject(obj) {
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
return typeof obj === 'object' && typeof obj.updated === 'number' && typeof obj.value !== 'undefined';
|
|
47
|
-
}
|
|
48
|
-
get(key, maxAge = 0) {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
yield Cache.fetch();
|
|
51
|
-
if (!Cache.currentData ||
|
|
52
|
-
!Cache.currentData[this.namespace] ||
|
|
53
|
-
!Cache.currentData[this.namespace][key]) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
const item = Cache.currentData[this.namespace][key];
|
|
57
|
-
if (!Cache.isCacheItemObject(item) && maxAge > 0) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
if (!Cache.isCacheItemObject(item)) {
|
|
61
|
-
return item;
|
|
62
|
-
}
|
|
63
|
-
if (maxAge > 0 && new Date().getTime() - item.updated > maxAge) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
return item.value;
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
set(key, value) {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
yield Cache.fetch();
|
|
72
|
-
if (!Cache.currentData) {
|
|
73
|
-
throw new Error('Unable to set value: currentData is empty!');
|
|
74
|
-
}
|
|
75
|
-
Cache.currentData[this.namespace] = Cache.currentData[this.namespace] || {};
|
|
76
|
-
Cache.currentData[this.namespace][key] = {
|
|
77
|
-
updated: new Date().getTime(),
|
|
78
|
-
value
|
|
79
|
-
};
|
|
80
|
-
yield Cache.save().catch(error => {
|
|
81
|
-
console.warn(`Unable to update cache: ${error}`);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
delete(key) {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
if (!Cache.currentData ||
|
|
88
|
-
!Cache.currentData[this.namespace]) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
delete Cache.currentData[this.namespace][key];
|
|
92
|
-
if (Object.keys(Cache.currentData[this.namespace]).length === 0) {
|
|
93
|
-
delete Cache.currentData[this.namespace];
|
|
94
|
-
}
|
|
95
|
-
yield Cache.save().catch(error => {
|
|
96
|
-
console.warn(`Unable to update cache: ${error}`);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
static save() {
|
|
101
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
yield writeFile(this.file, JSON.stringify(this.currentData, null, ' '));
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
Cache.file = join(process.env.HOME || '~', '.vestaboard2mqtt');
|
|
107
|
-
Cache.currentData = {};
|
|
108
|
-
//# sourceMappingURL=cache.js.map
|
package/dist/lib/cache.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/lib/cache.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAC,QAAQ,EAAC,MAAM,IAAI,CAAC;AAQ5B,kCAAkC;AAClC,MAAM,EAAC,QAAQ,EAAE,SAAS,EAAC,GAAG,QAAQ,CAAC;AAEvC,MAAM,CAAC,OAAO,OAAO,KAAK;IAMtB,YAAY,SAAiB;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,MAAM,CAAO,KAAK;;YACd,IAAG,IAAI,CAAC,YAAY,EAAE;gBAClB,OAAO,IAAI,CAAC,YAAY,CAAC;aAC5B;YAED,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YACnC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;YAC1B,OAAO,KAAK,CAAC;QACjB,CAAC;KAAA;IAED,MAAM,CAAO,aAAa;;YACtB,IAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBACvB,OAAO;aACV;YAED,I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C7B,OAAO,CAAC,IAAI,CAAC,2BAA2B,KAAK,EAAE,CAAC,CAAC;YACrD,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;IAED,MAAM,CAAO,IAAI;;YACb,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QAC/E,CAAC;KAAA;;AAzGuB,UAAI,GAAW,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,EAAE,kBAAkB,CAAC,CAAC;AAG1E,iBAAW,GAAe,EAAE,CAAC"}
|
package/dist/lib/config.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export interface ConfigBoardData {
|
|
2
|
-
id: string;
|
|
3
|
-
key: string;
|
|
4
|
-
secret: string;
|
|
5
|
-
disabled: boolean;
|
|
6
|
-
}
|
|
7
|
-
export interface ConfigMQTTData {
|
|
8
|
-
url: string;
|
|
9
|
-
prefix: string;
|
|
10
|
-
}
|
|
11
|
-
export interface ConfigCalendarData {
|
|
12
|
-
urls: Record<string, string>;
|
|
13
|
-
cacheTTL: number;
|
|
14
|
-
}
|
|
15
|
-
export interface ConfigData {
|
|
16
|
-
board: ConfigBoardData;
|
|
17
|
-
mqtt: ConfigMQTTData;
|
|
18
|
-
calendar: ConfigCalendarData;
|
|
19
|
-
}
|
|
20
|
-
export default class Config {
|
|
21
|
-
private static readonly cache;
|
|
22
|
-
private static data?;
|
|
23
|
-
static get loaded(): boolean;
|
|
24
|
-
static get board(): ConfigBoardData;
|
|
25
|
-
static get mqtt(): ConfigMQTTData;
|
|
26
|
-
static get calendar(): ConfigCalendarData;
|
|
27
|
-
static load(): Promise<void>;
|
|
28
|
-
static save(data: ConfigData): Promise<void>;
|
|
29
|
-
static updateDisabled(newValue: boolean): Promise<void>;
|
|
30
|
-
}
|
package/dist/lib/config.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import Cache from './cache.js';
|
|
11
|
-
export default class Config {
|
|
12
|
-
static get loaded() {
|
|
13
|
-
return !!this.data && !!this.cache;
|
|
14
|
-
}
|
|
15
|
-
static get board() {
|
|
16
|
-
var _a;
|
|
17
|
-
if (this.loaded && ((_a = this.data) === null || _a === void 0 ? void 0 : _a.board)) {
|
|
18
|
-
return this.data.board;
|
|
19
|
-
}
|
|
20
|
-
throw new Error('Unable to access board config, is config loaded?');
|
|
21
|
-
}
|
|
22
|
-
static get mqtt() {
|
|
23
|
-
var _a;
|
|
24
|
-
if (this.loaded && ((_a = this.data) === null || _a === void 0 ? void 0 : _a.mqtt)) {
|
|
25
|
-
return this.data.mqtt;
|
|
26
|
-
}
|
|
27
|
-
throw new Error('Unable to access mqtt config, is config loaded?');
|
|
28
|
-
}
|
|
29
|
-
static get calendar() {
|
|
30
|
-
var _a;
|
|
31
|
-
if (this.loaded && ((_a = this.data) === null || _a === void 0 ? void 0 : _a.calendar)) {
|
|
32
|
-
return this.data.calendar;
|
|
33
|
-
}
|
|
34
|
-
throw new Error('Unable to access calendar config, is config loaded?');
|
|
35
|
-
}
|
|
36
|
-
static load() {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
const data = yield this.cache.get('default');
|
|
39
|
-
if (!data) {
|
|
40
|
-
throw new Error('Unable to load configuration, try to run the setup script…');
|
|
41
|
-
}
|
|
42
|
-
this.data = data;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
static save(data) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
this.data = data;
|
|
48
|
-
yield this.cache.set('default', data);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
static updateDisabled(newValue) {
|
|
52
|
-
var _a, _b;
|
|
53
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
if (newValue === ((_a = this.data) === null || _a === void 0 ? void 0 : _a.board.disabled) || !this.loaded || !((_b = this.data) === null || _b === void 0 ? void 0 : _b.mqtt)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
this.data.board.disabled = newValue;
|
|
58
|
-
yield this.save(this.data);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
Config.cache = new Cache('config');
|
|
63
|
-
//# sourceMappingURL=config.js.map
|
package/dist/lib/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAyB/B,MAAM,CAAC,OAAO,OAAO,MAAM;IAIhB,MAAM,KAAK,MAAM;QACpB,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;IACvC,CAAC;IAEM,MAAM,KAAK,KAAK;;QACnB,IAAG,IAAI,CAAC,MAAM,KAAI,MAAA,IAAI,CAAC,IAAI,0CAAE,KAAK,CAAA,EAAE;YAChC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;SAC1B;QAED,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACxE,CAAC;IAEM,MAAM,KAAK,IAAI;;QAClB,IAAG,IAAI,CAAC,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YAAK,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/lib/message.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { BoardCharArray } from 'vestaboard-api/lib/cjs/values.js';
|
|
2
|
-
export declare enum MessageWriteOptionsLine {
|
|
3
|
-
CURRENT = "CURRENT",
|
|
4
|
-
NEXT = "NEXT"
|
|
5
|
-
}
|
|
6
|
-
export interface MessageWriteOptions {
|
|
7
|
-
line?: number | MessageWriteOptionsLine;
|
|
8
|
-
row?: number;
|
|
9
|
-
}
|
|
10
|
-
export interface MessageDrawOptions {
|
|
11
|
-
line?: number;
|
|
12
|
-
}
|
|
13
|
-
export default class Message {
|
|
14
|
-
private board;
|
|
15
|
-
private currentLine;
|
|
16
|
-
private isFilled;
|
|
17
|
-
constructor(board?: BoardCharArray);
|
|
18
|
-
static newBoardCharArray(): BoardCharArray;
|
|
19
|
-
write(text: string, options?: MessageWriteOptions): void;
|
|
20
|
-
static word2chars(word: string): number[];
|
|
21
|
-
static char2char(char: string): number[];
|
|
22
|
-
repeat(char: string, options?: MessageDrawOptions): void;
|
|
23
|
-
centerLines(): void;
|
|
24
|
-
center(): void;
|
|
25
|
-
isEmpty(): boolean;
|
|
26
|
-
toString(): string;
|
|
27
|
-
static charToString(char: number): string;
|
|
28
|
-
export(): BoardCharArray;
|
|
29
|
-
}
|