@tuya-miniapp/ark-extension-virtual-device 1.8.7 → 1.8.8-beta-2

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.
@@ -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.7-beta-7",
220755
+ version: "1.8.8-beta-1",
220756
220756
  license: "MIT",
220757
220757
  files: [
220758
220758
  "manifest.json",
@@ -262463,7 +262463,7 @@ async function getDebugMode() {
262463
262463
  try {
262464
262464
  result = res || "virtual";
262465
262465
  } catch (error) {
262466
- ark.storage.remove(key);
262466
+ await ark.storage.remove(key);
262467
262467
  return;
262468
262468
  }
262469
262469
  return result || "virtual";
@@ -262491,7 +262491,7 @@ var setCompilationParams = async (p2) => {
262491
262491
  }
262492
262492
  });
262493
262493
  const np = stringifySearchParams({ ...realParams, ...p2 });
262494
- ark.project.setCompilationParams({ page, params: np });
262494
+ await ark.project.setCompilationParams({ page, params: np });
262495
262495
  };
262496
262496
  var changeDeviceIdOrGroupId = async (p2) => {
262497
262497
  const { page, params } = await ark.project.getCompilationParams() || {};
@@ -262509,7 +262509,7 @@ var changeDeviceIdOrGroupId = async (p2) => {
262509
262509
  delete realParams["groupId"];
262510
262510
  }
262511
262511
  const np = stringifySearchParams(realParams);
262512
- ark.project.setCompilationParams({ page, params: np });
262512
+ await ark.project.setCompilationParams({ page, params: np });
262513
262513
  };
262514
262514
 
262515
262515
  // worker/api/services/mock/getProductInfo.ts
