@tuya-miniapp/ark-extension-virtual-device 1.7.3-beta-3 → 1.7.3-beta-4
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/worker/index.js +23 -5
- package/package.json +1 -1
package/dist/worker/index.js
CHANGED
|
@@ -220752,7 +220752,7 @@ var require_package2 = __commonJS({
|
|
|
220752
220752
|
"package.json"(exports, module2) {
|
|
220753
220753
|
module2.exports = {
|
|
220754
220754
|
name: "@tuya-miniapp/ark-extension-virtual-device",
|
|
220755
|
-
version: "1.7.3-beta-
|
|
220755
|
+
version: "1.7.3-beta-4",
|
|
220756
220756
|
license: "MIT",
|
|
220757
220757
|
files: [
|
|
220758
220758
|
"manifest.json",
|
|
@@ -279869,7 +279869,7 @@ async function getDeviceInfo2(params) {
|
|
|
279869
279869
|
};
|
|
279870
279870
|
}
|
|
279871
279871
|
async function publishDps2(params) {
|
|
279872
|
-
const { deviceId, dps } = params;
|
|
279872
|
+
const { deviceId, dps, showPublish = true } = params;
|
|
279873
279873
|
try {
|
|
279874
279874
|
let dev = cachedDevices2[deviceId];
|
|
279875
279875
|
if (!dev) {
|
|
@@ -279877,6 +279877,7 @@ async function publishDps2(params) {
|
|
|
279877
279877
|
dev = cachedDevices2[deviceId];
|
|
279878
279878
|
}
|
|
279879
279879
|
let _dps = { ...dps };
|
|
279880
|
+
let _atopDps = { ...dps };
|
|
279880
279881
|
if (dev) {
|
|
279881
279882
|
const { schema } = dev;
|
|
279882
279883
|
const idCodes = {};
|
|
@@ -279887,6 +279888,7 @@ async function publishDps2(params) {
|
|
|
279887
279888
|
});
|
|
279888
279889
|
const publish = {};
|
|
279889
279890
|
const pudp = {};
|
|
279891
|
+
const s2 = typeof schema === "string" ? JSON.parse(schema) : schema;
|
|
279890
279892
|
Object.keys(dps).map((key) => {
|
|
279891
279893
|
if (isNumeric(key)) {
|
|
279892
279894
|
const code2 = idCodes[key];
|
|
@@ -279896,13 +279898,28 @@ async function publishDps2(params) {
|
|
|
279896
279898
|
pudp[codeIds[key]] = dps[key];
|
|
279897
279899
|
}
|
|
279898
279900
|
});
|
|
279899
|
-
ark.runtime.sendMessage(
|
|
279901
|
+
showPublish && ark.runtime.sendMessage(
|
|
279900
279902
|
JSON.stringify({ type: "publishDps", value: publish, protocol: 5 })
|
|
279901
279903
|
);
|
|
279902
279904
|
if (Object.keys(pudp).length > 0) {
|
|
279903
279905
|
_dps = pudp;
|
|
279906
|
+
_atopDps = { ...pudp };
|
|
279904
279907
|
console.log("--------pudp", pudp);
|
|
279905
279908
|
}
|
|
279909
|
+
s2.map((item) => {
|
|
279910
|
+
const { id, code: code2, property, type: oType } = item;
|
|
279911
|
+
const { type } = property || {};
|
|
279912
|
+
if (Object.keys(_dps).includes(`${id}`) && (type === "raw" || oType === "raw") && isHexString(_dps[id])) {
|
|
279913
|
+
const b2 = Buffer.from(_dps[id], "hex");
|
|
279914
|
+
_dps[id] = b2.toString("base64");
|
|
279915
|
+
}
|
|
279916
|
+
if (Object.keys(_dps).includes(`${id}`) && (type === "raw" || oType === "raw") && !_dps[id]) {
|
|
279917
|
+
delete _dps[id];
|
|
279918
|
+
}
|
|
279919
|
+
if (Object.keys(_dps).includes(`${id}`) && (type === "value" || oType === "value") && !isInteger(_dps[id])) {
|
|
279920
|
+
viewLog("@i18n(number_publish_error)");
|
|
279921
|
+
}
|
|
279922
|
+
});
|
|
279906
279923
|
}
|
|
279907
279924
|
console.log("--------result publishDpsWithMqtt", deviceId, _dps);
|
|
279908
279925
|
let reason;
|
|
@@ -279939,7 +279956,7 @@ async function publishDps2(params) {
|
|
|
279939
279956
|
data = crypto_default.Encrypt23(message, dev.localKey);
|
|
279940
279957
|
break;
|
|
279941
279958
|
default:
|
|
279942
|
-
result = await publishDps({ deviceId, dps:
|
|
279959
|
+
result = await publishDps({ deviceId, dps: _atopDps }, (err) => {
|
|
279943
279960
|
reason = err;
|
|
279944
279961
|
console.log("--------error", err);
|
|
279945
279962
|
});
|
|
@@ -280089,7 +280106,8 @@ async function queryDps2(params) {
|
|
|
280089
280106
|
dps: q2,
|
|
280090
280107
|
mode: 2,
|
|
280091
280108
|
pipelines: [1, 2, 3, 4, 5, 6],
|
|
280092
|
-
options: {}
|
|
280109
|
+
options: {},
|
|
280110
|
+
showPublish: false
|
|
280093
280111
|
});
|
|
280094
280112
|
return {
|
|
280095
280113
|
data: true,
|