@ray-js/lock-sdk 1.0.0-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.d.ts +5 -0
- package/lib/api/index.js +18 -0
- package/lib/api/linkage.d.ts +161 -0
- package/lib/api/linkage.js +74 -0
- package/lib/api/lock.d.ts +195 -0
- package/lib/api/lock.js +129 -0
- package/lib/api/log.d.ts +166 -0
- package/lib/api/log.js +44 -0
- package/lib/api/setting.d.ts +14 -0
- package/lib/api/setting.js +36 -0
- package/lib/api/temp.d.ts +211 -0
- package/lib/api/temp.js +130 -0
- package/lib/api/user.d.ts +154 -0
- package/lib/api/user.js +59 -0
- package/lib/api/video.d.ts +9 -0
- package/lib/api/video.js +17 -0
- package/lib/config/dp-code/index.d.ts +175 -0
- package/lib/config/dp-code/index.js +224 -0
- package/lib/config/dp-map/common.d.ts +102 -0
- package/lib/config/dp-map/common.js +120 -0
- package/lib/config/dp-map/normal.d.ts +6 -0
- package/lib/config/dp-map/normal.js +51 -0
- package/lib/config/dp-map/open.d.ts +21 -0
- package/lib/config/dp-map/open.js +62 -0
- package/lib/config/dp-map/unlock-method-big.d.ts +559 -0
- package/lib/config/dp-map/unlock-method-big.js +237 -0
- package/lib/config/dp-map/unlock-method.d.ts +551 -0
- package/lib/config/dp-map/unlock-method.js +231 -0
- package/lib/config/index.d.ts +46 -0
- package/lib/config/index.js +56 -0
- package/lib/constant.d.ts +101 -0
- package/lib/constant.js +136 -0
- package/lib/dp-interface.d.ts +7 -0
- package/lib/dp-interface.js +1 -0
- package/lib/event.d.ts +8 -0
- package/lib/event.js +9 -0
- package/lib/index.d.ts +25 -0
- package/lib/index.js +92 -0
- package/lib/interface.d.ts +807 -0
- package/lib/interface.js +1 -0
- package/lib/linkage.d.ts +26 -0
- package/lib/linkage.js +175 -0
- package/lib/log.d.ts +91 -0
- package/lib/log.js +314 -0
- package/lib/media.d.ts +43 -0
- package/lib/media.js +80 -0
- package/lib/open.d.ts +48 -0
- package/lib/open.js +247 -0
- package/lib/other.d.ts +36 -0
- package/lib/other.js +178 -0
- package/lib/parse/index.d.ts +6 -0
- package/lib/parse/index.js +22 -0
- package/lib/signal.d.ts +26 -0
- package/lib/signal.js +38 -0
- package/lib/sleep.d.ts +61 -0
- package/lib/sleep.js +121 -0
- package/lib/state.d.ts +54 -0
- package/lib/state.js +429 -0
- package/lib/sync/remote-serect-key.d.ts +5 -0
- package/lib/sync/remote-serect-key.js +60 -0
- package/lib/sync/t0.d.ts +5 -0
- package/lib/sync/t0.js +33 -0
- package/lib/sync/temp.d.ts +7 -0
- package/lib/sync/temp.js +88 -0
- package/lib/sync/unlock-mothod.d.ts +5 -0
- package/lib/sync/unlock-mothod.js +54 -0
- package/lib/temporary.d.ts +226 -0
- package/lib/temporary.js +637 -0
- package/lib/unlock-method.d.ts +269 -0
- package/lib/unlock-method.js +723 -0
- package/lib/user.d.ts +108 -0
- package/lib/user.js +361 -0
- package/lib/utils/base64-to-hex.d.ts +1 -0
- package/lib/utils/base64-to-hex.js +12 -0
- package/lib/utils/byte.d.ts +19 -0
- package/lib/utils/byte.js +74 -0
- package/lib/utils/constant.d.ts +11 -0
- package/lib/utils/constant.js +17 -0
- package/lib/utils/device.d.ts +207 -0
- package/lib/utils/device.js +353 -0
- package/lib/utils/errors.d.ts +2 -0
- package/lib/utils/errors.js +125 -0
- package/lib/utils/event.d.ts +23 -0
- package/lib/utils/event.js +144 -0
- package/lib/utils/hex-to-base64.d.ts +1 -0
- package/lib/utils/hex-to-base64.js +8 -0
- package/lib/utils/hex-to-bytes.d.ts +6 -0
- package/lib/utils/hex-to-bytes.js +16 -0
- package/lib/utils/index.d.ts +169 -0
- package/lib/utils/index.js +419 -0
- package/lib/utils/log.d.ts +5 -0
- package/lib/utils/log.js +78 -0
- package/lib/utils/publishDps.d.ts +11 -0
- package/lib/utils/publishDps.js +91 -0
- package/package.json +37 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
|
3
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
4
|
+
import "core-js/modules/esnext.iterator.reduce.js";
|
|
5
|
+
import config from "./config";
|
|
6
|
+
import dpCodes from "./config/dp-code";
|
|
7
|
+
import { addEvents, clearState, initState, removeEvents, getCurrentUser, getDeviceStatus, onDeviceStatusChange, offDeviceStatusChange, getCurrentUserSync, getMediaRotate } from "./state";
|
|
8
|
+
import { getCapabilities } from "./utils";
|
|
9
|
+
import { getDeviceInfo, getLaunchOptionsSync } from "./utils/device";
|
|
10
|
+
import { syncUnlockMethod } from "./sync/unlock-mothod";
|
|
11
|
+
export * from "./user";
|
|
12
|
+
export * from "./unlock-method";
|
|
13
|
+
export * from "./temporary";
|
|
14
|
+
export * from "./open";
|
|
15
|
+
export * from "./log";
|
|
16
|
+
export * from "./signal";
|
|
17
|
+
export * from "./sleep";
|
|
18
|
+
export * from "./interface";
|
|
19
|
+
export * from "./constant";
|
|
20
|
+
export * from "./other";
|
|
21
|
+
export * from "./media";
|
|
22
|
+
export * from "./linkage";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 初始化sdk
|
|
26
|
+
* @param options 初始化参数
|
|
27
|
+
*/
|
|
28
|
+
export const init = async options => {
|
|
29
|
+
var _options$strictMode, _options$passwordDigi, _options$passwordSupp;
|
|
30
|
+
let {
|
|
31
|
+
devInfo,
|
|
32
|
+
deviceId
|
|
33
|
+
} = options || {};
|
|
34
|
+
if (!devInfo && !deviceId) {
|
|
35
|
+
// 从启动参数中获取设备id
|
|
36
|
+
const {
|
|
37
|
+
query
|
|
38
|
+
} = getLaunchOptionsSync();
|
|
39
|
+
deviceId = query.deviceId;
|
|
40
|
+
if (!deviceId) {
|
|
41
|
+
throw new Error("deviceId is required in lock sdk");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (deviceId && (!devInfo || devInfo.devId !== deviceId)) {
|
|
45
|
+
devInfo = await getDeviceInfo(deviceId);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 处理dp
|
|
49
|
+
let dpSchema = {};
|
|
50
|
+
const codesById = {};
|
|
51
|
+
const idsByCode = {};
|
|
52
|
+
if (devInfo.schema) {
|
|
53
|
+
dpSchema = devInfo.schema.reduce((acc, cur) => {
|
|
54
|
+
acc[cur.code] = cur;
|
|
55
|
+
codesById[cur.id] = cur.code;
|
|
56
|
+
idsByCode[cur.code] = cur.id;
|
|
57
|
+
return acc;
|
|
58
|
+
}, {});
|
|
59
|
+
} else if (devInfo.dpSchema) {
|
|
60
|
+
dpSchema = devInfo.dpSchema;
|
|
61
|
+
Object.keys(dpSchema).forEach(key => {
|
|
62
|
+
const item = dpSchema[key];
|
|
63
|
+
codesById[item.id] = item.code;
|
|
64
|
+
idsByCode[item.code] = item.id;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
config.strictMode = (_options$strictMode = options === null || options === void 0 ? void 0 : options.strictMode) !== null && _options$strictMode !== void 0 ? _options$strictMode : true;
|
|
68
|
+
config.passwordDigitalBase = (_options$passwordDigi = options === null || options === void 0 ? void 0 : options.passwordDigitalBase) !== null && _options$passwordDigi !== void 0 ? _options$passwordDigi : 10; // 默认十进制
|
|
69
|
+
config.passwordSupportZero = (_options$passwordSupp = options === null || options === void 0 ? void 0 : options.passwordSupportZero) !== null && _options$passwordSupp !== void 0 ? _options$passwordSupp : true; // 默认支持0
|
|
70
|
+
config.devInfo = devInfo;
|
|
71
|
+
config.dpSchema = dpSchema;
|
|
72
|
+
config.codesById = codesById;
|
|
73
|
+
config.idsByCode = idsByCode;
|
|
74
|
+
config.supportBigData = !!dpSchema[dpCodes.synchMethodW];
|
|
75
|
+
|
|
76
|
+
// 产品通讯能力
|
|
77
|
+
config.communication = getCapabilities(devInfo.capability).map(item => item.id);
|
|
78
|
+
|
|
79
|
+
// 初始化数据
|
|
80
|
+
await initState();
|
|
81
|
+
// 加入事件
|
|
82
|
+
addEvents();
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 销毁 sdk
|
|
87
|
+
*/
|
|
88
|
+
export const destroy = () => {
|
|
89
|
+
clearState();
|
|
90
|
+
removeEvents();
|
|
91
|
+
};
|
|
92
|
+
export { getCurrentUser, getMediaRotate, getCurrentUserSync, syncUnlockMethod, getDeviceStatus, onDeviceStatusChange, offDeviceStatusChange };
|