@tuya-miniapp/ark-extension-virtual-device 1.1.27 → 1.1.28-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.
Files changed (2) hide show
  1. package/dist/worker/index.js +154 -10
  2. package/package.json +1 -1
@@ -173003,7 +173003,7 @@ var require_package = __commonJS({
173003
173003
  "package.json"(exports2, module2) {
173004
173004
  module2.exports = {
173005
173005
  name: "@tuya-miniapp/ark-extension-virtual-device",
173006
- version: "1.1.27-beta-3",
173006
+ version: "1.1.28-beta-1",
173007
173007
  files: [
173008
173008
  "manifest.json",
173009
173009
  "package.json",
@@ -239211,6 +239211,7 @@ var getProjectProductId = async () => {
239211
239211
  productId = debugParams.productId;
239212
239212
  }
239213
239213
  }
239214
+ console.log("----------------------9999999999--------------------", mode, params, debugParams);
239214
239215
  if (mode === "real") {
239215
239216
  const realDevId = await getRealDevId();
239216
239217
  if (!!debugParams.deviceId || !!realDevId) {
@@ -239219,6 +239220,7 @@ var getProjectProductId = async () => {
239219
239220
  setCompilationParams({ deviceId: "" });
239220
239221
  return "";
239221
239222
  }
239223
+ console.log("----------------------deviceId--------------------", deviceId);
239222
239224
  const devInfo = await getDeviceInfo2({ deviceId });
239223
239225
  if (!devInfo.data) {
239224
239226
  ark.runtime.sendMessage("device_not_exist");
@@ -239244,8 +239246,11 @@ var getProjectProductId = async () => {
239244
239246
  };
239245
239247
  var getProjectDeviceId = async () => {
239246
239248
  const mode = await getDebugMode();
239249
+ console.log("----------------getDebugMode-----------------", mode);
239247
239250
  const { page, params } = await ark.project.getCompilationParams() || {};
239251
+ console.log("----------------getCompilationParams-----------------", page, params);
239248
239252
  const productId = await getProjectProductId();
239253
+ console.log("----------------getProjectProductId-----------------", productId);
239249
239254
  let deviceId = "";
239250
239255
  let debugParams = parseSearchParams(params);
239251
239256
  if (productId) {
@@ -239402,6 +239407,14 @@ var getDeviceInfo = async (body) => {
239402
239407
  devId: body?.deviceId
239403
239408
  }
239404
239409
  });
239410
+ const devInfo32 = await apiRequestByAtop({
239411
+ api: "tuya.m.device.get",
239412
+ version: "3.2",
239413
+ params: {
239414
+ devId: body?.deviceId
239415
+ }
239416
+ });
239417
+ devInfo.result.moduleMap = devInfo32.result?.moduleMap;
239405
239418
  try {
239406
239419
  const { schema, dps } = devInfo.result;
239407
239420
  const oDps = { ...dps };
@@ -239473,10 +239486,11 @@ async function getDeviceInfo2(params) {
239473
239486
  const { id, code } = item;
239474
239487
  objSchema[code] = dps[id];
239475
239488
  });
239489
+ console.log("--------->>>>>>>devInfo", devInfo);
239490
+ console.log("--------->>>>>>>dev", dev, JSON.stringify(dev.otaInfo.otaModuleMap));
239476
239491
  const d = {
239477
239492
  ...devInfo,
239478
239493
  dpCodes: objSchema,
239479
- icon: devInfo.iconUrl,
239480
239494
  schema: JSON.parse(devInfo.schema),
239481
239495
  capability: product.capability,
239482
239496
  category: product.category,
@@ -239488,9 +239502,16 @@ async function getDeviceInfo2(params) {
239488
239502
  longitude: devInfo.lon,
239489
239503
  ...dev.dataPointInfo,
239490
239504
  isVirtualDevice: dev.virtual,
239505
+ mac: dev.mac,
239491
239506
  panelConfig: product.panelConfig,
239492
- isVDevice: deviceId.indexOf("vdev") === 0,
239493
- dps
239507
+ dps,
239508
+ connectionStatus: dev.communication?.connectionStatus,
239509
+ baseAttribute: dev.baseAttribute,
239510
+ isSupportGroup: devInfo.supportGroup,
239511
+ isSupportOTA: dev.otaInfo?.support,
239512
+ hasWifi: !!devInfo.moduleMap?.wifi,
239513
+ cadv: devInfo.moduleMap?.wifi?.cadv || "",
239514
+ protocolAttribute: dev.protocolAttribute || 0
239494
239515
  };
239495
239516
  const result = { ...d };
239496
239517
  if (global.__deviceId === d.devId) {
@@ -239507,12 +239528,12 @@ async function getDeviceInfo2(params) {
239507
239528
  delete result["uiPhase"];
239508
239529
  delete result["uiType"];
239509
239530
  delete result["verSw"];
239510
- delete result["iconUrl"];
239511
239531
  delete result["isActive"];
239512
239532
  delete result["lat"];
239513
239533
  delete result["lon"];
239514
239534
  delete result["gwType"];
239515
239535
  delete result["dpMaxTime"];
239536
+ delete result["i18nTime"];
239516
239537
  chchedDevices[deviceId] = result;
239517
239538
  return {
239518
239539
  data: result,
@@ -239975,8 +239996,132 @@ ark.miniapp.addPluginMethod("TYUniOpenPageManager", "registerChannel", registerC
239975
239996
  ark.miniapp.addPluginMethod("TUNIOpenPageManager", "unRegisterChannel", unRegisterChannel);
239976
239997
  ark.miniapp.addPluginMethod("TYUniOpenPageManager", "unRegisterChannel", unRegisterChannel);
239977
239998
 
239978
- // worker/api/Bridge.ts
239999
+ // worker/api/TUNIHomeDataManager.ts
239979
240000
  var import_TYUniCode9 = __toESM(require_dist());
240001
+ async function getCurrentHomeInfo() {
240002
+ const u = await ark.auth.getCustomerUserInfo();
240003
+ const userInfo = typeof u === "string" ? JSON.parse(u) : u;
240004
+ const {
240005
+ extras: { homeId }
240006
+ } = userInfo;
240007
+ const data = await ark.http.atop({
240008
+ api: "tuya.m.location.get",
240009
+ version: "3.1",
240010
+ params: { gid: homeId }
240011
+ });
240012
+ if (data) {
240013
+ const homeInfo = {
240014
+ address: data.data?.result?.geoName,
240015
+ homeName: data.data?.result?.name,
240016
+ homeId,
240017
+ latitude: data.data?.result?.lat,
240018
+ longitude: data.data?.result?.lon
240019
+ };
240020
+ return {
240021
+ data: homeInfo,
240022
+ errorCode: 0,
240023
+ errorMsg: import_TYUniCode9.TYUniPluginError.SUCCESS.des
240024
+ };
240025
+ } else {
240026
+ return {
240027
+ data: null,
240028
+ devices: [],
240029
+ errorCode: import_TYUniCode9.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.code,
240030
+ errorMsg: import_TYUniCode9.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.des
240031
+ };
240032
+ }
240033
+ }
240034
+ async function getRoomList(params) {
240035
+ const data = await ark.http.atop({
240036
+ api: "tuya.m.security.web.home.room.list.get",
240037
+ version: "1.0",
240038
+ params: { homeId: params.ownerId }
240039
+ });
240040
+ if (data.data?.result) {
240041
+ const result = data.data?.result;
240042
+ const list = [];
240043
+ result.map((item) => {
240044
+ if (item.roomId !== "ALL_DEVICE") {
240045
+ const room = {
240046
+ name: item.roomName,
240047
+ roomId: item.roomId,
240048
+ deviceIds: item.deviceList.map((dev) => dev.deviceId)
240049
+ };
240050
+ list.push(room);
240051
+ }
240052
+ });
240053
+ return {
240054
+ data: { roomDatas: list },
240055
+ errorCode: 0,
240056
+ errorMsg: import_TYUniCode9.TYUniPluginError.SUCCESS.des
240057
+ };
240058
+ } else {
240059
+ return {
240060
+ data: null,
240061
+ devices: [],
240062
+ errorCode: import_TYUniCode9.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.code,
240063
+ errorMsg: import_TYUniCode9.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.des
240064
+ };
240065
+ }
240066
+ }
240067
+ async function getDeviceIdList(params) {
240068
+ const data = await ark.http.atop({
240069
+ api: "tuya.m.security.web.home.room.list.get",
240070
+ version: "1.0",
240071
+ params: { homeId: params.ownerId }
240072
+ });
240073
+ if (data.data?.result) {
240074
+ const result = data.data?.result;
240075
+ const devices = result.find((item) => item.roomId === "ALL_DEVICE");
240076
+ return {
240077
+ data: { devIds: devices?.deviceList?.map((item) => item.deviceId) },
240078
+ errorCode: 0,
240079
+ errorMsg: import_TYUniCode9.TYUniPluginError.SUCCESS.des
240080
+ };
240081
+ } else {
240082
+ return {
240083
+ data: null,
240084
+ devices: [],
240085
+ errorCode: import_TYUniCode9.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.code,
240086
+ errorMsg: import_TYUniCode9.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.des
240087
+ };
240088
+ }
240089
+ }
240090
+ async function updateHomeInfoData(params) {
240091
+ const data = await ark.http.atop({
240092
+ api: "tuya.m.location.update",
240093
+ version: "2.0",
240094
+ params: {
240095
+ gid: params.homeId,
240096
+ name: params.homeName,
240097
+ lon: params.longitude,
240098
+ lat: params.latitude,
240099
+ geoName: params.address
240100
+ }
240101
+ });
240102
+ if (data.data?.result) {
240103
+ const result = data.data?.result;
240104
+ return {
240105
+ data: result,
240106
+ errorCode: 0,
240107
+ errorMsg: import_TYUniCode9.TYUniPluginError.SUCCESS.des
240108
+ };
240109
+ } else {
240110
+ return {
240111
+ data: null,
240112
+ devices: [],
240113
+ errorCode: import_TYUniCode9.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.code,
240114
+ errorMsg: import_TYUniCode9.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.des
240115
+ };
240116
+ }
240117
+ }
240118
+ ark.miniapp.addPluginMethod("TUNIHomeDataManager", "getCurrentHomeInfo", getCurrentHomeInfo);
240119
+ ark.miniapp.addPluginMethod("TUNIHomeDataManager", "updateHomeInfoData", updateHomeInfoData);
240120
+ ark.miniapp.addPluginMethod("TUNIHomeDeviceListManager", "getRoomList", getRoomList);
240121
+ ark.miniapp.addPluginMethod("TUNIHomeDeviceListManager", "getDeviceIdList", getDeviceIdList);
240122
+
240123
+ // worker/api/Bridge.ts
240124
+ var import_TYUniCode10 = __toESM(require_dist());
239980
240125
  var bridgeWall = {
239981
240126
  send(event, payload) {
239982
240127
  const data = { event, payload };
@@ -239996,7 +240141,7 @@ async function handle(params) {
239996
240141
  return {
239997
240142
  data: { status: 0 },
239998
240143
  errorCode: 0,
239999
- errorMsg: import_TYUniCode9.TYUniPluginError.SUCCESS.des
240144
+ errorMsg: import_TYUniCode10.TYUniPluginError.SUCCESS.des
240000
240145
  };
240001
240146
  } else {
240002
240147
  return checkOTAUpgradeStatus(params);
@@ -240038,14 +240183,13 @@ async function initMqtt() {
240038
240183
  const productId = await services_default.getProjectProductId();
240039
240184
  if (!productId)
240040
240185
  return;
240041
- await startMQTT({
240042
- productId
240043
- });
240186
+ await startMQTT();
240044
240187
  }
240045
240188
  async function initLaunchParams() {
240046
240189
  const status = await ark.auth.checkStatus();
240047
240190
  if (status !== "authorized")
240048
240191
  return;
240192
+ console.log("to getProjectDeviceId");
240049
240193
  let deviceId = await services_default.getProjectDeviceId();
240050
240194
  if (deviceId) {
240051
240195
  await getLangContent({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/ark-extension-virtual-device",
3
- "version": "1.1.27",
3
+ "version": "1.1.28-beta-2",
4
4
  "files": [
5
5
  "manifest.json",
6
6
  "package.json",