@ray-js/lock-sdk 1.2.0-beta.9 → 1.2.0
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/lib/api/fit.d.ts +55 -2
- package/lib/api/fit.js +43 -1
- package/lib/api/gesture.d.ts +11 -0
- package/lib/api/gesture.js +18 -0
- package/lib/api/log.d.ts +52 -4
- package/lib/api/log.js +22 -0
- package/lib/api/temp.d.ts +21 -0
- package/lib/api/temp.js +24 -0
- package/lib/config/dp-code/index.d.ts +1 -1
- package/lib/config/dp-code/index.js +1 -0
- package/lib/entries/main/bootstrap/bootstrap-lock-instance.d.ts +2 -1
- package/lib/entries/main/bootstrap/bootstrap-lock-instance.js +23 -8
- package/lib/entries/main/bootstrap/bootstrap.d.ts +3 -2
- package/lib/entries/main/bootstrap/bootstrap.js +10 -6
- package/lib/entries/main/bootstrap/primary-instance.d.ts +1 -2
- package/lib/entries/main/bootstrap/primary-instance.js +1 -1
- package/lib/entries/main/bootstrap/resolve-runtime-from-export-this.js +1 -1
- package/lib/entries/main/build-instance.d.ts +6 -3
- package/lib/entries/main/build-instance.js +13 -1
- package/lib/entries/main/exports/capability.d.ts +2 -0
- package/lib/entries/main/exports/capability.js +7 -1
- package/lib/entries/main/exports/fit-sdk/binding.d.ts +10 -0
- package/lib/entries/{fit/exports → main/exports/fit-sdk}/binding.js +6 -3
- package/lib/entries/{fit/exports → main/exports/fit-sdk}/device.d.ts +11 -10
- package/lib/entries/{fit/exports → main/exports/fit-sdk}/device.js +20 -20
- package/lib/entries/{fit/exports → main/exports/fit-sdk}/index.d.ts +1 -0
- package/lib/entries/{fit/exports → main/exports/fit-sdk}/index.js +1 -0
- package/lib/entries/main/exports/fit-sdk/log.d.ts +3 -0
- package/lib/entries/main/exports/fit-sdk/log.js +5 -0
- package/lib/entries/main/exports/fit-sdk/temp.d.ts +40 -0
- package/lib/entries/main/exports/fit-sdk/temp.js +59 -0
- package/lib/entries/main/exports/gesture.d.ts +6 -0
- package/lib/entries/main/exports/gesture.js +8 -0
- package/lib/entries/main/exports/index.d.ts +5 -0
- package/lib/entries/main/exports/index.js +5 -0
- package/lib/entries/main/exports/log.d.ts +2 -0
- package/lib/entries/main/exports/log.js +7 -1
- package/lib/entries/main/exports/misc.d.ts +4 -2
- package/lib/entries/main/exports/misc.js +2 -2
- package/lib/entries/main/index.d.ts +3 -3
- package/lib/entries/main/index.js +11 -5
- package/lib/feature/fit/bind-lock-to-fit.d.ts +1 -0
- package/lib/feature/fit/bind-lock-to-fit.js +53 -0
- package/lib/feature/fit/ble-key.d.ts +10 -4
- package/lib/feature/fit/ble-key.js +145 -4
- package/lib/feature/fit/device-bv.d.ts +2 -0
- package/lib/feature/fit/device-bv.js +15 -0
- package/lib/feature/fit/invalid-password.d.ts +10 -0
- package/lib/feature/fit/invalid-password.js +43 -0
- package/lib/feature/fit/list.d.ts +12 -2
- package/lib/feature/fit/list.js +54 -5
- package/lib/feature/fit/log.d.ts +7 -0
- package/lib/feature/fit/log.js +123 -0
- package/lib/feature/fit/method/add-flow.js +2 -2
- package/lib/feature/fit/method/add-password.js +2 -2
- package/lib/feature/fit/method/update-remove.js +40 -14
- package/lib/feature/fit/password-list.d.ts +37 -0
- package/lib/feature/fit/password-list.js +44 -1
- package/lib/feature/fit/security-channel.d.ts +3 -0
- package/lib/feature/fit/security-channel.js +43 -0
- package/lib/feature/fit/shared.d.ts +8 -0
- package/lib/feature/fit/shared.js +40 -1
- package/lib/feature/fit/sync.d.ts +4 -2
- package/lib/feature/fit/sync.js +63 -22
- package/lib/feature/fit/temp-password.d.ts +23 -0
- package/lib/feature/fit/temp-password.js +95 -3
- package/lib/feature/fit/users.d.ts +1 -0
- package/lib/feature/fit/users.js +1 -0
- package/lib/feature/gesture/gesture.d.ts +6 -0
- package/lib/feature/gesture/gesture.js +3 -0
- package/lib/feature/log/log.d.ts +5 -1
- package/lib/feature/log/log.js +53 -6
- package/lib/feature/misc/ble-control.js +2 -2
- package/lib/feature/misc/capability.d.ts +2 -0
- package/lib/feature/misc/capability.js +33 -31
- package/lib/feature/misc/connect-device.d.ts +1 -1
- package/lib/feature/misc/connect-device.js +7 -6
- package/lib/feature/misc/is-use-near-channel-for-runtime.js +8 -1
- package/lib/feature/password/temporary/offline-create.d.ts +14 -0
- package/lib/feature/password/temporary/offline-create.js +77 -1
- package/lib/feature/service/goto-service.d.ts +1 -1
- package/lib/feature/state/clear.js +1 -0
- package/lib/feature/state/device-status.js +17 -6
- package/lib/feature/state/init-state.js +17 -9
- package/lib/feature/state/platform-routing.js +12 -3
- package/lib/feature/state/remote-permissions.js +2 -1
- package/lib/feature/state/sync/remote-serect-key.js +7 -0
- package/lib/feature/storage/swr-cache.d.ts +7 -0
- package/lib/feature/storage/swr-cache.js +54 -0
- package/lib/feature/unlock/method/add-flow.js +2 -2
- package/lib/feature/unlock/method/add-password.js +2 -2
- package/lib/feature/user/sync-user.js +4 -2
- package/lib/feature/utils/index.d.ts +1 -0
- package/lib/feature/utils/index.js +1 -0
- package/lib/interface.d.ts +23 -1
- package/lib/platform/device.d.ts +4 -3
- package/lib/platform/ipc.d.ts +3 -0
- package/lib/platform/ipc.js +13 -0
- package/lib/platform/storage.d.ts +1 -1
- package/lib/runtime/LockDeviceRuntime.js +3 -0
- package/lib/runtime/lock-config.d.ts +3 -0
- package/lib/runtime/lock-config.js +5 -0
- package/lib/runtime/runtime-state-types.d.ts +6 -0
- package/lib/utils/constant.d.ts +1 -0
- package/lib/utils/constant.js +6 -0
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +1 -0
- package/package.json +1 -11
- package/lib/bootstrap/bootstrap-lock-instance.d.ts +0 -7
- package/lib/bootstrap/bootstrap-lock-instance.js +0 -16
- package/lib/bootstrap/bootstrap.d.ts +0 -4
- package/lib/bootstrap/bootstrap.js +0 -53
- package/lib/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
- package/lib/bootstrap/lock-instance-runtime-ref.js +0 -7
- package/lib/bootstrap/primary-instance.d.ts +0 -6
- package/lib/bootstrap/primary-instance.js +0 -24
- package/lib/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
- package/lib/bootstrap/resolve-runtime-from-export-this.js +0 -29
- package/lib/bootstrap/top-level-runtime.d.ts +0 -2
- package/lib/bootstrap/top-level-runtime.js +0 -9
- package/lib/entries/ble/bootstrap/bootstrap-lock-instance.d.ts +0 -7
- package/lib/entries/ble/bootstrap/bootstrap-lock-instance.js +0 -12
- package/lib/entries/ble/bootstrap/bootstrap.d.ts +0 -4
- package/lib/entries/ble/bootstrap/bootstrap.js +0 -53
- package/lib/entries/ble/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
- package/lib/entries/ble/bootstrap/lock-instance-runtime-ref.js +0 -7
- package/lib/entries/ble/bootstrap/primary-instance.d.ts +0 -6
- package/lib/entries/ble/bootstrap/primary-instance.js +0 -24
- package/lib/entries/ble/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
- package/lib/entries/ble/bootstrap/resolve-runtime-from-export-this.js +0 -29
- package/lib/entries/ble/bootstrap/top-level-runtime.d.ts +0 -2
- package/lib/entries/ble/bootstrap/top-level-runtime.js +0 -9
- package/lib/entries/ble/build-instance.d.ts +0 -9
- package/lib/entries/ble/build-instance.js +0 -50
- package/lib/entries/ble/exports/capability.d.ts +0 -6
- package/lib/entries/ble/exports/capability.js +0 -17
- package/lib/entries/ble/exports/config.d.ts +0 -3
- package/lib/entries/ble/exports/config.js +0 -5
- package/lib/entries/ble/exports/dp.d.ts +0 -9
- package/lib/entries/ble/exports/dp.js +0 -13
- package/lib/entries/ble/exports/index.d.ts +0 -16
- package/lib/entries/ble/exports/index.js +0 -16
- package/lib/entries/ble/exports/linkage.d.ts +0 -5
- package/lib/entries/ble/exports/linkage.js +0 -15
- package/lib/entries/ble/exports/log.d.ts +0 -9
- package/lib/entries/ble/exports/log.js +0 -21
- package/lib/entries/ble/exports/media.d.ts +0 -4
- package/lib/entries/ble/exports/media.js +0 -12
- package/lib/entries/ble/exports/misc.d.ts +0 -19
- package/lib/entries/ble/exports/misc.js +0 -30
- package/lib/entries/ble/exports/offline-dps.d.ts +0 -8
- package/lib/entries/ble/exports/offline-dps.js +0 -24
- package/lib/entries/ble/exports/open/do-open-close-action.d.ts +0 -2
- package/lib/entries/ble/exports/open/do-open-close-action.js +0 -36
- package/lib/entries/ble/exports/open/index.d.ts +0 -18
- package/lib/entries/ble/exports/open/index.js +0 -45
- package/lib/entries/ble/exports/signal.d.ts +0 -6
- package/lib/entries/ble/exports/signal.js +0 -14
- package/lib/entries/ble/exports/sleep.d.ts +0 -13
- package/lib/entries/ble/exports/sleep.js +0 -31
- package/lib/entries/ble/exports/state.d.ts +0 -6
- package/lib/entries/ble/exports/state.js +0 -19
- package/lib/entries/ble/exports/temporary.d.ts +0 -31
- package/lib/entries/ble/exports/temporary.js +0 -91
- package/lib/entries/ble/exports/unlock/sync.d.ts +0 -1
- package/lib/entries/ble/exports/unlock/sync.js +0 -5
- package/lib/entries/ble/exports/unlock-method.d.ts +0 -19
- package/lib/entries/ble/exports/unlock-method.js +0 -58
- package/lib/entries/ble/exports/user/index.d.ts +0 -23
- package/lib/entries/ble/exports/user/index.js +0 -22
- package/lib/entries/ble/exports/user/sync.d.ts +0 -1
- package/lib/entries/ble/exports/user/sync.js +0 -5
- package/lib/entries/ble/index.d.ts +0 -8
- package/lib/entries/ble/index.js +0 -39
- package/lib/entries/fit/bootstrap/bootstrap-lock-instance.d.ts +0 -7
- package/lib/entries/fit/bootstrap/bootstrap-lock-instance.js +0 -12
- package/lib/entries/fit/bootstrap/bootstrap.d.ts +0 -4
- package/lib/entries/fit/bootstrap/bootstrap.js +0 -69
- package/lib/entries/fit/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
- package/lib/entries/fit/bootstrap/lock-instance-runtime-ref.js +0 -7
- package/lib/entries/fit/bootstrap/primary-instance.d.ts +0 -6
- package/lib/entries/fit/bootstrap/primary-instance.js +0 -24
- package/lib/entries/fit/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
- package/lib/entries/fit/bootstrap/resolve-runtime-from-export-this.js +0 -29
- package/lib/entries/fit/bootstrap/top-level-runtime.d.ts +0 -2
- package/lib/entries/fit/bootstrap/top-level-runtime.js +0 -9
- package/lib/entries/fit/build-instance.d.ts +0 -9
- package/lib/entries/fit/build-instance.js +0 -57
- package/lib/entries/fit/exports/binding.d.ts +0 -8
- package/lib/entries/fit/exports/temp.d.ts +0 -19
- package/lib/entries/fit/exports/temp.js +0 -18
- package/lib/entries/fit/index.d.ts +0 -8
- package/lib/entries/fit/index.js +0 -36
- package/lib/entries/main/exports/open.d.ts +0 -16
- package/lib/entries/main/exports/open.js +0 -44
- package/lib/entries/screen/bootstrap/bootstrap-lock-instance.d.ts +0 -7
- package/lib/entries/screen/bootstrap/bootstrap-lock-instance.js +0 -12
- package/lib/entries/screen/bootstrap/bootstrap.d.ts +0 -4
- package/lib/entries/screen/bootstrap/bootstrap.js +0 -69
- package/lib/entries/screen/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
- package/lib/entries/screen/bootstrap/lock-instance-runtime-ref.js +0 -7
- package/lib/entries/screen/bootstrap/primary-instance.d.ts +0 -6
- package/lib/entries/screen/bootstrap/primary-instance.js +0 -24
- package/lib/entries/screen/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
- package/lib/entries/screen/bootstrap/resolve-runtime-from-export-this.js +0 -29
- package/lib/entries/screen/bootstrap/top-level-runtime.d.ts +0 -2
- package/lib/entries/screen/bootstrap/top-level-runtime.js +0 -9
- package/lib/entries/screen/build-instance.d.ts +0 -9
- package/lib/entries/screen/build-instance.js +0 -57
- package/lib/entries/screen/exports/bind-events.d.ts +0 -4
- package/lib/entries/screen/exports/bind-events.js +0 -8
- package/lib/entries/screen/exports/binding.d.ts +0 -6
- package/lib/entries/screen/exports/binding.js +0 -15
- package/lib/entries/screen/exports/device.d.ts +0 -16
- package/lib/entries/screen/exports/device.js +0 -41
- package/lib/entries/screen/exports/event.d.ts +0 -3
- package/lib/entries/screen/exports/event.js +0 -5
- package/lib/entries/screen/exports/index.d.ts +0 -5
- package/lib/entries/screen/exports/index.js +0 -5
- package/lib/entries/screen/exports/user.d.ts +0 -2
- package/lib/entries/screen/exports/user.js +0 -8
- package/lib/entries/screen/index.d.ts +0 -8
- package/lib/entries/screen/index.js +0 -36
- package/lib/feature/unlock/door/door-action.d.ts +0 -2
- package/lib/feature/unlock/door/door-action.js +0 -32
- package/lib/fit.d.ts +0 -4
- package/lib/fit.js +0 -3
- package/lib/runtime/device-status/compute-device-status.d.ts +0 -25
- package/lib/runtime/device-status/compute-device-status.js +0 -94
- package/lib/screen.d.ts +0 -4
- package/lib/screen.js +0 -3
|
@@ -1,6 +1,8 @@
|
|
|
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
|
+
import { ipc } from "../../platform";
|
|
5
|
+
import { getWithLocalCache } from "../storage/swr-cache";
|
|
4
6
|
export const hasCapabilityForRuntime = (runtime, capability) => runtime.config.communication.includes(capability);
|
|
5
7
|
export const isBlePureDeviceForRuntime = (rt) => hasCapabilityForRuntime(rt, ProductCommunicationType.BLUETOOTH) &&
|
|
6
8
|
rt.config.communication.length === 1;
|
|
@@ -15,11 +17,17 @@ export const isActiveThreadForRuntime = async (rt) => {
|
|
|
15
17
|
if (hasThread) {
|
|
16
18
|
if (rt.deviceStatus.onlineTypes.includes("cloud") ||
|
|
17
19
|
rt.config.communication.length === 1) {
|
|
20
|
+
rt.cache.isActiveThreadCache = true;
|
|
18
21
|
return true;
|
|
19
22
|
}
|
|
20
23
|
const hasBle = hasCapabilityForRuntime(rt, ProductCommunicationType.BLUETOOTH);
|
|
24
|
+
if (rt.config.capabilities?.communicationType === CommunicationType.THREAD) {
|
|
25
|
+
rt.cache.isActiveThreadCache = true;
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
21
28
|
if (hasBle) {
|
|
22
29
|
if (rt.cache.isActiveThreadCache) {
|
|
30
|
+
rt.cache.isActiveThreadCache = true;
|
|
23
31
|
return true;
|
|
24
32
|
}
|
|
25
33
|
try {
|
|
@@ -52,28 +60,31 @@ const allModes = [
|
|
|
52
60
|
value: 2,
|
|
53
61
|
},
|
|
54
62
|
];
|
|
63
|
+
export const getDeviceAdvancedAbilitiesSyncForRuntime = (rt) => {
|
|
64
|
+
return rt.cache.deviceAdvanceAbilityCache;
|
|
65
|
+
};
|
|
55
66
|
export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
|
|
56
67
|
if (rt.cache.deviceAdvanceAbilityCache) {
|
|
57
68
|
return rt.cache.deviceAdvanceAbilityCache;
|
|
58
69
|
}
|
|
59
|
-
const
|
|
60
|
-
|
|
70
|
+
const devId = rt.config.devInfo.devId;
|
|
71
|
+
const [productAbilitiesRes, deviceAdvancedAbilityRes, tttList] = await Promise.allSettled([
|
|
72
|
+
getWithLocalCache(rt, "productAbilities", () => getProductAbilities(devId, [
|
|
61
73
|
"tyabi4ucx5",
|
|
62
74
|
"tyabis9tpe",
|
|
63
75
|
"tyabiwxrn9",
|
|
64
76
|
"tyabipd4hh",
|
|
65
77
|
"tyabin4u5v",
|
|
66
78
|
"visual_door_lock_cloud_store",
|
|
67
|
-
]),
|
|
68
|
-
getDeviceAdvancedAbility(
|
|
79
|
+
])),
|
|
80
|
+
getWithLocalCache(rt, "deviceAdvancedAbility", () => getDeviceAdvancedAbility(devId)),
|
|
81
|
+
ipc.getTTTAbilityKeyList("isSupportedVRMode"),
|
|
69
82
|
]);
|
|
70
83
|
const productAbilities = productAbilitiesRes.status === "fulfilled" ? productAbilitiesRes.value : [];
|
|
71
|
-
const
|
|
72
|
-
? deviceAdvancedAbilityRes.value
|
|
73
|
-
: undefined;
|
|
84
|
+
const tttAbList = tttList.status === "fulfilled" ? tttList.value.abilityList : [];
|
|
74
85
|
const deviceAdvanceAbilityCache = {
|
|
75
86
|
cloudStorage: {
|
|
76
|
-
support:
|
|
87
|
+
support: false,
|
|
77
88
|
},
|
|
78
89
|
vr: {
|
|
79
90
|
support: false,
|
|
@@ -127,26 +138,9 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
|
|
|
127
138
|
petRecognition ||
|
|
128
139
|
voice ||
|
|
129
140
|
message;
|
|
130
|
-
deviceAdvanceAbilityCache.vr.support =
|
|
141
|
+
deviceAdvanceAbilityCache.vr.support =
|
|
142
|
+
!!data?.lock_VR && tttAbList.length > 0;
|
|
131
143
|
if (deviceAdvanceAbilityCache.vr.support) {
|
|
132
|
-
const modeMap = {
|
|
133
|
-
original: {
|
|
134
|
-
mode: "original",
|
|
135
|
-
value: 0,
|
|
136
|
-
},
|
|
137
|
-
VR: {
|
|
138
|
-
mode: "VR",
|
|
139
|
-
value: 1,
|
|
140
|
-
},
|
|
141
|
-
horizontal: {
|
|
142
|
-
mode: "horizontal",
|
|
143
|
-
value: 2,
|
|
144
|
-
},
|
|
145
|
-
vertical: {
|
|
146
|
-
mode: "vertical",
|
|
147
|
-
value: 3,
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
144
|
deviceAdvanceAbilityCache.vr.modes = allModes.filter((item) => {
|
|
151
145
|
return data?.modes?.includes(item.mode);
|
|
152
146
|
});
|
|
@@ -154,7 +148,7 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
|
|
|
154
148
|
const exist = deviceAdvanceAbilityCache.vr.modes.find((x) => x.mode === deviceAdvanceAbilityCache.vr.defaultMode);
|
|
155
149
|
if (!exist) {
|
|
156
150
|
deviceAdvanceAbilityCache.vr.defaultMode =
|
|
157
|
-
deviceAdvanceAbilityCache.vr.modes?.[0]
|
|
151
|
+
deviceAdvanceAbilityCache.vr.modes?.[0]?.mode;
|
|
158
152
|
}
|
|
159
153
|
deviceAdvanceAbilityCache.vr.coverMode = data.photo_cover_format;
|
|
160
154
|
}
|
|
@@ -166,8 +160,6 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
|
|
|
166
160
|
break;
|
|
167
161
|
}
|
|
168
162
|
case "tyabiwxrn9": {
|
|
169
|
-
deviceAdvanceAbilityCache.wechatVoip.support =
|
|
170
|
-
deviceAdvancedAbility?.types?.includes(1) ?? false;
|
|
171
163
|
deviceAdvanceAbilityCache.wechatVoip.isPublice =
|
|
172
164
|
data?.WechatType === "0";
|
|
173
165
|
if (!deviceAdvanceAbilityCache.wechatVoip.isPublice) {
|
|
@@ -197,6 +189,16 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
|
|
|
197
189
|
console.warn(`setting [${item.abilityCode}] config error`, error);
|
|
198
190
|
}
|
|
199
191
|
});
|
|
192
|
+
if (deviceAdvancedAbilityRes.status === "fulfilled") {
|
|
193
|
+
const res = deviceAdvancedAbilityRes.value;
|
|
194
|
+
deviceAdvanceAbilityCache.cloudStorage.support =
|
|
195
|
+
res.types?.includes(0) ?? false;
|
|
196
|
+
deviceAdvanceAbilityCache.wechatVoip.support =
|
|
197
|
+
res.types?.includes(1) ?? false;
|
|
198
|
+
}
|
|
200
199
|
rt.cache.deviceAdvanceAbilityCache = deviceAdvanceAbilityCache;
|
|
201
200
|
return deviceAdvanceAbilityCache;
|
|
202
201
|
};
|
|
202
|
+
export const getDeviceCapabilitiesForRuntime = (rt) => {
|
|
203
|
+
return rt.config.capabilities;
|
|
204
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
|
|
2
|
-
export declare function connectDeviceForRuntime(rt: LockDeviceRuntime): Promise<true>;
|
|
2
|
+
export declare function connectDeviceForRuntime(rt: LockDeviceRuntime, timeout?: number): Promise<true>;
|
|
@@ -72,7 +72,7 @@ const awakeDevice = async (devId, timeout) => {
|
|
|
72
72
|
run();
|
|
73
73
|
});
|
|
74
74
|
};
|
|
75
|
-
const connectBle = async (devId) => {
|
|
75
|
+
const connectBle = async (devId, timeout) => {
|
|
76
76
|
const startedAt = Date.now();
|
|
77
77
|
sdkLog("info", "connectDevice", "bleConnectStart", { devId });
|
|
78
78
|
return new Promise((resolve, reject) => {
|
|
@@ -109,7 +109,7 @@ const connectBle = async (devId) => {
|
|
|
109
109
|
error,
|
|
110
110
|
});
|
|
111
111
|
reject(error);
|
|
112
|
-
}, 15000);
|
|
112
|
+
}, timeout ?? 15000);
|
|
113
113
|
const clearTimer = () => {
|
|
114
114
|
clearTimeout(timer);
|
|
115
115
|
offBleChange(handleStatusChange);
|
|
@@ -143,7 +143,7 @@ const connectBle = async (devId) => {
|
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
145
|
};
|
|
146
|
-
export async function connectDeviceForRuntime(rt) {
|
|
146
|
+
export async function connectDeviceForRuntime(rt, timeout) {
|
|
147
147
|
const cfg = rt.config;
|
|
148
148
|
const devId = cfg.devInfo.devId;
|
|
149
149
|
const deviceStatus = getDeviceStatusForRuntime(rt);
|
|
@@ -154,12 +154,13 @@ export async function connectDeviceForRuntime(rt) {
|
|
|
154
154
|
data: {
|
|
155
155
|
statusType: deviceStatus.type,
|
|
156
156
|
onlineTypes: deviceStatus.onlineTypes,
|
|
157
|
+
connectEnable: deviceStatus.connectEnable,
|
|
157
158
|
hasWirelessAwakeDp,
|
|
158
159
|
},
|
|
159
160
|
});
|
|
160
|
-
if (hasWirelessAwakeDp) {
|
|
161
|
+
if (deviceStatus.connectEnable && hasWirelessAwakeDp) {
|
|
161
162
|
if (cfg.devInfo.isCloudOnline && !getDpValueForRuntime(rt, wirelessAwake)) {
|
|
162
|
-
const result = await awakeDevice(devId);
|
|
163
|
+
const result = await awakeDevice(devId, timeout);
|
|
163
164
|
sdkLog("info", "connectDevice", "success", {
|
|
164
165
|
devId,
|
|
165
166
|
duration: Date.now() - startedAt,
|
|
@@ -178,7 +179,7 @@ export async function connectDeviceForRuntime(rt) {
|
|
|
178
179
|
});
|
|
179
180
|
return true;
|
|
180
181
|
}
|
|
181
|
-
await connectBle(devId);
|
|
182
|
+
await connectBle(devId, timeout);
|
|
182
183
|
if (rt.cache.deviceAdvanceAbilityCache?.yuChannel.support) {
|
|
183
184
|
if (rt.cache.deviceAdvanceAbilityCache?.yuChannel.value === 1) {
|
|
184
185
|
yuChannelSyncSingleSync(devId);
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
+
import dpCodes from "../../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
|
|
21
|
+
return isBleOnline && !devInfo.isCloudOnline;
|
|
15
22
|
}
|
|
16
23
|
return isBleOnline;
|
|
17
24
|
};
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
import { type LimitOfflinePwdItem, type OfflinePwdAvailableResult } from "../../../api/temp";
|
|
1
2
|
import type { TempPasswordResult } from "../../../interface";
|
|
2
3
|
import type { LockDeviceRuntime } from "../../../runtime/LockDeviceRuntime";
|
|
3
4
|
import type { CreateClearParams, CreateLimitParams, CreateOnceParams } from "./types";
|
|
4
5
|
export declare function createTempLimitForRuntime(rt: LockDeviceRuntime, params: CreateLimitParams): Promise<TempPasswordResult>;
|
|
5
6
|
export declare function createTempOnceForRuntime(rt: LockDeviceRuntime, params: CreateOnceParams): Promise<TempPasswordResult>;
|
|
7
|
+
export interface FitOfflineOnceResult {
|
|
8
|
+
password: string;
|
|
9
|
+
pwdId: string;
|
|
10
|
+
gmtExpired: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function createFitOfflineOnceForRuntime(rt: LockDeviceRuntime): Promise<FitOfflineOnceResult>;
|
|
13
|
+
export declare function createFitOfflineLimitForRuntime(rt: LockDeviceRuntime, params: {
|
|
14
|
+
effectiveTime: number;
|
|
15
|
+
invalidTime: number;
|
|
16
|
+
}): Promise<FitOfflineOnceResult>;
|
|
17
|
+
export declare function createFitOfflineClearAllForRuntime(rt: LockDeviceRuntime): Promise<FitOfflineOnceResult>;
|
|
18
|
+
export declare function getFitOfflineRevocableListForRuntime(rt: LockDeviceRuntime): Promise<LimitOfflinePwdItem[]>;
|
|
19
|
+
export declare function getFitOfflinePwdAvailableForRuntime(rt: LockDeviceRuntime, pwdType: string): Promise<OfflinePwdAvailableResult>;
|
|
6
20
|
export declare function createTempDynamicForRuntime(rt: LockDeviceRuntime): Promise<TempPasswordResult>;
|
|
7
21
|
export declare function createTempClearForRuntime(rt: LockDeviceRuntime, params: CreateClearParams): Promise<TempPasswordResult>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDynamicPassword, revokeOfflinePassword, } from "../../../api/temp";
|
|
1
|
+
import { createOfflineOnceAPI, getDynamicPassword, getLimitOfflinePwdListForClear, getOfflinePwdAvailable, revokeOfflinePassword, } from "../../../api/temp";
|
|
2
2
|
import { parseOfflinePasswordForRuntime } from "../../utils";
|
|
3
3
|
import { getError, handleCloudError } from "../../../utils/errors";
|
|
4
4
|
import { getOfflinePassword } from "./internal/password-helpers";
|
|
@@ -87,6 +87,82 @@ export async function createTempOnceForRuntime(rt, params) {
|
|
|
87
87
|
},
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
+
async function createFitOfflinePwdForRuntime(rt, params) {
|
|
91
|
+
const startedAt = Date.now();
|
|
92
|
+
sdkLog("info", "tempPassword", "createFitOfflinePwdStart", {
|
|
93
|
+
devId: rt.devId,
|
|
94
|
+
data: { pwdType: params.pwdType },
|
|
95
|
+
});
|
|
96
|
+
try {
|
|
97
|
+
const res = await createOfflineOnceAPI({
|
|
98
|
+
devId: rt.devId,
|
|
99
|
+
...params,
|
|
100
|
+
});
|
|
101
|
+
sdkLog("info", "tempPassword", "createFitOfflinePwdSuccess", {
|
|
102
|
+
devId: rt.devId,
|
|
103
|
+
duration: Date.now() - startedAt,
|
|
104
|
+
data: { pwdType: params.pwdType },
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
password: parseOfflinePasswordForRuntime(rt, res.pwd),
|
|
108
|
+
pwdId: res.pwdId,
|
|
109
|
+
gmtExpired: res.gmtExpired,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
sdkLog("error", "tempPassword", "createFitOfflinePwdFail", {
|
|
114
|
+
devId: rt.devId,
|
|
115
|
+
duration: Date.now() - startedAt,
|
|
116
|
+
data: { pwdType: params.pwdType },
|
|
117
|
+
error,
|
|
118
|
+
});
|
|
119
|
+
throw handleCloudError(error);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export function createFitOfflineOnceForRuntime(rt) {
|
|
123
|
+
return createFitOfflinePwdForRuntime(rt, {
|
|
124
|
+
pwdType: "1",
|
|
125
|
+
gmtStart: "0",
|
|
126
|
+
gmtExpired: "0",
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
export function createFitOfflineLimitForRuntime(rt, params) {
|
|
130
|
+
const { effectiveTime, invalidTime } = params;
|
|
131
|
+
if (effectiveTime >= invalidTime) {
|
|
132
|
+
throw getError(1010);
|
|
133
|
+
}
|
|
134
|
+
return createFitOfflinePwdForRuntime(rt, {
|
|
135
|
+
pwdType: "0",
|
|
136
|
+
gmtStart: String(effectiveTime),
|
|
137
|
+
gmtExpired: String(invalidTime),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
export function createFitOfflineClearAllForRuntime(rt) {
|
|
141
|
+
return createFitOfflinePwdForRuntime(rt, {
|
|
142
|
+
pwdType: "9",
|
|
143
|
+
gmtStart: "0",
|
|
144
|
+
gmtExpired: "0",
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
export async function getFitOfflineRevocableListForRuntime(rt) {
|
|
148
|
+
try {
|
|
149
|
+
return (await getLimitOfflinePwdListForClear({ devId: rt.devId })) || [];
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
throw handleCloudError(error);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export async function getFitOfflinePwdAvailableForRuntime(rt, pwdType) {
|
|
156
|
+
try {
|
|
157
|
+
return await getOfflinePwdAvailable({
|
|
158
|
+
devId: rt.config.devInfo.devId,
|
|
159
|
+
pwdType,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
throw handleCloudError(error);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
90
166
|
export async function createTempDynamicForRuntime(rt) {
|
|
91
167
|
const startedAt = Date.now();
|
|
92
168
|
sdkLog("info", "tempPassword", "createDynamicStart", {
|
|
@@ -3,4 +3,4 @@ export interface GotoServiceParams {
|
|
|
3
3
|
tab?: "cloudStorage" | "AI" | "voip";
|
|
4
4
|
showGift?: boolean;
|
|
5
5
|
}
|
|
6
|
-
export declare function gotoServiceForRuntime(rt: LockDeviceRuntime, params?: GotoServiceParams): Promise<
|
|
6
|
+
export declare function gotoServiceForRuntime(rt: LockDeviceRuntime, params?: GotoServiceParams): Promise<void>;
|
|
@@ -8,6 +8,7 @@ export function clearStateForRuntime(runtime) {
|
|
|
8
8
|
runtime.cache.currentUser = null;
|
|
9
9
|
runtime.cache.offlineDpCache = undefined;
|
|
10
10
|
runtime.cache.deviceAdvanceAbilityCache = undefined;
|
|
11
|
+
runtime.cache.fitDeviceBvCache = undefined;
|
|
11
12
|
runtime.cache.isActiveThreadCache = false;
|
|
12
13
|
runtime.sync.hasSyncedT0 = false;
|
|
13
14
|
runtime.sync.syncDeleteUsersBusy = false;
|
|
@@ -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;
|
|
@@ -23,7 +28,7 @@ export const updateOnlineType = async (runtime) => {
|
|
|
23
28
|
updateDeviceStatus(runtime);
|
|
24
29
|
};
|
|
25
30
|
export const getDeviceStatusForRuntime = (runtime) => {
|
|
26
|
-
const { onlineType, devInfo: { isCloudOnline, isOnline, wifiEnableState, isMatter }, } = runtime.config;
|
|
31
|
+
const { onlineType, notSupportWake, devInfo: { isCloudOnline, isOnline, wifiEnableState, isMatter }, } = runtime.config;
|
|
27
32
|
const supportWifi = hasCapabilityForRuntime(runtime, ProductCommunicationType.WIFI);
|
|
28
33
|
const supportBle = hasCapabilityForRuntime(runtime, ProductCommunicationType.BLUETOOTH);
|
|
29
34
|
const supportThread = hasCapabilityForRuntime(runtime, ProductCommunicationType.THREAD);
|
|
@@ -34,11 +39,18 @@ 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
|
-
|
|
41
|
-
|
|
47
|
+
let isLocalOnline = !isCloudOnline && isOnlineByType(onlineType, 1);
|
|
48
|
+
if (isLocalOnline &&
|
|
49
|
+
runtime.cache.isActiveThreadCache !== true &&
|
|
50
|
+
supportThread) {
|
|
51
|
+
isLocalOnline = false;
|
|
52
|
+
}
|
|
53
|
+
const hasWirelessAwakeDp = !notSupportWake && hasDpForRuntime(runtime, dpCodes.wirelessAwake);
|
|
42
54
|
const wirelessAwake = getDpValueForRuntime(runtime, dpCodes.wirelessAwake);
|
|
43
55
|
status.connectEnable = isSupportBleControlForRuntime(runtime) && !isOnline;
|
|
44
56
|
if (supportWifi) {
|
|
@@ -76,8 +88,7 @@ export const getDeviceStatusForRuntime = (runtime) => {
|
|
|
76
88
|
}
|
|
77
89
|
}
|
|
78
90
|
if (supportThread && supportBle) {
|
|
79
|
-
|
|
80
|
-
if (isShareThread && isOnline) {
|
|
91
|
+
if (status.isShareThread && isOnline) {
|
|
81
92
|
if (!status.onlineTypes.includes("local")) {
|
|
82
93
|
status.onlineTypes = ["local"];
|
|
83
94
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import dpCodes from "../../config/dp-code";
|
|
2
2
|
import { getDeviceSkill, getIPCConfig, getRotateInfo } from "../../api/video";
|
|
3
3
|
import { getDataWithPreFetchForRuntime } from "../utils";
|
|
4
|
-
import {
|
|
4
|
+
import { getWithLocalCache } from "../storage/swr-cache";
|
|
5
|
+
import { getDeviceAdvancedAbilitiesForRuntime, hasCapabilityForRuntime, isActiveThreadForRuntime, } from "../misc/capability";
|
|
5
6
|
import { getCurrentUserForRuntime } from "../user/current-user";
|
|
6
7
|
import { checkOfflineDpUpdateForRuntime } from "../offline-dps";
|
|
7
8
|
import { autoSyncTemp } from "../password/sync-temp";
|
|
@@ -13,9 +14,9 @@ import syncT0 from "./sync/t0";
|
|
|
13
14
|
import { getDeviceStatusForRuntime, updateOnlineType } from "./device-status";
|
|
14
15
|
import { handleDpChange } from "./dp-change";
|
|
15
16
|
import { fetchDeviceProperties } from "./remote-permissions";
|
|
16
|
-
import { ipc, yuChannelSyncSingleSync } from "../../platform";
|
|
17
|
+
import { ipc, yuChannelSyncSingleSync, } from "../../platform";
|
|
17
18
|
import { sdkLog } from "../../utils/sdk-log";
|
|
18
|
-
import { RotateType } from "../../constant";
|
|
19
|
+
import { ProductCommunicationType, RotateType } from "../../constant";
|
|
19
20
|
import { isHarmony } from "../../utils";
|
|
20
21
|
export const initState = async (runtime) => {
|
|
21
22
|
const { devInfo: { dps, devId, yuNetState }, dpSchema, } = runtime.config;
|
|
@@ -30,6 +31,7 @@ export const initState = async (runtime) => {
|
|
|
30
31
|
try {
|
|
31
32
|
handleDpChange(runtime, dps, true);
|
|
32
33
|
const isSupportVideo = !!dpSchema[dpCodes.initiativeMessage];
|
|
34
|
+
const hasThread = hasCapabilityForRuntime(runtime, ProductCommunicationType.THREAD);
|
|
33
35
|
runtime.deviceStatus = getDeviceStatusForRuntime(runtime);
|
|
34
36
|
sdkLog("debug", "initState", "baseStateReady", {
|
|
35
37
|
devId,
|
|
@@ -39,24 +41,29 @@ export const initState = async (runtime) => {
|
|
|
39
41
|
isSupportVideo,
|
|
40
42
|
},
|
|
41
43
|
});
|
|
42
|
-
const [, , , rotateInfo, deviceSkill, ipcConfig] = await Promise.allSettled([
|
|
44
|
+
const [, , , advanceAbilities, isActiveThread, rotateInfo, deviceSkill, ipcConfig,] = await Promise.allSettled([
|
|
43
45
|
updateOnlineType(runtime),
|
|
44
46
|
getCurrentUserForRuntime(runtime),
|
|
45
47
|
fetchDeviceProperties(runtime),
|
|
48
|
+
getDeviceAdvancedAbilitiesForRuntime(runtime),
|
|
49
|
+
hasThread ? isActiveThreadForRuntime(runtime) : Promise.resolve(false),
|
|
46
50
|
isSupportVideo
|
|
47
|
-
?
|
|
51
|
+
?
|
|
52
|
+
getDataWithPreFetchForRuntime(runtime, "getRotate", () => getWithLocalCache(runtime, "rotateInfo", () => getRotateInfo(devId), {
|
|
53
|
+
version: 1,
|
|
54
|
+
}))
|
|
48
55
|
: Promise.resolve({
|
|
49
56
|
angle: 0,
|
|
50
57
|
actualAngle: 0,
|
|
51
58
|
}),
|
|
52
59
|
isSupportVideo
|
|
53
|
-
? getDeviceSkill(devId)
|
|
60
|
+
? getWithLocalCache(runtime, "deviceSkill", () => getDeviceSkill(devId))
|
|
54
61
|
: Promise.resolve({
|
|
55
62
|
devId,
|
|
56
63
|
json: { videos: [{ width: 0, height: 0 }] },
|
|
57
64
|
}),
|
|
58
65
|
isSupportVideo
|
|
59
|
-
? getIPCConfig(devId)
|
|
66
|
+
? getWithLocalCache(runtime, "ipcConfig", () => getIPCConfig(devId))
|
|
60
67
|
: Promise.resolve({
|
|
61
68
|
audioAttributes: {
|
|
62
69
|
hardwareCapability: [],
|
|
@@ -121,7 +128,8 @@ export const initState = async (runtime) => {
|
|
|
121
128
|
videoAngle: runtime.config.videoAngle,
|
|
122
129
|
},
|
|
123
130
|
});
|
|
124
|
-
|
|
131
|
+
if (advanceAbilities.status === "fulfilled") {
|
|
132
|
+
const abilities = advanceAbilities.value;
|
|
125
133
|
sdkLog("debug", "initState", "advancedAbilitiesFetched", {
|
|
126
134
|
devId,
|
|
127
135
|
data: {
|
|
@@ -145,7 +153,7 @@ export const initState = async (runtime) => {
|
|
|
145
153
|
yuChannelSyncSingleSync(devId);
|
|
146
154
|
}
|
|
147
155
|
}
|
|
148
|
-
}
|
|
156
|
+
}
|
|
149
157
|
syncRemoteSerectKey(runtime);
|
|
150
158
|
checkOfflineDpUpdateForRuntime(runtime, {}, true).then(() => {
|
|
151
159
|
sdkLog("debug", "initState", "offlineDpCheckDone", { devId });
|
|
@@ -3,6 +3,7 @@ import { getRuntimeByDevId, listRegisteredRuntimes, } from "../../runtime/regist
|
|
|
3
3
|
import emitter from "../../utils/event";
|
|
4
4
|
import { getWiFiSignalChangeEvent } from "../misc/signal";
|
|
5
5
|
import { autoSyncTemp } from "../password/sync-temp";
|
|
6
|
+
import { syncFitBindingsForRuntime } from "../fit/sync";
|
|
6
7
|
import syncT0 from "./sync/t0";
|
|
7
8
|
import syncRemoteSerectKey from "./sync/remote-serect-key";
|
|
8
9
|
import { syncOfflineDps } from "./sync/offline-dps";
|
|
@@ -38,7 +39,6 @@ const globalHandleDeviceInfoChange = async ({ dps, deviceId, }) => {
|
|
|
38
39
|
handleDpChange(rt, dps);
|
|
39
40
|
}
|
|
40
41
|
await updateOnlineType(rt);
|
|
41
|
-
updateDeviceStatus(rt);
|
|
42
42
|
};
|
|
43
43
|
const globalUpdateAllOnlineTypes = async (data) => {
|
|
44
44
|
if (!data?.deviceId) {
|
|
@@ -90,8 +90,17 @@ const globalHandleBleChange = ({ deviceId, status }) => {
|
|
|
90
90
|
devId: deviceId,
|
|
91
91
|
data: { status, registered: !!rt },
|
|
92
92
|
});
|
|
93
|
-
if (
|
|
94
|
-
|
|
93
|
+
if (rt) {
|
|
94
|
+
updateOnlineType(rt);
|
|
95
|
+
if (status === "CONNECTED") {
|
|
96
|
+
if (rt.config.isFitting) {
|
|
97
|
+
syncFitBindingsForRuntime(rt).catch(() => { });
|
|
98
|
+
}
|
|
99
|
+
void syncRemoteSerectKey(rt);
|
|
100
|
+
autoSyncTemp(rt);
|
|
101
|
+
void syncT0(rt);
|
|
102
|
+
void syncOfflineDps(rt);
|
|
103
|
+
}
|
|
95
104
|
}
|
|
96
105
|
};
|
|
97
106
|
const globalHandleAppShow = () => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getDeviceProperties } from "../../api/setting";
|
|
2
2
|
import { getDataWithPreFetchForRuntime } from "../utils";
|
|
3
3
|
import { RemotePermissionType } from "../../constant";
|
|
4
|
+
import { cameraPositionMap } from "../../utils/constant";
|
|
4
5
|
export const permissions = [
|
|
5
6
|
RemotePermissionType.ADMINS_ONLY,
|
|
6
7
|
RemotePermissionType.EVERY_ONE,
|
|
@@ -37,7 +38,7 @@ export async function fetchDeviceProperties(runtime, isForce) {
|
|
|
37
38
|
width: item.w,
|
|
38
39
|
height: item.h,
|
|
39
40
|
rotate: item.al,
|
|
40
|
-
|
|
41
|
+
location: cameraPositionMap[item.p],
|
|
41
42
|
}));
|
|
42
43
|
}
|
|
43
44
|
catch (e) {
|
|
@@ -11,6 +11,13 @@ import { reportSetKey as reportSetKeyMap, setKey as setKeyMap, } from "../../../
|
|
|
11
11
|
import { sdkLog } from "../../../utils/sdk-log";
|
|
12
12
|
const syncRemoteSerectKey = async (runtime, force) => {
|
|
13
13
|
const rt = runtime;
|
|
14
|
+
if (rt.config.isFitting || !rt.config.idsByCode[dpCodes.remoteNoPdSetkey]) {
|
|
15
|
+
sdkLog("debug", "syncKey", "skipped", {
|
|
16
|
+
devId: rt.devId,
|
|
17
|
+
data: { reason: "unsupported", force: !!force },
|
|
18
|
+
});
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
14
21
|
const useNear = isUseNearChannelForRuntime(rt);
|
|
15
22
|
if (!useNear) {
|
|
16
23
|
sdkLog("debug", "syncKey", "skipped", {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
|
|
2
|
+
export interface SwrOptions<T> {
|
|
3
|
+
version?: number;
|
|
4
|
+
maxAge?: number;
|
|
5
|
+
applyToSession?: (rt: LockDeviceRuntime, fresh: T) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function getWithLocalCache<T>(rt: LockDeviceRuntime, key: string, fetcher: () => Promise<T>, options?: SwrOptions<T>): Promise<T>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getRuntimeByDevId } from "../../runtime/registry";
|
|
2
|
+
import { sdkLog } from "../../utils/sdk-log";
|
|
3
|
+
import { getStorageForRuntime, setStorageForRuntime } from "./index";
|
|
4
|
+
const CACHE_KEY_PREFIX = "swr_";
|
|
5
|
+
const buildKey = (key) => `${CACHE_KEY_PREFIX}${key}`;
|
|
6
|
+
function readValidCache(rt, storageKey, version, maxAge) {
|
|
7
|
+
const envelope = getStorageForRuntime(rt, storageKey);
|
|
8
|
+
if (!envelope ||
|
|
9
|
+
typeof envelope !== "object" ||
|
|
10
|
+
envelope.v !== version ||
|
|
11
|
+
!("data" in envelope)) {
|
|
12
|
+
return { hit: false };
|
|
13
|
+
}
|
|
14
|
+
if (typeof maxAge === "number" && maxAge >= 0 && Date.now() - envelope.t > maxAge) {
|
|
15
|
+
return { hit: false };
|
|
16
|
+
}
|
|
17
|
+
return { hit: true, data: envelope.data };
|
|
18
|
+
}
|
|
19
|
+
export async function getWithLocalCache(rt, key, fetcher, options) {
|
|
20
|
+
if (!rt.config.localCache) {
|
|
21
|
+
return fetcher();
|
|
22
|
+
}
|
|
23
|
+
const version = options?.version ?? 1;
|
|
24
|
+
const storageKey = buildKey(key);
|
|
25
|
+
const devId = rt.devId;
|
|
26
|
+
const writeCache = (data) => {
|
|
27
|
+
if (getRuntimeByDevId(devId) !== rt) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const envelope = { v: version, t: Date.now(), data };
|
|
31
|
+
setStorageForRuntime(rt, storageKey, envelope);
|
|
32
|
+
};
|
|
33
|
+
const cached = readValidCache(rt, storageKey, version, options?.maxAge);
|
|
34
|
+
if (cached.hit) {
|
|
35
|
+
void (async () => {
|
|
36
|
+
try {
|
|
37
|
+
const fresh = await fetcher();
|
|
38
|
+
writeCache(fresh);
|
|
39
|
+
options?.applyToSession?.(rt, fresh);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
sdkLog("warn", "swrCache", "revalidateFailed", {
|
|
43
|
+
devId,
|
|
44
|
+
data: { key },
|
|
45
|
+
error,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
49
|
+
return cached.data;
|
|
50
|
+
}
|
|
51
|
+
const fresh = await fetcher();
|
|
52
|
+
writeCache(fresh);
|
|
53
|
+
return fresh;
|
|
54
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import dpUtils from "@ray-js/tuya-dp-transform";
|
|
2
2
|
import { createUnlockMethod } from "../../../api/lock";
|
|
3
3
|
import { parallelOnlyForRuntime } from "../../utils";
|
|
4
|
-
import { sleep } from "../../../utils";
|
|
4
|
+
import { formatCloudUnlockId, sleep } from "../../../utils";
|
|
5
5
|
import { getError } from "../../../utils/errors";
|
|
6
6
|
import { publishDpsForRuntime } from "../../dp/publish-dps";
|
|
7
7
|
import emitter from "../../../utils/event";
|
|
@@ -207,7 +207,7 @@ const handleAddReport = async (dps) => {
|
|
|
207
207
|
const res = await createUnlockMethod({
|
|
208
208
|
devId: cfg.devInfo.devId,
|
|
209
209
|
userId: addUnlockMethodData.userId,
|
|
210
|
-
unlockId:
|
|
210
|
+
unlockId: formatCloudUnlockId(addUnlockMethodData.unlockDpId, result.unlockId),
|
|
211
211
|
unlockName: "",
|
|
212
212
|
unlockAttr: 0,
|
|
213
213
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import dpUtils from "@ray-js/tuya-dp-transform";
|
|
2
2
|
import { createUnlockMethod } from "../../../api/lock";
|
|
3
3
|
import { encrypt } from "../../../platform/device";
|
|
4
|
-
import { sleep } from "../../../utils";
|
|
4
|
+
import { formatCloudUnlockId, sleep } from "../../../utils";
|
|
5
5
|
import { getError, handleCloudError } from "../../../utils/errors";
|
|
6
6
|
import { publishDpsForRuntime } from "../../dp/publish-dps";
|
|
7
7
|
import { getUnlockMethodBase } from "./internal/base";
|
|
@@ -76,7 +76,7 @@ export async function addPasswordForRuntime(rt, params) {
|
|
|
76
76
|
const result = await createUnlockMethod({
|
|
77
77
|
devId: devId,
|
|
78
78
|
userId: params.userId,
|
|
79
|
-
unlockId:
|
|
79
|
+
unlockId: formatCloudUnlockId(dpId, res.unlockId),
|
|
80
80
|
unlockName: params.name,
|
|
81
81
|
unlockDetail: aesPwd,
|
|
82
82
|
...specialInfo,
|