@tuya-miniapp/ark-extension-virtual-device 1.6.2-beta-7 → 1.6.2-beta-8

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.
@@ -280244,6 +280244,7 @@ async function getShareDeviceInfo(params) {
280244
280244
  errorMsg: import_TYUniCode3.TYUniPluginError.SUCCESS.des
280245
280245
  };
280246
280246
  }
280247
+ var __vasInfo = {};
280247
280248
  async function requestAdvancedCapability(params) {
280248
280249
  const { resId, type, dpCodes, spaceId } = params;
280249
280250
  if (!resId || !type || !dpCodes || !spaceId) {
@@ -280275,10 +280276,30 @@ async function requestAdvancedCapability(params) {
280275
280276
  vasCodes: dpCodes.join(","),
280276
280277
  gid: spaceId
280277
280278
  },
280278
- result
280279
+ JSON.stringify(result?.result?.vasInfo)
280279
280280
  );
280281
+ const { vasInfo, bizId, bizType } = result?.result || {};
280282
+ if (vasInfo && vasInfo.length > 0) {
280283
+ const r2 = vasInfo.reduce((acc, cur) => {
280284
+ const { vasCode, abilityEnabled, keyPoints } = cur;
280285
+ return {
280286
+ ...acc,
280287
+ [vasCode]: {
280288
+ abilityEnabled,
280289
+ keyPoints
280290
+ }
280291
+ };
280292
+ }, {});
280293
+ __vasInfo = {
280294
+ ...__vasInfo,
280295
+ [`${bizId}_${bizType}`]: {
280296
+ ...__vasInfo[`${bizId}_${bizType}`] || {},
280297
+ ...r2
280298
+ }
280299
+ };
280300
+ }
280280
280301
  return {
280281
- data: result.result,
280302
+ data: __vasInfo,
280282
280303
  errorCode: 0,
280283
280304
  errorMsg: import_TYUniCode3.TYUniPluginError.SUCCESS.des
280284
280305
  };
@@ -280290,6 +280311,69 @@ async function requestAdvancedCapability(params) {
280290
280311
  };
280291
280312
  }
280292
280313
  }
280314
+ function dpTranslateAdvancedCapability(params) {
280315
+ const { resId, dps, type } = params;
280316
+ if (!resId || !dps || !type) {
280317
+ return {
280318
+ data: null,
280319
+ errorCode: import_TYUniCode3.TYUniPluginError.INCORRECT_PARAM.code,
280320
+ errorMsg: import_TYUniCode3.TYUniPluginError.INCORRECT_PARAM.des
280321
+ };
280322
+ }
280323
+ const vasInfo = __vasInfo[`${resId}_${type}`] || {};
280324
+ const advancedCapability = dps.map((dp) => {
280325
+ const { dpCode, dpValue } = dp;
280326
+ const { abilityEnabled, keyPoints } = vasInfo[dpCode] || {};
280327
+ if (!abilityEnabled)
280328
+ return { dpCode };
280329
+ if (keyPoints.length < 2)
280330
+ return { dpCode };
280331
+ let statusValue = Number(dpValue);
280332
+ let leftAdvancedKeyPoint = keyPoints[0];
280333
+ let rightAdvancedKeyPoint = keyPoints[keyPoints.length - 1];
280334
+ const unit = leftAdvancedKeyPoint.unit;
280335
+ let leftOriginalValue = Number(leftAdvancedKeyPoint.originalValue);
280336
+ let rightOriginalValue = Number(rightAdvancedKeyPoint.originalValue);
280337
+ let leftDisplayValue = Number(leftAdvancedKeyPoint.displayValue);
280338
+ let rightDisplayValue = Number(rightAdvancedKeyPoint.displayValue);
280339
+ if (statusValue < leftOriginalValue || statusValue > rightOriginalValue) {
280340
+ return { dpCode };
280341
+ }
280342
+ for (let i2 = 0; i2 < keyPoints.length - 1; i2++) {
280343
+ const obj = keyPoints[i2];
280344
+ const originalValue = Number(obj.originalValue);
280345
+ if (originalValue > statusValue) {
280346
+ rightAdvancedKeyPoint = obj;
280347
+ break;
280348
+ } else {
280349
+ leftAdvancedKeyPoint = obj;
280350
+ }
280351
+ }
280352
+ leftOriginalValue = Number(leftAdvancedKeyPoint.originalValue);
280353
+ rightOriginalValue = Number(rightAdvancedKeyPoint.originalValue);
280354
+ leftDisplayValue = Number(leftAdvancedKeyPoint.displayValue);
280355
+ rightDisplayValue = Number(rightAdvancedKeyPoint.displayValue);
280356
+ let targetStatusValue = statusValue;
280357
+ if (rightOriginalValue == statusValue) {
280358
+ targetStatusValue = rightDisplayValue;
280359
+ } else if (leftOriginalValue == statusValue) {
280360
+ targetStatusValue = leftDisplayValue;
280361
+ } else {
280362
+ let showValuePerStep = (rightDisplayValue - leftDisplayValue) / (rightOriginalValue - leftOriginalValue);
280363
+ targetStatusValue = Math.floor((statusValue - leftOriginalValue) * showValuePerStep + leftDisplayValue);
280364
+ }
280365
+ return {
280366
+ dpCode,
280367
+ translatedValue: targetStatusValue,
280368
+ unit
280369
+ };
280370
+ });
280371
+ return {
280372
+ data: { advancedCapability },
280373
+ errorCode: 0,
280374
+ errorMsg: import_TYUniCode3.TYUniPluginError.SUCCESS.des
280375
+ };
280376
+ }
280293
280377
  var dbDataChangeCb = null;
280294
280378
  function onDpDataChange(cb) {
280295
280379
  dbDataChangeCb = cb;
@@ -280730,6 +280814,11 @@ ark.miniapp.addPluginMethod(
280730
280814
  "requestAdvancedCapability",
280731
280815
  requestAdvancedCapability
280732
280816
  );
280817
+ ark.miniapp.addPluginMethod(
280818
+ "TUNIDeviceControlManager",
280819
+ "dpTranslateAdvancedCapability",
280820
+ dpTranslateAdvancedCapability
280821
+ );
280733
280822
  ark.miniapp.addPluginMethod(
280734
280823
  "TUNIOTAManager",
280735
280824
  "registerOTACompleted",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/ark-extension-virtual-device",
3
- "version": "1.6.2-beta-7",
3
+ "version": "1.6.2-beta-8",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "manifest.json",