@ray-js/lock-sdk 1.2.0-beta.8 → 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.
Files changed (239) hide show
  1. package/lib/api/fit.d.ts +55 -2
  2. package/lib/api/fit.js +43 -1
  3. package/lib/api/gesture.d.ts +11 -0
  4. package/lib/api/gesture.js +18 -0
  5. package/lib/api/log.d.ts +52 -4
  6. package/lib/api/log.js +22 -0
  7. package/lib/api/temp.d.ts +21 -0
  8. package/lib/api/temp.js +24 -0
  9. package/lib/api/video.d.ts +4 -0
  10. package/lib/api/video.js +10 -0
  11. package/lib/config/dp-code/index.d.ts +1 -1
  12. package/lib/config/dp-code/index.js +1 -0
  13. package/lib/entries/main/bootstrap/bootstrap-lock-instance.d.ts +2 -1
  14. package/lib/entries/main/bootstrap/bootstrap-lock-instance.js +23 -8
  15. package/lib/entries/main/bootstrap/bootstrap.d.ts +3 -2
  16. package/lib/entries/main/bootstrap/bootstrap.js +10 -6
  17. package/lib/entries/main/bootstrap/primary-instance.d.ts +1 -2
  18. package/lib/entries/main/bootstrap/primary-instance.js +1 -1
  19. package/lib/entries/main/bootstrap/resolve-runtime-from-export-this.js +1 -1
  20. package/lib/entries/main/build-instance.d.ts +6 -3
  21. package/lib/entries/main/build-instance.js +13 -1
  22. package/lib/entries/main/exports/capability.d.ts +2 -0
  23. package/lib/entries/main/exports/capability.js +7 -1
  24. package/lib/entries/main/exports/fit-sdk/binding.d.ts +10 -0
  25. package/lib/entries/{fit/exports → main/exports/fit-sdk}/binding.js +6 -3
  26. package/lib/entries/{fit/exports → main/exports/fit-sdk}/device.d.ts +11 -10
  27. package/lib/entries/{fit/exports → main/exports/fit-sdk}/device.js +20 -20
  28. package/lib/entries/{fit/exports → main/exports/fit-sdk}/index.d.ts +1 -0
  29. package/lib/entries/{fit/exports → main/exports/fit-sdk}/index.js +1 -0
  30. package/lib/entries/main/exports/fit-sdk/log.d.ts +3 -0
  31. package/lib/entries/main/exports/fit-sdk/log.js +5 -0
  32. package/lib/entries/main/exports/fit-sdk/temp.d.ts +40 -0
  33. package/lib/entries/main/exports/fit-sdk/temp.js +59 -0
  34. package/lib/entries/main/exports/gesture.d.ts +6 -0
  35. package/lib/entries/main/exports/gesture.js +8 -0
  36. package/lib/entries/main/exports/index.d.ts +5 -0
  37. package/lib/entries/main/exports/index.js +5 -0
  38. package/lib/entries/main/exports/log.d.ts +2 -0
  39. package/lib/entries/main/exports/log.js +7 -1
  40. package/lib/entries/main/exports/media.d.ts +3 -1
  41. package/lib/entries/main/exports/media.js +8 -2
  42. package/lib/entries/main/exports/misc.d.ts +4 -2
  43. package/lib/entries/main/exports/misc.js +2 -2
  44. package/lib/entries/main/index.d.ts +3 -3
  45. package/lib/entries/main/index.js +11 -5
  46. package/lib/feature/fit/bind-lock-to-fit.d.ts +1 -0
  47. package/lib/feature/fit/bind-lock-to-fit.js +53 -0
  48. package/lib/feature/fit/ble-key.d.ts +10 -4
  49. package/lib/feature/fit/ble-key.js +145 -4
  50. package/lib/feature/fit/device-bv.d.ts +2 -0
  51. package/lib/feature/fit/device-bv.js +15 -0
  52. package/lib/feature/fit/invalid-password.d.ts +10 -0
  53. package/lib/feature/fit/invalid-password.js +43 -0
  54. package/lib/feature/fit/list.d.ts +12 -2
  55. package/lib/feature/fit/list.js +54 -5
  56. package/lib/feature/fit/log.d.ts +7 -0
  57. package/lib/feature/fit/log.js +123 -0
  58. package/lib/feature/fit/method/add-flow.js +2 -2
  59. package/lib/feature/fit/method/add-password.js +2 -2
  60. package/lib/feature/fit/method/update-remove.js +40 -14
  61. package/lib/feature/fit/password-list.d.ts +37 -0
  62. package/lib/feature/fit/password-list.js +44 -1
  63. package/lib/feature/fit/security-channel.d.ts +3 -0
  64. package/lib/feature/fit/security-channel.js +43 -0
  65. package/lib/feature/fit/shared.d.ts +8 -0
  66. package/lib/feature/fit/shared.js +40 -1
  67. package/lib/feature/fit/sync.d.ts +4 -2
  68. package/lib/feature/fit/sync.js +63 -22
  69. package/lib/feature/fit/temp-password.d.ts +23 -0
  70. package/lib/feature/fit/temp-password.js +95 -3
  71. package/lib/feature/fit/users.d.ts +1 -0
  72. package/lib/feature/fit/users.js +1 -0
  73. package/lib/feature/gesture/gesture.d.ts +6 -0
  74. package/lib/feature/gesture/gesture.js +3 -0
  75. package/lib/feature/log/log.d.ts +5 -1
  76. package/lib/feature/log/log.js +53 -6
  77. package/lib/feature/media/camera.d.ts +12 -2
  78. package/lib/feature/media/camera.js +3 -0
  79. package/lib/feature/media/media.d.ts +2 -1
  80. package/lib/feature/media/media.js +4 -1
  81. package/lib/feature/misc/ble-control.js +2 -2
  82. package/lib/feature/misc/capability.d.ts +2 -0
  83. package/lib/feature/misc/capability.js +33 -31
  84. package/lib/feature/misc/connect-device.d.ts +1 -1
  85. package/lib/feature/misc/connect-device.js +7 -6
  86. package/lib/feature/misc/is-use-near-channel-for-runtime.js +8 -1
  87. package/lib/feature/password/temporary/offline-create.d.ts +14 -0
  88. package/lib/feature/password/temporary/offline-create.js +77 -1
  89. package/lib/feature/service/goto-service.d.ts +1 -1
  90. package/lib/feature/state/clear.js +1 -0
  91. package/lib/feature/state/device-status.js +17 -6
  92. package/lib/feature/state/init-state.js +18 -10
  93. package/lib/feature/state/platform-routing.js +12 -3
  94. package/lib/feature/state/remote-permissions.js +17 -0
  95. package/lib/feature/state/sync/remote-serect-key.js +7 -0
  96. package/lib/feature/storage/swr-cache.d.ts +7 -0
  97. package/lib/feature/storage/swr-cache.js +54 -0
  98. package/lib/feature/unlock/method/add-flow.js +2 -2
  99. package/lib/feature/unlock/method/add-password.js +2 -2
  100. package/lib/feature/user/sync-user.js +4 -2
  101. package/lib/feature/utils/index.d.ts +1 -0
  102. package/lib/feature/utils/index.js +1 -0
  103. package/lib/interface.d.ts +29 -0
  104. package/lib/platform/device.d.ts +4 -3
  105. package/lib/platform/ipc.d.ts +3 -0
  106. package/lib/platform/ipc.js +13 -0
  107. package/lib/platform/storage.d.ts +1 -1
  108. package/lib/runtime/LockDeviceRuntime.js +3 -0
  109. package/lib/runtime/lock-config.d.ts +5 -1
  110. package/lib/runtime/lock-config.js +6 -0
  111. package/lib/runtime/runtime-state-types.d.ts +6 -0
  112. package/lib/utils/constant.d.ts +1 -0
  113. package/lib/utils/constant.js +6 -0
  114. package/lib/utils/index.d.ts +2 -1
  115. package/lib/utils/index.js +1 -0
  116. package/package.json +1 -11
  117. package/lib/bootstrap/bootstrap-lock-instance.d.ts +0 -7
  118. package/lib/bootstrap/bootstrap-lock-instance.js +0 -16
  119. package/lib/bootstrap/bootstrap.d.ts +0 -4
  120. package/lib/bootstrap/bootstrap.js +0 -53
  121. package/lib/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
  122. package/lib/bootstrap/lock-instance-runtime-ref.js +0 -7
  123. package/lib/bootstrap/primary-instance.d.ts +0 -6
  124. package/lib/bootstrap/primary-instance.js +0 -24
  125. package/lib/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
  126. package/lib/bootstrap/resolve-runtime-from-export-this.js +0 -29
  127. package/lib/bootstrap/top-level-runtime.d.ts +0 -2
  128. package/lib/bootstrap/top-level-runtime.js +0 -9
  129. package/lib/entries/ble/bootstrap/bootstrap-lock-instance.d.ts +0 -7
  130. package/lib/entries/ble/bootstrap/bootstrap-lock-instance.js +0 -12
  131. package/lib/entries/ble/bootstrap/bootstrap.d.ts +0 -4
  132. package/lib/entries/ble/bootstrap/bootstrap.js +0 -53
  133. package/lib/entries/ble/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
  134. package/lib/entries/ble/bootstrap/lock-instance-runtime-ref.js +0 -7
  135. package/lib/entries/ble/bootstrap/primary-instance.d.ts +0 -6
  136. package/lib/entries/ble/bootstrap/primary-instance.js +0 -24
  137. package/lib/entries/ble/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
  138. package/lib/entries/ble/bootstrap/resolve-runtime-from-export-this.js +0 -29
  139. package/lib/entries/ble/bootstrap/top-level-runtime.d.ts +0 -2
  140. package/lib/entries/ble/bootstrap/top-level-runtime.js +0 -9
  141. package/lib/entries/ble/build-instance.d.ts +0 -9
  142. package/lib/entries/ble/build-instance.js +0 -50
  143. package/lib/entries/ble/exports/capability.d.ts +0 -6
  144. package/lib/entries/ble/exports/capability.js +0 -17
  145. package/lib/entries/ble/exports/config.d.ts +0 -3
  146. package/lib/entries/ble/exports/config.js +0 -5
  147. package/lib/entries/ble/exports/dp.d.ts +0 -9
  148. package/lib/entries/ble/exports/dp.js +0 -13
  149. package/lib/entries/ble/exports/index.d.ts +0 -16
  150. package/lib/entries/ble/exports/index.js +0 -16
  151. package/lib/entries/ble/exports/linkage.d.ts +0 -5
  152. package/lib/entries/ble/exports/linkage.js +0 -15
  153. package/lib/entries/ble/exports/log.d.ts +0 -9
  154. package/lib/entries/ble/exports/log.js +0 -21
  155. package/lib/entries/ble/exports/media.d.ts +0 -4
  156. package/lib/entries/ble/exports/media.js +0 -12
  157. package/lib/entries/ble/exports/misc.d.ts +0 -19
  158. package/lib/entries/ble/exports/misc.js +0 -30
  159. package/lib/entries/ble/exports/offline-dps.d.ts +0 -8
  160. package/lib/entries/ble/exports/offline-dps.js +0 -24
  161. package/lib/entries/ble/exports/open/do-open-close-action.d.ts +0 -2
  162. package/lib/entries/ble/exports/open/do-open-close-action.js +0 -36
  163. package/lib/entries/ble/exports/open/index.d.ts +0 -18
  164. package/lib/entries/ble/exports/open/index.js +0 -45
  165. package/lib/entries/ble/exports/signal.d.ts +0 -6
  166. package/lib/entries/ble/exports/signal.js +0 -14
  167. package/lib/entries/ble/exports/sleep.d.ts +0 -13
  168. package/lib/entries/ble/exports/sleep.js +0 -31
  169. package/lib/entries/ble/exports/state.d.ts +0 -6
  170. package/lib/entries/ble/exports/state.js +0 -19
  171. package/lib/entries/ble/exports/temporary.d.ts +0 -31
  172. package/lib/entries/ble/exports/temporary.js +0 -91
  173. package/lib/entries/ble/exports/unlock/sync.d.ts +0 -1
  174. package/lib/entries/ble/exports/unlock/sync.js +0 -5
  175. package/lib/entries/ble/exports/unlock-method.d.ts +0 -19
  176. package/lib/entries/ble/exports/unlock-method.js +0 -58
  177. package/lib/entries/ble/exports/user/index.d.ts +0 -23
  178. package/lib/entries/ble/exports/user/index.js +0 -22
  179. package/lib/entries/ble/exports/user/sync.d.ts +0 -1
  180. package/lib/entries/ble/exports/user/sync.js +0 -5
  181. package/lib/entries/ble/index.d.ts +0 -8
  182. package/lib/entries/ble/index.js +0 -39
  183. package/lib/entries/fit/bootstrap/bootstrap-lock-instance.d.ts +0 -7
  184. package/lib/entries/fit/bootstrap/bootstrap-lock-instance.js +0 -12
  185. package/lib/entries/fit/bootstrap/bootstrap.d.ts +0 -4
  186. package/lib/entries/fit/bootstrap/bootstrap.js +0 -69
  187. package/lib/entries/fit/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
  188. package/lib/entries/fit/bootstrap/lock-instance-runtime-ref.js +0 -7
  189. package/lib/entries/fit/bootstrap/primary-instance.d.ts +0 -6
  190. package/lib/entries/fit/bootstrap/primary-instance.js +0 -24
  191. package/lib/entries/fit/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
  192. package/lib/entries/fit/bootstrap/resolve-runtime-from-export-this.js +0 -29
  193. package/lib/entries/fit/bootstrap/top-level-runtime.d.ts +0 -2
  194. package/lib/entries/fit/bootstrap/top-level-runtime.js +0 -9
  195. package/lib/entries/fit/build-instance.d.ts +0 -9
  196. package/lib/entries/fit/build-instance.js +0 -57
  197. package/lib/entries/fit/exports/binding.d.ts +0 -8
  198. package/lib/entries/fit/exports/temp.d.ts +0 -19
  199. package/lib/entries/fit/exports/temp.js +0 -18
  200. package/lib/entries/fit/index.d.ts +0 -8
  201. package/lib/entries/fit/index.js +0 -36
  202. package/lib/entries/main/exports/open.d.ts +0 -16
  203. package/lib/entries/main/exports/open.js +0 -44
  204. package/lib/entries/screen/bootstrap/bootstrap-lock-instance.d.ts +0 -7
  205. package/lib/entries/screen/bootstrap/bootstrap-lock-instance.js +0 -12
  206. package/lib/entries/screen/bootstrap/bootstrap.d.ts +0 -4
  207. package/lib/entries/screen/bootstrap/bootstrap.js +0 -69
  208. package/lib/entries/screen/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
  209. package/lib/entries/screen/bootstrap/lock-instance-runtime-ref.js +0 -7
  210. package/lib/entries/screen/bootstrap/primary-instance.d.ts +0 -6
  211. package/lib/entries/screen/bootstrap/primary-instance.js +0 -24
  212. package/lib/entries/screen/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
  213. package/lib/entries/screen/bootstrap/resolve-runtime-from-export-this.js +0 -29
  214. package/lib/entries/screen/bootstrap/top-level-runtime.d.ts +0 -2
  215. package/lib/entries/screen/bootstrap/top-level-runtime.js +0 -9
  216. package/lib/entries/screen/build-instance.d.ts +0 -9
  217. package/lib/entries/screen/build-instance.js +0 -57
  218. package/lib/entries/screen/exports/bind-events.d.ts +0 -4
  219. package/lib/entries/screen/exports/bind-events.js +0 -8
  220. package/lib/entries/screen/exports/binding.d.ts +0 -6
  221. package/lib/entries/screen/exports/binding.js +0 -15
  222. package/lib/entries/screen/exports/device.d.ts +0 -16
  223. package/lib/entries/screen/exports/device.js +0 -41
  224. package/lib/entries/screen/exports/event.d.ts +0 -3
  225. package/lib/entries/screen/exports/event.js +0 -5
  226. package/lib/entries/screen/exports/index.d.ts +0 -5
  227. package/lib/entries/screen/exports/index.js +0 -5
  228. package/lib/entries/screen/exports/user.d.ts +0 -2
  229. package/lib/entries/screen/exports/user.js +0 -8
  230. package/lib/entries/screen/index.d.ts +0 -8
  231. package/lib/entries/screen/index.js +0 -36
  232. package/lib/feature/unlock/door/door-action.d.ts +0 -2
  233. package/lib/feature/unlock/door/door-action.js +0 -32
  234. package/lib/fit.d.ts +0 -4
  235. package/lib/fit.js +0 -3
  236. package/lib/runtime/device-status/compute-device-status.d.ts +0 -25
  237. package/lib/runtime/device-status/compute-device-status.js +0 -94
  238. package/lib/screen.d.ts +0 -4
  239. package/lib/screen.js +0 -3
