@tuya-miniapp/ark-extension-virtual-device 0.0.23 → 0.0.24
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 +55 -41
- package/package.json +1 -1
package/dist/worker/index.js
CHANGED
|
@@ -173196,6 +173196,7 @@ var queryDps = async ({ deviceId, dpIds }) => {
|
|
|
173196
173196
|
|
|
173197
173197
|
// worker/api/TYUniDeviceControlManager.ts
|
|
173198
173198
|
var deviceInfo = null;
|
|
173199
|
+
var cachedDeviceList = null;
|
|
173199
173200
|
async function getDeviceInfo2(params) {
|
|
173200
173201
|
const { deviceId } = params;
|
|
173201
173202
|
if (!deviceId) {
|
|
@@ -173216,18 +173217,15 @@ async function getDeviceInfo2(params) {
|
|
|
173216
173217
|
}
|
|
173217
173218
|
let product = {};
|
|
173218
173219
|
let dev = {};
|
|
173219
|
-
|
|
173220
|
-
|
|
173221
|
-
|
|
173222
|
-
|
|
173223
|
-
|
|
173224
|
-
|
|
173225
|
-
|
|
173226
|
-
|
|
173227
|
-
|
|
173228
|
-
}
|
|
173229
|
-
} catch (e) {
|
|
173230
|
-
console.log("\u672A\u83B7\u53D6\u5230\u4EA7\u54C1\u4FE1\u606F");
|
|
173220
|
+
const presponse = await getProductInfo2({
|
|
173221
|
+
productId: devInfo.productId,
|
|
173222
|
+
getDevices: true
|
|
173223
|
+
});
|
|
173224
|
+
const { data: productInfo, devices } = presponse || {};
|
|
173225
|
+
product = productInfo || {};
|
|
173226
|
+
if (devices) {
|
|
173227
|
+
const a = devices.filter((item) => item.devId === deviceId).pop();
|
|
173228
|
+
dev = a || {};
|
|
173231
173229
|
}
|
|
173232
173230
|
const { dps, schema } = devInfo;
|
|
173233
173231
|
const objSchema = {};
|
|
@@ -173255,12 +173253,12 @@ async function getDeviceInfo2(params) {
|
|
|
173255
173253
|
latitude: devInfo.lat,
|
|
173256
173254
|
longitude: devInfo.lon,
|
|
173257
173255
|
...dev.dataPointInfo,
|
|
173258
|
-
isVirtualDevice: dev.virtual
|
|
173256
|
+
isVirtualDevice: dev.virtual,
|
|
173257
|
+
panelConfig: product.panelConfig
|
|
173259
173258
|
};
|
|
173260
173259
|
const result = { ...deviceInfo };
|
|
173261
173260
|
delete result["accessType"];
|
|
173262
173261
|
delete result["appRnVersion"];
|
|
173263
|
-
delete result["panelConfig"];
|
|
173264
173262
|
delete result["rnFind"];
|
|
173265
173263
|
delete result["runtimeEnv"];
|
|
173266
173264
|
delete result["supportGroup"];
|
|
@@ -173332,44 +173330,39 @@ async function getProductInfo2(params) {
|
|
|
173332
173330
|
uiType: uiInfo.type,
|
|
173333
173331
|
uiVersion: uiInfo.ui.split("_").pop()
|
|
173334
173332
|
};
|
|
173335
|
-
|
|
173336
|
-
|
|
173337
|
-
const
|
|
173338
|
-
|
|
173339
|
-
|
|
173340
|
-
|
|
173341
|
-
|
|
173342
|
-
|
|
173343
|
-
|
|
173344
|
-
|
|
173345
|
-
|
|
173346
|
-
|
|
173347
|
-
|
|
173348
|
-
|
|
173349
|
-
|
|
173350
|
-
|
|
173351
|
-
|
|
173352
|
-
} =
|
|
173353
|
-
|
|
173354
|
-
const p = result.filter((item) => item.productId === params.productId).pop();
|
|
173355
|
-
if (p) {
|
|
173356
|
-
const { productVer } = p;
|
|
173357
|
-
productData["productVer"] = productVer;
|
|
173358
|
-
}
|
|
173333
|
+
const userInfo = await ark.auth.getCustomerUserInfo();
|
|
173334
|
+
if (userInfo && !cachedDeviceList) {
|
|
173335
|
+
const {
|
|
173336
|
+
extras: { homeId }
|
|
173337
|
+
} = userInfo;
|
|
173338
|
+
const deviceList = await ark.http.atop({
|
|
173339
|
+
api: "tuya.m.my.group.device.list",
|
|
173340
|
+
version: "2.1",
|
|
173341
|
+
meta: {
|
|
173342
|
+
gid: homeId
|
|
173343
|
+
}
|
|
173344
|
+
});
|
|
173345
|
+
if (deviceList) {
|
|
173346
|
+
const result = deviceList.data?.result;
|
|
173347
|
+
cachedDeviceList = result;
|
|
173348
|
+
const p = result.filter((item) => item.productId === params.productId).pop();
|
|
173349
|
+
if (p) {
|
|
173350
|
+
const { productVer } = p;
|
|
173351
|
+
productData["productVer"] = productVer;
|
|
173359
173352
|
}
|
|
173360
173353
|
}
|
|
173361
|
-
} catch (error) {
|
|
173362
|
-
console.error(error);
|
|
173363
173354
|
}
|
|
173364
173355
|
return {
|
|
173365
173356
|
data: productData,
|
|
173366
|
-
devices,
|
|
173357
|
+
devices: cachedDeviceList || [],
|
|
173367
173358
|
errorCode: !!productInfo ? 0 : import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.code,
|
|
173368
173359
|
errorMsg: !!productInfo ? import_TYUniCode.TYUniPluginError.SUCCESS.des : import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.des
|
|
173369
173360
|
};
|
|
173370
173361
|
} catch (e) {
|
|
173362
|
+
console.log("-------->>>error", e);
|
|
173371
173363
|
return {
|
|
173372
173364
|
data: null,
|
|
173365
|
+
devices: [],
|
|
173373
173366
|
errorCode: import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.code,
|
|
173374
173367
|
errorMsg: import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.des
|
|
173375
173368
|
};
|
|
@@ -174114,6 +174107,27 @@ ark.miniapp.addPluginMethod("TYUniGroupControlManager", "registerGroupChange", r
|
|
|
174114
174107
|
ark.miniapp.addPluginMethod("TYUniGroupControlManager", "unRegisterGroupChange", unRegisterGroupChange);
|
|
174115
174108
|
ark.miniapp.addPluginMethod("TYUniGroupControlManager", "getGroupInfo", getGroupInfo);
|
|
174116
174109
|
|
|
174110
|
+
// worker/api/TUNIAuthorizeManager.ts
|
|
174111
|
+
var import_TYUniCode7 = __toESM(require_dist());
|
|
174112
|
+
function authorizeStatus(params) {
|
|
174113
|
+
return {
|
|
174114
|
+
data: true,
|
|
174115
|
+
errorCode: 0,
|
|
174116
|
+
errorMsg: import_TYUniCode7.TYUniPluginError.SUCCESS.des
|
|
174117
|
+
};
|
|
174118
|
+
}
|
|
174119
|
+
function authorize(params) {
|
|
174120
|
+
return {
|
|
174121
|
+
data: true,
|
|
174122
|
+
errorCode: 0,
|
|
174123
|
+
errorMsg: import_TYUniCode7.TYUniPluginError.SUCCESS.des
|
|
174124
|
+
};
|
|
174125
|
+
}
|
|
174126
|
+
ark.miniapp.addPluginMethod("TUNIAuthorizeManager", "authorizeStatus", authorizeStatus);
|
|
174127
|
+
ark.miniapp.addPluginMethod("TUNIAuthorizeManager", "authorize", authorize);
|
|
174128
|
+
ark.miniapp.addPluginMethod("TYUNIAuthorizeManager", "authorizeStatus", authorizeStatus);
|
|
174129
|
+
ark.miniapp.addPluginMethod("TYUNIAuthorizeManager", "authorize", authorize);
|
|
174130
|
+
|
|
174117
174131
|
// worker/index.ts
|
|
174118
174132
|
console.log("ServicesMap", services_default);
|
|
174119
174133
|
ark.runtime.onMessage(async (event) => {
|