@ray-js/lock-sdk 1.2.0-beta.1 → 1.2.0-beta.10

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 (74) hide show
  1. package/lib/api/index.d.ts +3 -1
  2. package/lib/api/index.js +16 -0
  3. package/lib/api/notify.d.ts +28 -0
  4. package/lib/api/notify.js +17 -0
  5. package/lib/api/screen.d.ts +1 -0
  6. package/lib/api/service.d.ts +26 -0
  7. package/lib/api/service.js +25 -0
  8. package/lib/api/video.d.ts +9 -0
  9. package/lib/api/video.js +30 -0
  10. package/lib/api/voip.d.ts +10 -0
  11. package/lib/api/voip.js +17 -0
  12. package/lib/config/dp-code/index.d.ts +1 -0
  13. package/lib/config/dp-code/index.js +1 -0
  14. package/lib/config/dp-map/media.d.ts +13 -0
  15. package/lib/config/dp-map/media.js +19 -0
  16. package/lib/entries/main/exports/ai.d.ts +4 -0
  17. package/lib/entries/main/exports/ai.js +11 -0
  18. package/lib/entries/main/exports/index.d.ts +4 -0
  19. package/lib/entries/main/exports/index.js +4 -0
  20. package/lib/entries/main/exports/media.d.ts +10 -1
  21. package/lib/entries/main/exports/media.js +29 -1
  22. package/lib/entries/main/exports/notify.d.ts +7 -0
  23. package/lib/entries/main/exports/notify.js +8 -0
  24. package/lib/entries/main/exports/screen/bind.d.ts +6 -3
  25. package/lib/entries/main/exports/screen/bind.js +7 -0
  26. package/lib/entries/main/exports/service.d.ts +4 -0
  27. package/lib/entries/main/exports/service.js +11 -0
  28. package/lib/entries/main/exports/voip.d.ts +3 -0
  29. package/lib/entries/main/exports/voip.js +8 -0
  30. package/lib/entries/screen/exports/bind-events.d.ts +4 -0
  31. package/lib/entries/screen/exports/bind-events.js +8 -0
  32. package/lib/entries/screen/exports/index.d.ts +1 -0
  33. package/lib/entries/screen/exports/index.js +1 -0
  34. package/lib/feature/ai/report.d.ts +5 -0
  35. package/lib/feature/ai/report.js +37 -0
  36. package/lib/feature/media/camera.d.ts +18 -0
  37. package/lib/feature/media/camera.js +36 -0
  38. package/lib/feature/media/media.d.ts +10 -0
  39. package/lib/feature/media/media.js +31 -0
  40. package/lib/feature/misc/capability.js +77 -6
  41. package/lib/feature/notify/notify.d.ts +4 -0
  42. package/lib/feature/notify/notify.js +3 -0
  43. package/lib/feature/password/temporary/custom-dp.js +59 -54
  44. package/lib/feature/screen/bind-watch.d.ts +18 -0
  45. package/lib/feature/screen/bind-watch.js +92 -0
  46. package/lib/feature/screen/bind.d.ts +2 -2
  47. package/lib/feature/screen/bind.js +8 -38
  48. package/lib/feature/screen/list.js +13 -0
  49. package/lib/feature/service/goto-service.d.ts +2 -1
  50. package/lib/feature/service/goto-service.js +7 -1
  51. package/lib/feature/service/value-added.d.ts +4 -0
  52. package/lib/feature/service/value-added.js +4 -0
  53. package/lib/feature/state/init-state.js +26 -18
  54. package/lib/feature/state/remote-permissions.js +16 -0
  55. package/lib/feature/storage/index.d.ts +5 -0
  56. package/lib/feature/storage/index.js +32 -0
  57. package/lib/feature/unlock/sync/unlock-method.js +3 -0
  58. package/lib/feature/voip/voip.d.ts +3 -0
  59. package/lib/feature/voip/voip.js +3 -0
  60. package/lib/interface.d.ts +24 -1
  61. package/lib/platform/device.d.ts +1 -1
  62. package/lib/platform/device.js +1 -1
  63. package/lib/platform/index.d.ts +1 -0
  64. package/lib/platform/index.js +1 -0
  65. package/lib/platform/ipc.js +10 -7
  66. package/lib/platform/storage.d.ts +3 -0
  67. package/lib/platform/storage.js +9 -0
  68. package/lib/runtime/lock-config.d.ts +2 -1
  69. package/lib/runtime/lock-config.js +1 -0
  70. package/lib/utils/errors.js +3 -1
  71. package/lib/utils/index.d.ts +35 -0
  72. package/lib/utils/index.js +11 -1
  73. package/lib/utils/parse.js +1 -1
  74. package/package.json +1 -1
