@cutos/core 3.2.6 → 3.2.8

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 CHANGED
@@ -112,7 +112,7 @@ CoreAPI.getVersion();
112
112
  - Return result example:
113
113
 
114
114
  ```
115
- "3.2.6"
115
+ "3.2.8"
116
116
  ```
117
117
 
118
118
  ### CoreAPI.getPlatform
@@ -400,6 +400,18 @@ let ipc = CoreAPI.getIPC([destAddress]);
400
400
 
401
401
  ![ipc](https://oss.cut-os.com/resources/developer/images/ipc.jpg)
402
402
 
403
+ ### ipc.sendTo
404
+
405
+ Send IPC information
406
+
407
+ ```js
408
+ ipc.sendTo(channel, args, callback = null);
409
+ ```
410
+
411
+ * channel: channel name
412
+ * args: information to send
413
+ * callback: callback function
414
+
403
415
  ### ipc.on
404
416
 
405
417
  Listen IPC
@@ -409,18 +421,19 @@ ipc.on(channel, listener);
409
421
  ```
410
422
 
411
423
  * channel: channel name
412
- * listener: listener function (data)
424
+ * listener: listener function (args, context)
413
425
 
414
- ### ipc.sendTo
426
+ ### ipc.sendResponse
415
427
 
416
- Send IPC information
428
+ The receiver replies to the message
417
429
 
418
430
  ```js
419
- ipc.sendTo(channel, data);
431
+ ipc.sendResponse(context, result, error = null);
420
432
  ```
421
433
 
422
- * channel: channel name
423
- * data: sent information
434
+ * context: context information
435
+ * result: reply message content
436
+ * error: error message
424
437
 
425
438
  ##### Local device communication example:
426
439
 
@@ -430,11 +443,10 @@ import {CoreAPI} from '@cutos/core';
430
443
  CoreAPI.init();
431
444
 
432
445
  let ipc = CoreAPI.getIPC();
433
- //Listen for IPC information
434
- let ipcListener = function (data) {
435
- console.log(data);
436
- };
437
- ipc.on("channel-1", ipcListener);
446
+ //Listen to IPC information
447
+ ipc.on("channel-1", function (args, context) {
448
+ console.log(args);
449
+ });
438
450
  //Send IPC information
439
451
  ipc.sendTo("channel-1", {event: "event-1", msg: "msg-1"});
440
452
  ```
@@ -450,29 +462,51 @@ ipc.sendTo("channel-1", {event: "event-1", msg: "msg-1"});
450
462
 
451
463
  ##### Example of inter-device process communication:
452
464
 
465
+ ##### Sender
466
+ IP:192.168.1.136
453
467
  ```js
454
468
  import {CoreAPI} from '@cutos/core';
455
469
 
456
470
  CoreAPI.init();
457
-
471
+ //Destination IP:192.168.1.149
458
472
  let ipc = CoreAPI.getIPC("192.168.1.149");
473
+ //Send IPC information
474
+ ipc.sendTo("channel-2", {event: "event-2", msg: "msg-2"}, (result, error) => {
475
+ if (!error) {
476
+ console.log(result)
477
+ }
478
+ });
479
+ ```
480
+ - Return result example:
481
+
482
+ ```json
483
+ "Received"
484
+ ```
485
+
486
+ ##### Receiver
487
+ IP:192.168.1.149
488
+ ```js
489
+ import {CoreAPI} from '@cutos/core';
490
+
491
+ CoreAPI.init();
492
+ //Target IP:192.168.1.136
493
+ let ipc = CoreAPI.getIPC("192.168.1.136");
459
494
  //Listen for IPC information
460
- let ipcListener = function (data) {
461
- console.log(data);
495
+ let ipcListener = function (args, context) {
496
+ console.log(args);
497
+ ipc.sendResponse(context, "Received");
462
498
  }
463
499
  ipc.on("channel-2", ipcListener);
464
- //Send IPC information
465
- ipc.sendTo("channel-2", {event: "event-2", msg: "msg-2"});
466
500
  ```
467
501
 
468
502
  - Return result example:
469
503
 
470
504
  ```json
471
505
  {
472
- "event": "event-2",
473
- "msg": "msg-2"
506
+ "event": "event-2",
507
+ "msg": "msg-2"
474
508
  }
475
- ```
509
+ ```
476
510
 
477
511
 
478
512
  # Database API
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.2.6";
401
+ var version = "3.2.8";
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";
@@ -445,7 +445,7 @@ var require$$3 = {
445
445
  };
446
446
 
447
447
  /**
448
- * Copyright (C) 2010-2023 - SipTimes Technologies Corporation - All rights reserved.
448
+ * Copyright (C) 2010-2024 - SipTimes Technologies Corporation - All rights reserved.
449
449
  */
450
450
 
451
451
  const {v4: uuidv4} = require$$0;
@@ -456,6 +456,7 @@ const callbackMap = new Map();
456
456
  const callbackInterval = 500; // 500ms
457
457
  const callbackTimeout = 5000; // 5s
458
458
  const listenerMap = new Map();
459
+ const ipcListenerMap = new Map();
459
460
  const packageJson = require$$3;
460
461
 
461
462
  const ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
@@ -527,18 +528,26 @@ function doCallback(id, body, err) {
527
528
  return true;
528
529
  }
529
530
 
531
+ /**
532
+ * @Database
533
+ * The basic table structure of CUTOS database is in Key-Value format, and Value can be any json object.
534
+ */
530
535
  class Database {
531
536
  KEY_TYPE_TEXT = "TEXT";
532
537
  KEY_TYPE_INTEGER = "INTEGER";
533
538
 
534
539
  /**
535
540
  * The constructor of Database
536
- * @param {string} db - name of database, can be null
541
+ * @param {String} [db] - name of database, can be null
537
542
  */
538
543
  constructor(db) {
539
544
  this.db = db;
540
545
  }
541
546
 
547
+ /**
548
+ * Connect to database
549
+ * @param {Function} callback
550
+ */
542
551
  connect(callback) {
543
552
  let body = {
544
553
  cmd: "db.connect", db: this.db
@@ -546,6 +555,11 @@ class Database {
546
555
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
547
556
  }
548
557
 
558
+ /**
559
+ * Run sql
560
+ * @param {String} sql - execute sql statement
561
+ * @param {Function} callback
562
+ */
549
563
  run(sql, callback) {
550
564
  let body = {
551
565
  db: this.db, cmd: "db.run", sql: sql
@@ -559,6 +573,12 @@ class Database {
559
573
  }
560
574
 
561
575
  Database.Table = class {
576
+
577
+ /**
578
+ * @constructor The constructor of Table
579
+ * @param {String} name - name of table, can not be null
580
+ * @param {Object} database - database object, can not be null
581
+ */
562
582
  constructor(name, database) {
563
583
  this.name = name;
564
584
  this.database = database;
@@ -569,6 +589,11 @@ Database.Table = class {
569
589
  }
570
590
  }
571
591
 
592
+ /**
593
+ * Create a Table
594
+ * @param {Object} [opts]
595
+ * @param {Function} callback
596
+ */
572
597
  create(opts, callback) {
573
598
  if (typeof opts === "function") {
574
599
  callback = opts;
@@ -594,6 +619,12 @@ Database.Table = class {
594
619
  this.publishRequestMirror(cutosAPI$1.CORE.DATABASE, callback, body);
595
620
  }
596
621
 
622
+ /**
623
+ * Insert data
624
+ * @param {Object} value
625
+ * @param {Object} [opts]
626
+ * @param {Function} callback
627
+ */
597
628
  insert(value, opts, callback) {
598
629
  if (typeof opts === "function") {
599
630
  callback = opts;
@@ -618,6 +649,13 @@ Database.Table = class {
618
649
  this.publishRequestMirror(cutosAPI$1.CORE.DATABASE, callback, body);
619
650
  }
620
651
 
652
+ /**
653
+ * Insert data by key
654
+ * @param {String} key
655
+ * @param {Object} value
656
+ * @param {Object} [opts] - opts.tid - if exist it contains tid
657
+ * @param {Function} callback
658
+ */
621
659
  insertByKey(key, value, opts, callback) {
622
660
  if (typeof opts === "function") {
623
661
  callback = opts;
@@ -630,6 +668,12 @@ Database.Table = class {
630
668
  this.publishRequestMirror(cutosAPI$1.CORE.DATABASE, callback, body);
631
669
  }
632
670
 
671
+ /**
672
+ * Update data
673
+ * @param {Number} id
674
+ * @param {Object} value
675
+ * @param {Function} callback
676
+ */
633
677
  update(id, value, callback) {
634
678
  let body = {
635
679
  db: this.db, cmd: "db.table.update", name: this.name, id: id, value: value
@@ -644,6 +688,11 @@ Database.Table = class {
644
688
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
645
689
  }
646
690
 
691
+ /**
692
+ * delete data
693
+ * @param {Number} id
694
+ * @param {Function} callback
695
+ */
647
696
  delete(id, callback) {
648
697
  let body = {
649
698
  db: this.db, cmd: "db.table.delete", name: this.name, id: id
@@ -651,6 +700,11 @@ Database.Table = class {
651
700
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
652
701
  }
653
702
 
703
+ /**
704
+ * query data
705
+ * @param {Number} id
706
+ * @param {Function} callback
707
+ */
654
708
  query(id, callback) {
655
709
  let body = {
656
710
  db: this.db, cmd: "db.table.query", name: this.name, id: id
@@ -658,6 +712,11 @@ Database.Table = class {
658
712
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
659
713
  }
660
714
 
715
+ /**
716
+ * query data by key
717
+ * @param {String} key
718
+ * @param {Function} callback
719
+ */
661
720
  queryByKey(key, callback) {
662
721
  let body = {
663
722
  db: this.db, cmd: "db.table.queryByKey", name: this.name, key: key
@@ -665,6 +724,11 @@ Database.Table = class {
665
724
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
666
725
  }
667
726
 
727
+ /**
728
+ * query data by tid
729
+ * @param {Number} tid
730
+ * @param {Function} callback
731
+ */
668
732
  queryByTid(tid, callback) {
669
733
  let body = {
670
734
  db: this.db, cmd: "db.table.queryByTid", name: this.name, tid: tid
@@ -672,6 +736,11 @@ Database.Table = class {
672
736
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
673
737
  }
674
738
 
739
+ /**
740
+ * query unsynced data by tid
741
+ * @param {Number} tid
742
+ * @param {Function} callback
743
+ */
675
744
  queryUnsynced(opts, callback) {
676
745
  if (typeof opts === "function") {
677
746
  callback = opts;
@@ -686,6 +755,10 @@ Database.Table = class {
686
755
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
687
756
  }
688
757
 
758
+ /**
759
+ * query all data
760
+ * @param {Function} callback
761
+ */
689
762
  queryAll(callback) {
690
763
  let body = {
691
764
  db: this.db, cmd: "db.table.queryAll", name: this.name
@@ -693,6 +766,11 @@ Database.Table = class {
693
766
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
694
767
  }
695
768
 
769
+ /**
770
+ * sync data
771
+ * @param {Number} id
772
+ * @param {Function} callback
773
+ */
696
774
  sync(id, callback) {
697
775
  let body = {
698
776
  db: this.db, cmd: "db.table.sync", name: this.name, id: id
@@ -733,9 +811,19 @@ Database.Table = class {
733
811
  };
734
812
 
735
813
  class Logger {
814
+
815
+ /**
816
+ * The constructor of logger
817
+ */
736
818
  constructor() {
737
819
  }
738
820
 
821
+ /**
822
+ * Information
823
+ * @param {String} remark
824
+ * @param {String} content
825
+ * @param {String} type
826
+ */
739
827
  info(remark, content, type = "LWA") {
740
828
  let body = {
741
829
  type: type, level: "info", remark: remark, content: content
@@ -743,6 +831,12 @@ class Logger {
743
831
  return publishRequest(cutosAPI$1.CORE_NORESP.LOGGER, null, body);
744
832
  }
745
833
 
834
+ /**
835
+ * Warning
836
+ * @param {String} remark
837
+ * @param {String} content
838
+ * @param {String} type
839
+ */
746
840
  warning(remark, content, type = "LWA") {
747
841
  let body = {
748
842
  type: type, level: "warning", remark: remark, content: content
@@ -750,6 +844,12 @@ class Logger {
750
844
  return publishRequest(cutosAPI$1.CORE_NORESP.LOGGER, null, body);
751
845
  }
752
846
 
847
+ /**
848
+ * Error
849
+ * @param {String} remark
850
+ * @param {String} content
851
+ * @param {String} type
852
+ */
753
853
  error(remark, content, type = "LWA") {
754
854
  let body = {
755
855
  type: type, level: "error", remark: remark, content: content
@@ -757,6 +857,12 @@ class Logger {
757
857
  return publishRequest(cutosAPI$1.CORE_NORESP.LOGGER, null, body);
758
858
  }
759
859
 
860
+ /**
861
+ * Debug
862
+ * @param {String} remark
863
+ * @param {String} content
864
+ * @param {String} type
865
+ */
760
866
  debug(remark, content, type = "LWA") {
761
867
  let body = {
762
868
  type: type, level: "debug", remark: remark, content: content
@@ -776,34 +882,90 @@ class IPC {
776
882
  }
777
883
  }
778
884
 
779
- sendTo(channel, args) {
885
+ /**
886
+ * send message to channel
887
+ * @param channel
888
+ * @param args
889
+ * @param callback (result, error):void
890
+ * @returns {boolean}
891
+ */
892
+ sendTo(channel, args, callback = null) {
780
893
  let body = {};
781
894
  body.channel = channel;
782
895
  body.args = args;
783
- return publishRequest(cutosAPI$1.CORE_NORESP.IPC, null, body, this.destAddress);
896
+ let topic = cutosAPI$1.CORE_NORESP.IPC + (this.destAddress ? "" : "-endpoint");
897
+ return publishRequest(topic, callback, body, this.destAddress);
898
+ }
899
+
900
+ /**
901
+ * 发送需要callback的消息的响应
902
+ * @param context listener收到的context
903
+ * @param result
904
+ * @param error
905
+ */
906
+ sendResponse(context, result, error = null) {
907
+ let response = {};
908
+ response.context = {};
909
+ response.context.destAddress = context.sourceAddress;
910
+ response.id = context.id;
911
+ response.result = result;
912
+ response.err = error;
913
+ let topic = cutosAPI$1.CORE_NORESP.IPC + (this.destAddress ? "" : "-endpoint");
914
+ client.publish(topic, JSON.stringify(response));
784
915
  }
785
916
 
917
+ /**
918
+ * Listen IPC form channel
919
+ * @param channel
920
+ * @param listener (args, context) the context use when sendResponse
921
+ */
786
922
  on(channel, listener) {
787
- listenerMap.set(channel, listener);
923
+ if (!ipcListenerMap.has(channel)) {
924
+ ipcListenerMap.set(channel, []);
925
+ }
926
+ ipcListenerMap.get(channel).push(listener);
788
927
  }
789
928
 
790
- removeListener(channel) {
791
- listenerMap.delete(channel);
929
+ removeListener(channel, listener = null) {
930
+ if (!ipcListenerMap.has(channel)) {
931
+ return;
932
+ }
933
+ if (!listener) {
934
+ ipcListenerMap.delete(channel);
935
+ } else {
936
+ ipcListenerMap.has(channel).indexOf(listener) > -1 && ipcListenerMap.get(channel).splice(ipcListenerMap.get(channel).indexOf(listener), 1);
937
+ }
792
938
  }
793
939
  }
794
940
 
795
941
  class Notification {
942
+
943
+ /**
944
+ * The constructor of Notification
945
+ */
796
946
  constructor() {
797
947
  }
798
948
 
949
+ /**
950
+ * Register notification listener function
951
+ * @param {Function} listener - listener function (data)
952
+ */
799
953
  register(listener) {
800
954
  listenerMap.set(cutosAPI$1.CORE_APP.NOTIFICATION, listener);
801
955
  }
802
956
 
957
+ /**
958
+ * Unregister, used to cancel the registration of notification
959
+ */
803
960
  unregister() {
804
961
  listenerMap.delete(cutosAPI$1.CORE_APP.NOTIFICATION);
805
962
  }
806
963
 
964
+ /**
965
+ * Cancel registration, used to cancel the registration of notification
966
+ * @param {String} event - event name
967
+ * @param {String} msg - event content
968
+ */
807
969
  emit(event, msg) {
808
970
  client.publish(cutosAPI$1.CORE_APP.NOTIFICATION, JSON.stringify({event: event, msg: msg}));
809
971
  return true;
@@ -844,7 +1006,7 @@ class Heartbeat {
844
1006
 
845
1007
  class Device {
846
1008
  /**
847
- *
1009
+ * The constructor of Device
848
1010
  * @param name
849
1011
  * @param type
850
1012
  */
@@ -880,7 +1042,7 @@ class Device {
880
1042
  }
881
1043
 
882
1044
  /**
883
- *
1045
+ * Device initialize
884
1046
  * @param callback(result, error)
885
1047
  * @param opts
886
1048
  */
@@ -908,10 +1070,18 @@ class Device {
908
1070
  });
909
1071
  }
910
1072
 
1073
+ /**
1074
+ * Get device status
1075
+ * @param {Function} listener
1076
+ */
911
1077
  onStatus(listener) {
912
1078
  this.statusListener = listener;
913
1079
  }
914
1080
 
1081
+ /**
1082
+ * Get device status
1083
+ * @param {Function} listener
1084
+ */
915
1085
  getCurrentStatus() {
916
1086
  return this.msg;
917
1087
  }
@@ -926,6 +1096,10 @@ class Device {
926
1096
  publishRequest(this.topicCommand, callback, command);
927
1097
  }
928
1098
 
1099
+ /**
1100
+ * Receive data sent by the driver
1101
+ * @param listener - listener(data)
1102
+ */
929
1103
  onData(listener) {
930
1104
  if (!listenerMap.has(this.topicData)) {
931
1105
  client.subscribe(this.topicData); // receive data from device
@@ -953,6 +1127,13 @@ class Device {
953
1127
  }
954
1128
 
955
1129
  class Driver {
1130
+
1131
+ /**
1132
+ * The constructor of Driver
1133
+ * @param name
1134
+ * @param type
1135
+ * @param counter
1136
+ */
956
1137
  constructor(name = 'default-driver-name', type = cutosAPI$1.DEVICE.DEFAULT, counter = 10) {
957
1138
  this.name = name;
958
1139
  this.type = type;
@@ -979,6 +1160,10 @@ class Driver {
979
1160
  this.statusInfo.info = info;
980
1161
  }
981
1162
 
1163
+ /**
1164
+ * Send data to the device
1165
+ * @param data
1166
+ */
982
1167
  sendData(data) {
983
1168
  client.publish(this.topicData, JSON.stringify(data));
984
1169
  }
@@ -988,7 +1173,7 @@ class Driver {
988
1173
  }
989
1174
 
990
1175
  /**
991
- *
1176
+ * Receive device commands
992
1177
  * @param listener(command, callback(result))
993
1178
  */
994
1179
  onCommand(listener) {
@@ -1017,6 +1202,11 @@ class CutosError {
1017
1202
  }
1018
1203
 
1019
1204
  const CoreAPI$2 = {
1205
+ /**
1206
+ * Initialization of CUTOS core
1207
+ * @param {string} host CUTOS address.When host is equal to null, it takes the value 'localhost'. During development, it can be changed to the target address (the device address where CUTOS is installed), such as: '192.168.1.11'
1208
+ * @param {Function} callback callback(result, error)
1209
+ */
1020
1210
  init(host = 'localhost', callback) {
1021
1211
  let brokerUrl;
1022
1212
  if (host && host.startsWith('ws://') && host.endsWith(':1883')) {
@@ -1058,9 +1248,16 @@ const CoreAPI$2 = {
1058
1248
  // console.debug(topic.toString() + message.toString());
1059
1249
  let _message = JSON.parse(message);
1060
1250
  if (topic === cutosAPI$1.CORE_NORESP.IPC + '-endpoint') { // ipc
1061
- let listener = listenerMap.get(_message.body.channel);
1062
- if (listener !== undefined) {
1063
- listener(_message.body.args, _message.context);
1251
+ // process response message
1252
+ if (_message.id) {
1253
+ doCallback(_message.id, _message.result, _message.err);
1254
+ return
1255
+ }
1256
+ let listenerArray = ipcListenerMap.get(_message.body.channel);
1257
+ if (listenerArray) {
1258
+ for (const listener of listenerArray) {
1259
+ listener(_message.body.args, _message.context);
1260
+ }
1064
1261
  }
1065
1262
  } else if (topic === cutosAPI$1.CORE_APP.NOTIFICATION || topic === cutosAPI$1.CORE_APP.HEARTBEAT_LISTENER
1066
1263
  || topic.startsWith(cutosAPI$1.DEVICE.CHANNEL) && !topic.endsWith('-callback')) {
@@ -1091,26 +1288,49 @@ const CoreAPI$2 = {
1091
1288
  return !!client && client.connected;
1092
1289
  },
1093
1290
 
1291
+ /**
1292
+ * Get platform version information
1293
+ */
1094
1294
  getVersion() {
1095
1295
  return packageJson.version ;
1096
1296
  },
1097
1297
 
1298
+ /**
1299
+ * Get platform information
1300
+ * @param {Function} callback - callback(result)
1301
+ */
1098
1302
  getPlatform(callback) {
1099
1303
  return publishRequest(cutosAPI$1.CORE.PLATFORM, callback);
1100
1304
  },
1101
1305
 
1306
+ /**
1307
+ * Get configuration information
1308
+ * @param {Function} callback - callback(result)
1309
+ */
1102
1310
  getConfig(callback) {
1103
1311
  return publishRequest(cutosAPI$1.CORE.CONFIG, callback);
1104
1312
  },
1105
1313
 
1314
+ /**
1315
+ * Get host information
1316
+ * @param {Function} callback - callback(result)
1317
+ */
1106
1318
  getBoxInfo(callback) {
1107
1319
  return publishRequest(cutosAPI$1.CORE.BOX_INFO, callback);
1108
1320
  },
1109
1321
 
1322
+ /**
1323
+ * Get sign information
1324
+ * @param {Function} callback - callback(result)
1325
+ */
1110
1326
  getSignInfo(callback) {
1111
1327
  return publishRequest(cutosAPI$1.CORE.SIGN_INFO, callback);
1112
1328
  },
1113
1329
 
1330
+ /**
1331
+ * Get device information
1332
+ * @param {Function} callback - callback(result)
1333
+ */
1114
1334
  getDeviceInfo(callback) {
1115
1335
  return publishRequest(cutosAPI$1.CORE.DEVICE_INFO, callback);
1116
1336
  },
@@ -1119,10 +1339,17 @@ const CoreAPI$2 = {
1119
1339
  return publishRequest(cutosAPI$1.CORE.SIGN_GROUP_INFO, callback);
1120
1340
  },
1121
1341
 
1342
+ /**
1343
+ * Get IPC instance object
1344
+ * @param {String} destAddress - optional parameter, target IP address, used for inter-device process communication
1345
+ */
1122
1346
  getIPC(destAddress) {
1123
1347
  return new IPC(destAddress);
1124
1348
  },
1125
1349
 
1350
+ /**
1351
+ * Get notification information instance object
1352
+ */
1126
1353
  getNotification() {
1127
1354
  if (!_notification) {
1128
1355
  _notification = new Notification();
@@ -1130,6 +1357,9 @@ const CoreAPI$2 = {
1130
1357
  return _notification;
1131
1358
  },
1132
1359
 
1360
+ /**
1361
+ * Get the log instance object
1362
+ */
1133
1363
  getLogger() {
1134
1364
  if (!_logger) {
1135
1365
  _logger = new Logger();
@@ -1137,18 +1367,38 @@ const CoreAPI$2 = {
1137
1367
  return _logger;
1138
1368
  },
1139
1369
 
1370
+ /**
1371
+ * Shell command execution
1372
+ * @param {String} command - command
1373
+ * @param {Function} callback - callback(result, error)
1374
+ */
1140
1375
  shell(command, callback) {
1141
1376
  return publishRequest(cutosAPI$1.CORE.SHELL, callback, command);
1142
1377
  },
1143
1378
 
1379
+ /**
1380
+ * Get the volume
1381
+ * @param {Function} callback - callback(result)
1382
+ */
1144
1383
  getVolume(callback) {
1145
1384
  return publishRequest(cutosAPI$1.CORE.GET_VOLUME, callback);
1146
1385
  },
1147
1386
 
1387
+ /**
1388
+ * Set the volume
1389
+ * @param {Number} vol - volume:[0-100]
1390
+ * @param {Function} callback - callback(result)
1391
+ */
1148
1392
  setVolume(vol, callback) {
1149
1393
  return publishRequest(cutosAPI$1.CORE.SET_VOLUME, callback, vol);
1150
1394
  },
1151
1395
 
1396
+ /**
1397
+ * Set proxy to solve LWA cross-domain problem
1398
+ * @param {String} api - interface name
1399
+ * @param {String} target - target address
1400
+ * @param {Function} callback - callback(result, error)
1401
+ */
1152
1402
  setHttpProxy(api, target, callback) {
1153
1403
  return publishRequest(cutosAPI$1.CORE.SET_HTTP_PROXY, callback, {api, target});
1154
1404
  }
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.2.6";
693
+ var version = "3.2.8";
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";
@@ -737,7 +737,7 @@ var require$$3 = {
737
737
  };
738
738
 
739
739
  /**
740
- * Copyright (C) 2010-2023 - SipTimes Technologies Corporation - All rights reserved.
740
+ * Copyright (C) 2010-2024 - SipTimes Technologies Corporation - All rights reserved.
741
741
  */
742
742
 
743
743
  const {v4: uuidv4} = require$$0;
@@ -748,6 +748,7 @@ const callbackMap = new Map();
748
748
  const callbackInterval = 500; // 500ms
749
749
  const callbackTimeout = 5000; // 5s
750
750
  const listenerMap = new Map();
751
+ const ipcListenerMap = new Map();
751
752
  const packageJson = require$$3;
752
753
 
753
754
  const ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
@@ -819,18 +820,26 @@ function doCallback(id, body, err) {
819
820
  return true;
820
821
  }
821
822
 
823
+ /**
824
+ * @Database
825
+ * The basic table structure of CUTOS database is in Key-Value format, and Value can be any json object.
826
+ */
822
827
  class Database {
823
828
  KEY_TYPE_TEXT = "TEXT";
824
829
  KEY_TYPE_INTEGER = "INTEGER";
825
830
 
826
831
  /**
827
832
  * The constructor of Database
828
- * @param {string} db - name of database, can be null
833
+ * @param {String} [db] - name of database, can be null
829
834
  */
830
835
  constructor(db) {
831
836
  this.db = db;
832
837
  }
833
838
 
839
+ /**
840
+ * Connect to database
841
+ * @param {Function} callback
842
+ */
834
843
  connect(callback) {
835
844
  let body = {
836
845
  cmd: "db.connect", db: this.db
@@ -838,6 +847,11 @@ class Database {
838
847
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
839
848
  }
840
849
 
850
+ /**
851
+ * Run sql
852
+ * @param {String} sql - execute sql statement
853
+ * @param {Function} callback
854
+ */
841
855
  run(sql, callback) {
842
856
  let body = {
843
857
  db: this.db, cmd: "db.run", sql: sql
@@ -851,6 +865,12 @@ class Database {
851
865
  }
852
866
 
853
867
  Database.Table = class {
868
+
869
+ /**
870
+ * @constructor The constructor of Table
871
+ * @param {String} name - name of table, can not be null
872
+ * @param {Object} database - database object, can not be null
873
+ */
854
874
  constructor(name, database) {
855
875
  this.name = name;
856
876
  this.database = database;
@@ -861,6 +881,11 @@ Database.Table = class {
861
881
  }
862
882
  }
863
883
 
884
+ /**
885
+ * Create a Table
886
+ * @param {Object} [opts]
887
+ * @param {Function} callback
888
+ */
864
889
  create(opts, callback) {
865
890
  if (typeof opts === "function") {
866
891
  callback = opts;
@@ -886,6 +911,12 @@ Database.Table = class {
886
911
  this.publishRequestMirror(cutosAPI$1.CORE.DATABASE, callback, body);
887
912
  }
888
913
 
914
+ /**
915
+ * Insert data
916
+ * @param {Object} value
917
+ * @param {Object} [opts]
918
+ * @param {Function} callback
919
+ */
889
920
  insert(value, opts, callback) {
890
921
  if (typeof opts === "function") {
891
922
  callback = opts;
@@ -910,6 +941,13 @@ Database.Table = class {
910
941
  this.publishRequestMirror(cutosAPI$1.CORE.DATABASE, callback, body);
911
942
  }
912
943
 
944
+ /**
945
+ * Insert data by key
946
+ * @param {String} key
947
+ * @param {Object} value
948
+ * @param {Object} [opts] - opts.tid - if exist it contains tid
949
+ * @param {Function} callback
950
+ */
913
951
  insertByKey(key, value, opts, callback) {
914
952
  if (typeof opts === "function") {
915
953
  callback = opts;
@@ -922,6 +960,12 @@ Database.Table = class {
922
960
  this.publishRequestMirror(cutosAPI$1.CORE.DATABASE, callback, body);
923
961
  }
924
962
 
963
+ /**
964
+ * Update data
965
+ * @param {Number} id
966
+ * @param {Object} value
967
+ * @param {Function} callback
968
+ */
925
969
  update(id, value, callback) {
926
970
  let body = {
927
971
  db: this.db, cmd: "db.table.update", name: this.name, id: id, value: value
@@ -936,6 +980,11 @@ Database.Table = class {
936
980
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
937
981
  }
938
982
 
983
+ /**
984
+ * delete data
985
+ * @param {Number} id
986
+ * @param {Function} callback
987
+ */
939
988
  delete(id, callback) {
940
989
  let body = {
941
990
  db: this.db, cmd: "db.table.delete", name: this.name, id: id
@@ -943,6 +992,11 @@ Database.Table = class {
943
992
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
944
993
  }
945
994
 
995
+ /**
996
+ * query data
997
+ * @param {Number} id
998
+ * @param {Function} callback
999
+ */
946
1000
  query(id, callback) {
947
1001
  let body = {
948
1002
  db: this.db, cmd: "db.table.query", name: this.name, id: id
@@ -950,6 +1004,11 @@ Database.Table = class {
950
1004
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
951
1005
  }
952
1006
 
1007
+ /**
1008
+ * query data by key
1009
+ * @param {String} key
1010
+ * @param {Function} callback
1011
+ */
953
1012
  queryByKey(key, callback) {
954
1013
  let body = {
955
1014
  db: this.db, cmd: "db.table.queryByKey", name: this.name, key: key
@@ -957,6 +1016,11 @@ Database.Table = class {
957
1016
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
958
1017
  }
959
1018
 
1019
+ /**
1020
+ * query data by tid
1021
+ * @param {Number} tid
1022
+ * @param {Function} callback
1023
+ */
960
1024
  queryByTid(tid, callback) {
961
1025
  let body = {
962
1026
  db: this.db, cmd: "db.table.queryByTid", name: this.name, tid: tid
@@ -964,6 +1028,11 @@ Database.Table = class {
964
1028
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
965
1029
  }
966
1030
 
1031
+ /**
1032
+ * query unsynced data by tid
1033
+ * @param {Number} tid
1034
+ * @param {Function} callback
1035
+ */
967
1036
  queryUnsynced(opts, callback) {
968
1037
  if (typeof opts === "function") {
969
1038
  callback = opts;
@@ -978,6 +1047,10 @@ Database.Table = class {
978
1047
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
979
1048
  }
980
1049
 
1050
+ /**
1051
+ * query all data
1052
+ * @param {Function} callback
1053
+ */
981
1054
  queryAll(callback) {
982
1055
  let body = {
983
1056
  db: this.db, cmd: "db.table.queryAll", name: this.name
@@ -985,6 +1058,11 @@ Database.Table = class {
985
1058
  publishRequest(cutosAPI$1.CORE.DATABASE, callback, body);
986
1059
  }
987
1060
 
1061
+ /**
1062
+ * sync data
1063
+ * @param {Number} id
1064
+ * @param {Function} callback
1065
+ */
988
1066
  sync(id, callback) {
989
1067
  let body = {
990
1068
  db: this.db, cmd: "db.table.sync", name: this.name, id: id
@@ -1025,9 +1103,19 @@ Database.Table = class {
1025
1103
  };
1026
1104
 
1027
1105
  class Logger {
1106
+
1107
+ /**
1108
+ * The constructor of logger
1109
+ */
1028
1110
  constructor() {
1029
1111
  }
1030
1112
 
1113
+ /**
1114
+ * Information
1115
+ * @param {String} remark
1116
+ * @param {String} content
1117
+ * @param {String} type
1118
+ */
1031
1119
  info(remark, content, type = "LWA") {
1032
1120
  let body = {
1033
1121
  type: type, level: "info", remark: remark, content: content
@@ -1035,6 +1123,12 @@ class Logger {
1035
1123
  return publishRequest(cutosAPI$1.CORE_NORESP.LOGGER, null, body);
1036
1124
  }
1037
1125
 
1126
+ /**
1127
+ * Warning
1128
+ * @param {String} remark
1129
+ * @param {String} content
1130
+ * @param {String} type
1131
+ */
1038
1132
  warning(remark, content, type = "LWA") {
1039
1133
  let body = {
1040
1134
  type: type, level: "warning", remark: remark, content: content
@@ -1042,6 +1136,12 @@ class Logger {
1042
1136
  return publishRequest(cutosAPI$1.CORE_NORESP.LOGGER, null, body);
1043
1137
  }
1044
1138
 
1139
+ /**
1140
+ * Error
1141
+ * @param {String} remark
1142
+ * @param {String} content
1143
+ * @param {String} type
1144
+ */
1045
1145
  error(remark, content, type = "LWA") {
1046
1146
  let body = {
1047
1147
  type: type, level: "error", remark: remark, content: content
@@ -1049,6 +1149,12 @@ class Logger {
1049
1149
  return publishRequest(cutosAPI$1.CORE_NORESP.LOGGER, null, body);
1050
1150
  }
1051
1151
 
1152
+ /**
1153
+ * Debug
1154
+ * @param {String} remark
1155
+ * @param {String} content
1156
+ * @param {String} type
1157
+ */
1052
1158
  debug(remark, content, type = "LWA") {
1053
1159
  let body = {
1054
1160
  type: type, level: "debug", remark: remark, content: content
@@ -1068,34 +1174,90 @@ class IPC {
1068
1174
  }
1069
1175
  }
1070
1176
 
1071
- sendTo(channel, args) {
1177
+ /**
1178
+ * send message to channel
1179
+ * @param channel
1180
+ * @param args
1181
+ * @param callback (result, error):void
1182
+ * @returns {boolean}
1183
+ */
1184
+ sendTo(channel, args, callback = null) {
1072
1185
  let body = {};
1073
1186
  body.channel = channel;
1074
1187
  body.args = args;
1075
- return publishRequest(cutosAPI$1.CORE_NORESP.IPC, null, body, this.destAddress);
1188
+ let topic = cutosAPI$1.CORE_NORESP.IPC + (this.destAddress ? "" : "-endpoint");
1189
+ return publishRequest(topic, callback, body, this.destAddress);
1190
+ }
1191
+
1192
+ /**
1193
+ * 发送需要callback的消息的响应
1194
+ * @param context listener收到的context
1195
+ * @param result
1196
+ * @param error
1197
+ */
1198
+ sendResponse(context, result, error = null) {
1199
+ let response = {};
1200
+ response.context = {};
1201
+ response.context.destAddress = context.sourceAddress;
1202
+ response.id = context.id;
1203
+ response.result = result;
1204
+ response.err = error;
1205
+ let topic = cutosAPI$1.CORE_NORESP.IPC + (this.destAddress ? "" : "-endpoint");
1206
+ client.publish(topic, JSON.stringify(response));
1076
1207
  }
1077
1208
 
1209
+ /**
1210
+ * Listen IPC form channel
1211
+ * @param channel
1212
+ * @param listener (args, context) the context use when sendResponse
1213
+ */
1078
1214
  on(channel, listener) {
1079
- listenerMap.set(channel, listener);
1215
+ if (!ipcListenerMap.has(channel)) {
1216
+ ipcListenerMap.set(channel, []);
1217
+ }
1218
+ ipcListenerMap.get(channel).push(listener);
1080
1219
  }
1081
1220
 
1082
- removeListener(channel) {
1083
- listenerMap.delete(channel);
1221
+ removeListener(channel, listener = null) {
1222
+ if (!ipcListenerMap.has(channel)) {
1223
+ return;
1224
+ }
1225
+ if (!listener) {
1226
+ ipcListenerMap.delete(channel);
1227
+ } else {
1228
+ ipcListenerMap.has(channel).indexOf(listener) > -1 && ipcListenerMap.get(channel).splice(ipcListenerMap.get(channel).indexOf(listener), 1);
1229
+ }
1084
1230
  }
1085
1231
  }
1086
1232
 
1087
1233
  class Notification {
1234
+
1235
+ /**
1236
+ * The constructor of Notification
1237
+ */
1088
1238
  constructor() {
1089
1239
  }
1090
1240
 
1241
+ /**
1242
+ * Register notification listener function
1243
+ * @param {Function} listener - listener function (data)
1244
+ */
1091
1245
  register(listener) {
1092
1246
  listenerMap.set(cutosAPI$1.CORE_APP.NOTIFICATION, listener);
1093
1247
  }
1094
1248
 
1249
+ /**
1250
+ * Unregister, used to cancel the registration of notification
1251
+ */
1095
1252
  unregister() {
1096
1253
  listenerMap.delete(cutosAPI$1.CORE_APP.NOTIFICATION);
1097
1254
  }
1098
1255
 
1256
+ /**
1257
+ * Cancel registration, used to cancel the registration of notification
1258
+ * @param {String} event - event name
1259
+ * @param {String} msg - event content
1260
+ */
1099
1261
  emit(event, msg) {
1100
1262
  client.publish(cutosAPI$1.CORE_APP.NOTIFICATION, JSON.stringify({event: event, msg: msg}));
1101
1263
  return true;
@@ -1136,7 +1298,7 @@ class Heartbeat {
1136
1298
 
1137
1299
  class Device {
1138
1300
  /**
1139
- *
1301
+ * The constructor of Device
1140
1302
  * @param name
1141
1303
  * @param type
1142
1304
  */
@@ -1172,7 +1334,7 @@ class Device {
1172
1334
  }
1173
1335
 
1174
1336
  /**
1175
- *
1337
+ * Device initialize
1176
1338
  * @param callback(result, error)
1177
1339
  * @param opts
1178
1340
  */
@@ -1200,10 +1362,18 @@ class Device {
1200
1362
  });
1201
1363
  }
1202
1364
 
1365
+ /**
1366
+ * Get device status
1367
+ * @param {Function} listener
1368
+ */
1203
1369
  onStatus(listener) {
1204
1370
  this.statusListener = listener;
1205
1371
  }
1206
1372
 
1373
+ /**
1374
+ * Get device status
1375
+ * @param {Function} listener
1376
+ */
1207
1377
  getCurrentStatus() {
1208
1378
  return this.msg;
1209
1379
  }
@@ -1218,6 +1388,10 @@ class Device {
1218
1388
  publishRequest(this.topicCommand, callback, command);
1219
1389
  }
1220
1390
 
1391
+ /**
1392
+ * Receive data sent by the driver
1393
+ * @param listener - listener(data)
1394
+ */
1221
1395
  onData(listener) {
1222
1396
  if (!listenerMap.has(this.topicData)) {
1223
1397
  client.subscribe(this.topicData); // receive data from device
@@ -1245,6 +1419,13 @@ class Device {
1245
1419
  }
1246
1420
 
1247
1421
  class Driver {
1422
+
1423
+ /**
1424
+ * The constructor of Driver
1425
+ * @param name
1426
+ * @param type
1427
+ * @param counter
1428
+ */
1248
1429
  constructor(name = 'default-driver-name', type = cutosAPI$1.DEVICE.DEFAULT, counter = 10) {
1249
1430
  this.name = name;
1250
1431
  this.type = type;
@@ -1271,6 +1452,10 @@ class Driver {
1271
1452
  this.statusInfo.info = info;
1272
1453
  }
1273
1454
 
1455
+ /**
1456
+ * Send data to the device
1457
+ * @param data
1458
+ */
1274
1459
  sendData(data) {
1275
1460
  client.publish(this.topicData, JSON.stringify(data));
1276
1461
  }
@@ -1280,7 +1465,7 @@ class Driver {
1280
1465
  }
1281
1466
 
1282
1467
  /**
1283
- *
1468
+ * Receive device commands
1284
1469
  * @param listener(command, callback(result))
1285
1470
  */
1286
1471
  onCommand(listener) {
@@ -1309,6 +1494,11 @@ class CutosError {
1309
1494
  }
1310
1495
 
1311
1496
  const CoreAPI$2 = {
1497
+ /**
1498
+ * Initialization of CUTOS core
1499
+ * @param {string} host CUTOS address.When host is equal to null, it takes the value 'localhost'. During development, it can be changed to the target address (the device address where CUTOS is installed), such as: '192.168.1.11'
1500
+ * @param {Function} callback callback(result, error)
1501
+ */
1312
1502
  init(host = 'localhost', callback) {
1313
1503
  let brokerUrl;
1314
1504
  if (host && host.startsWith('ws://') && host.endsWith(':1883')) {
@@ -1350,9 +1540,16 @@ const CoreAPI$2 = {
1350
1540
  // console.debug(topic.toString() + message.toString());
1351
1541
  let _message = JSON.parse(message);
1352
1542
  if (topic === cutosAPI$1.CORE_NORESP.IPC + '-endpoint') { // ipc
1353
- let listener = listenerMap.get(_message.body.channel);
1354
- if (listener !== undefined) {
1355
- listener(_message.body.args, _message.context);
1543
+ // process response message
1544
+ if (_message.id) {
1545
+ doCallback(_message.id, _message.result, _message.err);
1546
+ return
1547
+ }
1548
+ let listenerArray = ipcListenerMap.get(_message.body.channel);
1549
+ if (listenerArray) {
1550
+ for (const listener of listenerArray) {
1551
+ listener(_message.body.args, _message.context);
1552
+ }
1356
1553
  }
1357
1554
  } else if (topic === cutosAPI$1.CORE_APP.NOTIFICATION || topic === cutosAPI$1.CORE_APP.HEARTBEAT_LISTENER
1358
1555
  || topic.startsWith(cutosAPI$1.DEVICE.CHANNEL) && !topic.endsWith('-callback')) {
@@ -1383,26 +1580,49 @@ const CoreAPI$2 = {
1383
1580
  return !!client && client.connected;
1384
1581
  },
1385
1582
 
1583
+ /**
1584
+ * Get platform version information
1585
+ */
1386
1586
  getVersion() {
1387
1587
  return packageJson.version ;
1388
1588
  },
1389
1589
 
1590
+ /**
1591
+ * Get platform information
1592
+ * @param {Function} callback - callback(result)
1593
+ */
1390
1594
  getPlatform(callback) {
1391
1595
  return publishRequest(cutosAPI$1.CORE.PLATFORM, callback);
1392
1596
  },
1393
1597
 
1598
+ /**
1599
+ * Get configuration information
1600
+ * @param {Function} callback - callback(result)
1601
+ */
1394
1602
  getConfig(callback) {
1395
1603
  return publishRequest(cutosAPI$1.CORE.CONFIG, callback);
1396
1604
  },
1397
1605
 
1606
+ /**
1607
+ * Get host information
1608
+ * @param {Function} callback - callback(result)
1609
+ */
1398
1610
  getBoxInfo(callback) {
1399
1611
  return publishRequest(cutosAPI$1.CORE.BOX_INFO, callback);
1400
1612
  },
1401
1613
 
1614
+ /**
1615
+ * Get sign information
1616
+ * @param {Function} callback - callback(result)
1617
+ */
1402
1618
  getSignInfo(callback) {
1403
1619
  return publishRequest(cutosAPI$1.CORE.SIGN_INFO, callback);
1404
1620
  },
1405
1621
 
1622
+ /**
1623
+ * Get device information
1624
+ * @param {Function} callback - callback(result)
1625
+ */
1406
1626
  getDeviceInfo(callback) {
1407
1627
  return publishRequest(cutosAPI$1.CORE.DEVICE_INFO, callback);
1408
1628
  },
@@ -1411,10 +1631,17 @@ const CoreAPI$2 = {
1411
1631
  return publishRequest(cutosAPI$1.CORE.SIGN_GROUP_INFO, callback);
1412
1632
  },
1413
1633
 
1634
+ /**
1635
+ * Get IPC instance object
1636
+ * @param {String} destAddress - optional parameter, target IP address, used for inter-device process communication
1637
+ */
1414
1638
  getIPC(destAddress) {
1415
1639
  return new IPC(destAddress);
1416
1640
  },
1417
1641
 
1642
+ /**
1643
+ * Get notification information instance object
1644
+ */
1418
1645
  getNotification() {
1419
1646
  if (!_notification) {
1420
1647
  _notification = new Notification();
@@ -1422,6 +1649,9 @@ const CoreAPI$2 = {
1422
1649
  return _notification;
1423
1650
  },
1424
1651
 
1652
+ /**
1653
+ * Get the log instance object
1654
+ */
1425
1655
  getLogger() {
1426
1656
  if (!_logger) {
1427
1657
  _logger = new Logger();
@@ -1429,18 +1659,38 @@ const CoreAPI$2 = {
1429
1659
  return _logger;
1430
1660
  },
1431
1661
 
1662
+ /**
1663
+ * Shell command execution
1664
+ * @param {String} command - command
1665
+ * @param {Function} callback - callback(result, error)
1666
+ */
1432
1667
  shell(command, callback) {
1433
1668
  return publishRequest(cutosAPI$1.CORE.SHELL, callback, command);
1434
1669
  },
1435
1670
 
1671
+ /**
1672
+ * Get the volume
1673
+ * @param {Function} callback - callback(result)
1674
+ */
1436
1675
  getVolume(callback) {
1437
1676
  return publishRequest(cutosAPI$1.CORE.GET_VOLUME, callback);
1438
1677
  },
1439
1678
 
1679
+ /**
1680
+ * Set the volume
1681
+ * @param {Number} vol - volume:[0-100]
1682
+ * @param {Function} callback - callback(result)
1683
+ */
1440
1684
  setVolume(vol, callback) {
1441
1685
  return publishRequest(cutosAPI$1.CORE.SET_VOLUME, callback, vol);
1442
1686
  },
1443
1687
 
1688
+ /**
1689
+ * Set proxy to solve LWA cross-domain problem
1690
+ * @param {String} api - interface name
1691
+ * @param {String} target - target address
1692
+ * @param {Function} callback - callback(result, error)
1693
+ */
1444
1694
  setHttpProxy(api, target, callback) {
1445
1695
  return publishRequest(cutosAPI$1.CORE.SET_HTTP_PROXY, callback, {api, target});
1446
1696
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cutos/core",
3
- "version": "3.2.6",
3
+ "version": "3.2.8",
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",