@@ -264748,7 +264748,7 @@ var getProjectInfo = async () => {
264748
264748
  // worker/api/services/clearProjectInfo.ts
264749
264749
  var clearProjectInfo = async (body) => {
264750
264750
  const info = await getProjectInfo();
264751
- setCompilationParams({ deviceId: "" });
264751
+ await setCompilationParams({ deviceId: "" });
264752
264752
  if (info) {
264753
264753
  await ark.storage.remove(info.productId);
264754
264754
  await ark.storage.remove(info.deviceId);
@@ -266002,7 +266002,7 @@ var getVirtualBindInfo = async (params) => {
266002
266002
  result: { devId }
266003
266003
  } = res;
266004
266004
  if (devId) {
266005
- setCompilationParams({ deviceId: devId });
266005
+ await setCompilationParams({ deviceId: devId });
266006
266006
  }
266007
266007
  return res?.result;
266008
266008
  };
@@ -279365,7 +279365,7 @@ function validateConfig(config) {
279365
279365
  }
279366
279366
  return viewResult;
279367
279367
  }
279368
- function saveDebugExtension({ service, params: { path: path6 }, eventId }) {
279368
+ async function saveDebugExtension({ service, params: { path: path6 }, eventId }) {
279369
279369
  try {
279370
279370
  const result = {
279371
279371
  service,
@@ -279376,7 +279376,7 @@ function saveDebugExtension({ service, params: { path: path6 }, eventId }) {
279376
279376
  }
279377
279377
  };
279378
279378
  if (!path6) {
279379
- ark.storage.remove(DEBUG_EXT_STORAGE_KEY2);
279379
+ await ark.storage.remove(DEBUG_EXT_STORAGE_KEY2);
279380
279380
  ark.runtime.sendMessage(
279381
279381
  JSON.stringify({
279382
279382
  ...result,
@@ -279552,7 +279552,7 @@ var deleteFromInstalledExtList = (item) => {
279552
279552
  await ark.storage.set(INSTALLED_EXT_STORAGE_KEY2, JSON.stringify(list));
279553
279553
  const debugExt = await getDebugExt();
279554
279554
  if (debugExt && debugExt.npmName === item.npmName) {
279555
- saveDebugExtension({
279555
+ await saveDebugExtension({
279556
279556
  service: null,
279557
279557
  params: { path: null },
279558
279558
  eventId: null
@@ -279951,6 +279951,7 @@ async function getDeviceInfo2(params) {
279951
279951
  errorMsg: import_TYUniCode3.TYUniPluginError.SUCCESS.des
279952
279952
  };
279953
279953
  } catch (error) {
279954
+ console.log("----------error", error);
279954
279955
  return {
279955
279956
  data: null,
279956
279957
  errorCode: import_TYUniCode3.TYUniPluginError.INTERNAL_ERROR.code,
@@ -280687,17 +280688,18 @@ async function removeDevice(params) {
280687
280688
  }
280688
280689
  }
280689
280690
  async function registerMQTTDeviceListener(params) {
280690
- const { deviceId } = params;
280691
- await getDeviceInfo2({ deviceId });
280692
- const deviceInfo2 = cachedDevices2[deviceId];
280693
- initMqttClient_default.addDeviceListener(deviceInfo2);
280694
280691
  try {
280692
+ const { deviceId } = params;
280693
+ await getDeviceInfo2({ deviceId });
280694
+ const deviceInfo2 = cachedDevices2[deviceId];
280695
+ initMqttClient_default.addDeviceListener(deviceInfo2);
280695
280696
  return {
280696
280697
  data: {},
280697
280698
  errorCode: 0,
280698
280699
  errorMsg: import_TYUniCode3.TYUniPluginError.SUCCESS.des
280699
280700
  };
280700
280701
  } catch (error) {
280702
+ console.error("registerMQTTDeviceListener error:", error);
280701
280703
  return {
280702
280704
  data: false,
280703
280705
  errorCode: import_TYUniCode3.TYUniPluginError.DEVICEKIT_GW_ID_INVALID.code,
@@ -280772,58 +280774,69 @@ async function unSubscribeDeviceRemoved(params) {
280772
280774
  }
280773
280775
  }
280774
280776
  async function sendMqttMessage(params) {
280775
- const { protocol, message: data, deviceId } = params;
280776
- let dev = cachedDevices2[deviceId];
280777
- const { parentId, nodeId } = dev;
280778
- const message = {
280779
- t: `${(/* @__PURE__ */ new Date()).getTime()}`.substring(0, 10),
280780
- protocol,
280781
- data
280782
- };
280783
- const topic = `smart/mb/out/${dev.devId}`;
280784
- const { pv = "2.2", localKey } = dev;
280785
- if (localKey) {
280786
- let data2 = null;
280787
- switch (pv) {
280788
- case "2.0":
280789
- data2 = crypto_default.Encrypt20(message, dev.localKey, dev.gwId || dev.devId);
280790
- break;
280791
- case "2.2":
280792
- if (dev.localKey) {
280793
- data2 = crypto_default.Encrypt22(message, dev.localKey);
280794
- }
280795
- break;
280796
- case "2.3":
280797
- data2 = crypto_default.Encrypt23(message, dev.localKey);
280798
- break;
280799
- default:
280800
- break;
280777
+ try {
280778
+ const { protocol, message: data, deviceId } = params;
280779
+ if (!deviceId) {
280780
+ return {
280781
+ data: null,
280782
+ errorCode: import_TYUniCode3.TYUniPluginError.INCORRECT_PARAM.code,
280783
+ errorMsg: import_TYUniCode3.TYUniPluginError.INCORRECT_PARAM.des
280784
+ };
280801
280785
  }
280802
- if (data2) {
280803
- initMqttClient_default._client.publish(
280804
- topic,
280805
- data2,
280806
- {
280807
- qos: 1,
280808
- retain: true
280809
- },
280810
- (error, pocket) => {
280811
- }
280812
- );
280786
+ let dev = cachedDevices2[deviceId];
280787
+ if (!dev) {
280788
+ await getDeviceInfo2({ deviceId });
280789
+ dev = cachedDevices2[deviceId];
280813
280790
  }
280814
- try {
280791
+ const message = {
280792
+ t: `${(/* @__PURE__ */ new Date()).getTime()}`.substring(0, 10),
280793
+ protocol,
280794
+ data
280795
+ };
280796
+ const topic = `smart/mb/out/${dev.devId}`;
280797
+ const { pv = "2.2", localKey } = dev;
280798
+ if (localKey) {
280799
+ let data2 = null;
280800
+ switch (pv) {
280801
+ case "2.0":
280802
+ data2 = crypto_default.Encrypt20(message, dev.localKey, dev.gwId || dev.devId);
280803
+ break;
280804
+ case "2.2":
280805
+ if (dev.localKey) {
280806
+ data2 = crypto_default.Encrypt22(message, dev.localKey);
280807
+ }
280808
+ break;
280809
+ case "2.3":
280810
+ data2 = crypto_default.Encrypt23(message, dev.localKey);
280811
+ break;
280812
+ default:
280813
+ break;
280814
+ }
280815
+ if (data2) {
280816
+ initMqttClient_default._client.publish(
280817
+ topic,
280818
+ data2,
280819
+ {
280820
+ qos: 1,
280821
+ retain: true
280822
+ },
280823
+ (error, pocket) => {
280824
+ }
280825
+ );
280826
+ }
280815
280827
  return {
280816
280828
  data: null,
280817
280829
  errorCode: 0,
280818
280830
  errorMsg: import_TYUniCode3.TYUniPluginError.SUCCESS.des
280819
280831
  };
280820
- } catch (error) {
280821
- return {
280822
- data: false,
280823
- errorCode: import_TYUniCode3.TYUniPluginError.DEVICEKIT_GW_ID_INVALID.code,
280824
- errorMsg: import_TYUniCode3.TYUniPluginError.DEVICEKIT_GW_ID_INVALID.des
280825
- };
280826
280832
  }
280833
+ } catch (error) {
280834
+ console.log("sendMqttMessage error:", error);
280835
+ return {
280836
+ data: false,
280837
+ errorCode: import_TYUniCode3.TYUniPluginError.DEVICEKIT_GW_ID_INVALID.code,
280838
+ errorMsg: import_TYUniCode3.TYUniPluginError.DEVICEKIT_GW_ID_INVALID.des
280839
+ };
280827
280840
  }
280828
280841
  }
280829
280842
  async function syncDeviceInfo(params) {
@@ -283039,7 +283052,7 @@ async function requestNgConfig(uid) {
283039
283052
  }
283040
283053
  });
283041
283054
  if (res.success) {
283042
- ark.storage.set(`ng_config_${uid}`, JSON.stringify(res));
283055
+ await ark.storage.set(`ng_config_${uid}`, JSON.stringify(res));
283043
283056
  }
283044
283057
  return res;
283045
283058
  } catch (error) {
@@ -283320,7 +283333,7 @@ try {
283320
283333
  } else if (service === "startMQTT") {
283321
283334
  initMqttClient_default.reconnectAll();
283322
283335
  } else if (service === "set_debug_extension_path") {
283323
- saveDebugExtension(data);
283336
+ await saveDebugExtension(data);
283324
283337
  }
283325
283338
  }
283326
283339
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/ark-extension-virtual-device",
3
- "version": "1.8.7",
3
+ "version": "1.8.8-beta-2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "manifest.json",