@@ -10,10 +10,12 @@ var DeviceProperties;
10
10
  (function (DeviceProperties) {
11
11
  DeviceProperties["REMOTE_UNLOCK_AUTH"] = "REMOTE_UNLOCK_AUTH";
12
12
  DeviceProperties["UNLOCK_PHONE_REMOTE"] = "UNLOCK_PHONE_REMOTE";
13
+ DeviceProperties["LOCK_POS_ROT_ANGLE"] = "LOCK_POS_ROT_ANGLE";
13
14
  })(DeviceProperties || (DeviceProperties = {}));
14
15
  const propsList = [
15
16
  DeviceProperties.REMOTE_UNLOCK_AUTH,
16
17
  DeviceProperties.UNLOCK_PHONE_REMOTE,
18
+ DeviceProperties.LOCK_POS_ROT_ANGLE,
17
19
  ];
18
20
  export async function fetchDeviceProperties(runtime, isForce) {
19
21
  let result = null;
@@ -27,4 +29,18 @@ export async function fetchDeviceProperties(runtime, isForce) {
27
29
  result[DeviceProperties.UNLOCK_PHONE_REMOTE] === "true";
28
30
  runtime.config.remoteOpenPermission =
29
31
  permissions[+result[DeviceProperties.REMOTE_UNLOCK_AUTH] || 0];
32
+ if (result[DeviceProperties.LOCK_POS_ROT_ANGLE]) {
33
+ try {
34
+ const data = JSON.parse(result[DeviceProperties.LOCK_POS_ROT_ANGLE]);
35
+ runtime.config.cameraConfig = data.map((item) => ({
36
+ isVR: !!item.vr,
37
+ width: item.w,
38
+ height: item.h,
39
+ rotate: item.al,
40
+ localtion: item.p,
41
+ }));
42
+ }
43
+ catch (e) {
44
+ }
45
+ }
30
46
  }
@@ -0,0 +1,5 @@
1
+ import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
2
+ export declare const setStorageForRuntime: (rt: LockDeviceRuntime, key: string, data: unknown) => void;
3
+ export declare const getStorageForRuntime: <T = unknown>(rt: LockDeviceRuntime, key: string) => T | null;
4
+ export declare const removeStorageForRuntime: (rt: LockDeviceRuntime, key: string) => void;
5
+ export declare const clearStorageForRuntime: (rt: LockDeviceRuntime, keys: string[]) => void;
@@ -0,0 +1,32 @@
1
+ import { getStorageSync, removeStorageSync, setStorageSync, } from "../../platform";
2
+ const buildStorageKey = (rt, key) => {
3
+ const { devId, activeTime } = rt.config.devInfo;
4
+ return `${devId}_${activeTime}_${key}`;
5
+ };
6
+ export const setStorageForRuntime = (rt, key, data) => {
7
+ const value = typeof data === "string" ? data : JSON.stringify(data);
8
+ setStorageSync(buildStorageKey(rt, key), value);
9
+ };
10
+ export const getStorageForRuntime = (rt, key) => {
11
+ const raw = getStorageSync(buildStorageKey(rt, key));
12
+ if (raw == null || raw === "") {
13
+ return null;
14
+ }
15
+ if (typeof raw === "string") {
16
+ try {
17
+ return JSON.parse(raw);
18
+ }
19
+ catch {
20
+ return raw;
21
+ }
22
+ }
23
+ return raw;
24
+ };
25
+ export const removeStorageForRuntime = (rt, key) => {
26
+ removeStorageSync(buildStorageKey(rt, key));
27
+ };
28
+ export const clearStorageForRuntime = (rt, keys) => {
29
+ keys.forEach((key) => {
30
+ removeStorageSync(buildStorageKey(rt, key));
31
+ });
32
+ };
@@ -19,6 +19,9 @@ export const syncUnlockMethodWithRuntime = async (runtime) => {
19
19
  });
