@cutos/core 3.0.2 → 3.0.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/README.md +5 -6
- package/dist/cutos.cjs.js +28 -9
- package/dist/cutos.esm.js +28 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ CoreAPI.getVersion();
|
|
|
85
85
|
- Return result example:
|
|
86
86
|
|
|
87
87
|
```
|
|
88
|
-
3.0.
|
|
88
|
+
3.0.3
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
### CoreAPI.getPlatform
|
|
@@ -175,10 +175,9 @@ CoreAPI.getBoxInfo(result => {
|
|
|
175
175
|
```json
|
|
176
176
|
{
|
|
177
177
|
"id": 1004,
|
|
178
|
-
"macAddress": "54-48-10-D9-BB-
|
|
178
|
+
"macAddress": "54-48-10-D9-BB-27",
|
|
179
179
|
"ipAddress": "192.168.1.136",
|
|
180
|
-
"masterIpAddress": ""
|
|
181
|
-
"status": 1
|
|
180
|
+
"masterIpAddress": ""
|
|
182
181
|
}
|
|
183
182
|
```
|
|
184
183
|
-Return results:
|
|
@@ -205,7 +204,7 @@ CoreAPI.getVolume(result => {
|
|
|
205
204
|
- Return result example:
|
|
206
205
|
|
|
207
206
|
```js
|
|
208
|
-
|
|
207
|
+
10
|
|
209
208
|
```
|
|
210
209
|
|
|
211
210
|
### CoreAPI.setVolume
|
|
@@ -220,7 +219,7 @@ CoreAPI.setVolume(value,callback)
|
|
|
220
219
|
##### Example:
|
|
221
220
|
|
|
222
221
|
```js
|
|
223
|
-
CoreAPI.setVolume(70,result => {
|
|
222
|
+
CoreAPI.setVolume(70, result => {
|
|
224
223
|
console.log(result)
|
|
225
224
|
})
|
|
226
225
|
```
|
package/dist/cutos.cjs.js
CHANGED
|
@@ -398,7 +398,7 @@ const cutosAPI$2 = {
|
|
|
398
398
|
var cutosApi = cutosAPI$2;
|
|
399
399
|
|
|
400
400
|
var name = "@cutos/core";
|
|
401
|
-
var version = "3.0.
|
|
401
|
+
var version = "3.0.3";
|
|
402
402
|
var description = "The CUTOS (CUT Operating System) Core API is a JavaScript library that provides essential functionalities for LWA (Local Web Application) edge computing and communication in the CUTOS ecosystem. ";
|
|
403
403
|
var main = "dist/cutos.cjs.js";
|
|
404
404
|
var module$1 = "dist/cutos.esm.js";
|
|
@@ -449,7 +449,7 @@ const mqtt = require$$1;
|
|
|
449
449
|
const cutosAPI$1 = cutosApi;
|
|
450
450
|
const callbackMap = new Map();
|
|
451
451
|
const callbackInterval = 500; // 500ms
|
|
452
|
-
const callbackTimeout = 5000; // 5s
|
|
452
|
+
const callbackTimeout = 5000; // 5s
|
|
453
453
|
const listenerMap = new Map();
|
|
454
454
|
const packageJson = require$$3;
|
|
455
455
|
|
|
@@ -458,6 +458,8 @@ const ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|
|
|
|
458
458
|
let client = null;
|
|
459
459
|
let callbackTimer = null;
|
|
460
460
|
let coreApiInitialized = false;
|
|
461
|
+
let _logger = null;
|
|
462
|
+
let _notification = null;
|
|
461
463
|
|
|
462
464
|
function publishRequest(topic, callback, body, destAddress) {
|
|
463
465
|
let request = {};
|
|
@@ -493,7 +495,7 @@ function saveCallback(id, item) {
|
|
|
493
495
|
return;
|
|
494
496
|
}
|
|
495
497
|
|
|
496
|
-
//
|
|
498
|
+
// process timeout callback
|
|
497
499
|
callbackTimer = setInterval(() => {
|
|
498
500
|
let currentTimestamp = new Date().getTime();
|
|
499
501
|
callbackMap.forEach((callbackItem, id) => {
|
|
@@ -934,14 +936,25 @@ class Driver {
|
|
|
934
936
|
}
|
|
935
937
|
|
|
936
938
|
const CoreAPI$2 = {
|
|
937
|
-
init(host = '
|
|
938
|
-
|
|
939
|
-
|
|
939
|
+
init(host = 'localhost', callback) {
|
|
940
|
+
let brokerUrl;
|
|
941
|
+
if (host && host.startsWith('ws://') && host.endsWith(':1883')) {
|
|
942
|
+
brokerUrl = host;
|
|
943
|
+
} else {
|
|
944
|
+
if (!host) {
|
|
945
|
+
host = 'localhost';
|
|
946
|
+
}
|
|
947
|
+
if (host !== 'localhost' && !host.match(ipformat)) {
|
|
948
|
+
throw new Error("invalid host address");
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
brokerUrl = `ws://${host}:1883`;
|
|
940
952
|
}
|
|
953
|
+
|
|
941
954
|
if (callback && typeof (callback) !== 'function') {
|
|
942
955
|
throw new Error("callback must be a function");
|
|
943
956
|
}
|
|
944
|
-
client = mqtt.connect(
|
|
957
|
+
client = mqtt.connect(brokerUrl);
|
|
945
958
|
|
|
946
959
|
client.on('connect', function () {
|
|
947
960
|
console.log("CUTOS CORE connected.");
|
|
@@ -1029,11 +1042,17 @@ const CoreAPI$2 = {
|
|
|
1029
1042
|
},
|
|
1030
1043
|
|
|
1031
1044
|
getNotification() {
|
|
1032
|
-
|
|
1045
|
+
if (!_notification) {
|
|
1046
|
+
_notification = new Notification();
|
|
1047
|
+
}
|
|
1048
|
+
return _notification;
|
|
1033
1049
|
},
|
|
1034
1050
|
|
|
1035
1051
|
getLogger() {
|
|
1036
|
-
|
|
1052
|
+
if (!_logger) {
|
|
1053
|
+
_logger = new Logger();
|
|
1054
|
+
}
|
|
1055
|
+
return _logger;
|
|
1037
1056
|
},
|
|
1038
1057
|
|
|
1039
1058
|
shell(command, callback) {
|
package/dist/cutos.esm.js
CHANGED
|
@@ -690,7 +690,7 @@ const cutosAPI$2 = {
|
|
|
690
690
|
var cutosApi = cutosAPI$2;
|
|
691
691
|
|
|
692
692
|
var name = "@cutos/core";
|
|
693
|
-
var version = "3.0.
|
|
693
|
+
var version = "3.0.3";
|
|
694
694
|
var description = "The CUTOS (CUT Operating System) Core API is a JavaScript library that provides essential functionalities for LWA (Local Web Application) edge computing and communication in the CUTOS ecosystem. ";
|
|
695
695
|
var main = "dist/cutos.cjs.js";
|
|
696
696
|
var module = "dist/cutos.esm.js";
|
|
@@ -741,7 +741,7 @@ const mqtt = require$$1;
|
|
|
741
741
|
const cutosAPI$1 = cutosApi;
|
|
742
742
|
const callbackMap = new Map();
|
|
743
743
|
const callbackInterval = 500; // 500ms
|
|
744
|
-
const callbackTimeout = 5000; // 5s
|
|
744
|
+
const callbackTimeout = 5000; // 5s
|
|
745
745
|
const listenerMap = new Map();
|
|
746
746
|
const packageJson = require$$3;
|
|
747
747
|
|
|
@@ -750,6 +750,8 @@ const ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|
|
|
|
750
750
|
let client = null;
|
|
751
751
|
let callbackTimer = null;
|
|
752
752
|
let coreApiInitialized = false;
|
|
753
|
+
let _logger = null;
|
|
754
|
+
let _notification = null;
|
|
753
755
|
|
|
754
756
|
function publishRequest(topic, callback, body, destAddress) {
|
|
755
757
|
let request = {};
|
|
@@ -785,7 +787,7 @@ function saveCallback(id, item) {
|
|
|
785
787
|
return;
|
|
786
788
|
}
|
|
787
789
|
|
|
788
|
-
//
|
|
790
|
+
// process timeout callback
|
|
789
791
|
callbackTimer = setInterval(() => {
|
|
790
792
|
let currentTimestamp = new Date().getTime();
|
|
791
793
|
callbackMap.forEach((callbackItem, id) => {
|
|
@@ -1226,14 +1228,25 @@ class Driver {
|
|
|
1226
1228
|
}
|
|
1227
1229
|
|
|
1228
1230
|
const CoreAPI$2 = {
|
|
1229
|
-
init(host = '
|
|
1230
|
-
|
|
1231
|
-
|
|
1231
|
+
init(host = 'localhost', callback) {
|
|
1232
|
+
let brokerUrl;
|
|
1233
|
+
if (host && host.startsWith('ws://') && host.endsWith(':1883')) {
|
|
1234
|
+
brokerUrl = host;
|
|
1235
|
+
} else {
|
|
1236
|
+
if (!host) {
|
|
1237
|
+
host = 'localhost';
|
|
1238
|
+
}
|
|
1239
|
+
if (host !== 'localhost' && !host.match(ipformat)) {
|
|
1240
|
+
throw new Error("invalid host address");
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
brokerUrl = `ws://${host}:1883`;
|
|
1232
1244
|
}
|
|
1245
|
+
|
|
1233
1246
|
if (callback && typeof (callback) !== 'function') {
|
|
1234
1247
|
throw new Error("callback must be a function");
|
|
1235
1248
|
}
|
|
1236
|
-
client = mqtt.connect(
|
|
1249
|
+
client = mqtt.connect(brokerUrl);
|
|
1237
1250
|
|
|
1238
1251
|
client.on('connect', function () {
|
|
1239
1252
|
console.log("CUTOS CORE connected.");
|
|
@@ -1321,11 +1334,17 @@ const CoreAPI$2 = {
|
|
|
1321
1334
|
},
|
|
1322
1335
|
|
|
1323
1336
|
getNotification() {
|
|
1324
|
-
|
|
1337
|
+
if (!_notification) {
|
|
1338
|
+
_notification = new Notification();
|
|
1339
|
+
}
|
|
1340
|
+
return _notification;
|
|
1325
1341
|
},
|
|
1326
1342
|
|
|
1327
1343
|
getLogger() {
|
|
1328
|
-
|
|
1344
|
+
if (!_logger) {
|
|
1345
|
+
_logger = new Logger();
|
|
1346
|
+
}
|
|
1347
|
+
return _logger;
|
|
1329
1348
|
},
|
|
1330
1349
|
|
|
1331
1350
|
shell(command, callback) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cutos/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "The CUTOS (CUT Operating System) Core API is a JavaScript library that provides essential functionalities for LWA (Local Web Application) edge computing and communication in the CUTOS ecosystem. ",
|
|
5
5
|
"main": "dist/cutos.cjs.js",
|
|
6
6
|
"module": "dist/cutos.esm.js",
|