@ray-js/lock-sdk 1.0.1 → 1.0.3-beta-1
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/index.js +13 -15
- package/lib/api/linkage.d.ts +0 -18
- package/lib/api/linkage.js +61 -81
- package/lib/api/lock.d.ts +0 -69
- package/lib/api/lock.js +91 -113
- package/lib/api/log.d.ts +0 -33
- package/lib/api/log.js +33 -38
- package/lib/api/setting.d.ts +0 -11
- package/lib/api/setting.js +17 -30
- package/lib/api/temp.d.ts +0 -48
- package/lib/api/temp.js +85 -115
- package/lib/api/user.d.ts +5 -54
- package/lib/api/user.js +40 -52
- package/lib/api/video.d.ts +0 -5
- package/lib/api/video.js +9 -15
- package/lib/config/dp-code/index.d.ts +0 -117
- package/lib/config/dp-code/index.js +79 -221
- package/lib/config/dp-map/common.d.ts +0 -3
- package/lib/config/dp-map/common.js +101 -116
- package/lib/config/dp-map/normal.js +29 -50
- package/lib/config/dp-map/open.d.ts +0 -16
- package/lib/config/dp-map/open.js +62 -63
- package/lib/config/dp-map/unlock-method-big.d.ts +0 -60
- package/lib/config/dp-map/unlock-method-big.js +196 -233
- package/lib/config/dp-map/unlock-method.d.ts +0 -63
- package/lib/config/dp-map/unlock-method.js +189 -227
- package/lib/config/index.d.ts +0 -25
- package/lib/config/index.js +21 -54
- package/lib/constant.d.ts +12 -40
- package/lib/constant.js +83 -136
- package/lib/event.d.ts +0 -6
- package/lib/event.js +1 -8
- package/lib/index.d.ts +0 -7
- package/lib/index.js +45 -71
- package/lib/interface.d.ts +0 -523
- package/lib/interface.js +1 -1
- package/lib/linkage.d.ts +0 -18
- package/lib/linkage.js +125 -162
- package/lib/log.d.ts +0 -50
- package/lib/log.js +255 -290
- package/lib/media.d.ts +0 -34
- package/lib/media.js +6 -77
- package/lib/open.d.ts +0 -35
- package/lib/open.js +129 -224
- package/lib/other.d.ts +8 -26
- package/lib/other.js +107 -159
- package/lib/parse/index.d.ts +0 -4
- package/lib/parse/index.js +13 -19
- package/lib/signal.d.ts +0 -13
- package/lib/signal.js +17 -31
- package/lib/sleep.d.ts +0 -42
- package/lib/sleep.js +41 -98
- package/lib/state.d.ts +0 -38
- package/lib/state.js +223 -369
- package/lib/sync/remote-serect-key.d.ts +0 -4
- package/lib/sync/remote-serect-key.js +33 -49
- package/lib/sync/t0.d.ts +0 -3
- package/lib/sync/t0.js +14 -21
- package/lib/sync/temp.d.ts +0 -5
- package/lib/sync/temp.js +68 -77
- package/lib/sync/unlock-mothod.d.ts +0 -3
- package/lib/sync/unlock-mothod.js +28 -40
- package/lib/temporary.d.ts +0 -149
- package/lib/temporary.js +469 -593
- package/lib/unlock-method.d.ts +0 -185
- package/lib/unlock-method.js +479 -650
- package/lib/user.d.ts +2 -81
- package/lib/user.js +202 -336
- package/lib/utils/base64-to-hex.js +10 -10
- package/lib/utils/byte.d.ts +0 -16
- package/lib/utils/byte.js +57 -68
- package/lib/utils/constant.js +7 -11
- package/lib/utils/device.d.ts +46 -83
- package/lib/utils/device.js +294 -322
- package/lib/utils/errors.js +75 -122
- package/lib/utils/event.js +79 -135
- package/lib/utils/hex-to-base64.js +5 -5
- package/lib/utils/hex-to-bytes.d.ts +0 -5
- package/lib/utils/hex-to-bytes.js +10 -15
- package/lib/utils/index.d.ts +0 -42
- package/lib/utils/index.js +247 -377
- package/lib/utils/log.d.ts +1 -4
- package/lib/utils/log.js +71 -74
- package/lib/utils/publishDps.d.ts +0 -5
- package/lib/utils/publishDps.js +58 -80
- package/package.json +3 -4
package/lib/utils/byte.d.ts
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 大端格式 字节数组转为无符号位数据
|
|
3
|
-
*
|
|
4
|
-
* @param data
|
|
5
|
-
* @returns
|
|
6
|
-
*/
|
|
7
1
|
export declare function bytesToUint(data: Uint8Array): number;
|
|
8
|
-
/**
|
|
9
|
-
* 大端格式 字节转为16进制字符串
|
|
10
|
-
* @param data
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
13
2
|
export declare function bytesToHex(data: Uint8Array): string;
|
|
14
|
-
/**
|
|
15
|
-
* 字符串转为字节
|
|
16
|
-
* @param str
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
3
|
export declare function stringToBytes(str: string): Uint8Array<ArrayBuffer>;
|
package/lib/utils/byte.js
CHANGED
|
@@ -1,74 +1,63 @@
|
|
|
1
|
-
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
-
import "core-js/modules/esnext.iterator.reduce.js";
|
|
3
|
-
/**
|
|
4
|
-
* 大端格式 字节数组转为无符号位数据
|
|
5
|
-
*
|
|
6
|
-
* @param data
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
1
|
export function bytesToUint(data) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
const view = new DataView(data.buffer);
|
|
3
|
+
switch (data.length) {
|
|
4
|
+
case 0:
|
|
5
|
+
throw new Error("data of Uint8Array is empty");
|
|
6
|
+
case 1:
|
|
7
|
+
return view.getUint8(0);
|
|
8
|
+
case 2:
|
|
9
|
+
return view.getUint16(0);
|
|
10
|
+
case 3:
|
|
11
|
+
return data.reduce((res, value) => {
|
|
12
|
+
return (res << 8) | value;
|
|
13
|
+
}, 0);
|
|
14
|
+
case 4:
|
|
15
|
+
return view.getUint32(0);
|
|
16
|
+
default:
|
|
17
|
+
return parseInt(bytesToHex(data), 16);
|
|
18
|
+
}
|
|
27
19
|
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 大端格式 字节转为16进制字符串
|
|
31
|
-
* @param data
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
20
|
export function bytesToHex(data) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
21
|
+
if (!data.length) {
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
if (data.length <= 4) {
|
|
25
|
+
return bytesToUint(data)
|
|
26
|
+
.toString(16)
|
|
27
|
+
.padStart(data.length * 2, "0")
|
|
28
|
+
.toUpperCase();
|
|
29
|
+
}
|
|
30
|
+
return data
|
|
31
|
+
.reduce((res, value) => {
|
|
32
|
+
res.push(value.toString(16).padStart(2, "0"));
|
|
33
|
+
return res;
|
|
34
|
+
}, [])
|
|
35
|
+
.join("")
|
|
36
|
+
.toUpperCase();
|
|
45
37
|
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 字符串转为字节
|
|
49
|
-
* @param str
|
|
50
|
-
* @returns
|
|
51
|
-
*/
|
|
52
38
|
export function stringToBytes(str) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
39
|
+
const bytes = [];
|
|
40
|
+
const len = str.length;
|
|
41
|
+
for (let i = 0; i < len; i++) {
|
|
42
|
+
const c = str.charCodeAt(i);
|
|
43
|
+
if (c >= 0x010000 && c <= 0x10ffff) {
|
|
44
|
+
bytes.push(((c >> 18) & 0x07) | 0xf0);
|
|
45
|
+
bytes.push(((c >> 12) & 0x3f) | 0x80);
|
|
46
|
+
bytes.push(((c >> 6) & 0x3f) | 0x80);
|
|
47
|
+
bytes.push((c & 0x3f) | 0x80);
|
|
48
|
+
}
|
|
49
|
+
else if (c >= 0x000800 && c <= 0x00ffff) {
|
|
50
|
+
bytes.push(((c >> 12) & 0x0f) | 0xe0);
|
|
51
|
+
bytes.push(((c >> 6) & 0x3f) | 0x80);
|
|
52
|
+
bytes.push((c & 0x3f) | 0x80);
|
|
53
|
+
}
|
|
54
|
+
else if (c >= 0x000080 && c <= 0x0007ff) {
|
|
55
|
+
bytes.push(((c >> 6) & 0x1f) | 0xc0);
|
|
56
|
+
bytes.push((c & 0x3f) | 0x80);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
bytes.push(c & 0xff);
|
|
60
|
+
}
|
|
71
61
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
62
|
+
return new Uint8Array(bytes);
|
|
63
|
+
}
|
package/lib/utils/constant.js
CHANGED
|
@@ -4,14 +4,10 @@ export { THING };
|
|
|
4
4
|
export const DPCHANGE = "dpChange";
|
|
5
5
|
export const LOGCHANGE = "logChange";
|
|
6
6
|
export const UNLOCK_METHOD_EVENT = "UMEvent";
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// 月循环
|
|
15
|
-
LoopTypes[LoopTypes["MONTH"] = 3] = "MONTH";
|
|
16
|
-
return LoopTypes;
|
|
17
|
-
}({});
|
|
7
|
+
export var LoopTypes;
|
|
8
|
+
(function (LoopTypes) {
|
|
9
|
+
LoopTypes[LoopTypes["NONE"] = 0] = "NONE";
|
|
10
|
+
LoopTypes[LoopTypes["DAY"] = 1] = "DAY";
|
|
11
|
+
LoopTypes[LoopTypes["WEEK"] = 2] = "WEEK";
|
|
12
|
+
LoopTypes[LoopTypes["MONTH"] = 3] = "MONTH";
|
|
13
|
+
})(LoopTypes || (LoopTypes = {}));
|
package/lib/utils/device.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/***
|
|
2
|
-
* 统一重新封装 TTT 能力api
|
|
3
|
-
* 以便于以后支持跨端能力
|
|
4
|
-
*/
|
|
5
1
|
import { DeviceInfo, DpData, ParamType } from "../interface";
|
|
6
2
|
export declare const getDeviceInfo: (devId: string) => Promise<DeviceInfo>;
|
|
7
3
|
export declare const getDeviceProperties: (devId: string) => Promise<Record<string, any>>;
|
|
@@ -26,9 +22,42 @@ export declare const onOnlineChange: (func: ParamType<typeof ty.device.onDeviceO
|
|
|
26
22
|
export declare const offOnlineChange: (func: ParamType<typeof ty.device.offDeviceOnlineStatusUpdate>) => void;
|
|
27
23
|
export declare const onBleChange: (func: ParamType<typeof ty.device.onBLEConnectStatusChange>) => void;
|
|
28
24
|
export declare const offBleChange: (func: ParamType<typeof ty.device.offBLEConnectStatusChange>) => void;
|
|
29
|
-
export declare const getSystemInfo: () =>
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
export declare const getSystemInfo: () => {
|
|
26
|
+
is24Hour: boolean;
|
|
27
|
+
system: string;
|
|
28
|
+
brand: string;
|
|
29
|
+
model: string;
|
|
30
|
+
platform: string;
|
|
31
|
+
timezoneId: string;
|
|
32
|
+
pixelRatio: number;
|
|
33
|
+
screenWidth: number;
|
|
34
|
+
screenHeight: number;
|
|
35
|
+
windowWidth: number;
|
|
36
|
+
windowHeight: number;
|
|
37
|
+
useableWindowWidth: number;
|
|
38
|
+
useableWindowHeight: number;
|
|
39
|
+
statusBarHeight: number;
|
|
40
|
+
language: string;
|
|
41
|
+
safeArea: ty.SafeArea;
|
|
42
|
+
albumAuthorized: boolean;
|
|
43
|
+
cameraAuthorized: boolean;
|
|
44
|
+
locationAuthorized: boolean;
|
|
45
|
+
microphoneAuthorized: boolean;
|
|
46
|
+
notificationAuthorized: boolean;
|
|
47
|
+
notificationAlertAuthorized: boolean;
|
|
48
|
+
notificationBadgeAuthorized: boolean;
|
|
49
|
+
notificationSoundAuthorized: boolean;
|
|
50
|
+
bluetoothEnabled: boolean;
|
|
51
|
+
locationEnabled: boolean;
|
|
52
|
+
wifiEnabled: boolean;
|
|
53
|
+
theme?: ty.Themes;
|
|
54
|
+
deviceOrientation?: ty.Orientation;
|
|
55
|
+
deviceLevel: string;
|
|
56
|
+
isSupportPinShortcut?: boolean;
|
|
57
|
+
deviceType?: string;
|
|
58
|
+
};
|
|
59
|
+
export declare const showModal: (options: ParamType<typeof ty.showModal>) => void;
|
|
60
|
+
export declare const showToast: (options: ParamType<typeof ty.showToast>) => void;
|
|
32
61
|
export declare const api: <T>(options: {
|
|
33
62
|
url: string;
|
|
34
63
|
data: Record<string, any>;
|
|
@@ -41,24 +70,21 @@ export declare const requestCloud: <T>(options: {
|
|
|
41
70
|
data: Record<string, any>;
|
|
42
71
|
extData?: Record<string, any>;
|
|
43
72
|
}) => Promise<T>;
|
|
44
|
-
export declare const getLaunchOptionsSync: () =>
|
|
73
|
+
export declare const getLaunchOptionsSync: () => {
|
|
74
|
+
path: string;
|
|
75
|
+
scene?: ty.MiniAppScene;
|
|
76
|
+
query: any;
|
|
77
|
+
referrerInfo: ty.ReferrerInfo;
|
|
78
|
+
apiCategory?: string;
|
|
79
|
+
};
|
|
45
80
|
export declare function encrypt(deviceId: string, plaintext: string): Promise<string>;
|
|
46
81
|
export declare function decrypt(deviceId: string, plaintext: string): Promise<string>;
|
|
47
82
|
export declare const getCurrentHomeInfo: () => Promise<{
|
|
48
|
-
/** 家庭名称 */
|
|
49
83
|
homeName: string;
|
|
50
|
-
/** 家庭id */
|
|
51
84
|
homeId: string;
|
|
52
|
-
/** 经度 */
|
|
53
85
|
longitude: string;
|
|
54
|
-
/** 维度 */
|
|
55
86
|
latitude: string;
|
|
56
|
-
/** 详细地址 */
|
|
57
87
|
address: string;
|
|
58
|
-
/**
|
|
59
|
-
* 是否是管理员
|
|
60
|
-
* true 是管理员; false 非管理员
|
|
61
|
-
*/
|
|
62
88
|
admin: boolean;
|
|
63
89
|
}>;
|
|
64
90
|
export declare const isSupportShortLink: (link: string) => Promise<unknown>;
|
|
@@ -75,18 +101,10 @@ export declare const getBackgroundFetchData: (fetchApiKeys: string[]) => Promise
|
|
|
75
101
|
}>;
|
|
76
102
|
} | null>;
|
|
77
103
|
interface SendMqttMessageParams {
|
|
78
|
-
/** 消息内容 */
|
|
79
104
|
message: Record<string, {}>;
|
|
80
|
-
/** 设备id */
|
|
81
105
|
deviceId: string;
|
|
82
|
-
/** 协议号 */
|
|
83
106
|
protocol: number;
|
|
84
107
|
}
|
|
85
|
-
/**
|
|
86
|
-
* 发送 MQTT 消息
|
|
87
|
-
* @param params
|
|
88
|
-
* @returns
|
|
89
|
-
*/
|
|
90
108
|
export declare const sendMqttMessage: (params: SendMqttMessageParams) => Promise<{
|
|
91
109
|
fetchedData: Record<string, {
|
|
92
110
|
fetchedData: any;
|
|
@@ -94,17 +112,11 @@ export declare const sendMqttMessage: (params: SendMqttMessageParams) => Promise
|
|
|
94
112
|
}>;
|
|
95
113
|
} | null>;
|
|
96
114
|
type MqttResponse = {
|
|
97
|
-
/** 设备 id */
|
|
98
115
|
deviceId?: string;
|
|
99
|
-
/** 原始消息数据 */
|
|
100
116
|
message: any;
|
|
101
|
-
/** 双端抹平后的消息数据 */
|
|
102
117
|
messageData: any;
|
|
103
|
-
/** 消息类型 */
|
|
104
118
|
type: string;
|
|
105
|
-
/** 协议号 */
|
|
106
119
|
protocol: number;
|
|
107
|
-
/** topic */
|
|
108
120
|
topic?: string;
|
|
109
121
|
};
|
|
110
122
|
type MqttMessageListener = (data: MqttResponse) => void;
|
|
@@ -112,89 +124,38 @@ export declare const onMqttMessage: (cb: MqttMessageListener) => void;
|
|
|
112
124
|
export declare const offMqttMessage: (cb: MqttMessageListener) => void;
|
|
113
125
|
export declare const registerMQTTDeviceListener: (deviceId: string) => void;
|
|
114
126
|
export declare const registerMQTTProtocolListener: (protocol: number) => void;
|
|
115
|
-
export declare const openPanel: (params: ParamType<typeof ty.openPanel>) =>
|
|
127
|
+
export declare const openPanel: (params: ParamType<typeof ty.openPanel>) => void;
|
|
116
128
|
export declare const openNativeRouter: (name: string, params: Record<string, any>) => Promise<unknown>;
|
|
117
129
|
export type SceneAction = {
|
|
118
|
-
/** 条件 ID */
|
|
119
130
|
id?: string;
|
|
120
|
-
/** 场景 ID */
|
|
121
131
|
ruleId?: string;
|
|
122
|
-
/** 场景 ID */
|
|
123
132
|
orderNum?: number;
|
|
124
|
-
/** 条件为设备类型时,表示设备 ID */
|
|
125
133
|
entityId: string;
|
|
126
|
-
/** 设备名称 */
|
|
127
134
|
entityName?: string;
|
|
128
|
-
/**
|
|
129
|
-
* 动作类型。枚举:
|
|
130
|
-
* ruleTrigger:触发场景
|
|
131
|
-
* ruleEnable:启用场景
|
|
132
|
-
* ruleDisable:禁用场景
|
|
133
|
-
* appPushTrigger:推送消息
|
|
134
|
-
* mobileVoiceSend:电话服务
|
|
135
|
-
* smsSend:短信服务
|
|
136
|
-
* deviceGroupDpIssue:执行群组
|
|
137
|
-
* irIssue:执行红外设备
|
|
138
|
-
* dpIssue:执行普通设备
|
|
139
|
-
* delay:延时
|
|
140
|
-
* irIssueVii:执行红外设备,执行参数为真实的红外控制码
|
|
141
|
-
* toggle:执行切换开关动作
|
|
142
|
-
* dpStep:执行步进动作
|
|
143
|
-
*/
|
|
144
135
|
actionExecutor: string;
|
|
145
|
-
/** 动作执行信息 */
|
|
146
136
|
executorProperty: any;
|
|
147
|
-
/** 动作额外信息 */
|
|
148
137
|
extraProperty: any;
|
|
149
|
-
/** 设备是否在线 */
|
|
150
138
|
isDevOnline?: boolean;
|
|
151
|
-
/** 条件为设备类型时,表示设备是否被移除 */
|
|
152
139
|
devDelMark?: boolean;
|
|
153
|
-
/** 条件为设备类型时,表示设备被删除时的图标 */
|
|
154
140
|
deleteDevIcon?: string;
|
|
155
|
-
/** 条件为设备类型时,设备的图标 */
|
|
156
141
|
devIcon?: string;
|
|
157
|
-
/** 动作的策略 */
|
|
158
142
|
actionStrategy?: string;
|
|
159
|
-
/** 设备产品 ID */
|
|
160
143
|
pid?: string;
|
|
161
|
-
/** 设备产品 ID */
|
|
162
144
|
productId?: string;
|
|
163
|
-
/** 条件为设备类型时,表示设备产品图片 */
|
|
164
145
|
productPic?: string;
|
|
165
|
-
/** 条件默认图标 */
|
|
166
146
|
defaultIconUrl?: string;
|
|
167
|
-
/** 动作展示信息 */
|
|
168
147
|
actionDisplay?: string;
|
|
169
|
-
/** 动作展示信息 */
|
|
170
148
|
actionDisplayNew?: any;
|
|
171
|
-
/** 执行状态 */
|
|
172
149
|
status?: boolean;
|
|
173
|
-
/** 批量控制设备的数据 */
|
|
174
150
|
relationGroup?: any;
|
|
175
151
|
};
|
|
176
152
|
export declare const createAction: (params: {
|
|
177
|
-
/**
|
|
178
|
-
* 动作类型:device,smart,remind,delay
|
|
179
|
-
* device:设备
|
|
180
|
-
* smart:操作某个智能(执行智能、开关自动化)
|
|
181
|
-
* remind:提醒
|
|
182
|
-
* delay:延时
|
|
183
|
-
*/
|
|
184
153
|
createType: string;
|
|
185
|
-
/**
|
|
186
|
-
* 智能类型:scene,auto
|
|
187
|
-
* scene:一键执行
|
|
188
|
-
* auto:自动化
|
|
189
|
-
*/
|
|
190
154
|
smartType: string;
|
|
191
155
|
}) => Promise<SceneAction[]>;
|
|
192
156
|
export declare const editAction: (params: {
|
|
193
|
-
/** 当前编辑的actionIndex */
|
|
194
157
|
editIndex: number;
|
|
195
|
-
/** 智能类型 */
|
|
196
158
|
smartType: string;
|
|
197
|
-
/** 动作列表 */
|
|
198
159
|
actionArray: SceneAction[];
|
|
199
160
|
}) => Promise<SceneAction[]>;
|
|
200
161
|
export declare const getHomeInfo: () => Promise<{
|
|
@@ -205,4 +166,6 @@ export declare const getHomeInfo: () => Promise<{
|
|
|
205
166
|
address: string;
|
|
206
167
|
admin: boolean;
|
|
207
168
|
}>;
|
|
169
|
+
export declare const navigateToMiniProgram: (params: ParamType<typeof ty.navigateToMiniProgram>) => void;
|
|
170
|
+
export declare const navigateTo: (params: ParamType<typeof ty.navigateTo>) => void;
|
|
208
171
|
export {};
|