@tuya-miniapp/ark-extension-virtual-device 1.8.2-beta-3 → 1.8.2-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 +122 -114
- 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.8.2-beta-
|
|
220755
|
+
version: "1.8.2-beta-3",
|
|
220756
220756
|
license: "MIT",
|
|
220757
220757
|
files: [
|
|
220758
220758
|
"manifest.json",
|
|
@@ -262861,8 +262861,8 @@ var getDeviceInfo = async (body) => {
|
|
|
262861
262861
|
const { schema, dps } = devInfo.result;
|
|
262862
262862
|
const oDps = { ...dps };
|
|
262863
262863
|
JSON.parse(schema).map((item) => {
|
|
262864
|
-
const { id, type } = item;
|
|
262865
|
-
if (Object.keys(oDps).includes(`${id}`) && type === "raw") {
|
|
262864
|
+
const { id, type, property } = item;
|
|
262865
|
+
if (Object.keys(oDps).includes(`${id}`) && (type === "raw" || type === "obj" && property?.type === "string")) {
|
|
262866
262866
|
if (!isHexString(oDps[id])) {
|
|
262867
262867
|
const b2 = Buffer.from(oDps[id], "base64");
|
|
262868
262868
|
oDps[id] = b2.toString("hex");
|
|
@@ -263750,7 +263750,7 @@ function parseRawMessage(result, devInfo) {
|
|
|
263750
263750
|
schema.map((item) => {
|
|
263751
263751
|
const { id, property, type: oType } = item;
|
|
263752
263752
|
const { type } = property || {};
|
|
263753
|
-
if (Object.keys(result.data.dps).includes(`${id}`) && (oType === "raw" || type === "raw")) {
|
|
263753
|
+
if (Object.keys(result.data.dps).includes(`${id}`) && (oType === "raw" || type === "raw" || oType === "obj" && type === "string")) {
|
|
263754
263754
|
const b2 = Buffer.from(result.data.dps[id], "base64");
|
|
263755
263755
|
result.data.dps[id] = b2.toString("hex");
|
|
263756
263756
|
}
|
|
@@ -279821,125 +279821,133 @@ async function getDeviceInfo2(params) {
|
|
|
279821
279821
|
}
|
|
279822
279822
|
if (cachedDevices2[deviceId]) {
|
|
279823
279823
|
deviceInfo = cachedDevices2[deviceId];
|
|
279824
|
-
const
|
|
279825
|
-
delete
|
|
279826
|
-
delete
|
|
279827
|
-
delete
|
|
279828
|
-
delete
|
|
279829
|
-
delete
|
|
279830
|
-
delete
|
|
279831
|
-
delete
|
|
279832
|
-
delete
|
|
279833
|
-
delete
|
|
279834
|
-
delete
|
|
279835
|
-
delete
|
|
279836
|
-
delete
|
|
279837
|
-
delete
|
|
279838
|
-
delete
|
|
279839
|
-
delete
|
|
279840
|
-
delete
|
|
279841
|
-
delete
|
|
279824
|
+
const result = { ...cachedDevices2[deviceId] };
|
|
279825
|
+
delete result["accessType"];
|
|
279826
|
+
delete result["appRnVersion"];
|
|
279827
|
+
delete result["rnFind"];
|
|
279828
|
+
delete result["runtimeEnv"];
|
|
279829
|
+
delete result["supportGroup"];
|
|
279830
|
+
delete result["time"];
|
|
279831
|
+
delete result["ui"];
|
|
279832
|
+
delete result["uiConfig"];
|
|
279833
|
+
delete result["uiPhase"];
|
|
279834
|
+
delete result["uiType"];
|
|
279835
|
+
delete result["verSw"];
|
|
279836
|
+
delete result["isActive"];
|
|
279837
|
+
delete result["lat"];
|
|
279838
|
+
delete result["lon"];
|
|
279839
|
+
delete result["gwType"];
|
|
279840
|
+
delete result["dpMaxTime"];
|
|
279841
|
+
delete result["i18nTime"];
|
|
279842
279842
|
return {
|
|
279843
|
-
data:
|
|
279843
|
+
data: result,
|
|
279844
279844
|
errorCode: 0,
|
|
279845
279845
|
errorMsg: import_TYUniCode3.TYUniPluginError.SUCCESS.des
|
|
279846
279846
|
};
|
|
279847
279847
|
}
|
|
279848
|
-
|
|
279849
|
-
|
|
279850
|
-
|
|
279848
|
+
try {
|
|
279849
|
+
const response = await getDeviceInfo({ deviceId });
|
|
279850
|
+
const { result: devInfo } = response || {};
|
|
279851
|
+
if (!devInfo) {
|
|
279852
|
+
return {
|
|
279853
|
+
data: null,
|
|
279854
|
+
errorCode: import_TYUniCode3.TYUniPluginError.DEVICEKIT_DEVICE_ID_INVALID.code,
|
|
279855
|
+
errorMsg: import_TYUniCode3.TYUniPluginError.DEVICEKIT_DEVICE_ID_INVALID.des
|
|
279856
|
+
};
|
|
279857
|
+
}
|
|
279858
|
+
let product = {};
|
|
279859
|
+
let dev = {};
|
|
279860
|
+
const presponse = await getProductInfo2({
|
|
279861
|
+
productId: devInfo.productId,
|
|
279862
|
+
getDevices: true
|
|
279863
|
+
});
|
|
279864
|
+
const { data: productInfo, devices } = presponse || {};
|
|
279865
|
+
product = productInfo || {};
|
|
279866
|
+
if (devices) {
|
|
279867
|
+
const a2 = devices.filter((item) => item.devId === deviceId).pop();
|
|
279868
|
+
dev = a2 || {};
|
|
279869
|
+
}
|
|
279870
|
+
const { dps, schema } = devInfo;
|
|
279871
|
+
const objSchema = {};
|
|
279872
|
+
const oDps = { ...dps };
|
|
279873
|
+
JSON.parse(schema).map((item) => {
|
|
279874
|
+
const { id, code } = item;
|
|
279875
|
+
objSchema[code] = dps[id];
|
|
279876
|
+
});
|
|
279877
|
+
console.log("--------objSchema", dev);
|
|
279878
|
+
const d2 = {
|
|
279879
|
+
...devInfo,
|
|
279880
|
+
attributeString: parseInt(productInfo.attribute, 10).toString(2),
|
|
279881
|
+
dpCodes: objSchema,
|
|
279882
|
+
// deviceOnline: devInfo.isOnline,
|
|
279883
|
+
// icon: devInfo.iconUrl,
|
|
279884
|
+
schema: JSON.parse(devInfo.schema),
|
|
279885
|
+
// @ts-ignore
|
|
279886
|
+
capability: product.capability,
|
|
279887
|
+
category: product.category,
|
|
279888
|
+
attribute: product.attribute,
|
|
279889
|
+
devAttribute: devInfo.devAttribute,
|
|
279890
|
+
// devTimezoneId: dev.timezoneId,
|
|
279891
|
+
isCloudOnline: devInfo.cloudOnline,
|
|
279892
|
+
isOnline: devInfo.isOnline || dev.cloudOnline || devInfo.cloudOnline,
|
|
279893
|
+
latitude: devInfo.lat,
|
|
279894
|
+
longitude: devInfo.lon,
|
|
279895
|
+
...devInfo.dataPointInfo,
|
|
279896
|
+
isVirtualDevice: devInfo.virtual,
|
|
279897
|
+
panelConfig: product.panelConfig,
|
|
279898
|
+
// isVDevice: dev.virtual,
|
|
279899
|
+
dps,
|
|
279900
|
+
connectionStatus: devInfo.communication?.connectionStatus,
|
|
279901
|
+
baseAttribute: devInfo.baseAttribute,
|
|
279902
|
+
isSupportGroup: devInfo.supportGroup,
|
|
279903
|
+
isSupportOTA: devInfo.otaInfo?.support,
|
|
279904
|
+
hasWifi: !!dev.moduleMap?.wifi,
|
|
279905
|
+
cadv: dev.moduleMap?.wifi?.cadv || "",
|
|
279906
|
+
protocolAttribute: dev.protocolAttribute || 0,
|
|
279907
|
+
isGW: dev.protocolAttribute !== 0 && !!dev.protocolAttribute,
|
|
279908
|
+
isLocalOnline: false,
|
|
279909
|
+
isTripartiteMatter: devInfo.accessType == 1,
|
|
279910
|
+
isSupportLink: devInfo.accessType == 2,
|
|
279911
|
+
pcc: product.meshCategory,
|
|
279912
|
+
isMatter: !!getBitValue(devInfo.baseAttribute, 7)
|
|
279913
|
+
// bizAttribute: dev.bizAttribute
|
|
279914
|
+
};
|
|
279915
|
+
const result = { ...d2 };
|
|
279916
|
+
if (projectDeviceId === d2.devId) {
|
|
279917
|
+
deviceInfo = d2;
|
|
279918
|
+
}
|
|
279919
|
+
cachedDevices2[deviceId] = { ...d2 };
|
|
279920
|
+
delete result["accessType"];
|
|
279921
|
+
delete result["appRnVersion"];
|
|
279922
|
+
delete result["rnFind"];
|
|
279923
|
+
delete result["runtimeEnv"];
|
|
279924
|
+
delete result["supportGroup"];
|
|
279925
|
+
delete result["time"];
|
|
279926
|
+
delete result["ui"];
|
|
279927
|
+
delete result["uiConfig"];
|
|
279928
|
+
delete result["uiPhase"];
|
|
279929
|
+
delete result["uiType"];
|
|
279930
|
+
delete result["verSw"];
|
|
279931
|
+
delete result["isActive"];
|
|
279932
|
+
delete result["lat"];
|
|
279933
|
+
delete result["lon"];
|
|
279934
|
+
delete result["gwType"];
|
|
279935
|
+
delete result["dpMaxTime"];
|
|
279936
|
+
delete result["i18nTime"];
|
|
279937
|
+
const returnData = { ...result };
|
|
279938
|
+
delete returnData["localKey"];
|
|
279939
|
+
return {
|
|
279940
|
+
data: returnData,
|
|
279941
|
+
errorCode: 0,
|
|
279942
|
+
errorMsg: import_TYUniCode3.TYUniPluginError.SUCCESS.des
|
|
279943
|
+
};
|
|
279944
|
+
} catch (error) {
|
|
279851
279945
|
return {
|
|
279852
279946
|
data: null,
|
|
279853
|
-
errorCode: import_TYUniCode3.TYUniPluginError.
|
|
279854
|
-
errorMsg: import_TYUniCode3.TYUniPluginError.
|
|
279947
|
+
errorCode: import_TYUniCode3.TYUniPluginError.INTERNAL_ERROR.code,
|
|
279948
|
+
errorMsg: import_TYUniCode3.TYUniPluginError.INTERNAL_ERROR.des
|
|
279855
279949
|
};
|
|
279856
279950
|
}
|
|
279857
|
-
let product = {};
|
|
279858
|
-
let dev = {};
|
|
279859
|
-
const presponse = await getProductInfo2({
|
|
279860
|
-
productId: devInfo.productId,
|
|
279861
|
-
getDevices: true
|
|
279862
|
-
});
|
|
279863
|
-
const { data: productInfo, devices } = presponse || {};
|
|
279864
|
-
product = productInfo || {};
|
|
279865
|
-
if (devices) {
|
|
279866
|
-
const a2 = devices.filter((item) => item.devId === deviceId).pop();
|
|
279867
|
-
dev = a2 || {};
|
|
279868
|
-
}
|
|
279869
|
-
const { dps, schema } = devInfo;
|
|
279870
|
-
const objSchema = {};
|
|
279871
|
-
const oDps = { ...dps };
|
|
279872
|
-
JSON.parse(schema).map((item) => {
|
|
279873
|
-
const { id, code } = item;
|
|
279874
|
-
objSchema[code] = dps[id];
|
|
279875
|
-
});
|
|
279876
|
-
console.log("--------objSchema", dev);
|
|
279877
|
-
const d2 = {
|
|
279878
|
-
...devInfo,
|
|
279879
|
-
attributeString: parseInt(productInfo.attribute, 10).toString(2),
|
|
279880
|
-
dpCodes: objSchema,
|
|
279881
|
-
// deviceOnline: devInfo.isOnline,
|
|
279882
|
-
// icon: devInfo.iconUrl,
|
|
279883
|
-
schema: JSON.parse(devInfo.schema),
|
|
279884
|
-
// @ts-ignore
|
|
279885
|
-
capability: product.capability,
|
|
279886
|
-
category: product.category,
|
|
279887
|
-
attribute: product.attribute,
|
|
279888
|
-
devAttribute: devInfo.devAttribute,
|
|
279889
|
-
// devTimezoneId: dev.timezoneId,
|
|
279890
|
-
isCloudOnline: devInfo.cloudOnline,
|
|
279891
|
-
isOnline: devInfo.isOnline || dev.cloudOnline || devInfo.cloudOnline,
|
|
279892
|
-
latitude: devInfo.lat,
|
|
279893
|
-
longitude: devInfo.lon,
|
|
279894
|
-
...devInfo.dataPointInfo,
|
|
279895
|
-
isVirtualDevice: devInfo.virtual,
|
|
279896
|
-
panelConfig: product.panelConfig,
|
|
279897
|
-
// isVDevice: dev.virtual,
|
|
279898
|
-
dps,
|
|
279899
|
-
connectionStatus: devInfo.communication?.connectionStatus,
|
|
279900
|
-
baseAttribute: devInfo.baseAttribute,
|
|
279901
|
-
isSupportGroup: devInfo.supportGroup,
|
|
279902
|
-
isSupportOTA: devInfo.otaInfo?.support,
|
|
279903
|
-
hasWifi: !!dev.moduleMap?.wifi,
|
|
279904
|
-
cadv: dev.moduleMap?.wifi?.cadv || "",
|
|
279905
|
-
protocolAttribute: dev.protocolAttribute || 0,
|
|
279906
|
-
isGW: dev.protocolAttribute !== 0 && !!dev.protocolAttribute,
|
|
279907
|
-
isLocalOnline: false,
|
|
279908
|
-
isTripartiteMatter: devInfo.accessType == 1,
|
|
279909
|
-
isSupportLink: devInfo.accessType == 2,
|
|
279910
|
-
pcc: product.meshCategory,
|
|
279911
|
-
isMatter: !!getBitValue(devInfo.baseAttribute, 7)
|
|
279912
|
-
// bizAttribute: dev.bizAttribute
|
|
279913
|
-
};
|
|
279914
|
-
const result = { ...d2 };
|
|
279915
|
-
if (projectDeviceId === d2.devId) {
|
|
279916
|
-
deviceInfo = d2;
|
|
279917
|
-
}
|
|
279918
|
-
cachedDevices2[deviceId] = { ...d2 };
|
|
279919
|
-
delete result["accessType"];
|
|
279920
|
-
delete result["appRnVersion"];
|
|
279921
|
-
delete result["rnFind"];
|
|
279922
|
-
delete result["runtimeEnv"];
|
|
279923
|
-
delete result["supportGroup"];
|
|
279924
|
-
delete result["time"];
|
|
279925
|
-
delete result["ui"];
|
|
279926
|
-
delete result["uiConfig"];
|
|
279927
|
-
delete result["uiPhase"];
|
|
279928
|
-
delete result["uiType"];
|
|
279929
|
-
delete result["verSw"];
|
|
279930
|
-
delete result["isActive"];
|
|
279931
|
-
delete result["lat"];
|
|
279932
|
-
delete result["lon"];
|
|
279933
|
-
delete result["gwType"];
|
|
279934
|
-
delete result["dpMaxTime"];
|
|
279935
|
-
delete result["i18nTime"];
|
|
279936
|
-
const returnData = { ...result };
|
|
279937
|
-
delete returnData["localKey"];
|
|
279938
|
-
return {
|
|
279939
|
-
data: returnData,
|
|
279940
|
-
errorCode: 0,
|
|
279941
|
-
errorMsg: import_TYUniCode3.TYUniPluginError.SUCCESS.des
|
|
279942
|
-
};
|
|
279943
279951
|
}
|
|
279944
279952
|
async function publishDps2(params) {
|
|
279945
279953
|
const { deviceId, dps, showPublish = true } = params;
|