@ray-js/lock-sdk 1.2.0-beta.16 → 1.2.0-beta.18

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.
@@ -1,12 +1,23 @@
1
- import { addEvents } from "../../../feature/state/platform-routing";
1
+ import { addEvents, removeEvents, } from "../../../feature/state/platform-routing";
2
2
  import { initState } from "../../../feature/state/init-state";
3
- import { registerRuntime } from "../../../runtime/registry";
3
+ import { clearStateForRuntime } from "../../../feature/state/clear";
4
+ import { registerRuntime, unregisterRuntime, getRegisteredRuntimeCount, } from "../../../runtime/registry";
4
5
  import { buildFitSDKInstance } from "../build-instance";
5
6
  import { createBootstrappedRuntime } from "./bootstrap";
6
7
  export async function bootstrapRegisteredFitInstance(options) {
7
8
  const runtime = await createBootstrappedRuntime(options);
8
9
  registerRuntime(runtime);
9
- addEvents(runtime);
10
- await initState(runtime);
11
- return { runtime, instance: buildFitSDKInstance(runtime) };
10
+ try {
11
+ addEvents(runtime);
12
+ await initState(runtime);
13
+ return { runtime, instance: buildFitSDKInstance(runtime) };
14
+ }
15
+ catch (error) {
16
+ unregisterRuntime(runtime.devId);
17
+ clearStateForRuntime(runtime);
18
+ if (getRegisteredRuntimeCount() === 0) {
19
+ removeEvents();
20
+ }
21
+ throw error;
22
+ }
12
23
  }
@@ -1,12 +1,23 @@
1
- import { addEvents } from "../../../feature/state/platform-routing";
1
+ import { addEvents, removeEvents, } from "../../../feature/state/platform-routing";
2
2
  import { initState } from "../../../feature/state/init-state";
3
- import { registerRuntime } from "../../../runtime/registry";
3
+ import { clearStateForRuntime } from "../../../feature/state/clear";
4
+ import { registerRuntime, unregisterRuntime, getRegisteredRuntimeCount, } from "../../../runtime/registry";
4
5
  import { buildLockSDKInstance, } from "../build-instance";
5
6
  import { createBootstrappedRuntime } from "./bootstrap";
6
7
  export async function bootstrapRegisteredLockInstance(options) {
7
8
  const runtime = await createBootstrappedRuntime(options);
8
9
  registerRuntime(runtime);
9
- addEvents(runtime);
10
- await initState(runtime);
11
- return { runtime, instance: buildLockSDKInstance(runtime) };
10
+ try {
11
+ addEvents(runtime);
12
+ await initState(runtime);
13
+ return { runtime, instance: buildLockSDKInstance(runtime) };
14
+ }
15
+ catch (error) {
16
+ unregisterRuntime(runtime.devId);
17
+ clearStateForRuntime(runtime);
18
+ if (getRegisteredRuntimeCount() === 0) {
19
+ removeEvents();
20
+ }
21
+ throw error;
22
+ }
12
23
  }
@@ -60,7 +60,7 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
60
60
  if (rt.cache.deviceAdvanceAbilityCache) {
61
61
  return rt.cache.deviceAdvanceAbilityCache;
62
62
  }
63
- const [productAbilitiesRes, deviceAdvancedAbilityRes, tttList] = await Promise.allSettled([
63
+ const [productAbilitiesRes, tttList] = await Promise.allSettled([
64
64
  getProductAbilities(rt.config.devInfo.devId, [
65
65
  "tyabi4ucx5",
66
66
  "tyabis9tpe",
@@ -69,17 +69,13 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
69
69
  "tyabin4u5v",
70
70
  "visual_door_lock_cloud_store",
71
71
  ]),
72
- getDeviceAdvancedAbility(rt.config.devInfo.devId),
73
72
  ipc.getTTTAbilityKeyList("isSupportedVRMode"),
74
73
  ]);
75
74
  const productAbilities = productAbilitiesRes.status === "fulfilled" ? productAbilitiesRes.value : [];
76
- const deviceAdvancedAbility = deviceAdvancedAbilityRes.status === "fulfilled"
77
- ? deviceAdvancedAbilityRes.value
78
- : undefined;
79
75
  const tttAbList = tttList.status === "fulfilled" ? tttList.value.abilityList : [];
80
76
  const deviceAdvanceAbilityCache = {
81
77
  cloudStorage: {
82
- support: deviceAdvancedAbility?.types?.includes(0) ?? false,
78
+ support: false,
83
79
  },
84
80
  vr: {
85
81
  support: false,
@@ -155,8 +151,6 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
155
151
  break;
156
152
  }
157
153
  case "tyabiwxrn9": {
158
- deviceAdvanceAbilityCache.wechatVoip.support =
159
- deviceAdvancedAbility?.types?.includes(1) ?? false;
160
154
  deviceAdvanceAbilityCache.wechatVoip.isPublice =
161
155
  data?.WechatType === "0";
162
156
  if (!deviceAdvanceAbilityCache.wechatVoip.isPublice) {
@@ -186,6 +180,12 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
186
180
  console.warn(`setting [${item.abilityCode}] config error`, error);
187
181
  }
188
182
  });
183
+ getDeviceAdvancedAbility(rt.config.devInfo.devId).then((res) => {
184
+ deviceAdvanceAbilityCache.cloudStorage.support =
185
+ res.types?.includes(0) ?? false;
186
+ deviceAdvanceAbilityCache.wechatVoip.support =
187
+ res.types?.includes(1) ?? false;
188
+ });
189
189
  rt.cache.deviceAdvanceAbilityCache = deviceAdvanceAbilityCache;
190
190
  return deviceAdvanceAbilityCache;
191
191
  };
@@ -90,8 +90,14 @@ const globalHandleBleChange = ({ deviceId, status }) => {
90
90
  devId: deviceId,
91
91
  data: { status, registered: !!rt },
92
92
  });
93
- if (!rt || status !== "CONNECTED") {
94
- return;
93
+ if (rt) {
94
+ updateOnlineType(rt);
95
+ if (status === "CONNECTED") {
96
+ void syncRemoteSerectKey(rt);
97
+ autoSyncTemp(rt);
98
+ void syncT0(rt);
99
+ void syncOfflineDps(rt);
100
+ }
95
101
  }
96
102
  };
97
103
  const globalHandleAppShow = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.2.0-beta.16",
3
+ "version": "1.2.0-beta.18",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"