@ray-js/api 0.20.0-beta.3 → 1.0.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.
- package/@types/BaseKit.d.ts +104 -104
- package/@types/MiniKit.d.ts +28 -28
- package/@types/api-extend.d.ts +188 -1
- package/lib/DeviceKit-3.3.1.d.ts +1 -1
- package/lib/DeviceKit-3.3.1.js +1 -1
- package/lib/index.d.ts +8 -0
- package/lib/index.js +11 -1
- package/lib/panel/devInfo/index.d.ts +59 -0
- package/lib/panel/devInfo/index.js +176 -0
- package/lib/panel/index.d.ts +3 -0
- package/lib/panel/index.js +3 -0
- package/lib/panel/normalizeNetwork.d.ts +15 -0
- package/lib/panel/normalizeNetwork.js +25 -0
- package/lib/panel/publishDps.d.ts +15 -0
- package/lib/panel/publishDps.js +71 -0
- package/lib/panel/types/app.d.ts +14 -0
- package/lib/panel/types/app.js +1 -0
- package/lib/panel/types/devInfo.d.ts +106 -0
- package/lib/panel/types/devInfo.js +1 -0
- package/lib/panel/types/index.d.ts +3 -0
- package/lib/panel/types/index.js +3 -0
- package/lib/panel/types/utilities.d.ts +9 -0
- package/lib/panel/types/utilities.js +1 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +27 -0
- package/lib/viewAPI.d.ts +13 -0
- package/lib/viewAPI.js +14 -0
- package/package.json +5 -5
package/@types/BaseKit.d.ts
CHANGED
@@ -1,3 +1,90 @@
|
|
1
|
+
declare enum WidgetVersionType {
|
2
|
+
/** 线上版本 */
|
3
|
+
release = 'release',
|
4
|
+
|
5
|
+
/** 预发版本 */
|
6
|
+
preview = 'preview',
|
7
|
+
}
|
8
|
+
|
9
|
+
declare enum WidgetPosition {
|
10
|
+
/** 居底展示 */
|
11
|
+
bottom = 'bottom',
|
12
|
+
|
13
|
+
/** 居顶展示 */
|
14
|
+
top = 'top',
|
15
|
+
}
|
16
|
+
|
17
|
+
declare enum HTTPMethod {
|
18
|
+
/** HTTP 请求 OPTIONS */
|
19
|
+
OPTIONS = 'OPTIONS',
|
20
|
+
|
21
|
+
/** HTTP 请求 GET */
|
22
|
+
GET = 'GET',
|
23
|
+
|
24
|
+
/** HTTP 请求 HEAD */
|
25
|
+
HEAD = 'HEAD',
|
26
|
+
|
27
|
+
/** HTTP 请求 POST */
|
28
|
+
POST = 'POST',
|
29
|
+
|
30
|
+
/** HTTP 请求 PUT */
|
31
|
+
PUT = 'PUT',
|
32
|
+
|
33
|
+
/** HTTP 请求 DELETE */
|
34
|
+
DELETE = 'DELETE',
|
35
|
+
|
36
|
+
/** HTTP 请求 TRACE */
|
37
|
+
TRACE = 'TRACE',
|
38
|
+
|
39
|
+
/** HTTP 请求 TRACE */
|
40
|
+
CONNECT = 'CONNECT',
|
41
|
+
}
|
42
|
+
|
43
|
+
declare enum AccelerometerInterval {
|
44
|
+
/** 适用于更新游戏的回调频率,在 20ms/次 左右 */
|
45
|
+
game = 'game',
|
46
|
+
|
47
|
+
/** 适用于更新 UI 的回调频率,在 60ms/次 左右 */
|
48
|
+
ui = 'ui',
|
49
|
+
|
50
|
+
/** 普通的回调频率,在 200ms/次 左右 */
|
51
|
+
normal = 'normal',
|
52
|
+
}
|
53
|
+
|
54
|
+
declare enum DeviceMotionInterval {
|
55
|
+
/** 适用于更新游戏的回调频率,在 20ms/次 左右 */
|
56
|
+
game = 'game',
|
57
|
+
|
58
|
+
/** 适用于更新 UI 的回调频率,在 60ms/次 左右 */
|
59
|
+
ui = 'ui',
|
60
|
+
|
61
|
+
/** 普通的回调频率,在 200ms/次 左右 */
|
62
|
+
normal = 'normal',
|
63
|
+
}
|
64
|
+
|
65
|
+
declare enum GyroscopeInterval {
|
66
|
+
/** 适用于更新游戏的回调频率,在 20ms/次 左右 */
|
67
|
+
game = 'game',
|
68
|
+
|
69
|
+
/** 适用于更新 UI 的回调频率,在 60ms/次 左右 */
|
70
|
+
ui = 'ui',
|
71
|
+
|
72
|
+
/** 普通的回调频率,在 200ms/次 左右 */
|
73
|
+
normal = 'normal',
|
74
|
+
}
|
75
|
+
|
76
|
+
declare enum Themes {
|
77
|
+
dark = 'dark',
|
78
|
+
|
79
|
+
light = 'light',
|
80
|
+
}
|
81
|
+
|
82
|
+
declare enum Orientation {
|
83
|
+
portrait = 'portrait',
|
84
|
+
|
85
|
+
landscape = 'landscape',
|
86
|
+
}
|
87
|
+
|
1
88
|
/**
|
2
89
|
* BaseKit
|
3
90
|
*
|
@@ -25,7 +112,7 @@ declare namespace ty {
|
|
25
112
|
*/
|
26
113
|
export function startAccelerometer(params?: {
|
27
114
|
/** 监听加速度数据回调函数的执行频率 */
|
28
|
-
interval?: AccelerometerInterval
|
115
|
+
interval?: AccelerometerInterval | keyof typeof AccelerometerInterval
|
29
116
|
complete?: () => void
|
30
117
|
success?: (params: null) => void
|
31
118
|
failure?: (params: {
|
@@ -182,7 +269,7 @@ declare namespace ty {
|
|
182
269
|
*/
|
183
270
|
export function startDeviceMotionListening(params?: {
|
184
271
|
/** 监听加速度数据回调函数的执行频率 */
|
185
|
-
interval?: DeviceMotionInterval
|
272
|
+
interval?: DeviceMotionInterval | keyof typeof DeviceMotionInterval
|
186
273
|
complete?: () => void
|
187
274
|
success?: (params: null) => void
|
188
275
|
failure?: (params: {
|
@@ -235,7 +322,7 @@ declare namespace ty {
|
|
235
322
|
*/
|
236
323
|
export function startGyroscope(params?: {
|
237
324
|
/** 监听陀螺仪数据回调函数的执行频率 */
|
238
|
-
interval?: GyroscopeInterval
|
325
|
+
interval?: GyroscopeInterval | keyof typeof GyroscopeInterval
|
239
326
|
complete?: () => void
|
240
327
|
success?: (params: null) => void
|
241
328
|
failure?: (params: {
|
@@ -912,8 +999,8 @@ declare namespace ty {
|
|
912
999
|
bluetoothEnabled: boolean
|
913
1000
|
locationEnabled: boolean
|
914
1001
|
wifiEnabled: boolean
|
915
|
-
theme?: Themes
|
916
|
-
deviceOrientation?: Orientation
|
1002
|
+
theme?: Themes | keyof typeof Themes
|
1003
|
+
deviceOrientation?: Orientation | keyof typeof Orientation
|
917
1004
|
/** 设备等级(低:low-中:middle-高:high) */
|
918
1005
|
deviceLevel: string
|
919
1006
|
}) => void
|
@@ -960,8 +1047,8 @@ declare namespace ty {
|
|
960
1047
|
bluetoothEnabled: boolean
|
961
1048
|
locationEnabled: boolean
|
962
1049
|
wifiEnabled: boolean
|
963
|
-
theme?: Themes
|
964
|
-
deviceOrientation?: Orientation
|
1050
|
+
theme?: Themes | keyof typeof Themes
|
1051
|
+
deviceOrientation?: Orientation | keyof typeof Orientation
|
965
1052
|
/** 设备等级(低:low-中:middle-高:high) */
|
966
1053
|
deviceLevel: string
|
967
1054
|
}
|
@@ -1506,22 +1593,6 @@ declare namespace ty {
|
|
1506
1593
|
}) => void
|
1507
1594
|
): void
|
1508
1595
|
|
1509
|
-
export enum WidgetVersionType {
|
1510
|
-
/** 线上版本 */
|
1511
|
-
release = 'release',
|
1512
|
-
|
1513
|
-
/** 预发版本 */
|
1514
|
-
preview = 'preview',
|
1515
|
-
}
|
1516
|
-
|
1517
|
-
export enum WidgetPosition {
|
1518
|
-
/** 居底展示 */
|
1519
|
-
bottom = 'bottom',
|
1520
|
-
|
1521
|
-
/** 居顶展示 */
|
1522
|
-
top = 'top',
|
1523
|
-
}
|
1524
|
-
|
1525
1596
|
export type Profile = {
|
1526
1597
|
/** 第一个 HTTP 重定向发生时的时间。有跳转且是同域名内的重定向才算,否则值为 0 */
|
1527
1598
|
redirectStart: number
|
@@ -1660,65 +1731,6 @@ declare namespace ty {
|
|
1660
1731
|
encoding?: string
|
1661
1732
|
}
|
1662
1733
|
|
1663
|
-
export enum HTTPMethod {
|
1664
|
-
/** HTTP 请求 OPTIONS */
|
1665
|
-
OPTIONS = 'OPTIONS',
|
1666
|
-
|
1667
|
-
/** HTTP 请求 GET */
|
1668
|
-
GET = 'GET',
|
1669
|
-
|
1670
|
-
/** HTTP 请求 HEAD */
|
1671
|
-
HEAD = 'HEAD',
|
1672
|
-
|
1673
|
-
/** HTTP 请求 POST */
|
1674
|
-
POST = 'POST',
|
1675
|
-
|
1676
|
-
/** HTTP 请求 PUT */
|
1677
|
-
PUT = 'PUT',
|
1678
|
-
|
1679
|
-
/** HTTP 请求 DELETE */
|
1680
|
-
DELETE = 'DELETE',
|
1681
|
-
|
1682
|
-
/** HTTP 请求 TRACE */
|
1683
|
-
TRACE = 'TRACE',
|
1684
|
-
|
1685
|
-
/** HTTP 请求 TRACE */
|
1686
|
-
CONNECT = 'CONNECT',
|
1687
|
-
}
|
1688
|
-
|
1689
|
-
export enum AccelerometerInterval {
|
1690
|
-
/** 适用于更新游戏的回调频率,在 20ms/次 左右 */
|
1691
|
-
game = 'game',
|
1692
|
-
|
1693
|
-
/** 适用于更新 UI 的回调频率,在 60ms/次 左右 */
|
1694
|
-
ui = 'ui',
|
1695
|
-
|
1696
|
-
/** 普通的回调频率,在 200ms/次 左右 */
|
1697
|
-
normal = 'normal',
|
1698
|
-
}
|
1699
|
-
|
1700
|
-
export enum DeviceMotionInterval {
|
1701
|
-
/** 适用于更新游戏的回调频率,在 20ms/次 左右 */
|
1702
|
-
game = 'game',
|
1703
|
-
|
1704
|
-
/** 适用于更新 UI 的回调频率,在 60ms/次 左右 */
|
1705
|
-
ui = 'ui',
|
1706
|
-
|
1707
|
-
/** 普通的回调频率,在 200ms/次 左右 */
|
1708
|
-
normal = 'normal',
|
1709
|
-
}
|
1710
|
-
|
1711
|
-
export enum GyroscopeInterval {
|
1712
|
-
/** 适用于更新游戏的回调频率,在 20ms/次 左右 */
|
1713
|
-
game = 'game',
|
1714
|
-
|
1715
|
-
/** 适用于更新 UI 的回调频率,在 60ms/次 左右 */
|
1716
|
-
ui = 'ui',
|
1717
|
-
|
1718
|
-
/** 普通的回调频率,在 200ms/次 左右 */
|
1719
|
-
normal = 'normal',
|
1720
|
-
}
|
1721
|
-
|
1722
1734
|
export type TempFileCB = {
|
1723
1735
|
/** 本地临时文件路径 (本地路径) */
|
1724
1736
|
path: string
|
@@ -1756,18 +1768,6 @@ declare namespace ty {
|
|
1756
1768
|
height: number
|
1757
1769
|
}
|
1758
1770
|
|
1759
|
-
export enum Themes {
|
1760
|
-
dark = 'dark',
|
1761
|
-
|
1762
|
-
light = 'light',
|
1763
|
-
}
|
1764
|
-
|
1765
|
-
export enum Orientation {
|
1766
|
-
portrait = 'portrait',
|
1767
|
-
|
1768
|
-
landscape = 'landscape',
|
1769
|
-
}
|
1770
|
-
|
1771
1771
|
export type StorageDataBean = {
|
1772
1772
|
/** 本地缓存中指定的 key */
|
1773
1773
|
key: string
|
@@ -1891,11 +1891,11 @@ declare namespace ty {
|
|
1891
1891
|
/** 小部件样式,默认middle */
|
1892
1892
|
style?: string
|
1893
1893
|
/** 版本类型,默认release */
|
1894
|
-
versionType?: WidgetVersionType
|
1894
|
+
versionType?: WidgetVersionType | keyof typeof WidgetVersionType
|
1895
1895
|
/** 版本号 */
|
1896
1896
|
version?: string
|
1897
1897
|
/** 展示位置,默认bottom */
|
1898
|
-
position?: WidgetPosition
|
1898
|
+
position?: WidgetPosition | keyof typeof WidgetPosition
|
1899
1899
|
/** 点击空白处是否关闭 */
|
1900
1900
|
autoDismiss?: boolean
|
1901
1901
|
/**
|
@@ -1914,7 +1914,7 @@ declare namespace ty {
|
|
1914
1914
|
|
1915
1915
|
export type DeviceMotionBean = {
|
1916
1916
|
/** 监听加速度数据回调函数的执行频率 */
|
1917
|
-
interval?: DeviceMotionInterval
|
1917
|
+
interval?: DeviceMotionInterval | keyof typeof DeviceMotionInterval
|
1918
1918
|
}
|
1919
1919
|
|
1920
1920
|
export type DownLoadBean = {
|
@@ -1980,7 +1980,7 @@ declare namespace ty {
|
|
1980
1980
|
|
1981
1981
|
export type GyroscopeBean = {
|
1982
1982
|
/** 监听陀螺仪数据回调函数的执行频率 */
|
1983
|
-
interval?: GyroscopeInterval
|
1983
|
+
interval?: GyroscopeInterval | keyof typeof GyroscopeInterval
|
1984
1984
|
}
|
1985
1985
|
|
1986
1986
|
export type ChooseImageBean = {
|
@@ -2194,7 +2194,7 @@ declare namespace ty {
|
|
2194
2194
|
/** 超时时间,单位为毫秒 */
|
2195
2195
|
timeout?: number
|
2196
2196
|
/** HTTP 请求方法 */
|
2197
|
-
method?: HTTPMethod
|
2197
|
+
method?: HTTPMethod | keyof typeof HTTPMethod
|
2198
2198
|
/** 返回的数据格式 */
|
2199
2199
|
dataType?: any
|
2200
2200
|
/** 返回的数据类型 */
|
@@ -2348,8 +2348,8 @@ declare namespace ty {
|
|
2348
2348
|
bluetoothEnabled: boolean
|
2349
2349
|
locationEnabled: boolean
|
2350
2350
|
wifiEnabled: boolean
|
2351
|
-
theme?: Themes
|
2352
|
-
deviceOrientation?: Orientation
|
2351
|
+
theme?: Themes | keyof typeof Themes
|
2352
|
+
deviceOrientation?: Orientation | keyof typeof Orientation
|
2353
2353
|
/** 设备等级(低:low-中:middle-高:high) */
|
2354
2354
|
deviceLevel: string
|
2355
2355
|
}
|
@@ -2668,11 +2668,11 @@ declare namespace ty {
|
|
2668
2668
|
/** 小部件样式,默认middle */
|
2669
2669
|
style?: string
|
2670
2670
|
/** 版本类型,默认release */
|
2671
|
-
versionType?: WidgetVersionType
|
2671
|
+
versionType?: WidgetVersionType | keyof typeof WidgetVersionType
|
2672
2672
|
/** 版本号 */
|
2673
2673
|
version?: string
|
2674
2674
|
/** 展示位置,默认bottom */
|
2675
|
-
position?: WidgetPosition
|
2675
|
+
position?: WidgetPosition | keyof typeof WidgetPosition
|
2676
2676
|
/** 点击空白处是否关闭 */
|
2677
2677
|
autoDismiss?: boolean
|
2678
2678
|
/**
|
@@ -3095,7 +3095,7 @@ declare namespace ty {
|
|
3095
3095
|
/** 超时时间,单位为毫秒 */
|
3096
3096
|
timeout?: number
|
3097
3097
|
/** HTTP 请求方法 */
|
3098
|
-
method?: HTTPMethod
|
3098
|
+
method?: HTTPMethod | keyof typeof HTTPMethod
|
3099
3099
|
/** 返回的数据格式 */
|
3100
3100
|
dataType?: any
|
3101
3101
|
/** 返回的数据类型 */
|
package/@types/MiniKit.d.ts
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
declare enum HighwayMethod {
|
2
|
+
/** HTTP 请求 OPTIONS */
|
3
|
+
OPTIONS = 'OPTIONS',
|
4
|
+
|
5
|
+
/** HTTP 请求 GET */
|
6
|
+
GET = 'GET',
|
7
|
+
|
8
|
+
/** HTTP 请求 HEAD */
|
9
|
+
HEAD = 'HEAD',
|
10
|
+
|
11
|
+
/** HTTP 请求 POST */
|
12
|
+
POST = 'POST',
|
13
|
+
|
14
|
+
/** HTTP 请求 PUT */
|
15
|
+
PUT = 'PUT',
|
16
|
+
|
17
|
+
/** HTTP 请求 DELETE */
|
18
|
+
DELETE = 'DELETE',
|
19
|
+
|
20
|
+
/** HTTP 请求 TRACE */
|
21
|
+
TRACE = 'TRACE',
|
22
|
+
|
23
|
+
/** HTTP 请求 TRACE */
|
24
|
+
CONNECT = 'CONNECT',
|
25
|
+
}
|
26
|
+
|
1
27
|
/**
|
2
28
|
* MiniKit
|
3
29
|
*
|
@@ -299,7 +325,7 @@ declare namespace ty {
|
|
299
325
|
/** data 请求入参 */
|
300
326
|
data?: Record<string, any>
|
301
327
|
/** method 请求方法 */
|
302
|
-
method?: HighwayMethod
|
328
|
+
method?: HighwayMethod | keyof typeof HighwayMethod
|
303
329
|
complete?: () => void
|
304
330
|
success?: (params: {
|
305
331
|
/**
|
@@ -1070,32 +1096,6 @@ declare namespace ty {
|
|
1070
1096
|
*/
|
1071
1097
|
export function offNativeEvent(listener: (params: NativeUploadData) => void): void
|
1072
1098
|
|
1073
|
-
export enum HighwayMethod {
|
1074
|
-
/** HTTP 请求 OPTIONS */
|
1075
|
-
OPTIONS = 'OPTIONS',
|
1076
|
-
|
1077
|
-
/** HTTP 请求 GET */
|
1078
|
-
GET = 'GET',
|
1079
|
-
|
1080
|
-
/** HTTP 请求 HEAD */
|
1081
|
-
HEAD = 'HEAD',
|
1082
|
-
|
1083
|
-
/** HTTP 请求 POST */
|
1084
|
-
POST = 'POST',
|
1085
|
-
|
1086
|
-
/** HTTP 请求 PUT */
|
1087
|
-
PUT = 'PUT',
|
1088
|
-
|
1089
|
-
/** HTTP 请求 DELETE */
|
1090
|
-
DELETE = 'DELETE',
|
1091
|
-
|
1092
|
-
/** HTTP 请求 TRACE */
|
1093
|
-
TRACE = 'TRACE',
|
1094
|
-
|
1095
|
-
/** HTTP 请求 TRACE */
|
1096
|
-
CONNECT = 'CONNECT',
|
1097
|
-
}
|
1098
|
-
|
1099
1099
|
export type ReferrerInfo = {
|
1100
1100
|
/** 来源小程序、公众号或 App 的 appId */
|
1101
1101
|
appId: string
|
@@ -1245,7 +1245,7 @@ declare namespace ty {
|
|
1245
1245
|
/** data 请求入参 */
|
1246
1246
|
data?: Record<string, any>
|
1247
1247
|
/** method 请求方法 */
|
1248
|
-
method?: HighwayMethod
|
1248
|
+
method?: HighwayMethod | keyof typeof HighwayMethod
|
1249
1249
|
}
|
1250
1250
|
|
1251
1251
|
export type HighwayRequestResponse = {
|
package/@types/api-extend.d.ts
CHANGED
@@ -32,6 +32,81 @@ interface OnWindowResizeListenerResult {
|
|
32
32
|
type: string
|
33
33
|
size: { windowWidth: number; windowHeight: number }
|
34
34
|
}
|
35
|
+
|
36
|
+
interface Callback {
|
37
|
+
success?: (res?: any) => void
|
38
|
+
fail?: (res?: any) => void
|
39
|
+
complete?: (res?: any) => void
|
40
|
+
}
|
41
|
+
interface PageScrollToProps extends Callback {
|
42
|
+
scrollTop?: number
|
43
|
+
duration?: number
|
44
|
+
selector?: string
|
45
|
+
}
|
46
|
+
|
47
|
+
interface CreateAnimationProps {
|
48
|
+
duration: number
|
49
|
+
timingFunction:
|
50
|
+
| 'linear'
|
51
|
+
| 'ease'
|
52
|
+
| 'ease-in'
|
53
|
+
| 'ease-out'
|
54
|
+
| 'ease-in-out'
|
55
|
+
| 'step-start'
|
56
|
+
| 'step-end'
|
57
|
+
delay: number
|
58
|
+
transformOrigin: string
|
59
|
+
}
|
60
|
+
|
61
|
+
interface NodesRef {
|
62
|
+
fields(e: any, t: any): SelectorQuery
|
63
|
+
boundingClientRect(e: any): SelectorQuery
|
64
|
+
scrollOffset(e: any): SelectorQuery
|
65
|
+
}
|
66
|
+
interface SelectorQuery {
|
67
|
+
select: (e: any) => NodesRef
|
68
|
+
selectAll: (e: any) => NodesRef
|
69
|
+
selectViewport: () => NodesRef
|
70
|
+
exec: (e: any) => void
|
71
|
+
}
|
72
|
+
|
73
|
+
interface CreateIntersectionObserverProps {
|
74
|
+
thresholds?: number[]
|
75
|
+
initialRatio?: number
|
76
|
+
observeAll?: boolean
|
77
|
+
}
|
78
|
+
|
79
|
+
interface IntersectionMargin {
|
80
|
+
left?: number
|
81
|
+
right?: number
|
82
|
+
bottom?: number
|
83
|
+
top?: number
|
84
|
+
}
|
85
|
+
|
86
|
+
interface IntersectionObserveRect {
|
87
|
+
left?: number
|
88
|
+
right?: number
|
89
|
+
bottom?: number
|
90
|
+
top?: number
|
91
|
+
width?: number
|
92
|
+
height?: number
|
93
|
+
}
|
94
|
+
interface IntersectionObserveCbParam {
|
95
|
+
id: string
|
96
|
+
dataset: Record<string, any>
|
97
|
+
intersectionRatio: number
|
98
|
+
intersectionRect: IntersectionObserveRect
|
99
|
+
boundingClientRect: IntersectionObserveRect
|
100
|
+
relativeRect: IntersectionObserveRect
|
101
|
+
time: number
|
102
|
+
}
|
103
|
+
interface IntersectionObserver {
|
104
|
+
observe(targetSelector: string, cb: (e: IntersectionObserveCbParam) => void): IntersectionObserver
|
105
|
+
disconnect(): void
|
106
|
+
relativeTo(selector: string, margin: IntersectionMargin): IntersectionObserver
|
107
|
+
relativeToViewport(margin: IntersectionMargin): IntersectionObserver
|
108
|
+
}
|
109
|
+
|
35
110
|
interface OnThemeChangeListenerResult {
|
36
111
|
/** 系统当前的主题,取值为`light`或`dark`
|
37
112
|
*
|
@@ -44,6 +119,100 @@ interface OnThemeChangeListenerResult {
|
|
44
119
|
interface setNavigationBarBackParam {
|
45
120
|
type: 'system' | 'custom'
|
46
121
|
}
|
122
|
+
|
123
|
+
interface CanvasGetImageDataProps extends Callback {
|
124
|
+
canvasId: string
|
125
|
+
x: string
|
126
|
+
y: string
|
127
|
+
width: string
|
128
|
+
height: string
|
129
|
+
success(res: { width: string; height: string; data: Uint8ClampedArray }): void
|
130
|
+
}
|
131
|
+
|
132
|
+
interface CanvasPutImageDataProps extends Callback {
|
133
|
+
canvasId: string
|
134
|
+
x: string
|
135
|
+
y: string
|
136
|
+
width: string
|
137
|
+
height: string
|
138
|
+
data: Uint8ClampedArray
|
139
|
+
}
|
140
|
+
|
141
|
+
interface VideoContext {
|
142
|
+
play(): void
|
143
|
+
pause(): void
|
144
|
+
stop(): void
|
145
|
+
playbackRate(rate: number): void
|
146
|
+
seek(position: number): void
|
147
|
+
sendDanmu(data: { text: string; color: string }): void
|
148
|
+
}
|
149
|
+
|
150
|
+
interface AddMarker extends Callback {
|
151
|
+
markers: any[]
|
152
|
+
clear?: boolean
|
153
|
+
}
|
154
|
+
interface RemoveMarkers extends Callback {
|
155
|
+
markerIds: string[]
|
156
|
+
clear?: boolean
|
157
|
+
}
|
158
|
+
interface GetScale extends Callback {
|
159
|
+
success({ scale: number }): void
|
160
|
+
}
|
161
|
+
interface GetCenterLocation extends Callback {
|
162
|
+
iconPath?: string
|
163
|
+
clear?: boolean
|
164
|
+
success({ longitude: number, latitude: number }): void
|
165
|
+
}
|
166
|
+
interface MoveToLocation extends Callback {
|
167
|
+
longitude: number
|
168
|
+
latitude: number
|
169
|
+
}
|
170
|
+
interface MoveAlong extends Callback {
|
171
|
+
markerId: number
|
172
|
+
path: Array<{ longitude: number; latitude: number }>
|
173
|
+
duration: number
|
174
|
+
}
|
175
|
+
interface MapContext {
|
176
|
+
addMarkers(data: AddMarker): void
|
177
|
+
removeMarkers(data: RemoveMarkers): void
|
178
|
+
getScale(data: GetScale): void
|
179
|
+
getCenterLocation(data: GetCenterLocation): void
|
180
|
+
moveToLocation(data: MoveToLocation): void
|
181
|
+
moveAlong(data: MoveAlong): void
|
182
|
+
}
|
183
|
+
|
184
|
+
interface IpcContext {
|
185
|
+
connect(res?: Callback): void
|
186
|
+
disconnect(res?: Callback): void
|
187
|
+
startPreview(res?: any): void
|
188
|
+
stopPreview(res?: any): void
|
189
|
+
snapshot(res: Callback & { saveToAlbum?: number }): void
|
190
|
+
setMuted(res: Callback & { mute?: boolean }): void
|
191
|
+
setSoundMode(res: Callback & { mode?: 'speaker' | 'ear' }): void
|
192
|
+
setClarity(res: Callback & { clarity?: 'normal' | 'hd' }): void
|
193
|
+
startTalk(res: Callback): void
|
194
|
+
stopTalk(res: Callback & { saveToAlbum?: number }): void
|
195
|
+
isTalkBacking(res?: Callback & { success: { r: boolean } }): void
|
196
|
+
startRecord(res?: Callback & { saveToAlbum?: 0 | 1 }): void
|
197
|
+
stopRecord(res?: Callback & { saveToAlbum?: 0 | 1 }): void
|
198
|
+
isRecording(res?: Callback & { success: { r: boolean } }): void
|
199
|
+
setAvailableRockerDirections(
|
200
|
+
res?: Callback & { left?: number; right?: number; top?: number; bottom?: number }
|
201
|
+
): void
|
202
|
+
setTrackingStatus(res?: Callback & { status?: boolean }): void
|
203
|
+
getVideoInfo(res?: Callback): void
|
204
|
+
isMuted(res: Callback & { success: (r: { isMuted: boolean }) => void }): void
|
205
|
+
}
|
206
|
+
|
207
|
+
interface CameraContext {
|
208
|
+
takePhoto(
|
209
|
+
res: Callback & {
|
210
|
+
quality?: 'normal' | 'high' | 'low'
|
211
|
+
success(res: { tempImagePath: string }): void
|
212
|
+
}
|
213
|
+
): void
|
214
|
+
setZoom(res: Callback & { zoom: number; success(res: { zoom: number }): void }): void
|
215
|
+
}
|
47
216
|
declare namespace ty {
|
48
217
|
/**
|
49
218
|
* 小程序云能力
|
@@ -81,8 +250,26 @@ declare namespace ty {
|
|
81
250
|
export function onPageNotFound(listeners: ({ url: string, query: CommonObject }) => void)
|
82
251
|
export function onNavigationBarBack(callback: (res?: any) => void)
|
83
252
|
export function setNavigationBarBack(param: setNavigationBarBackParam)
|
253
|
+
/**
|
254
|
+
* 0.10.3
|
255
|
+
*/
|
256
|
+
export function createAnimation(param: CreateAnimationProps): IAnimation
|
257
|
+
export function pageScrollTo(param: PageScrollToProps): void
|
258
|
+
export function createSelectorQuery(): SelectorQuery
|
259
|
+
export function createIntersectionObserver(
|
260
|
+
param: CreateIntersectionObserverProps
|
261
|
+
): IntersectionObserver
|
262
|
+
export function createCanvasContext(canvasId: string): any
|
263
|
+
export function canvasGetImageData(param: CanvasGetImageDataProps): void
|
264
|
+
export function canvasPutImageData(param: CanvasPutImageDataProps): void
|
265
|
+
export function createVideoContext(id: string): VideoContext
|
266
|
+
export function createMapContext(mapId: string): MapContext
|
267
|
+
export function createIpcPlayerContext(deviceId: string): IpcContext
|
268
|
+
export function createCameraContext(): CameraContext
|
269
|
+
export type env = {
|
270
|
+
USER_DATA_PATH: string
|
271
|
+
}
|
84
272
|
}
|
85
|
-
|
86
273
|
declare namespace WechatMiniprogram {
|
87
274
|
interface Wx {
|
88
275
|
requestCloud(params: RequestCloudParams): RequestCloudReturn
|
package/lib/DeviceKit-3.3.1.d.ts
CHANGED
@@ -52,7 +52,7 @@ export declare const getDeviceInfo: typeof ty.device.getDeviceInfo;
|
|
52
52
|
export declare const getProductInfo: typeof ty.device.getProductInfo;
|
53
53
|
export declare const getSubDeviceInfoList: typeof ty.device.getSubDeviceInfoList;
|
54
54
|
export declare const validDeviceOnlineType: typeof ty.device.validDeviceOnlineType;
|
55
|
-
export declare const
|
55
|
+
export declare const publishDpsBase: typeof ty.device.publishDps;
|
56
56
|
export declare const publishCommands: typeof ty.device.publishCommands;
|
57
57
|
export declare const publishDpsWithPipeType: typeof ty.device.publishDpsWithPipeType;
|
58
58
|
export declare const queryDps: typeof ty.device.queryDps;
|
package/lib/DeviceKit-3.3.1.js
CHANGED
@@ -159,7 +159,7 @@ export var getSubDeviceInfoList = factory('getSubDeviceInfoList', {
|
|
159
159
|
export var validDeviceOnlineType = factory('validDeviceOnlineType', {
|
160
160
|
"namespace": "device"
|
161
161
|
});
|
162
|
-
export var
|
162
|
+
export var publishDpsBase = factory('publishDps', {
|
163
163
|
"namespace": "device"
|
164
164
|
});
|
165
165
|
export var publishCommands = factory('publishCommands', {
|
package/lib/index.d.ts
CHANGED
@@ -25,3 +25,11 @@ export { default as getCdnUrl } from './getCdnUrl';
|
|
25
25
|
*/
|
26
26
|
export { default as globalApi } from './global-api';
|
27
27
|
export * from './cloud';
|
28
|
+
/**
|
29
|
+
* panel-sdk中一些面板小程序中必用API
|
30
|
+
*/
|
31
|
+
export * from './panel';
|
32
|
+
/**
|
33
|
+
* 0.10.3将一部分未支持的api导入
|
34
|
+
*/
|
35
|
+
export * from './viewAPI';
|
package/lib/index.js
CHANGED
@@ -25,4 +25,14 @@ export { default as getCdnUrl } from './getCdnUrl';
|
|
25
25
|
*/
|
26
26
|
|
27
27
|
export { default as globalApi } from './global-api';
|
28
|
-
export * from './cloud';
|
28
|
+
export * from './cloud';
|
29
|
+
/**
|
30
|
+
* panel-sdk中一些面板小程序中必用API
|
31
|
+
*/
|
32
|
+
|
33
|
+
export * from './panel';
|
34
|
+
/**
|
35
|
+
* 0.10.3将一部分未支持的api导入
|
36
|
+
*/
|
37
|
+
|
38
|
+
export * from './viewAPI';
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { DevInfo } from '../types/devInfo';
|
2
|
+
export interface InitPanelEnvironmentOptions {
|
3
|
+
/**
|
4
|
+
* @description 是否需要使用默认离线弹窗
|
5
|
+
* @default true
|
6
|
+
*/
|
7
|
+
useDefaultOffline?: boolean;
|
8
|
+
/**
|
9
|
+
* @description 蓝牙提示是否需要阻止交互
|
10
|
+
* @default false
|
11
|
+
*/
|
12
|
+
bleCover?: boolean;
|
13
|
+
/**
|
14
|
+
* @description 蓝牙及 toast 提示自定义顶部高度(自定义导航时使用)如: 100px,10vh等
|
15
|
+
* @default 0
|
16
|
+
*/
|
17
|
+
customTop?: string;
|
18
|
+
/**
|
19
|
+
*@description 蓝牙连接方式,默认0
|
20
|
+
* 0: 网关和app都需要,默认值,本地和网关两个途径任何一个可用均可生效
|
21
|
+
* 1: 仅 app, 只会判定本地是否在线, 以及本地连接是否成功
|
22
|
+
* 2: 仅网关连接, 只会判定网关是否在线,以及网关连接是否成功
|
23
|
+
* @default 0
|
24
|
+
*/
|
25
|
+
bleConnectType?: number;
|
26
|
+
/**
|
27
|
+
* @description 是否显示蓝牙连接状态提示
|
28
|
+
*
|
29
|
+
* @default true
|
30
|
+
* @version 2.10.4
|
31
|
+
*/
|
32
|
+
showBLEToast?: boolean;
|
33
|
+
/**
|
34
|
+
* @description 当前设备 id,默认为 undefined,表示自动从小程序的 query参数中获取
|
35
|
+
* @default undefined
|
36
|
+
*/
|
37
|
+
deviceId?: string;
|
38
|
+
/**
|
39
|
+
* @description 当前群组 id,默认为 undefined,表示自动从小程序的 query参数中获取
|
40
|
+
* @default undefined
|
41
|
+
*/
|
42
|
+
groupId?: string;
|
43
|
+
}
|
44
|
+
export declare function parseDevice(dev: ty.device.DeviceInfo | DevInfo): DevInfo;
|
45
|
+
/**
|
46
|
+
* 初始化面板环境下使用到的设备信息
|
47
|
+
* @returns Promise<DevInfo>
|
48
|
+
*/
|
49
|
+
export declare const initDevInfo: (option?: {
|
50
|
+
deviceId?: string;
|
51
|
+
groupId?: string;
|
52
|
+
}) => Promise<DevInfo>;
|
53
|
+
export declare const getDevInfo: () => DevInfo;
|
54
|
+
export declare const updateDevInfo: (devInfo: DevInfo) => void;
|
55
|
+
/**
|
56
|
+
* 绑定当前设备或群组基础事件
|
57
|
+
* @param config: InitPanelEnvironmentOptions 配置项
|
58
|
+
*/
|
59
|
+
export declare function initPanelEnvironment(options?: InitPanelEnvironmentOptions): Promise<void>;
|
@@ -0,0 +1,176 @@
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
4
|
+
import "core-js/modules/es.object.to-string.js";
|
5
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
6
|
+
import "core-js/modules/es.promise.js";
|
7
|
+
import { getDeviceInfo, getLaunchOptionsSync, getGroupInfo, getApp, registerDeviceListListener, registerGroupChange, exitMiniProgram, subscribeDeviceRemoved, onDeviceRemoved } from '../../';
|
8
|
+
// 本地化缓存 deviceInfo 方便随时调用
|
9
|
+
var __deviceInfo = null;
|
10
|
+
var defaultPanelEnvironmentOptions = {
|
11
|
+
useDefaultOffline: true,
|
12
|
+
bleCover: false,
|
13
|
+
customTop: null,
|
14
|
+
bleConnectType: 0,
|
15
|
+
showBLEToast: true
|
16
|
+
};
|
17
|
+
export function parseDevice(dev) {
|
18
|
+
if (!dev) return null; // @ts-ignore
|
19
|
+
|
20
|
+
var deviceInfo = _objectSpread({}, dev);
|
21
|
+
|
22
|
+
var schema = dev.schema;
|
23
|
+
var idCodes = {};
|
24
|
+
var codeIds = {};
|
25
|
+
schema.forEach(function (item) {
|
26
|
+
// @ts-ignore
|
27
|
+
var id = item.id,
|
28
|
+
code = item.code;
|
29
|
+
idCodes[id] = code;
|
30
|
+
codeIds[code] = id;
|
31
|
+
});
|
32
|
+
deviceInfo.idCodes = idCodes;
|
33
|
+
deviceInfo.codeIds = codeIds;
|
34
|
+
return deviceInfo;
|
35
|
+
}
|
36
|
+
/**
|
37
|
+
* 初始化面板环境下使用到的设备信息
|
38
|
+
* @returns Promise<DevInfo>
|
39
|
+
*/
|
40
|
+
|
41
|
+
export var initDevInfo = function (option) {
|
42
|
+
return new Promise(function (resolve, reject) {
|
43
|
+
if (__deviceInfo) {
|
44
|
+
resolve(__deviceInfo);
|
45
|
+
}
|
46
|
+
|
47
|
+
var data = getLaunchOptionsSync();
|
48
|
+
|
49
|
+
var _ref = option || data.query,
|
50
|
+
deviceId = _ref.deviceId,
|
51
|
+
groupId = _ref.groupId;
|
52
|
+
|
53
|
+
if (groupId) {
|
54
|
+
getGroupInfo({
|
55
|
+
groupId: groupId,
|
56
|
+
success: function success(groupInfo) {
|
57
|
+
__deviceInfo = groupInfo;
|
58
|
+
resolve(__deviceInfo);
|
59
|
+
}
|
60
|
+
});
|
61
|
+
} else {
|
62
|
+
getDeviceInfo({
|
63
|
+
deviceId: deviceId,
|
64
|
+
success: function success(deviceInfo) {
|
65
|
+
__deviceInfo = parseDevice(deviceInfo);
|
66
|
+
resolve(__deviceInfo);
|
67
|
+
},
|
68
|
+
fail: reject
|
69
|
+
});
|
70
|
+
}
|
71
|
+
});
|
72
|
+
};
|
73
|
+
export var getDevInfo = function () {
|
74
|
+
return __deviceInfo;
|
75
|
+
};
|
76
|
+
export var updateDevInfo = function (devInfo) {
|
77
|
+
__deviceInfo = devInfo;
|
78
|
+
};
|
79
|
+
/**
|
80
|
+
* 监听设备移除
|
81
|
+
*/
|
82
|
+
|
83
|
+
var handleDeviceRemoved = function () {
|
84
|
+
exitMiniProgram();
|
85
|
+
};
|
86
|
+
/**
|
87
|
+
* 绑定当前设备或群组基础事件
|
88
|
+
* @param config: InitPanelEnvironmentOptions 配置项
|
89
|
+
*/
|
90
|
+
|
91
|
+
|
92
|
+
export function initPanelEnvironment() {
|
93
|
+
return _initPanelEnvironment.apply(this, arguments);
|
94
|
+
}
|
95
|
+
|
96
|
+
function _initPanelEnvironment() {
|
97
|
+
_initPanelEnvironment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
98
|
+
var options,
|
99
|
+
App,
|
100
|
+
_args = arguments;
|
101
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
102
|
+
while (1) {
|
103
|
+
switch (_context.prev = _context.next) {
|
104
|
+
case 0:
|
105
|
+
options = _args.length > 0 && _args[0] !== undefined ? _args[0] : defaultPanelEnvironmentOptions;
|
106
|
+
|
107
|
+
if (getApp()) {
|
108
|
+
_context.next = 5;
|
109
|
+
break;
|
110
|
+
}
|
111
|
+
|
112
|
+
_context.next = 4;
|
113
|
+
return new Promise(function (resolve) {
|
114
|
+
setTimeout(function () {
|
115
|
+
resolve(initPanelEnvironment(options));
|
116
|
+
}, 0);
|
117
|
+
});
|
118
|
+
|
119
|
+
case 4:
|
120
|
+
return _context.abrupt("return");
|
121
|
+
|
122
|
+
case 5:
|
123
|
+
App = getApp(); // 基础库版本需要大于 2.6.0
|
124
|
+
|
125
|
+
App.onReady = function (event) {
|
126
|
+
var _options$deviceId, _options$groupId;
|
127
|
+
|
128
|
+
var deviceId = (_options$deviceId = options.deviceId) !== null && _options$deviceId !== void 0 ? _options$deviceId : event.query.deviceId;
|
129
|
+
var groupId = (_options$groupId = options.groupId) !== null && _options$groupId !== void 0 ? _options$groupId : event.query.groupId;
|
130
|
+
var useDefaultOffline = options.useDefaultOffline; // @ts-ignore
|
131
|
+
|
132
|
+
if (ty.panel && ty.panel.initPanelKit && useDefaultOffline) {
|
133
|
+
// @ts-ignore
|
134
|
+
ty.panel.initPanelKit(_objectSpread({
|
135
|
+
deviceId: deviceId,
|
136
|
+
groupId: groupId
|
137
|
+
}, options));
|
138
|
+
} else {
|
139
|
+
// 否则使用 registerDeviceListListener 注册,删除上述条件方法
|
140
|
+
// 若需要能用离线逻辑,则需要在 global.config.ts 中添加 pageWrapper: ['@ray-js/ray-panel-wrapper/lib/page'],
|
141
|
+
if (deviceId) {
|
142
|
+
registerDeviceListListener({
|
143
|
+
deviceIdList: [deviceId]
|
144
|
+
});
|
145
|
+
}
|
146
|
+
|
147
|
+
if (groupId) {
|
148
|
+
registerGroupChange({
|
149
|
+
groupIdList: [groupId]
|
150
|
+
});
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
if (deviceId) {
|
155
|
+
subscribeDeviceRemoved({
|
156
|
+
deviceId: deviceId,
|
157
|
+
success: function success() {
|
158
|
+
onDeviceRemoved(handleDeviceRemoved);
|
159
|
+
}
|
160
|
+
});
|
161
|
+
}
|
162
|
+
}; // 使用 Promise 确保业务可以通过 initPanelEnvironment 的正常调用明确设备信息初始化完成
|
163
|
+
|
164
|
+
|
165
|
+
_context.next = 9;
|
166
|
+
return initDevInfo(options.deviceId || options.groupId ? options : undefined);
|
167
|
+
|
168
|
+
case 9:
|
169
|
+
case "end":
|
170
|
+
return _context.stop();
|
171
|
+
}
|
172
|
+
}
|
173
|
+
}, _callee);
|
174
|
+
}));
|
175
|
+
return _initPanelEnvironment.apply(this, arguments);
|
176
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { getNetworkType, onNetworkStatusChange } from '../';
|
2
|
+
import { GetTTTSuccessData, GetTTTEventListenerParams, NetworkState } from './types';
|
3
|
+
declare type GetNetworkResult = GetTTTSuccessData<typeof getNetworkType>;
|
4
|
+
declare type NetworkStatusChangeParam = GetTTTEventListenerParams<typeof onNetworkStatusChange>;
|
5
|
+
/**
|
6
|
+
* 规范统一处理 network 返回值
|
7
|
+
*
|
8
|
+
* 1. 比如 getNetworkType 里没有返回 isConnected 字段是正常的,为了和 wx 保持统一
|
9
|
+
* 2. 事件回调数据里没有返回 signalStrength 字段是正常的,为了和 wx 保持统一
|
10
|
+
*
|
11
|
+
* @param network - 当前的 network 数据
|
12
|
+
* @param data - 从 getNetworkType 或 onNetworkStatusChange 获取到的数据
|
13
|
+
*/
|
14
|
+
export declare function normalizeNetwork(network: NetworkState, data: GetNetworkResult | NetworkStatusChangeParam): NetworkState;
|
15
|
+
export {};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* 规范统一处理 network 返回值
|
5
|
+
*
|
6
|
+
* 1. 比如 getNetworkType 里没有返回 isConnected 字段是正常的,为了和 wx 保持统一
|
7
|
+
* 2. 事件回调数据里没有返回 signalStrength 字段是正常的,为了和 wx 保持统一
|
8
|
+
*
|
9
|
+
* @param network - 当前的 network 数据
|
10
|
+
* @param data - 从 getNetworkType 或 onNetworkStatusChange 获取到的数据
|
11
|
+
*/
|
12
|
+
export function normalizeNetwork(network, data) {
|
13
|
+
var _result$networkType;
|
14
|
+
|
15
|
+
var result = _objectSpread(_objectSpread({}, network), data);
|
16
|
+
|
17
|
+
var networkType = result === null || result === void 0 ? void 0 : (_result$networkType = result.networkType) === null || _result$networkType === void 0 ? void 0 : _result$networkType.toUpperCase();
|
18
|
+
result.networkType = networkType;
|
19
|
+
|
20
|
+
if (typeof result.isConnected === 'undefined') {
|
21
|
+
result.isConnected = networkType !== 'NONE';
|
22
|
+
}
|
23
|
+
|
24
|
+
return result;
|
25
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { publishDpsBase } from '../';
|
2
|
+
import { GetTTTAllParams, DpState } from './types';
|
3
|
+
declare type PublishDpsOptions = Omit<GetTTTAllParams<typeof publishDpsBase>, 'deviceId' | 'dps'>;
|
4
|
+
/**
|
5
|
+
* 兼容新旧 publishDps,可以使用原有小程序提供的调用方式,也可以使用 SDK 提供的调用方式。
|
6
|
+
* @param data ty.device.publishDps的参数 或 当前要下发的 DP 数据,同时支持 key 为 dp code 或 dp id
|
7
|
+
* @param options publishDps 的高阶配置,默认值为 { mode: 2, options: {}, pipelines: [] } * @example
|
8
|
+
*
|
9
|
+
* @example
|
10
|
+
* publishDps({ deviceId: string, dps: {}, mode: number, pipelines: number[], options: {}, success(){}, fail(){},complete(){} })
|
11
|
+
* publishDps({ switch: false });
|
12
|
+
* publishDps({ '1': false })
|
13
|
+
*/
|
14
|
+
export declare function publishDps<T extends GetTTTAllParams<typeof publishDpsBase> | DpState>(data: T, options?: PublishDpsOptions): T extends GetTTTAllParams<typeof publishDpsBase> ? void : Promise<boolean>;
|
15
|
+
export {};
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
|
+
import "core-js/modules/es.object.to-string.js";
|
3
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
4
|
+
import "core-js/modules/es.object.keys.js";
|
5
|
+
import "core-js/modules/es.promise.js";
|
6
|
+
import { publishDpsBase } from '../';
|
7
|
+
import { getDevInfo } from './devInfo';
|
8
|
+
var DEFAULT_OPTIONS = {
|
9
|
+
mode: 2,
|
10
|
+
options: {},
|
11
|
+
pipelines: []
|
12
|
+
};
|
13
|
+
/**
|
14
|
+
* 下发 DP 点控制设备
|
15
|
+
*
|
16
|
+
* @param data - 当前要下发的 DP 数据,同时支持 key 为 dp code 或 dp id
|
17
|
+
* @param options - publishDps 的高阶配置
|
18
|
+
|
19
|
+
* @example
|
20
|
+
*
|
21
|
+
* publishDps({ switch: false });
|
22
|
+
* publishDps({ '1': false })
|
23
|
+
*/
|
24
|
+
|
25
|
+
function sendDps(data) {
|
26
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPTIONS;
|
27
|
+
var devInfo = getDevInfo();
|
28
|
+
var dps = {};
|
29
|
+
var codeIds = (devInfo === null || devInfo === void 0 ? void 0 : devInfo.codeIds) || {};
|
30
|
+
Object.keys(data).forEach(function (code) {
|
31
|
+
if (codeIds[code] !== undefined) {
|
32
|
+
dps["".concat(codeIds[code])] = data[code];
|
33
|
+
} else {
|
34
|
+
dps[code] = data[code];
|
35
|
+
}
|
36
|
+
});
|
37
|
+
return new Promise(function (resolve, reject) {
|
38
|
+
publishDpsBase(_objectSpread({
|
39
|
+
deviceId: devInfo.devId,
|
40
|
+
dps: dps,
|
41
|
+
success: function success(ret) {
|
42
|
+
resolve(ret);
|
43
|
+
},
|
44
|
+
fail: function fail(err) {
|
45
|
+
reject(err);
|
46
|
+
}
|
47
|
+
}, options));
|
48
|
+
});
|
49
|
+
}
|
50
|
+
/**
|
51
|
+
* 兼容新旧 publishDps,可以使用原有小程序提供的调用方式,也可以使用 SDK 提供的调用方式。
|
52
|
+
* @param data ty.device.publishDps的参数 或 当前要下发的 DP 数据,同时支持 key 为 dp code 或 dp id
|
53
|
+
* @param options publishDps 的高阶配置,默认值为 { mode: 2, options: {}, pipelines: [] } * @example
|
54
|
+
*
|
55
|
+
* @example
|
56
|
+
* publishDps({ deviceId: string, dps: {}, mode: number, pipelines: number[], options: {}, success(){}, fail(){},complete(){} })
|
57
|
+
* publishDps({ switch: false });
|
58
|
+
* publishDps({ '1': false })
|
59
|
+
*/
|
60
|
+
|
61
|
+
|
62
|
+
export function publishDps(data) {
|
63
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPTIONS;
|
64
|
+
|
65
|
+
if (data.deviceId && data.dps) {
|
66
|
+
publishDpsBase(_objectSpread(_objectSpread({}, data), options));
|
67
|
+
} else {
|
68
|
+
// @ts-ignore
|
69
|
+
return sendDps(data, options);
|
70
|
+
}
|
71
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,106 @@
|
|
1
|
+
export declare type DpValue = boolean | number | string;
|
2
|
+
export declare type DpState = Record<string, DpValue>;
|
3
|
+
export interface DpSchema {
|
4
|
+
attr: number;
|
5
|
+
canTrigger: boolean;
|
6
|
+
/**
|
7
|
+
* 功能点标识码,如 switch
|
8
|
+
*/
|
9
|
+
code: string;
|
10
|
+
defaultRecommend: boolean;
|
11
|
+
editPermission: boolean;
|
12
|
+
executable: boolean;
|
13
|
+
extContent: string;
|
14
|
+
iconname: string;
|
15
|
+
/**
|
16
|
+
* 功能点 ID
|
17
|
+
*/
|
18
|
+
id: number;
|
19
|
+
/**
|
20
|
+
* 功能点模式类型
|
21
|
+
* rw: 可下发可上报(可读可写)
|
22
|
+
* ro: 只可上报(仅可读)
|
23
|
+
* wr: 只可下发(仅可写)
|
24
|
+
*/
|
25
|
+
mode: 'rw' | 'ro' | 'wr';
|
26
|
+
/**
|
27
|
+
* 功能点名称,一般用于语音等场景
|
28
|
+
*/
|
29
|
+
name: string;
|
30
|
+
/**
|
31
|
+
* 功能点属性
|
32
|
+
*/
|
33
|
+
property?: {
|
34
|
+
/**
|
35
|
+
* 功能点类型
|
36
|
+
*/
|
37
|
+
type: 'bool' | 'value' | 'enum' | 'bitmap' | 'string';
|
38
|
+
/**
|
39
|
+
* 枚举值范围,type = enum 时才存在
|
40
|
+
*/
|
41
|
+
range?: string[] | readonly string[];
|
42
|
+
/**
|
43
|
+
* 故障型标签列表,type = bitmap 时才存在
|
44
|
+
*/
|
45
|
+
label?: string[] | readonly string[];
|
46
|
+
/**
|
47
|
+
* 故障型最大长度,type = bitmap 时才存在
|
48
|
+
*/
|
49
|
+
maxlen?: number;
|
50
|
+
/**
|
51
|
+
* 数值型单位,type = value 时才存在
|
52
|
+
*/
|
53
|
+
unit?: string;
|
54
|
+
/**
|
55
|
+
* 数值型最小值,type = value 时才存在
|
56
|
+
*/
|
57
|
+
min?: number;
|
58
|
+
/**
|
59
|
+
* 数值型最大值,type = value 时才存在
|
60
|
+
*/
|
61
|
+
max?: number;
|
62
|
+
/**
|
63
|
+
* 数值型精度,type = value 时才存在
|
64
|
+
* @example
|
65
|
+
* scale = 0; value = 10; 则业务上显示值为 10
|
66
|
+
* scale = 1; value = 10; 则业务上显示值为 1
|
67
|
+
* scale = 2; value = 10; 则业务上显示值为 0.1
|
68
|
+
*/
|
69
|
+
scale?: number;
|
70
|
+
/**
|
71
|
+
* 数值型步长,type = value 时才存在
|
72
|
+
*/
|
73
|
+
step?: number;
|
74
|
+
};
|
75
|
+
type: 'raw' | 'obj';
|
76
|
+
}
|
77
|
+
interface PanelConfig {
|
78
|
+
bic: Array<{
|
79
|
+
code: string;
|
80
|
+
selected: boolean;
|
81
|
+
value?: string | undefined;
|
82
|
+
}>;
|
83
|
+
fun?: Record<string, any> | undefined;
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* 设备信息
|
87
|
+
*/
|
88
|
+
export declare type DevInfo = Omit<ty.device.DeviceInfo, 'schema' | 'panelConfig'> & {
|
89
|
+
/**
|
90
|
+
* dp id 与 dp code 的映射
|
91
|
+
*/
|
92
|
+
idCodes: Record<string, string>;
|
93
|
+
/**
|
94
|
+
* dp code 与 dp id 的映射
|
95
|
+
*/
|
96
|
+
codeIds: Record<string, string>;
|
97
|
+
/**
|
98
|
+
* 产品信息,schema,功能定义都在里面
|
99
|
+
*/
|
100
|
+
schema: Array<DpSchema>;
|
101
|
+
/**
|
102
|
+
* 面板云配置
|
103
|
+
*/
|
104
|
+
panelConfig: PanelConfig;
|
105
|
+
};
|
106
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
declare type AnyFn = (...args: any) => any;
|
2
|
+
export declare type GetTTTAllParams<Fn extends AnyFn> = Parameters<Fn>['0'];
|
3
|
+
export declare type GetTTTParams<Fn extends AnyFn> = Omit<GetTTTAllParams<Fn>, 'complete' | 'success' | 'fail'>;
|
4
|
+
export declare type GetTTTSuccessData<Fn extends AnyFn, TTTParams extends AnyFn = GetTTTAllParams<Fn>['success']> = Parameters<TTTParams>['0'];
|
5
|
+
export declare type GetTTTFailData<Fn extends AnyFn, TTTParams extends AnyFn = GetTTTAllParams<Fn>['failed']> = Parameters<TTTParams>['0'];
|
6
|
+
export declare type GetTTTEventListener<Fn extends AnyFn> = GetTTTAllParams<Fn>;
|
7
|
+
export declare type GetTTTEventListenerParams<Fn extends AnyFn, TTTEventListener extends AnyFn = GetTTTEventListener<Fn>> = Parameters<TTTEventListener>['0'];
|
8
|
+
export declare type PromisifyTTT<Fn extends AnyFn> = (params: GetTTTParams<Fn>) => Promise<GetTTTSuccessData<Fn>>;
|
9
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/lib/utils.d.ts
CHANGED
package/lib/utils.js
CHANGED
@@ -30,4 +30,31 @@ export function factory(name) {
|
|
30
30
|
|
31
31
|
return method.apply(this, arguments);
|
32
32
|
};
|
33
|
+
}
|
34
|
+
export function factoryContants(name) {
|
35
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
36
|
+
|
37
|
+
if (opts.deprecated) {
|
38
|
+
console.warn("\u8BE5\u53D8\u91CF ".concat(name, " \u5DF2\u5F03\u7528"));
|
39
|
+
}
|
40
|
+
|
41
|
+
if (isWechat) {
|
42
|
+
var _inst2 = typeof wx === 'undefined' ? {} : wx;
|
43
|
+
|
44
|
+
if (!_inst2[name]) {
|
45
|
+
console.warn("// TODO \u6682\u672A\u5B9E\u73B0\u53D8\u91CF wx.".concat(name));
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
|
49
|
+
return _inst2[name];
|
50
|
+
}
|
51
|
+
|
52
|
+
var inst = typeof ty === 'undefined' ? {} : ty;
|
53
|
+
|
54
|
+
if (!inst[name]) {
|
55
|
+
console.warn("// TODO \u6682\u672A\u5B9E\u73B0\u53D8\u91CF ".concat(name));
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
|
59
|
+
return inst[name];
|
33
60
|
}
|
package/lib/viewAPI.d.ts
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
/// <reference path="../@types/api.d.ts" />
|
2
|
+
export declare const env: ty.env;
|
3
|
+
export declare const createAnimation: typeof ty.createAnimation;
|
4
|
+
export declare const pageScrollTo: typeof ty.pageScrollTo;
|
5
|
+
export declare const createSelectorQuery: typeof ty.createSelectorQuery;
|
6
|
+
export declare const createIntersectionObserver: typeof ty.createIntersectionObserver;
|
7
|
+
export declare const createCanvasContext: typeof ty.createCanvasContext;
|
8
|
+
export declare const canvasGetImageData: typeof ty.canvasGetImageData;
|
9
|
+
export declare const canvasPutImageData: typeof ty.canvasPutImageData;
|
10
|
+
export declare const createVideoContext: typeof ty.createVideoContext;
|
11
|
+
export declare const createMapContext: typeof ty.createMapContext;
|
12
|
+
export declare const createIpcPlayerContext: typeof ty.createIpcPlayerContext;
|
13
|
+
export declare const createCameraContext: typeof ty.createCameraContext;
|
package/lib/viewAPI.js
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
/// <reference path="../@types/api.d.ts" />
|
2
|
+
import { factory, factoryContants } from './utils';
|
3
|
+
export var env = factoryContants('env');
|
4
|
+
export var createAnimation = factory('createAnimation');
|
5
|
+
export var pageScrollTo = factory('pageScrollTo');
|
6
|
+
export var createSelectorQuery = factory('createSelectorQuery');
|
7
|
+
export var createIntersectionObserver = factory('createIntersectionObserver');
|
8
|
+
export var createCanvasContext = factory('createCanvasContext');
|
9
|
+
export var canvasGetImageData = factory('canvasGetImageData');
|
10
|
+
export var canvasPutImageData = factory('canvasPutImageData');
|
11
|
+
export var createVideoContext = factory('createVideoContext');
|
12
|
+
export var createMapContext = factory('createMapContext');
|
13
|
+
export var createIpcPlayerContext = factory('createIpcPlayerContext');
|
14
|
+
export var createCameraContext = factory('createCameraContext');
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/api",
|
3
|
-
"version": "0.
|
3
|
+
"version": "1.0.0",
|
4
4
|
"description": "Ray universal api",
|
5
5
|
"keywords": [
|
6
6
|
"ray"
|
@@ -26,13 +26,13 @@
|
|
26
26
|
"build:kit:api": "node scripts/api-creator.mjs"
|
27
27
|
},
|
28
28
|
"dependencies": {
|
29
|
-
"@ray-js/framework": "^0.
|
30
|
-
"@ray-js/router": "^0.
|
29
|
+
"@ray-js/framework": "^1.0.0",
|
30
|
+
"@ray-js/router": "^1.0.0",
|
31
31
|
"@ray-js/wechat": "^0.0.8",
|
32
32
|
"base64-browser": "^1.0.1"
|
33
33
|
},
|
34
34
|
"devDependencies": {
|
35
|
-
"@ray-js/cli": "^0.
|
35
|
+
"@ray-js/cli": "^1.0.0",
|
36
36
|
"art-template": "^4.13.2",
|
37
37
|
"fs-extra": "^10.1.0",
|
38
38
|
"miniprogram-api-typings": "^3.4.3",
|
@@ -44,6 +44,6 @@
|
|
44
44
|
"email": "tuyafe@tuya.com"
|
45
45
|
}
|
46
46
|
],
|
47
|
-
"gitHead": "
|
47
|
+
"gitHead": "bcc9fee074c97125f75a48895d1a5e449a243eed",
|
48
48
|
"repository": {}
|
49
49
|
}
|