@@ -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: `${addUnlockMethodData.unlockDpId}-${result.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: `${dpId}-${res.unlockId}`,
79
+ unlockId: formatCloudUnlockId(dpId, res.unlockId),
80
80
  unlockName: params.name,
81
81
  unlockDetail: aesPwd,
82
82
  ...specialInfo,
@@ -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 "../../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" },
@@ -1,5 +1,6 @@
1
1
  import type { UnlockMethodConfig } from "../../interface";
2
2
  import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
3
+ export declare const unlockMethodDpCodes: string[];
3
4
  export declare const getUnlockMethodTypeByDpCodeForRuntime: (rt: LockDeviceRuntime, dpCode: string) => UnlockMethodConfig;
4
5
  export declare const getUnlockMethodTypeByIdForRuntime: (rt: LockDeviceRuntime, id: number | string) => UnlockMethodConfig;
5
6
  export declare const getUnlockMethodTypeByTypeForRuntime: (rt: LockDeviceRuntime, type: string) => UnlockMethodConfig;
@@ -33,6 +33,7 @@ const unlockMethodConfigs = [
33
33
  id: 6,
34
34
  },
35
35
  ];
36
+ export const unlockMethodDpCodes = unlockMethodConfigs.reduce((res, item) => res.concat(item.codes), []);
36
37
  const getUnlockMethodTypeForRuntime = (rt, cb) => {
37
38
  const result = unlockMethodConfigs.find(cb);
38
39
  if (result) {
@@ -12,9 +12,12 @@ export interface LockSDKOption {
12
12
  supportMultipleFace?: boolean;
13
13
  supportOfflineDps?: boolean;
14
14
  preFetch?: boolean;
15
+ localCache?: boolean;
16
+ notSupportWake?: boolean;
15
17
  logLevel?: SDKLogLevel;
16
18
  logger?: SDKLogSink;
17
19
  logToConsole?: boolean;
20
+ kind?: "lock" | "fit" | "screen";
18
21
  }
19
22
  export interface ErrorData {
20
23
  errorCode: number;
@@ -180,6 +183,16 @@ export interface EffectiveConfig {
180
183
  effectiveTime?: number;
181
184
  expiredTime?: number;
182
185
  }
186
+ export interface FitBleKeyItem {
187
+ id: string;
188
+ unlockBindingId: string;
189
+ name: string;
190
+ opModeSubType?: number;
191
+ effectiveConfig: EffectiveConfig;
192
+ sn?: number;
193
+ userName?: string;
194
+ devNameList?: string[];
195
+ }
183
196
  export interface UnBindUnlockMethod {
184
197
  dpId: number;
185
198
  dpCode: string;
@@ -204,6 +217,8 @@ export interface DeviceStatus {
204
217
  };
205
218
  isWifiActive: boolean;
206
219
  isWifiMatter: boolean;
220
+ isActiveThread: boolean;
221
+ isShareThread: boolean;
207
222
  }
208
223
  export interface UnionUnlockInfo {
209
224
  userId: string;
@@ -254,6 +269,11 @@ export interface MediaInfo {
254
269
  fileUrl: string;
255
270
  mediaBucket: string;
256
271
  mediaKey: string;
272
+ width: number;
273
+ height: number;
274
+ angle: number;
275
+ position: number;
276
+ isVR: boolean;
257
277
  }
258
278
  export type LogType = "alarm_record" | "close_record" | "unlock_record" | "operation" | "local_operation";
259
279
  export type CloseValue = "UNDEFINED" | "VOICE_REMOTE" | "APP_REMOTE" | "AUTO" | "LOCAL_MANUAL" | "FITTINGS" | "APP" | "GEO_FENCE";
@@ -269,6 +289,8 @@ export interface LogData {
269
289
  dpCode: string;
270
290
  data: any;
271
291
  userName: string;
292
+ avatarUrl?: string;
293
+ relateDevName?: string;
272
294
  bindable: boolean;
273
295
  unlockName: string;
274
296
  mediaInfo?: MediaInfo[];
@@ -402,4 +424,11 @@ export interface AIReportPopup {
402
424
  reportId: string;
403
425
  yearMonth: number;
404
426
  }
427
+ export interface CameraConfig {
428
+ isVR: boolean;
429
+ width: number;
430
+ height: number;
431
+ rotate: number;
432
+ location: number;
433
+ }
405
434
  export {};
@@ -52,7 +52,7 @@ export declare const getSystemInfoSync: () => {
52
52
  locationEnabled: boolean;
53
53
  wifiEnabled: boolean;
54
54
  theme?: ty.Themes;
55
- deviceOrientation?: ty.Orientation;
55
+ deviceOrientation?: ty.PhoneOrientation;
56
56
  deviceLevel: string;
57
57
  isSupportPinShortcut?: boolean;
58
58
  deviceType?: string;
@@ -74,9 +74,10 @@ export declare const requestCloud: <T>(options: {
74
74
  export declare const getLaunchOptionsSync: () => {
75
75
  path: string;
76
76
  scene?: ty.MiniAppScene;
77
- query: any;
77
+ query: Record<string, any>;
78
78
  referrerInfo: ty.ReferrerInfo;
79
79
  apiCategory?: string;
80
+ extraQuery?: Record<string, any>;
80
81
  };
81
82
  export declare function encrypt(deviceId: string, plaintext: string): Promise<string>;
82
83
  export declare function decrypt(deviceId: string, plaintext: string): Promise<string>;
@@ -219,7 +220,7 @@ export declare const onResetMemberName: (cb: HomeMemberListener) => void;
219
220
  export declare const offResetMemberName: (cb: HomeMemberListener) => void;
220
221
  export declare const onResetMemberRole: (cb: HomeMemberListener) => void;
221
222
  export declare const offResetMemberRole: (cb: HomeMemberListener) => void;
222
- export declare const getLogManager: () => ty.GetLogManagerTask;
223
+ export declare const getLogManager: () => ty.LogManager;
223
224
  export declare const getAppUserInfo: () => Promise<{
224
225
  nickName: string;
225
226
  avatarUrl: string;
@@ -10,5 +10,8 @@ declare const _default: {
10
10
  getCurrentSupportedTalkMode: (deviceId: string) => Promise<{
11
11
  talkbackMode: number;
12
12
  }>;
13
+ getTTTAbilityKeyList: (key: string) => Promise<{
14
+ abilityList: string[];
15
+ }>;
13
16
  };
14
17
  export default _default;
@@ -31,10 +31,23 @@ const getCurrentSupportedTalkMode = (deviceId) => {
31
31
  }
32
32
  return Promise.reject(new Error("not support"));
33
33
  };
34
+ const getTTTAbilityKeyList = (key) => {
35
+ if (ty.ipc.getTTTAbilityKeyList) {
36
+ return new Promise((resolve, reject) => {
37
+ ty.ipc.getTTTAbilityKeyList({
38
+ key,
39
+ success: resolve,
40
+ fail: reject,
41
+ });
42
+ });
43
+ }
44
+ return Promise.resolve({ abilityList: [] });
45
+ };
34
46
  export default {
35
47
  wakeUpDoorBell,
36
48
  isConnected,
37
49
  isConnecting,
38
50
  connect,
39
51
  getCurrentSupportedTalkMode,
52
+ getTTTAbilityKeyList,
40
53
  };
@@ -1,3 +1,3 @@
1
- export declare const setStorageSync: (key: string, data: unknown) => void;
1
+ export declare const setStorageSync: (key: string, data: string) => void;
2
2
  export declare const getStorageSync: (key: string) => any;
3
3
  export declare const removeStorageSync: (key: string) => void;
@@ -14,6 +14,7 @@ export class LockDeviceRuntime {
14
14
  offlineDpCache: undefined,
15
15
  isActiveThreadCache: false,
16
16
  deviceAdvanceAbilityCache: undefined,
17
+ fitDeviceBvCache: undefined,
17
18
  };
18
19
  this.sync = {
19
20
  hasSyncedT0: false,
@@ -21,6 +22,8 @@ export class LockDeviceRuntime {
21
22
  unlockMethodAutoSyncEnabled: true,
22
23
  tempAutoSyncEnabled: true,
23
24
  tempPayloadSyncing: false,
25
+ fitSyncReportHandler: null,
26
+ fitBindingsSyncStarted: false,
24
27
  };
25
28
  this.infra = {
26
29
  eventsRegistered: false,
@@ -1,5 +1,5 @@
1
1
  import { ProductCommunicationType, RemotePermissionType } from "../constant";
2
- import { CapabilityInfo, DeviceInfo, DeviceStatus, DpSchema } from "../interface";
2
+ import { CameraConfig, CapabilityInfo, DeviceInfo, DeviceStatus, DpSchema } from "../interface";
3
3
  export type LockConfigState = {
4
4
  devInfo: DeviceInfo;
5
5
  dpSchema: Record<string, DpSchema>;
@@ -21,8 +21,12 @@ export type LockConfigState = {
21
21
  supportMultipleFace: boolean;
22
22
  supportOfflineDps: boolean;
23
23
  preFetch: boolean;
24
+ localCache: boolean;
24
25
  supportTalk: boolean;
25
26
  isTwoWayTalk: boolean;
27
+ cameraConfig: CameraConfig[];
28
+ notSupportWake: boolean;
29
+ isFitting: boolean;
26
30
  };
27
31
  export declare function createDefaultDeviceStatus(): DeviceStatus;
28
32
  export declare function createLockConfigState(): LockConfigState;
@@ -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() {
@@ -31,7 +33,11 @@ export function createLockConfigState() {
31
33
  supportMultipleFace: false,
32
34
  supportOfflineDps: false,
33
35
  preFetch: false,
36
+ localCache: true,
34
37
  supportTalk: false,
35
38
  isTwoWayTalk: false,
39
+ cameraConfig: [],
40
+ notSupportWake: false,
41
+ isFitting: false
36
42
  };
37
43
  }
@@ -5,6 +5,7 @@ export interface LockRuntimeCacheFields {
5
5
  offlineDpCache: OfflineDps | undefined;
6
6
  isActiveThreadCache: boolean;
7
7
  deviceAdvanceAbilityCache: DeviceAdvancedAbility | undefined;
8
+ fitDeviceBvCache: Promise<number> | undefined;
8
9
  }
9
10
  export interface LockRuntimeSyncFlags {
10
11
  hasSyncedT0: boolean;
@@ -12,6 +13,11 @@ export interface LockRuntimeSyncFlags {
12
13
  unlockMethodAutoSyncEnabled: boolean;
13
14
  tempAutoSyncEnabled: boolean;
14
15
  tempPayloadSyncing: boolean;
16
+ fitSyncReportHandler: ((data: {
17
+ deviceId?: string;
18
+ data?: string;
19
+ }) => void) | null;
20
+ fitBindingsSyncStarted: boolean;
15
21
  }
16
22
  export interface LockRuntimeInfraFields {
17
23
  eventsRegistered: boolean;
@@ -12,3 +12,4 @@ export declare enum LoopTypes {
12
12
  WEEK = 2,
13
13
  MONTH = 3
14
14
  }
15
+ export declare const cameraPositionMap: Record<number, number>;
@@ -14,3 +14,9 @@ export var LoopTypes;
14
14
  LoopTypes[LoopTypes["WEEK"] = 2] = "WEEK";
15
15
  LoopTypes[LoopTypes["MONTH"] = 3] = "MONTH";
16
16
  })(LoopTypes || (LoopTypes = {}));
17
+ export const cameraPositionMap = {
18
+ 0: 4,
19
+ 1: 3,
20
+ 2: 5,
21
+ 3: 6,
22
+ };
@@ -32,7 +32,7 @@ export declare const getSystemInfo: () => {
32
32
  locationEnabled: boolean;
33
33
  wifiEnabled: boolean;
34
34
  theme?: ty.Themes;
35
- deviceOrientation?: ty.Orientation;
35
+ deviceOrientation?: ty.PhoneOrientation;
36
36
  deviceLevel: string;
37
37
  isSupportPinShortcut?: boolean;
38
38
  deviceType?: string;
@@ -121,6 +121,7 @@ export declare function getCapabilities(capability: number): ({
121
121
  readonly short: "thread";
122
122
  })[];
123
123
  export declare const formatWeek: (value: number[]) => number;
124
+ export declare const formatCloudUnlockId: (dpId: number | string, sn: number) => string;
124
125
  export declare const parseWeek: (value: number) => Week;
125
126
  export declare const getPermanentSetting: () => {
126
127
  startTime: number;
@@ -56,6 +56,7 @@ export const formatWeek = (value) => {
56
56
  const temp = value.slice(0, 7);
57
57
  return parseInt(temp.reverse().join(""), 2);
58
58
  };
59
+ export const formatCloudUnlockId = (dpId, sn) => `${dpId}-${sn.toString(16).padStart(2, "0")}`;
59
60
  export const parseWeek = (value) => {
60
61
  return Number(value)
61
62
  .toString(2)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.2.0-beta.8",
3
+ "version": "1.2.0",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"
@@ -12,16 +12,6 @@
12
12
  "types": "./lib/index.d.ts",
13
13
  "import": "./lib/index.js",
14
14
  "default": "./lib/index.js"
15
- },
16
- "./fit": {
17
- "types": "./lib/fit.d.ts",
18
- "import": "./lib/fit.js",
19
- "default": "./lib/fit.js"
20
- },
21
- "./screen": {
22
- "types": "./lib/screen.d.ts",
23
- "import": "./lib/screen.js",
24
- "default": "./lib/screen.js"
25
15
  }
26
16
  },
27
17
  "scripts": {
@@ -1,7 +0,0 @@
1
- import type { LockSDKOption } from "../interface";
2
- import type { LockDeviceRuntime } from "../runtime/LockDeviceRuntime";
3
- import { type LockSDKInstance } from "../entries/main/build-instance";
4
- export declare function bootstrapRegisteredLockInstance(options?: LockSDKOption): Promise<{
5
- runtime: LockDeviceRuntime;
6
- instance: LockSDKInstance;
7
- }>;
@@ -1,16 +0,0 @@
1
- import { addEvents } from "../feature/state/platform-routing";
2
- import { initState } from "../feature/state/init-state";
3
- import { registerRuntime } from "../runtime/registry";
4
- import { buildLockSDKInstance, } from "../entries/main/build-instance";
5
- import * as MainDeviceExports from "../entries/main/exports";
6
- import { createBootstrappedRuntime } from "./bootstrap";
7
- export async function bootstrapRegisteredLockInstance(options) {
8
- const runtime = await createBootstrappedRuntime(options);
9
- registerRuntime(runtime);
10
- addEvents(runtime);
11
- await initState(runtime);
12
- return {
13
- runtime,
14
- instance: buildLockSDKInstance(runtime, MainDeviceExports),
15
- };
16
- }
@@ -1,4 +0,0 @@
1
- import type { LockSDKOption } from "../interface";
2
- import { LockDeviceRuntime } from "../runtime/LockDeviceRuntime";
3
- export declare function applyLockOptionsToRuntime(runtime: LockDeviceRuntime, options?: LockSDKOption): Promise<void>;
4
- export declare function createBootstrappedRuntime(options?: LockSDKOption): Promise<LockDeviceRuntime>;
@@ -1,53 +0,0 @@
1
- import dpCodes from "../config/dp-code";
2
- import { getCapabilities } from "../utils";
3
- import { getDeviceInfo, trackEvent } from "../platform/device";
4
- import { LockDeviceRuntime } from "../runtime/LockDeviceRuntime";
5
- export async function applyLockOptionsToRuntime(runtime, options) {
6
- const { config } = runtime;
7
- let { devInfo, deviceId } = options || {};
8
- if (!devInfo && !deviceId) {
9
- throw new Error("deviceId is required in lock sdk");
10
- }
11
- if (deviceId && (!devInfo || devInfo.devId !== deviceId)) {
12
- devInfo = await getDeviceInfo(deviceId);
13
- }
14
- let dpSchema = {};
15
- const codesById = {};
16
- const idsByCode = {};
17
- if (devInfo.schema) {
18
- dpSchema = devInfo.schema.reduce((acc, cur) => {
19
- acc[cur.code] = cur;
20
- codesById[cur.id] = cur.code;
21
- idsByCode[cur.code] = cur.id;
22
- return acc;
23
- }, {});
24
- }
25
- else if (devInfo.dpSchema) {
26
- dpSchema = devInfo.dpSchema;
27
- Object.keys(dpSchema).forEach((key) => {
28
- const item = dpSchema[key];
29
- codesById[item.id] = item.code;
30
- idsByCode[item.code] = item.id;
31
- });
32
- }
33
- config.strictMode = options?.strictMode ?? true;
34
- config.passwordDigitalBase = options?.passwordDigitalBase ?? 10;
35
- config.passwordSupportZero = options?.passwordSupportZero ?? true;
36
- config.supportMultipleFace = options?.supportMultipleFace ?? false;
37
- config.supportOfflineDps = options?.supportOfflineDps ?? false;
38
- config.devInfo = devInfo;
39
- config.dpSchema = dpSchema;
40
- config.codesById = codesById;
41
- config.idsByCode = idsByCode;
42
- config.supportBigData = !!dpSchema[dpCodes.synchMethodW];
43
- config.preFetch = options?.preFetch ?? false;
44
- config.communication = getCapabilities(devInfo.capability).map((item) => item.id);
45
- trackEvent("t$y_UztB3Lj9Qns375R0r7dA0L5Kr2VytH3J".replace("$", ""), {
46
- pid: devInfo.productId,
47
- });
48
- }
49
- export async function createBootstrappedRuntime(options) {
50
- const runtime = new LockDeviceRuntime();
51
- await applyLockOptionsToRuntime(runtime, options);
52
- return runtime;
53
- }
@@ -1,3 +0,0 @@
1
- import type { LockDeviceRuntime } from "../runtime/LockDeviceRuntime";
2
- export declare function registerLockSDKInstanceRuntime(instance: object, runtime: LockDeviceRuntime): void;
3
- export declare function getRuntimeForLockSDKInstance(instance: object): LockDeviceRuntime | undefined;
@@ -1,7 +0,0 @@
1
- const runtimeByInstance = new WeakMap();
2
- export function registerLockSDKInstanceRuntime(instance, runtime) {
3
- runtimeByInstance.set(instance, runtime);
4
- }
5
- export function getRuntimeForLockSDKInstance(instance) {
6
- return runtimeByInstance.get(instance);
7
- }
@@ -1,6 +0,0 @@
1
- import type { LockDeviceRuntime } from "../runtime/LockDeviceRuntime";
2
- import type { LockSDKInstance } from "../entries/main/build-instance";
3
- export declare function setPrimaryLockSDKInstance(instance: LockSDKInstance): void;
4
- export declare function getPrimaryLockSDKRuntime(): LockDeviceRuntime | null;
5
- export declare function clearPrimaryLockSDKInstance(): void;
6
- export declare function clearPrimaryLockSDKInstanceIfDevId(devId: string): void;
@@ -1,24 +0,0 @@
1
- import { getRuntimeForLockSDKInstance } from "./lock-instance-runtime-ref";
2
- let primaryDevId = null;
3
- let primaryRuntime = null;
4
- export function setPrimaryLockSDKInstance(instance) {
5
- const runtime = getRuntimeForLockSDKInstance(instance);
6
- if (!runtime) {
7
- throw new Error("setPrimaryLockSDKInstance: instance must be returned by createLockSDK or init");
8
- }
9
- primaryDevId = runtime.devId;
10
- primaryRuntime = runtime;
11
- }
12
- export function getPrimaryLockSDKRuntime() {
13
- return primaryRuntime;
14
- }
15
- export function clearPrimaryLockSDKInstance() {
16
- primaryDevId = null;
17
- primaryRuntime = null;
18
- }
19
- export function clearPrimaryLockSDKInstanceIfDevId(devId) {
20
- if (primaryDevId === devId) {
21
- primaryDevId = null;
22
- primaryRuntime = null;
23
- }
24
- }
@@ -1,5 +0,0 @@
1
- import type { LockDeviceRuntime } from "../runtime/LockDeviceRuntime";
2
- export type LockSdkBoundExportThis = {
3
- devId: string;
4
- };
5
- export declare function resolveRuntimeFromExportThis(thisArg: unknown): LockDeviceRuntime;
@@ -1,29 +0,0 @@
1
- import { getRuntimeByDevId } from "../runtime/registry";
2
- import { getRuntimeForLockSDKInstance } from "./lock-instance-runtime-ref";
3
- import { resolveTopLevelTargetRuntime } from "./top-level-runtime";
4
- export function resolveRuntimeFromExportThis(thisArg) {
5
- if (thisArg !== null &&
6
- thisArg !== undefined &&
7
- typeof thisArg === "object") {
8
- const rtFromInstance = getRuntimeForLockSDKInstance(thisArg);
9
- if (rtFromInstance) {
10
- return rtFromInstance;
11
- }
12
- }
13
- if (thisArg !== null &&
14
- thisArg !== undefined &&
15
- typeof thisArg === "object" &&
16
- "devId" in thisArg &&
17
- typeof thisArg.devId === "string") {
18
- const devId = thisArg.devId;
19
- if (devId.length === 0) {
20
- throw new Error("Lock SDK: bound context devId must be non-empty");
21
- }
22
- const rt = getRuntimeByDevId(devId);
23
- if (!rt) {
24
- throw new Error(`Lock SDK: no registered runtime for devId "${devId}"; use createLockSDK or init first`);
25
- }
26
- return rt;
27
- }
28
- return resolveTopLevelTargetRuntime();
29
- }
@@ -1,2 +0,0 @@
1
- import type { LockDeviceRuntime } from "../runtime/LockDeviceRuntime";
2
- export declare function resolveTopLevelTargetRuntime(): LockDeviceRuntime;
@@ -1,9 +0,0 @@
1
- import { getError } from "../utils/errors";
2
- import { getPrimaryLockSDKRuntime } from "./primary-instance";
3
- export function resolveTopLevelTargetRuntime() {
4
- const primary = getPrimaryLockSDKRuntime();
5
- if (!primary) {
6
- throw getError(1071);
7
- }
8
- return primary;
9
- }
@@ -1,7 +0,0 @@
1
- import type { LockSDKOption } from "../../../interface";
2
- import type { LockDeviceRuntime } from "../../../runtime/LockDeviceRuntime";
3
- import { type LockSDKInstance } from "../build-instance";
4
- export declare function bootstrapRegisteredLockInstance(options?: LockSDKOption): Promise<{
5
- runtime: LockDeviceRuntime;
6
- instance: LockSDKInstance;
7
- }>;
@@ -1,12 +0,0 @@
1
- import { addEvents } from "../../../feature/state/platform-routing";
2
- import { initState } from "../../../feature/state/init-state";
3
- import { registerRuntime } from "../../../runtime/registry";
4
- import { buildLockSDKInstance, } from "../build-instance";
5
- import { createBootstrappedRuntime } from "./bootstrap";
6
- export async function bootstrapRegisteredLockInstance(options) {
7
- const runtime = await createBootstrappedRuntime(options);
8
- registerRuntime(runtime);
9
- addEvents(runtime);
10
- await initState(runtime);
11
- return { runtime, instance: buildLockSDKInstance(runtime) };
12
- }
@@ -1,4 +0,0 @@
1
- import type { LockSDKOption } from "../../../interface";
2
- import { LockDeviceRuntime } from "../../../runtime/LockDeviceRuntime";
3
- export declare function applyLockOptionsToRuntime(runtime: LockDeviceRuntime, options?: LockSDKOption): Promise<void>;
4
- export declare function createBootstrappedRuntime(options?: LockSDKOption): Promise<LockDeviceRuntime>;