@ledvance/base 1.2.61 → 1.2.62
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/localazy.json +697 -697
- package/localazy.keys.json +3 -3
- package/package.json +1 -4
- package/src/api/nativeEventEmitter.ts +26 -2
- package/src/models/modules/NativePropsSlice.tsx +19 -1
package/localazy.keys.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
"writeKey": "",
|
|
3
|
+
"readKey": "a7349213573288779040-d092b120e7d6d90c7e9528ddf2aa600659f60631bd4a5c2d55de0aa2b081af1b"
|
|
4
|
+
}
|
package/package.json
CHANGED
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
"name": "@ledvance/base",
|
|
5
5
|
"pid": [],
|
|
6
6
|
"uiid": "",
|
|
7
|
-
"version": "1.2.
|
|
8
|
-
"scripts": {
|
|
9
|
-
"prepublishOnly": "python update-localazy.py"
|
|
10
|
-
},
|
|
7
|
+
"version": "1.2.62",
|
|
11
8
|
"dependencies": {
|
|
12
9
|
"@reduxjs/toolkit": "^1.8.6",
|
|
13
10
|
"@tuya/tuya-panel-api": "^1.12.0",
|
|
@@ -3,12 +3,14 @@ import {
|
|
|
3
3
|
DeviceInfo,
|
|
4
4
|
NativeProps,
|
|
5
5
|
setGroupDevices,
|
|
6
|
+
setGroupDps,
|
|
6
7
|
setGroupNativeProps,
|
|
7
8
|
setNativeProps,
|
|
8
9
|
UAGroupInfo,
|
|
9
10
|
} from '../models/modules/NativePropsSlice'
|
|
10
11
|
import {actions} from '@models'
|
|
11
12
|
import { cloneDeep } from 'lodash'
|
|
13
|
+
import {DpValue} from "tuya-panel-kit";
|
|
12
14
|
|
|
13
15
|
const nativeModule = NativeModules.LDVDeviceEventEmitter
|
|
14
16
|
|
|
@@ -17,12 +19,18 @@ export const nativeEventEmitter = new NativeEventEmitter(nativeModule)
|
|
|
17
19
|
let deviceDPListener: EmitterSubscription | null
|
|
18
20
|
let groupFeatureListener: EmitterSubscription | null
|
|
19
21
|
let groupDeviceListener: EmitterSubscription | null
|
|
22
|
+
let groupDpListener: EmitterSubscription | null
|
|
20
23
|
|
|
21
24
|
interface GroupFeatureEvent {
|
|
22
25
|
tyGroupId: number
|
|
23
26
|
config: string
|
|
24
27
|
}
|
|
25
28
|
|
|
29
|
+
interface GroupDpEvent {
|
|
30
|
+
tyGroupId?: number
|
|
31
|
+
dps?: any
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
interface DeviceEvent {
|
|
27
35
|
devId: string
|
|
28
36
|
dps: any
|
|
@@ -40,6 +48,7 @@ export const addListener = (store) => {
|
|
|
40
48
|
// device info
|
|
41
49
|
if (event.dps && event.devId && event.devId === store.getState().ldvModules.deviceInfo.devId) {
|
|
42
50
|
console.log('长链接刷新DP数据', event.devId, event.dps)
|
|
51
|
+
// @ts-ignore
|
|
43
52
|
const nativeProps: NativeProps = {
|
|
44
53
|
familyName: '',
|
|
45
54
|
deviceInfo: {
|
|
@@ -61,6 +70,7 @@ export const addListener = (store) => {
|
|
|
61
70
|
const tyGroupId = Number(event.tyGroupId)
|
|
62
71
|
if (tyGroupId == store.getState().ldvModules.uaGroupInfo.tyGroupId) {
|
|
63
72
|
console.log('长链接刷新Group数据', event)
|
|
73
|
+
// @ts-ignore
|
|
64
74
|
const nativeProps: NativeProps = {
|
|
65
75
|
familyName: '',
|
|
66
76
|
deviceInfo: {} as DeviceInfo,
|
|
@@ -69,14 +79,25 @@ export const addListener = (store) => {
|
|
|
69
79
|
pId: '',
|
|
70
80
|
config: JSON.parse(event.config),
|
|
71
81
|
dps: {},
|
|
72
|
-
},
|
|
82
|
+
} as UAGroupInfo,
|
|
73
83
|
}
|
|
74
84
|
store.dispatch(setGroupNativeProps(nativeProps))
|
|
75
85
|
}
|
|
76
86
|
})
|
|
77
87
|
|
|
88
|
+
groupDpListener = nativeEventEmitter.addListener('UAGroupDpUpdate', (event: GroupDpEvent) => {
|
|
89
|
+
const tyGroupId = Number(event.tyGroupId);
|
|
90
|
+
const groupId = Number(store.getState().ldvModules.uaGroupInfo.tyGroupId)
|
|
91
|
+
if (tyGroupId === groupId) {
|
|
92
|
+
let data = event.dps
|
|
93
|
+
if (typeof event.dps === 'string') {
|
|
94
|
+
data = JSON.parse(event.dps)
|
|
95
|
+
}
|
|
96
|
+
store.dispatch(setGroupDps(data as Record<string, DpValue>))
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
|
|
78
100
|
groupDeviceListener = nativeEventEmitter.addListener('TYInfoUpdate', (event: TYInfoUpdateType) =>{
|
|
79
|
-
console.log(event, 'event')
|
|
80
101
|
const groupDevices = store.getState().ldvModules.uaGroupInfo.groupDevices
|
|
81
102
|
const newGroupDevices = cloneDeep(groupDevices).map(device => {
|
|
82
103
|
if(device.deviceId.indexOf(event.devId) !== -1){
|
|
@@ -100,4 +121,7 @@ export const removeListener = () => {
|
|
|
100
121
|
|
|
101
122
|
groupDeviceListener && groupDeviceListener.remove()
|
|
102
123
|
groupDeviceListener = null
|
|
124
|
+
|
|
125
|
+
groupDpListener && groupDpListener.remove()
|
|
126
|
+
groupDpListener = null
|
|
103
127
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
|
2
|
-
import {
|
|
2
|
+
import {useSelector} from '../index'
|
|
3
3
|
import { Dispatch, useCallback } from 'react'
|
|
4
4
|
import { DpsResult, Result } from './Result'
|
|
5
5
|
import { DevInfo, DpValue } from 'tuya-panel-kit'
|
|
@@ -119,6 +119,12 @@ const nativePropsSlice = createSlice({
|
|
|
119
119
|
state.deviceInfo.dps[dp] = action.payload[dp]
|
|
120
120
|
})
|
|
121
121
|
},
|
|
122
|
+
setGroupDps(state, action: PayloadAction<any>) {
|
|
123
|
+
const dpKeys = Object.keys(action.payload)
|
|
124
|
+
dpKeys.forEach(dp => {
|
|
125
|
+
state.uaGroupInfo.dps[dp] = action.payload[dp]
|
|
126
|
+
})
|
|
127
|
+
},
|
|
122
128
|
setTimeSchedule(state, action: PayloadAction<any>) {
|
|
123
129
|
state.timeSchedule = action.payload
|
|
124
130
|
},
|
|
@@ -189,6 +195,10 @@ const useDeviceId = () => {
|
|
|
189
195
|
return useSelector(store => store.ldvModules.deviceInfo.devId)
|
|
190
196
|
}
|
|
191
197
|
|
|
198
|
+
const useGroupId = () => {
|
|
199
|
+
return useSelector(store => store.ldvModules.uaGroupInfo.tyGroupId)
|
|
200
|
+
}
|
|
201
|
+
|
|
192
202
|
const useFamilyName: () => string = () => {
|
|
193
203
|
return useSelector(store => store.ldvModules.familyName)
|
|
194
204
|
}
|
|
@@ -207,6 +217,11 @@ function useDp<T, R extends any>(dp: string): [T, (value: T) => Promise<Result<R
|
|
|
207
217
|
return [dpValue, setDp]
|
|
208
218
|
}
|
|
209
219
|
|
|
220
|
+
function useGroupDp<T>(dp: string): [T] {
|
|
221
|
+
const dpValue = useSelector(store => store.ldvModules.uaGroupInfo.dps[dp])
|
|
222
|
+
return [dpValue]
|
|
223
|
+
}
|
|
224
|
+
|
|
210
225
|
function useScaledDp<R extends any>(dp: string, scaled: number = 10): [number, (value: number) => Promise<Result<R>>] {
|
|
211
226
|
const [sd, setSd] = useDp<number, R>(dp)
|
|
212
227
|
const setScaledDpValue = useCallback(async (value: number) => {
|
|
@@ -391,6 +406,7 @@ export const {
|
|
|
391
406
|
setNativeProps,
|
|
392
407
|
setGroupNativeProps,
|
|
393
408
|
setDps,
|
|
409
|
+
setGroupDps,
|
|
394
410
|
setTimeSchedule,
|
|
395
411
|
setMoods,
|
|
396
412
|
setFlags,
|
|
@@ -408,6 +424,8 @@ export {
|
|
|
408
424
|
useDeviceId,
|
|
409
425
|
useDeviceInfo,
|
|
410
426
|
useDp,
|
|
427
|
+
useGroupId,
|
|
428
|
+
useGroupDp,
|
|
411
429
|
useScaledDp,
|
|
412
430
|
useDps,
|
|
413
431
|
useFamilyName,
|