@tuya-miniapp/ark-extension-virtual-device 1.8.2-beta-3 → 1.8.2-beta-5

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