20
20
  rt.sync.unlockMethodAutoSyncEnabled = false;
21
21
  const { allOpenDps = "" } = await getCurrentUserForRuntime(rt);
22
+ if (!allOpenDps) {
23
+ return;
24
+ }
22
25
  const { ins = "", distributed = false } = await fetchSyncUnlockMethodInfo({
23
26
  devId: rt.config.devInfo.devId,
24
27
  dpIds: allOpenDps.split(","),
@@ -0,0 +1,3 @@
1
+ import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
2
+ export declare const getVoipAuthForRuntime: (rt: LockDeviceRuntime) => Promise<import("../../api/voip").VoipAuth>;
3
+ export declare const saveVoipAuthForRuntime: (rt: LockDeviceRuntime, userId: string) => Promise<boolean>;
@@ -0,0 +1,3 @@
1
+ import { getVoipAuthApi, saveVoipAuthApi } from "../../api/voip";
2
+ export const getVoipAuthForRuntime = (rt) => getVoipAuthApi(rt.config.devInfo.devId);
3
+ export const saveVoipAuthForRuntime = (rt, userId) => saveVoipAuthApi(rt.config.devInfo.devId, userId);
@@ -334,10 +334,20 @@ export interface AlbumMessage extends MediaInfo {
334
334
  type: number;
335
335
  createTime: number;
336
336
  }
337
+ export type VRModeType = "original" | "VR" | "horizontal" | "vertical";
337
338
  export interface DeviceAdvancedAbility {
338
339
  cloudStorage: {
339
340
  support: boolean;
340
341
  };
342
+ vr: {
343
+ support: boolean;
344
+ coverMode: VRModeType;
345
+ modes: Array<{
346
+ mode: VRModeType;
347
+ value: number;
348
+ }>;
349
+ defaultMode: VRModeType;
350
+ };
341
351
  ai: {
342
352
  support: boolean;
343
353
  config: Record<string, any>;
@@ -348,7 +358,9 @@ export interface DeviceAdvancedAbility {
348
358
  };
349
359
  wechatVoip: {
350
360
  support: boolean;
351
- config: Record<string, any>;
361
+ isPublice: boolean;
362
+ appId?: string;
363
+ modeId?: string;
352
364
  };
353
365
  voip: {
354
366
  support: boolean;
@@ -386,4 +398,15 @@ export interface SharedUserInfo {
386
398
  lockUserId: number;
387
399
  userExist: boolean;
388
400
  }
401
+ export interface AIReportPopup {
402
+ reportId: string;
403
+ yearMonth: number;
404
+ }
405
+ export interface CameraConfig {
406
+ isVR: boolean;
407
+ width: number;
408
+ height: number;
409
+ rotate: number;
410
+ localtion: number;
411
+ }
389
412
  export {};
@@ -23,7 +23,7 @@ export declare const onOnlineChange: (func: ParamType<typeof ty.device.onDeviceO
23
23
  export declare const offOnlineChange: (func: ParamType<typeof ty.device.offDeviceOnlineStatusUpdate>) => void;
24
24
  export declare const onBleChange: (func: ParamType<typeof ty.device.onBLEConnectStatusChange>) => void;
25
25
  export declare const offBleChange: (func: ParamType<typeof ty.device.offBLEConnectStatusChange>) => void;
26
- export declare const getSystemInfo: () => {
26
+ export declare const getSystemInfoSync: () => {
27
27
  is24Hour: boolean;
28
28
  system: string;
29
29
  brand: string;
@@ -98,7 +98,7 @@ export const onBleChange = (func) => {
98
98
  export const offBleChange = (func) => {
99
99
  ty.device.offBLEConnectStatusChange(func);
100
100
  };
101
- export const getSystemInfo = () => ty.getSystemInfoSync();
101
+ export const getSystemInfoSync = () => ty.getSystemInfoSync();
102
102
  export const showModal = (options) => {
103
103
  return ty.showModal(options);
104
104
  };
@@ -1,2 +1,3 @@
1
1
  export * from "./device";
2
+ export * from "./storage";
2
3
  export { default as ipc } from "./ipc";
@@ -1,2 +1,3 @@
1
1
  export * from "./device";
2
+ export * from "./storage";
2
3
  export { default as ipc } from "./ipc";
@@ -19,14 +19,17 @@ const connect = (deviceId) => {
19
19
  });
20
20
  };
21
21
  const getCurrentSupportedTalkMode = (deviceId) => {
22
- return new Promise((resolve, reject) => {
23
- ty.ipc.getCurrentSupportedTalkMode({
24
- deviceId,
25
- extendParam: {},
26
- success: resolve,
27
- fail: reject,
22
+ if (ty.ipc.getCurrentSupportedTalkMode) {
23
+ return new Promise((resolve, reject) => {
24
+ ty.ipc.getCurrentSupportedTalkMode({
25
+ deviceId,
26
+ extendParam: {},
27
+ success: resolve,
28
+ fail: reject,
29
+ });
28
30
  });
29
- });
31
+ }
32
+ return Promise.reject(new Error("not support"));
30
33
  };
31
34
  export default {
32
35
  wakeUpDoorBell,
@@ -0,0 +1,3 @@
1
+ export declare const setStorageSync: (key: string, data: unknown) => void;
2
+ export declare const getStorageSync: (key: string) => any;
3
+ export declare const removeStorageSync: (key: string) => void;
@@ -0,0 +1,9 @@
1
+ export const setStorageSync = (key, data) => {
2
+ ty.setStorageSync({ key, data });
3
+ };
4
+ export const getStorageSync = (key) => {
5
+ return ty.getStorageSync({ key });
6
+ };
7
+ export const removeStorageSync = (key) => {
8
+ ty.removeStorageSync({ key });
9
+ };
@@ -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>;
@@ -23,6 +23,7 @@ export type LockConfigState = {
23
23
  preFetch: boolean;
24
24
  supportTalk: boolean;
25
25
  isTwoWayTalk: boolean;
26
+ cameraConfig: CameraConfig[];
26
27
  };
27
28
  export declare function createDefaultDeviceStatus(): DeviceStatus;
28
29
  export declare function createLockConfigState(): LockConfigState;
@@ -33,5 +33,6 @@ export function createLockConfigState() {
33
33
  preFetch: false,
34
34
  supportTalk: false,
35
35
  isTwoWayTalk: false,
36
+ cameraConfig: [],
36
37
  };
37
38
  }
@@ -102,7 +102,9 @@ const errors = {
102
102
  1100: "Binding limit reached",
103
103
  1101: "The lock has already been bound, please do not bind it again",
104
104
  1102: "Lock is binding",
105
- 1103: "Binding failed"
105
+ 1103: "Binding failed",
106
+ 1104: "Failed to switch cameras",
107
+ 1105: "Camera switching is not supported",
106
108
  };
107
109
  export const getError = (code, ...places) => {
108
110
  if (errors[code]) {
@@ -3,6 +3,40 @@ import type { EffectiveConfig, Week } from "../interface";
3
3
  import { LoopTypes } from "./constant";
4
4
  export declare const get24Time: (time: number) => number[];
5
5
  export declare const getNowTime: () => number;
6
+ export declare const getSystemInfo: () => {
7
+ is24Hour: boolean;
8
+ system: string;
9
+ brand: string;
10
+ model: string;
11
+ platform: string;
12
+ timezoneId: string;
13
+ pixelRatio: number;
14
+ screenWidth: number;
15
+ screenHeight: number;
16
+ windowWidth: number;
17
+ windowHeight: number;
18
+ useableWindowWidth: number;
19
+ useableWindowHeight: number;
20
+ statusBarHeight: number;
21
+ language: string;
22
+ safeArea: ty.SafeArea;
23
+ albumAuthorized: boolean;
24
+ cameraAuthorized: boolean;
25
+ locationAuthorized: boolean;
26
+ microphoneAuthorized: boolean;
27
+ notificationAuthorized: boolean;
28
+ notificationAlertAuthorized: boolean;
29
+ notificationBadgeAuthorized: boolean;
30
+ notificationSoundAuthorized: boolean;
31
+ bluetoothEnabled: boolean;
32
+ locationEnabled: boolean;
33
+ wifiEnabled: boolean;
34
+ theme?: ty.Themes;
35
+ deviceOrientation?: ty.Orientation;
36
+ deviceLevel: string;
37
+ isSupportPinShortcut?: boolean;
38
+ deviceType?: string;
39
+ };
6
40
  export declare const isOnlineByType: (onlineType: number, type: number) => boolean;
7
41
  export declare function isCapability(capability: number, id: number): boolean;
8
42
  export declare function getCapabilities(capability: number): ({
@@ -134,3 +168,4 @@ export declare const getAppUser: () => {
134
168
  phoneCode: string;
135
169
  isTemporaryUser: boolean;
136
170
  } | null;
171
+ export declare const isHarmony: () => boolean;
@@ -1,5 +1,5 @@
1
1
  import { LoopTypes } from "./constant";
2
- import { getAppUserInfo, getCurrentHomeInfo } from "../platform/device";
2
+ import { getAppUserInfo, getCurrentHomeInfo, getSystemInfoSync, } from "../platform/device";
3
3
  import { getError } from "./errors";
4
4
  export const get24Time = (time) => {
5
5
  const hours = Math.floor(time / 60);
@@ -10,6 +10,13 @@ export const getNowTime = () => {
10
10
  const now = new Date();
11
11
  return now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds();
12
12
  };
13
+ let system;
14
+ export const getSystemInfo = () => {
15
+ if (!system) {
16
+ system = getSystemInfoSync();
17
+ }
18
+ return system;
19
+ };
13
20
  export const isOnlineByType = (onlineType, type) => {
14
21
  const base = 2 ** type;
15
22
  return (onlineType & base) >> type === 1;
@@ -210,3 +217,6 @@ const getAppUserAsync = async () => {
210
217
  getAppUserAsync().catch(() => {
211
218
  getAppUserAsync().catch(() => undefined);
212
219
  });
220
+ export const isHarmony = () => {
221
+ return getSystemInfo().platform === "harmony";
222
+ };
@@ -6,7 +6,7 @@ export const parseCapabilities = (dpValue) => {
6
6
  return null;
7
7
  }
8
8
  const data = dpUtils.parse(dpValue, capabilitiesMap);
9
- if (data.tyep === ModuleType.M7258) {
9
+ if (data.type === ModuleType.M7258) {
10
10
  return {
11
11
  ...data,
12
12
  rotateType: data.rotateType === 1 ? 0 : data.rotateType === 0 ? 1 : data.rotateType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.2.0-beta.1",
3
+ "version": "1.2.0-beta.10",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"