@ray-js/lock-sdk 1.2.0-beta.26 → 1.2.0-beta.27

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.
@@ -391,7 +391,20 @@ export async function getAlarmsForRuntime(rt, params) {
391
391
  dpCode,
392
392
  userName: record.userName,
393
393
  unlockName: record.unlockName,
394
- mediaInfo: record.mediaInfoList,
394
+ mediaInfo: record.mediaInfoList?.map?.(item => {
395
+ return {
396
+ mediaPath: item.mediaPath,
397
+ fileKey: item.fileKey,
398
+ fileUrl: item.fileUrl,
399
+ mediaBucket: item.mediaBucket,
400
+ mediaKey: item.mediaKey,
401
+ width: item.positionWidth,
402
+ height: item.positionHeight,
403
+ angle: item.positionAngle,
404
+ isVR: !!item.positionVr,
405
+ position: item.position,
406
+ };
407
+ }),
395
408
  time: record.gmtCreate,
396
409
  currentUser: +record.userId === +currentUser.userId,
397
410
  bindable: false,
@@ -1,5 +1,5 @@
1
1
  import { getDeviceAdvancedAbility, getProductAbilities } from "../../api";
2
- import { ProductCommunicationType } from "../../constant";
2
+ import { CommunicationType, ProductCommunicationType } from "../../constant";
3
3
  import { checkShowMatterMutilpleShare } from "../../platform/device";
4
4
  import { ipc } from "../../platform";
5
5
  import { getWithLocalCache } from "../storage/swr-cache";
@@ -17,11 +17,17 @@ export const isActiveThreadForRuntime = async (rt) => {
17
17
  if (hasThread) {
18
18
  if (rt.deviceStatus.onlineTypes.includes("cloud") ||
19
19
  rt.config.communication.length === 1) {
20
+ rt.cache.isActiveThreadCache = true;
20
21
  return true;
21
22
  }
22
23
  const hasBle = hasCapabilityForRuntime(rt, ProductCommunicationType.BLUETOOTH);
24
+ if (rt.config.capabilities?.communicationType === CommunicationType.THREAD) {
25
+ rt.cache.isActiveThreadCache = true;
26
+ return true;
27
+ }
23
28
  if (hasBle) {
24
29
  if (rt.cache.isActiveThreadCache) {
30
+ rt.cache.isActiveThreadCache = true;
25
31
  return true;
26
32
  }
27
33
  try {
@@ -1,17 +1,24 @@
1
+ import dpCodes from "src/config/dp-code";
1
2
  import { ProductCommunicationType } from "../../constant";
2
3
  import { isOnlineByType } from "../../utils";
4
+ import { hasDpForRuntime } from "../dp/has-dp";
3
5
  import { hasCapabilityForRuntime } from "./capability";
4
6
  export const isUseNearChannelForRuntime = (rt) => {
5
7
  const { onlineType, devInfo } = rt.config;
6
8
  const isBleOnline = isOnlineByType(onlineType, 2);
7
9
  const isSupportWifi = hasCapabilityForRuntime(rt, ProductCommunicationType.WIFI);
8
10
  const isSupportBle = hasCapabilityForRuntime(rt, ProductCommunicationType.BLUETOOTH);
11
+ if (isSupportWifi &&
12
+ isSupportBle &&
13
+ !hasDpForRuntime(rt, dpCodes.unlockBle)) {
14
+ return false;
15
+ }
9
16
  const isSupportThread = hasCapabilityForRuntime(rt, ProductCommunicationType.THREAD);
10
17
  if (isSupportWifi && isSupportBle) {
11
18
  return isBleOnline;
12
19
  }
13
20
  if (isSupportThread && isSupportBle) {
14
- return isBleOnline && !devInfo.isCloudOnline && !devInfo.isLocalOnline;
21
+ return isBleOnline && !devInfo.isCloudOnline;
15
22
  }
16
23
  return isBleOnline;
17
24
  };
@@ -1,4 +1,4 @@
1
- import { hasCapabilityForRuntime } from "../misc/capability";
1
+ import { hasCapabilityForRuntime, isActiveThreadForRuntime, } from "../misc/capability";
2
2
  import { hasDpForRuntime } from "../dp/has-dp";
3
3
  import dpCodes from "../../config/dp-code";
4
4
  import { ProductCommunicationType } from "../../constant";
@@ -13,9 +13,14 @@ import { getDpValueForRuntime } from "../dp/get-dp-value";
13
13
  import { readIsSleepForRuntime } from "./internal/read-is-sleep";
14
14
  import { isShareThreadRuntimeLocal } from "./internal/share-thread-local";
15
15
  export const updateOnlineType = async (runtime) => {
16
+ const hasThreadBle = hasCapabilityForRuntime(runtime, ProductCommunicationType.THREAD) &&
17
+ hasCapabilityForRuntime(runtime, ProductCommunicationType.BLUETOOTH);
16
18
  const [devInfo, onlineType] = await Promise.all([
17
19
  getDeviceInfo(runtime.config.devInfo.devId),
18
20
  getDeviceOnlineType(runtime.config.devInfo.devId),
21
+ hasThreadBle && runtime.cache.isActiveThreadCache !== true
22
+ ? isActiveThreadForRuntime(runtime)
23
+ : Promise.resolve(false),
19
24
  ]);
20
25
  runtime.config.onlineType = onlineType;
21
26
  runtime.config.devInfo = devInfo;
@@ -34,10 +39,17 @@ export const getDeviceStatusForRuntime = (runtime) => {
34
39
  onlineTypes: [],
35
40
  isWifiActive: wifiEnableState !== 1,
36
41
  isWifiMatter: !!isMatter && supportWifi,
42
+ isActiveThread: runtime.cache.isActiveThreadCache ?? false,
43
+ isShareThread: isShareThreadRuntimeLocal(runtime),
37
44
  };
38
45
  const isMatterLocal = isOnlineByType(onlineType, 8);
39
46
  const isBleOnline = isOnlineByType(onlineType, 2);
40
- const isLocalOnline = !isCloudOnline && isOnlineByType(onlineType, 1);
47
+ let isLocalOnline = !isCloudOnline && isOnlineByType(onlineType, 1);
48
+ if (isLocalOnline &&
49
+ runtime.cache.isActiveThreadCache !== true &&
50
+ supportThread) {
51
+ isLocalOnline = false;
52
+ }
41
53
  const hasWirelessAwakeDp = !notSupportWake && hasDpForRuntime(runtime, dpCodes.wirelessAwake);
42
54
  const wirelessAwake = getDpValueForRuntime(runtime, dpCodes.wirelessAwake);
43
55
  status.connectEnable = isSupportBleControlForRuntime(runtime) && !isOnline;
@@ -76,8 +88,7 @@ export const getDeviceStatusForRuntime = (runtime) => {
76
88
  }
77
89
  }
78
90
  if (supportThread && supportBle) {
79
- const isShareThread = isShareThreadRuntimeLocal(runtime);
80
- if (isShareThread && isOnline) {
91
+ if (status.isShareThread && isOnline) {
81
92
  if (!status.onlineTypes.includes("local")) {
82
93
  status.onlineTypes = ["local"];
83
94
  }
@@ -2,7 +2,7 @@ import dpCodes from "../../config/dp-code";
2
2
  import { getDeviceSkill, getIPCConfig, getRotateInfo } from "../../api/video";
3
3
  import { getDataWithPreFetchForRuntime } from "../utils";
4
4
  import { getWithLocalCache } from "../storage/swr-cache";
5
- import { getDeviceAdvancedAbilitiesForRuntime, } from "../misc/capability";
5
+ import { getDeviceAdvancedAbilitiesForRuntime, hasCapabilityForRuntime, isActiveThreadForRuntime, } from "../misc/capability";
6
6
  import { getCurrentUserForRuntime } from "../user/current-user";
7
7
  import { checkOfflineDpUpdateForRuntime } from "../offline-dps";
8
8
  import { autoSyncTemp } from "../password/sync-temp";
@@ -14,9 +14,9 @@ import syncT0 from "./sync/t0";
14
14
  import { getDeviceStatusForRuntime, updateOnlineType } from "./device-status";
15
15
  import { handleDpChange } from "./dp-change";
16
16
  import { fetchDeviceProperties } from "./remote-permissions";
17
- import { ipc, yuChannelSyncSingleSync } from "../../platform";
17
+ import { ipc, yuChannelSyncSingleSync, } from "../../platform";
18
18
  import { sdkLog } from "../../utils/sdk-log";
19
- import { RotateType } from "../../constant";
19
+ import { ProductCommunicationType, RotateType } from "../../constant";
20
20
  import { isHarmony } from "../../utils";
21
21
  export const initState = async (runtime) => {
22
22
  const { devInfo: { dps, devId, yuNetState }, dpSchema, } = runtime.config;
@@ -31,6 +31,7 @@ export const initState = async (runtime) => {
31
31
  try {
32
32
  handleDpChange(runtime, dps, true);
33
33
  const isSupportVideo = !!dpSchema[dpCodes.initiativeMessage];
34
+ const hasThread = hasCapabilityForRuntime(runtime, ProductCommunicationType.THREAD);
34
35
  runtime.deviceStatus = getDeviceStatusForRuntime(runtime);
35
36
  sdkLog("debug", "initState", "baseStateReady", {
36
37
  devId,
@@ -40,11 +41,12 @@ export const initState = async (runtime) => {
40
41
  isSupportVideo,
41
42
  },
42
43
  });
43
- const [, , , advanceAbilities, rotateInfo, deviceSkill, ipcConfig] = await Promise.allSettled([
44
+ const [, , , advanceAbilities, isActiveThread, rotateInfo, deviceSkill, ipcConfig,] = await Promise.allSettled([
44
45
  updateOnlineType(runtime),
45
46
  getCurrentUserForRuntime(runtime),
46
47
  fetchDeviceProperties(runtime),
47
48
  getDeviceAdvancedAbilitiesForRuntime(runtime),
49
+ hasThread ? isActiveThreadForRuntime(runtime) : Promise.resolve(false),
48
50
  isSupportVideo
49
51
  ?
50
52
  getDataWithPreFetchForRuntime(runtime, "getRotate", () => getWithLocalCache(runtime, "rotateInfo", () => getRotateInfo(devId), {
@@ -39,7 +39,6 @@ const globalHandleDeviceInfoChange = async ({ dps, deviceId, }) => {
39
39
  handleDpChange(rt, dps);
40
40
  }
41
41
  await updateOnlineType(rt);
42
- updateDeviceStatus(rt);
43
42
  };
44
43
  const globalUpdateAllOnlineTypes = async (data) => {
45
44
  if (!data?.deviceId) {
@@ -3,10 +3,12 @@ import { deleteUserForRuntime } from "./delete-user-dp";
3
3
  import { isUseNearChannelForRuntime } from "../misc/is-use-near-channel-for-runtime";
4
4
  import { publishDpsOnlyWithRuntime, } from "../dp/publish-dps";
5
5
  import dpCodes from "../../config/dp-code";
6
- import { isBlePureDeviceForRuntime } from "../misc/capability";
6
+ import { hasCapabilityForRuntime, isBlePureDeviceForRuntime } from "../misc/capability";
7
7
  import { sdkLog } from "../../utils/sdk-log";
8
+ import { ProductCommunicationType } from "src/constant";
8
9
  export async function syncDeleteUsersWithRuntime(runtime) {
9
- if (runtime.config.devInfo.wifiEnableState !== 1) {
10
+ const hasWifi = hasCapabilityForRuntime(runtime, ProductCommunicationType.WIFI);
11
+ if (hasWifi && runtime.config.devInfo.wifiEnableState !== 1) {
10
12
  sdkLog("debug", "syncUser", "deleteUsersSkipped", {
11
13
  devId: runtime.devId,
12
14
  data: { reason: "wifiActive" },
@@ -216,6 +216,8 @@ export interface DeviceStatus {
216
216
  };
217
217
  isWifiActive: boolean;
218
218
  isWifiMatter: boolean;
219
+ isActiveThread: boolean;
220
+ isShareThread: boolean;
219
221
  }
220
222
  export interface UnionUnlockInfo {
221
223
  userId: string;
@@ -7,6 +7,8 @@ export function createDefaultDeviceStatus() {
7
7
  onlineTypes: [],
8
8
  isWifiActive: false,
9
9
  isWifiMatter: false,
10
+ isActiveThread: false,
11
+ isShareThread: false,
10
12
  };
11
13
  }
12
14
  export function createLockConfigState() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.2.0-beta.26",
3
+ "version": "1.2.0-beta.27",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"