@ledvance/base 1.2.82 → 1.2.83
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/.babelrc +31 -31
- package/.eslintignore +5 -5
- package/.eslintrc.js +27 -27
- package/.prettierrc.js +1 -1
- package/.versionrc +5 -5
- package/localazy.json +848 -848
- package/localazy.keys.json +4 -4
- package/package.json +74 -74
- package/rn-cli.config.js +8 -8
- package/src/api/native.d.ts +71 -71
- package/src/api/native.ts +423 -423
- package/src/api/nativeEventEmitter.d.ts +3 -3
- package/src/api/nativeEventEmitter.ts +125 -125
- package/src/components/AdvanceCard.d.ts +25 -25
- package/src/components/AdvanceCard.tsx +117 -117
- package/src/components/AdvanceList.d.ts +9 -9
- package/src/components/AdvanceList.tsx +69 -69
- package/src/components/ApplyForDeviceItem.d.ts +6 -6
- package/src/components/ApplyForDeviceItem.tsx +83 -83
- package/src/components/ApplyForDeviceList.d.ts +7 -7
- package/src/components/ApplyForDeviceList.tsx +61 -61
- package/src/components/ApplyForText.d.ts +6 -6
- package/src/components/ApplyForText.tsx +52 -52
- package/src/components/Card.d.ts +10 -10
- package/src/components/Card.tsx +40 -40
- package/src/components/Cell.d.ts +21 -21
- package/src/components/Cell.tsx +69 -69
- package/src/components/CircularProgress.d.ts +8 -8
- package/src/components/CircularProgress.tsx +42 -42
- package/src/components/ColorAdjustView.d.ts +12 -12
- package/src/components/ColorAdjustView.tsx +64 -64
- package/src/components/ColorExtractor.d.ts +73 -73
- package/src/components/ColorExtractor.tsx +374 -374
- package/src/components/ColorTempAdjustView.d.ts +13 -13
- package/src/components/ColorTempAdjustView.tsx +57 -57
- package/src/components/ColorsLine.d.ts +7 -7
- package/src/components/ColorsLine.tsx +47 -47
- package/src/components/CustomListDialog.d.ts +15 -15
- package/src/components/CustomListDialog.tsx +66 -65
- package/src/components/DeleteButton.d.ts +10 -10
- package/src/components/DeleteButton.tsx +40 -40
- package/src/components/Dialog.d.ts +10 -10
- package/src/components/Dialog.tsx +38 -38
- package/src/components/DrawToolView.d.ts +46 -46
- package/src/components/DrawToolView.tsx +262 -262
- package/src/components/FanAdjustView.d.ts +23 -23
- package/src/components/FanAdjustView.tsx +141 -141
- package/src/components/InfoText.d.ts +11 -11
- package/src/components/InfoText.tsx +45 -45
- package/src/components/LampAdjustView.d.ts +10 -10
- package/src/components/LampAdjustView.tsx +75 -75
- package/src/components/LampAdjustView2.d.ts +24 -24
- package/src/components/LampAdjustView2.tsx +104 -104
- package/src/components/LinearGradientLine.d.ts +9 -9
- package/src/components/LinearGradientLine.tsx +63 -63
- package/src/components/LoadingView.tsx +39 -39
- package/src/components/MoodColorsLine.d.ts +9 -9
- package/src/components/MoodColorsLine.tsx +38 -38
- package/src/components/Page.d.ts +21 -21
- package/src/components/Page.tsx +104 -104
- package/src/components/Popup.d.ts +7 -7
- package/src/components/Popup.tsx +71 -71
- package/src/components/Segmented.d.ts +14 -14
- package/src/components/Segmented.tsx +76 -76
- package/src/components/ShowSelect.d.ts +1 -1
- package/src/components/ShowSelect.tsx +158 -158
- package/src/components/SocketItem.d.ts +13 -13
- package/src/components/SocketItem.tsx +87 -87
- package/src/components/Spacer.d.ts +7 -7
- package/src/components/Spacer.tsx +13 -13
- package/src/components/Stepper.d.ts +19 -19
- package/src/components/Stepper.tsx +130 -130
- package/src/components/StripAdjustView.d.ts +16 -16
- package/src/components/StripAdjustView.tsx +129 -129
- package/src/components/StripLightView.d.ts +14 -14
- package/src/components/StripLightView.tsx +24 -24
- package/src/components/Summary.tsx +116 -116
- package/src/components/Tag.d.ts +8 -8
- package/src/components/Tag.tsx +56 -56
- package/src/components/TextButton.d.ts +9 -9
- package/src/components/TextButton.tsx +31 -31
- package/src/components/TextField.d.ts +9 -9
- package/src/components/TextField.tsx +92 -92
- package/src/components/TextFieldStyleButton.d.ts +8 -8
- package/src/components/TextFieldStyleButton.tsx +85 -85
- package/src/components/UATabTitle.d.ts +6 -6
- package/src/components/UATabTitle.tsx +31 -31
- package/src/components/UATabs.d.ts +12 -12
- package/src/components/UATabs.tsx +77 -77
- package/src/components/connect.d.ts +10 -10
- package/src/components/connect.tsx +20 -20
- package/src/components/ldvColorBrightness.d.ts +1 -1
- package/src/components/ldvColorBrightness.tsx +18 -18
- package/src/components/ldvColorSlider.d.ts +14 -14
- package/src/components/ldvColorSlider.tsx +131 -131
- package/src/components/ldvItemView.d.ts +12 -12
- package/src/components/ldvItemView.tsx +43 -43
- package/src/components/ldvPickerView.d.ts +13 -13
- package/src/components/ldvPickerView.tsx +97 -97
- package/src/components/ldvPresetView.d.ts +2 -2
- package/src/components/ldvPresetView.tsx +86 -86
- package/src/components/ldvSaturation.d.ts +2 -2
- package/src/components/ldvSaturation.tsx +22 -22
- package/src/components/ldvSlider.d.ts +15 -15
- package/src/components/ldvSlider.tsx +103 -103
- package/src/components/ldvSwitch.d.ts +10 -10
- package/src/components/ldvSwitch.tsx +52 -52
- package/src/components/ldvTemperatureSlider.d.ts +13 -13
- package/src/components/ldvTemperatureSlider.tsx +139 -139
- package/src/components/ldvTopBar.d.ts +10 -10
- package/src/components/ldvTopBar.tsx +76 -76
- package/src/components/ldvTopName.d.ts +9 -9
- package/src/components/ldvTopName.tsx +63 -63
- package/src/components/segmentControl.d.ts +1 -1
- package/src/components/segmentControl.tsx +65 -65
- package/src/components/weekSelect.d.ts +7 -7
- package/src/components/weekSelect.tsx +98 -98
- package/src/composeLayout.d.ts +30 -30
- package/src/composeLayout.tsx +261 -261
- package/src/config/dark-theme.ts +61 -61
- package/src/config/light-theme.ts +61 -61
- package/src/hooks/Hooks.d.ts +2 -2
- package/src/hooks/Hooks.ts +8 -8
- package/src/i18n/index.d.ts +16 -16
- package/src/i18n/index.ts +37 -37
- package/src/i18n/strings.d.ts +15953 -15953
- package/src/i18n/strings.ts +23723 -23723
- package/src/main.tsx +9 -9
- package/src/models/GlobalParams.d.ts +14 -14
- package/src/models/GlobalParams.ts +14 -14
- package/src/models/TuyaApi.d.ts +29 -29
- package/src/models/TuyaApi.ts +92 -92
- package/src/models/combine.d.ts +26 -26
- package/src/models/combine.ts +17 -17
- package/src/models/configureStore.d.ts +9 -9
- package/src/models/configureStore.ts +33 -33
- package/src/models/index.d.ts +31 -31
- package/src/models/index.ts +22 -22
- package/src/models/modules/NativePropsSlice.d.ts +61 -61
- package/src/models/modules/NativePropsSlice.tsx +467 -467
- package/src/models/modules/Result.d.ts +14 -14
- package/src/models/modules/Result.ts +15 -15
- package/src/models/modules/common.d.ts +44 -44
- package/src/models/modules/common.ts +161 -161
- package/src/res/index.d.ts +70 -70
- package/src/res/index.ts +73 -73
- package/src/utils/ColorParser.d.ts +66 -66
- package/src/utils/ColorParser.ts +189 -189
- package/src/utils/ColorUtils.d.ts +71 -71
- package/src/utils/ColorUtils.tsx +448 -448
- package/src/utils/Support.d.ts +13 -13
- package/src/utils/Support.ts +108 -108
- package/src/utils/TypeUtils.d.ts +3 -3
- package/src/utils/cctUtils.d.ts +1 -1
- package/src/utils/cctUtils.ts +110 -110
- package/src/utils/common.d.ts +35 -35
- package/src/utils/common.ts +379 -379
- package/src/utils/index.d.ts +26 -26
- package/src/utils/index.ts +191 -191
- package/src/utils/interface.d.ts +6 -6
- package/src/utils/interface.ts +50 -11
- package/src/utils/loopsCompare.d.ts +1 -1
- package/src/utils/loopsCompare.ts +62 -62
- package/tsconfig.json +50 -50
- package/update-localazy.py +52 -52
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export interface Result<T> {
|
|
2
|
-
success: boolean;
|
|
3
|
-
data?: T | undefined;
|
|
4
|
-
msg?: string | undefined;
|
|
5
|
-
}
|
|
6
|
-
export interface DpsResult<T> {
|
|
7
|
-
result: Result<T>;
|
|
8
|
-
dps?: any | undefined;
|
|
9
|
-
}
|
|
10
|
-
export interface NativeResult<T> {
|
|
11
|
-
result: boolean;
|
|
12
|
-
data?: T;
|
|
13
|
-
msg?: string;
|
|
14
|
-
}
|
|
1
|
+
export interface Result<T> {
|
|
2
|
+
success: boolean;
|
|
3
|
+
data?: T | undefined;
|
|
4
|
+
msg?: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface DpsResult<T> {
|
|
7
|
+
result: Result<T>;
|
|
8
|
+
dps?: any | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface NativeResult<T> {
|
|
11
|
+
result: boolean;
|
|
12
|
+
data?: T;
|
|
13
|
+
msg?: string;
|
|
14
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export interface Result<T> {
|
|
2
|
-
success: boolean;
|
|
3
|
-
data?: T | undefined,
|
|
4
|
-
msg?: string | undefined
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface DpsResult<T> {
|
|
8
|
-
result: Result<T>,
|
|
9
|
-
dps?: any | undefined
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface NativeResult<T> {
|
|
13
|
-
result: boolean
|
|
14
|
-
data?: T
|
|
15
|
-
msg?: string
|
|
1
|
+
export interface Result<T> {
|
|
2
|
+
success: boolean;
|
|
3
|
+
data?: T | undefined,
|
|
4
|
+
msg?: string | undefined
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface DpsResult<T> {
|
|
8
|
+
result: Result<T>,
|
|
9
|
+
dps?: any | undefined
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface NativeResult<T> {
|
|
13
|
+
result: boolean
|
|
14
|
+
data?: T
|
|
15
|
+
msg?: string
|
|
16
16
|
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { DevInfo, DpValue } from 'tuya-panel-kit';
|
|
2
|
-
import { Observable } from 'rxjs/Observable';
|
|
3
|
-
import { ActionsObservable } from 'redux-observable';
|
|
4
|
-
import 'rxjs/add/observable/fromPromise';
|
|
5
|
-
import 'rxjs/add/observable/of';
|
|
6
|
-
import 'rxjs/add/observable/merge';
|
|
7
|
-
import 'rxjs/add/operator/catch';
|
|
8
|
-
import 'rxjs/add/operator/map';
|
|
9
|
-
import 'rxjs/add/operator/mergeMap';
|
|
10
|
-
import 'rxjs/add/operator/partition';
|
|
11
|
-
export interface DpState {
|
|
12
|
-
switch: boolean;
|
|
13
|
-
[dpCode: string]: DpValue;
|
|
14
|
-
}
|
|
15
|
-
export interface Log {
|
|
16
|
-
strCodes: string;
|
|
17
|
-
strIds: string;
|
|
18
|
-
time: string;
|
|
19
|
-
isSend: boolean;
|
|
20
|
-
}
|
|
21
|
-
declare type Logs = Array<Log>;
|
|
22
|
-
declare type UpdateDevInfoPayload = DevInfo;
|
|
23
|
-
declare type UpdateDpStatePayload = Partial<DpState> & {
|
|
24
|
-
[key: string]: DpValue;
|
|
25
|
-
};
|
|
26
|
-
export declare const actions: {
|
|
27
|
-
devInfoChange: import("redux-actions").ActionFunction1<UpdateDevInfoPayload, import("redux-actions").Action<UpdateDevInfoPayload>>;
|
|
28
|
-
deviceChange: import("redux-actions").ActionFunction1<UpdateDevInfoPayload, import("redux-actions").Action<UpdateDevInfoPayload>>;
|
|
29
|
-
responseUpdateDp: import("redux-actions").ActionFunction1<UpdateDpStatePayload, import("redux-actions").Action<UpdateDpStatePayload>>;
|
|
30
|
-
updateDp: import("redux-actions").ActionFunction1<UpdateDpStatePayload, import("redux-actions").Action<UpdateDpStatePayload>>;
|
|
31
|
-
consoleChange: import("redux-actions").ActionFunctionAny<import("redux-actions").Action<any>>;
|
|
32
|
-
clearConsole: import("redux-actions").ActionFunctionAny<import("redux-actions").Action<any>>;
|
|
33
|
-
};
|
|
34
|
-
export declare type Actions = {
|
|
35
|
-
[K in keyof typeof actions]: ReturnType<typeof actions[K]>;
|
|
36
|
-
};
|
|
37
|
-
export declare const reducers: {
|
|
38
|
-
dpState: import("redux-actions").ReduxCompatibleReducer<DpState, UpdateDevInfoPayload | UpdateDpStatePayload>;
|
|
39
|
-
devInfo: import("redux-actions").ReduxCompatibleReducer<DevInfo<DpState>, DevInfo<DpState>>;
|
|
40
|
-
logs: import("redux-actions").ReduxCompatibleReducer<Logs, DevInfo<Record<string, import("tuya-panel-kit").DpType>> | UpdateDpStatePayload | undefined>;
|
|
41
|
-
ldvModules: import("@reduxjs/toolkit").Reducer<import("./NativePropsSlice").NativeProps, import("@reduxjs/toolkit").AnyAction>;
|
|
42
|
-
};
|
|
43
|
-
export declare const epics: ((action$: ActionsObservable<Actions['updateDp']>) => Observable<import("redux-actions").Action<UpdateDpStatePayload>>)[];
|
|
44
|
-
export {};
|
|
1
|
+
import { DevInfo, DpValue } from 'tuya-panel-kit';
|
|
2
|
+
import { Observable } from 'rxjs/Observable';
|
|
3
|
+
import { ActionsObservable } from 'redux-observable';
|
|
4
|
+
import 'rxjs/add/observable/fromPromise';
|
|
5
|
+
import 'rxjs/add/observable/of';
|
|
6
|
+
import 'rxjs/add/observable/merge';
|
|
7
|
+
import 'rxjs/add/operator/catch';
|
|
8
|
+
import 'rxjs/add/operator/map';
|
|
9
|
+
import 'rxjs/add/operator/mergeMap';
|
|
10
|
+
import 'rxjs/add/operator/partition';
|
|
11
|
+
export interface DpState {
|
|
12
|
+
switch: boolean;
|
|
13
|
+
[dpCode: string]: DpValue;
|
|
14
|
+
}
|
|
15
|
+
export interface Log {
|
|
16
|
+
strCodes: string;
|
|
17
|
+
strIds: string;
|
|
18
|
+
time: string;
|
|
19
|
+
isSend: boolean;
|
|
20
|
+
}
|
|
21
|
+
declare type Logs = Array<Log>;
|
|
22
|
+
declare type UpdateDevInfoPayload = DevInfo;
|
|
23
|
+
declare type UpdateDpStatePayload = Partial<DpState> & {
|
|
24
|
+
[key: string]: DpValue;
|
|
25
|
+
};
|
|
26
|
+
export declare const actions: {
|
|
27
|
+
devInfoChange: import("redux-actions").ActionFunction1<UpdateDevInfoPayload, import("redux-actions").Action<UpdateDevInfoPayload>>;
|
|
28
|
+
deviceChange: import("redux-actions").ActionFunction1<UpdateDevInfoPayload, import("redux-actions").Action<UpdateDevInfoPayload>>;
|
|
29
|
+
responseUpdateDp: import("redux-actions").ActionFunction1<UpdateDpStatePayload, import("redux-actions").Action<UpdateDpStatePayload>>;
|
|
30
|
+
updateDp: import("redux-actions").ActionFunction1<UpdateDpStatePayload, import("redux-actions").Action<UpdateDpStatePayload>>;
|
|
31
|
+
consoleChange: import("redux-actions").ActionFunctionAny<import("redux-actions").Action<any>>;
|
|
32
|
+
clearConsole: import("redux-actions").ActionFunctionAny<import("redux-actions").Action<any>>;
|
|
33
|
+
};
|
|
34
|
+
export declare type Actions = {
|
|
35
|
+
[K in keyof typeof actions]: ReturnType<typeof actions[K]>;
|
|
36
|
+
};
|
|
37
|
+
export declare const reducers: {
|
|
38
|
+
dpState: import("redux-actions").ReduxCompatibleReducer<DpState, UpdateDevInfoPayload | UpdateDpStatePayload>;
|
|
39
|
+
devInfo: import("redux-actions").ReduxCompatibleReducer<DevInfo<DpState>, DevInfo<DpState>>;
|
|
40
|
+
logs: import("redux-actions").ReduxCompatibleReducer<Logs, DevInfo<Record<string, import("tuya-panel-kit").DpType>> | UpdateDpStatePayload | undefined>;
|
|
41
|
+
ldvModules: import("@reduxjs/toolkit").Reducer<import("./NativePropsSlice").NativeProps, import("@reduxjs/toolkit").AnyAction>;
|
|
42
|
+
};
|
|
43
|
+
export declare const epics: ((action$: ActionsObservable<Actions['updateDp']>) => Observable<import("redux-actions").Action<UpdateDpStatePayload>>)[];
|
|
44
|
+
export {};
|
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
import {DevInfo, DpValue, TYSdk} from 'tuya-panel-kit'
|
|
2
|
-
import {createAction, handleActions} from 'redux-actions'
|
|
3
|
-
import {Observable} from 'rxjs/Observable'
|
|
4
|
-
import {ActionsObservable} from 'redux-observable'
|
|
5
|
-
import 'rxjs/add/observable/fromPromise'
|
|
6
|
-
import 'rxjs/add/observable/of'
|
|
7
|
-
import 'rxjs/add/observable/merge'
|
|
8
|
-
import 'rxjs/add/operator/catch'
|
|
9
|
-
import 'rxjs/add/operator/map'
|
|
10
|
-
import 'rxjs/add/operator/mergeMap'
|
|
11
|
-
import 'rxjs/add/operator/partition'
|
|
12
|
-
import {ldvModules} from './NativePropsSlice'
|
|
13
|
-
|
|
14
|
-
const {putDeviceData} = TYSdk.device
|
|
15
|
-
|
|
16
|
-
export interface DpState {
|
|
17
|
-
switch: boolean;
|
|
18
|
-
|
|
19
|
-
[dpCode: string]: DpValue;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface Log {
|
|
23
|
-
strCodes: string;
|
|
24
|
-
strIds: string;
|
|
25
|
-
time: string;
|
|
26
|
-
isSend: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type Logs = Array<Log>;
|
|
30
|
-
|
|
31
|
-
type UpdateDevInfoPayload = DevInfo;
|
|
32
|
-
type UpdateDpStatePayload = Partial<DpState> & { [key: string]: DpValue }; // 保证起码有一个键值对存在
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* actions
|
|
36
|
-
*/
|
|
37
|
-
const devInfoChange = createAction<UpdateDevInfoPayload>('_DEVINFOCHANGE_')
|
|
38
|
-
const deviceChange = createAction<UpdateDevInfoPayload>('_DEVICECHANGED_')
|
|
39
|
-
const responseUpdateDp = createAction<UpdateDpStatePayload>('RESPONSE_UPDATE_DP')
|
|
40
|
-
const updateDp = createAction<UpdateDpStatePayload>('CHANGE_DP')
|
|
41
|
-
const consoleChange = createAction('CONSOLECHNAGE')
|
|
42
|
-
const clearConsole = createAction('CLEARCONSOLE')
|
|
43
|
-
|
|
44
|
-
export const actions = {
|
|
45
|
-
devInfoChange,
|
|
46
|
-
deviceChange,
|
|
47
|
-
responseUpdateDp,
|
|
48
|
-
updateDp,
|
|
49
|
-
consoleChange,
|
|
50
|
-
clearConsole,
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type Actions = { [K in keyof typeof actions]: ReturnType<typeof actions[K]> };
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* reducers
|
|
57
|
-
*/
|
|
58
|
-
const dpState = handleActions<DpState, UpdateDpStatePayload | UpdateDevInfoPayload>(
|
|
59
|
-
{
|
|
60
|
-
[devInfoChange.toString()]: (state, action: Actions['devInfoChange']) => {
|
|
61
|
-
return {
|
|
62
|
-
...state,
|
|
63
|
-
...action.payload.state,
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
[responseUpdateDp.toString()]: (state, action: Actions['responseUpdateDp']) => ({
|
|
68
|
-
...state,
|
|
69
|
-
...action.payload,
|
|
70
|
-
}),
|
|
71
|
-
},
|
|
72
|
-
{} as DpState,
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
const devInfo = handleActions<DevInfo<DpState>>(
|
|
76
|
-
{
|
|
77
|
-
[devInfoChange.toString()]: (state, action) => ({
|
|
78
|
-
...state,
|
|
79
|
-
...action.payload,
|
|
80
|
-
}),
|
|
81
|
-
|
|
82
|
-
[deviceChange.toString()]: (state, action) => ({
|
|
83
|
-
...state,
|
|
84
|
-
...action.payload,
|
|
85
|
-
}),
|
|
86
|
-
},
|
|
87
|
-
{} as DevInfo<DpState>,
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
let isSend = false
|
|
91
|
-
|
|
92
|
-
const formatLogs = (state: Logs, action: { payload: UpdateDpStatePayload }, send: boolean) => {
|
|
93
|
-
const ret = Object.keys(action.payload).reduce((obj, p) => {
|
|
94
|
-
const id = TYSdk.device.getDpIdByCode(p)
|
|
95
|
-
return {...obj, [id]: action.payload[p]}
|
|
96
|
-
}, {})
|
|
97
|
-
const strIds = JSON.stringify(ret, null, 2)
|
|
98
|
-
const strCodes = JSON.stringify(action.payload, null, 2)
|
|
99
|
-
const date = new Date()
|
|
100
|
-
const time = `[${[
|
|
101
|
-
date.getHours(),
|
|
102
|
-
date.getMinutes(),
|
|
103
|
-
date.getSeconds(),
|
|
104
|
-
date.getMilliseconds(),
|
|
105
|
-
].join(':')}]`
|
|
106
|
-
const s = [{strCodes, strIds, time, isSend: send}, ...state]
|
|
107
|
-
return s.slice(0, 30)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const logs = handleActions<Logs, undefined | UpdateDpStatePayload | DevInfo>(
|
|
111
|
-
{
|
|
112
|
-
[consoleChange.toString()]: state => {
|
|
113
|
-
isSend = true
|
|
114
|
-
return state
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
[updateDp.toString()]: (state, action: Actions['updateDp']) => {
|
|
118
|
-
isSend = true
|
|
119
|
-
return formatLogs(state, action, isSend)
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
[devInfoChange.toString()]: (state, action: Actions['devInfoChange']) => {
|
|
123
|
-
const formatAction = {payload: action.payload.state}
|
|
124
|
-
return formatLogs(state, formatAction, isSend)
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
[responseUpdateDp.toString()]: (state, action: Actions['responseUpdateDp']) => {
|
|
128
|
-
isSend = false
|
|
129
|
-
return formatLogs(state, action, isSend)
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
[clearConsole.toString()]: () => [],
|
|
133
|
-
},
|
|
134
|
-
[],
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
export const reducers = {
|
|
138
|
-
dpState,
|
|
139
|
-
devInfo,
|
|
140
|
-
logs,
|
|
141
|
-
ldvModules,
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* epics
|
|
146
|
-
*/
|
|
147
|
-
const dpUpdateEpic$ = (action$: ActionsObservable<Actions['updateDp']>) => {
|
|
148
|
-
return action$.ofType(updateDp.toString()).mergeMap(action => {
|
|
149
|
-
const {payload} = action
|
|
150
|
-
const [success, error] = Observable.fromPromise(putDeviceData(payload))
|
|
151
|
-
.catch(() => Observable.of(responseUpdateDp({})))
|
|
152
|
-
.partition((x: { success: boolean }) => x.success)
|
|
153
|
-
|
|
154
|
-
return Observable.merge(
|
|
155
|
-
success.map(() => responseUpdateDp(payload)), // 如果每次操作都必须等到上报以后再更新,可以注释掉本段代码
|
|
156
|
-
error.map(() => responseUpdateDp({})),
|
|
157
|
-
)
|
|
158
|
-
})
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export const epics = [dpUpdateEpic$]
|
|
1
|
+
import {DevInfo, DpValue, TYSdk} from 'tuya-panel-kit'
|
|
2
|
+
import {createAction, handleActions} from 'redux-actions'
|
|
3
|
+
import {Observable} from 'rxjs/Observable'
|
|
4
|
+
import {ActionsObservable} from 'redux-observable'
|
|
5
|
+
import 'rxjs/add/observable/fromPromise'
|
|
6
|
+
import 'rxjs/add/observable/of'
|
|
7
|
+
import 'rxjs/add/observable/merge'
|
|
8
|
+
import 'rxjs/add/operator/catch'
|
|
9
|
+
import 'rxjs/add/operator/map'
|
|
10
|
+
import 'rxjs/add/operator/mergeMap'
|
|
11
|
+
import 'rxjs/add/operator/partition'
|
|
12
|
+
import {ldvModules} from './NativePropsSlice'
|
|
13
|
+
|
|
14
|
+
const {putDeviceData} = TYSdk.device
|
|
15
|
+
|
|
16
|
+
export interface DpState {
|
|
17
|
+
switch: boolean;
|
|
18
|
+
|
|
19
|
+
[dpCode: string]: DpValue;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Log {
|
|
23
|
+
strCodes: string;
|
|
24
|
+
strIds: string;
|
|
25
|
+
time: string;
|
|
26
|
+
isSend: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type Logs = Array<Log>;
|
|
30
|
+
|
|
31
|
+
type UpdateDevInfoPayload = DevInfo;
|
|
32
|
+
type UpdateDpStatePayload = Partial<DpState> & { [key: string]: DpValue }; // 保证起码有一个键值对存在
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* actions
|
|
36
|
+
*/
|
|
37
|
+
const devInfoChange = createAction<UpdateDevInfoPayload>('_DEVINFOCHANGE_')
|
|
38
|
+
const deviceChange = createAction<UpdateDevInfoPayload>('_DEVICECHANGED_')
|
|
39
|
+
const responseUpdateDp = createAction<UpdateDpStatePayload>('RESPONSE_UPDATE_DP')
|
|
40
|
+
const updateDp = createAction<UpdateDpStatePayload>('CHANGE_DP')
|
|
41
|
+
const consoleChange = createAction('CONSOLECHNAGE')
|
|
42
|
+
const clearConsole = createAction('CLEARCONSOLE')
|
|
43
|
+
|
|
44
|
+
export const actions = {
|
|
45
|
+
devInfoChange,
|
|
46
|
+
deviceChange,
|
|
47
|
+
responseUpdateDp,
|
|
48
|
+
updateDp,
|
|
49
|
+
consoleChange,
|
|
50
|
+
clearConsole,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type Actions = { [K in keyof typeof actions]: ReturnType<typeof actions[K]> };
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* reducers
|
|
57
|
+
*/
|
|
58
|
+
const dpState = handleActions<DpState, UpdateDpStatePayload | UpdateDevInfoPayload>(
|
|
59
|
+
{
|
|
60
|
+
[devInfoChange.toString()]: (state, action: Actions['devInfoChange']) => {
|
|
61
|
+
return {
|
|
62
|
+
...state,
|
|
63
|
+
...action.payload.state,
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
[responseUpdateDp.toString()]: (state, action: Actions['responseUpdateDp']) => ({
|
|
68
|
+
...state,
|
|
69
|
+
...action.payload,
|
|
70
|
+
}),
|
|
71
|
+
},
|
|
72
|
+
{} as DpState,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
const devInfo = handleActions<DevInfo<DpState>>(
|
|
76
|
+
{
|
|
77
|
+
[devInfoChange.toString()]: (state, action) => ({
|
|
78
|
+
...state,
|
|
79
|
+
...action.payload,
|
|
80
|
+
}),
|
|
81
|
+
|
|
82
|
+
[deviceChange.toString()]: (state, action) => ({
|
|
83
|
+
...state,
|
|
84
|
+
...action.payload,
|
|
85
|
+
}),
|
|
86
|
+
},
|
|
87
|
+
{} as DevInfo<DpState>,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
let isSend = false
|
|
91
|
+
|
|
92
|
+
const formatLogs = (state: Logs, action: { payload: UpdateDpStatePayload }, send: boolean) => {
|
|
93
|
+
const ret = Object.keys(action.payload).reduce((obj, p) => {
|
|
94
|
+
const id = TYSdk.device.getDpIdByCode(p)
|
|
95
|
+
return {...obj, [id]: action.payload[p]}
|
|
96
|
+
}, {})
|
|
97
|
+
const strIds = JSON.stringify(ret, null, 2)
|
|
98
|
+
const strCodes = JSON.stringify(action.payload, null, 2)
|
|
99
|
+
const date = new Date()
|
|
100
|
+
const time = `[${[
|
|
101
|
+
date.getHours(),
|
|
102
|
+
date.getMinutes(),
|
|
103
|
+
date.getSeconds(),
|
|
104
|
+
date.getMilliseconds(),
|
|
105
|
+
].join(':')}]`
|
|
106
|
+
const s = [{strCodes, strIds, time, isSend: send}, ...state]
|
|
107
|
+
return s.slice(0, 30)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const logs = handleActions<Logs, undefined | UpdateDpStatePayload | DevInfo>(
|
|
111
|
+
{
|
|
112
|
+
[consoleChange.toString()]: state => {
|
|
113
|
+
isSend = true
|
|
114
|
+
return state
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
[updateDp.toString()]: (state, action: Actions['updateDp']) => {
|
|
118
|
+
isSend = true
|
|
119
|
+
return formatLogs(state, action, isSend)
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
[devInfoChange.toString()]: (state, action: Actions['devInfoChange']) => {
|
|
123
|
+
const formatAction = {payload: action.payload.state}
|
|
124
|
+
return formatLogs(state, formatAction, isSend)
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
[responseUpdateDp.toString()]: (state, action: Actions['responseUpdateDp']) => {
|
|
128
|
+
isSend = false
|
|
129
|
+
return formatLogs(state, action, isSend)
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
[clearConsole.toString()]: () => [],
|
|
133
|
+
},
|
|
134
|
+
[],
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
export const reducers = {
|
|
138
|
+
dpState,
|
|
139
|
+
devInfo,
|
|
140
|
+
logs,
|
|
141
|
+
ldvModules,
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* epics
|
|
146
|
+
*/
|
|
147
|
+
const dpUpdateEpic$ = (action$: ActionsObservable<Actions['updateDp']>) => {
|
|
148
|
+
return action$.ofType(updateDp.toString()).mergeMap(action => {
|
|
149
|
+
const {payload} = action
|
|
150
|
+
const [success, error] = Observable.fromPromise(putDeviceData(payload))
|
|
151
|
+
.catch(() => Observable.of(responseUpdateDp({})))
|
|
152
|
+
.partition((x: { success: boolean }) => x.success)
|
|
153
|
+
|
|
154
|
+
return Observable.merge(
|
|
155
|
+
success.map(() => responseUpdateDp(payload)), // 如果每次操作都必须等到上报以后再更新,可以注释掉本段代码
|
|
156
|
+
error.map(() => responseUpdateDp({})),
|
|
157
|
+
)
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const epics = [dpUpdateEpic$]
|
package/src/res/index.d.ts
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
button: string;
|
|
3
|
-
tuya_decrease: string;
|
|
4
|
-
tuya_goto_icon: string;
|
|
5
|
-
tuya_increase: string;
|
|
6
|
-
tuya_select_icon: string;
|
|
7
|
-
ldv_timer_empty: string;
|
|
8
|
-
ldv_right_arrow: string;
|
|
9
|
-
ldv_list_select: string;
|
|
10
|
-
switch_1: string;
|
|
11
|
-
switch_2: string;
|
|
12
|
-
switch_3: string;
|
|
13
|
-
switch_4: string;
|
|
14
|
-
ic_cancel: string;
|
|
15
|
-
ic_more: string;
|
|
16
|
-
device_panel_timer_add: any;
|
|
17
|
-
device_panel_schedule_alert: string;
|
|
18
|
-
device_panel_schedule_add: string;
|
|
19
|
-
ic_arrows_nav_clear: any;
|
|
20
|
-
ic_info: any;
|
|
21
|
-
ic_warning_amber: any;
|
|
22
|
-
ic_check: string;
|
|
23
|
-
ic_uncheck: any;
|
|
24
|
-
rn_ic_download: string;
|
|
25
|
-
scheduleEmpty: any;
|
|
26
|
-
summary_icon1: any;
|
|
27
|
-
summary_icon2: any;
|
|
28
|
-
summary_icon3: any;
|
|
29
|
-
energy_consumption_right: any;
|
|
30
|
-
energy_consumption_chart: any;
|
|
31
|
-
energy_consumption_cash: any;
|
|
32
|
-
energy_consumption_greenery: any;
|
|
33
|
-
app_music_check: any;
|
|
34
|
-
co2Icon: any;
|
|
35
|
-
download_icon: any;
|
|
36
|
-
energy_consumption_empty: any;
|
|
37
|
-
rhythm_icon1: string;
|
|
38
|
-
rhythm_icon2: string;
|
|
39
|
-
rhythm_icon3: string;
|
|
40
|
-
rhythm_icon4: string;
|
|
41
|
-
color_temperature_wheel: string;
|
|
42
|
-
color_wheel: string;
|
|
43
|
-
scene_goodnight: string;
|
|
44
|
-
scene_reading: string;
|
|
45
|
-
scene_work: string;
|
|
46
|
-
scene_leisure: string;
|
|
47
|
-
scene_custom1: string;
|
|
48
|
-
scene_custom2: string;
|
|
49
|
-
biorhythm_plan_timer: string;
|
|
50
|
-
add: string;
|
|
51
|
-
delete: string;
|
|
52
|
-
icon_edit_scene: string;
|
|
53
|
-
light_on: any;
|
|
54
|
-
light_off: any;
|
|
55
|
-
rn_image_contact_sensor_open: string;
|
|
56
|
-
rn_image_contact_sensor_close: string;
|
|
57
|
-
rn_image_motion_detected: string;
|
|
58
|
-
rn_image_no_motion_detected: string;
|
|
59
|
-
sensor_status: any;
|
|
60
|
-
automation_status: any;
|
|
61
|
-
ic_colorize: any;
|
|
62
|
-
ic_mood_del: any;
|
|
63
|
-
ic_paint_bucket: any;
|
|
64
|
-
ic_text_field_input_error: any;
|
|
65
|
-
ic_minus: any;
|
|
66
|
-
ic_plus: any;
|
|
67
|
-
ic_disabled_light: any;
|
|
68
|
-
ic_top_arrow: any;
|
|
69
|
-
};
|
|
70
|
-
export default _default;
|
|
1
|
+
declare const _default: {
|
|
2
|
+
button: string;
|
|
3
|
+
tuya_decrease: string;
|
|
4
|
+
tuya_goto_icon: string;
|
|
5
|
+
tuya_increase: string;
|
|
6
|
+
tuya_select_icon: string;
|
|
7
|
+
ldv_timer_empty: string;
|
|
8
|
+
ldv_right_arrow: string;
|
|
9
|
+
ldv_list_select: string;
|
|
10
|
+
switch_1: string;
|
|
11
|
+
switch_2: string;
|
|
12
|
+
switch_3: string;
|
|
13
|
+
switch_4: string;
|
|
14
|
+
ic_cancel: string;
|
|
15
|
+
ic_more: string;
|
|
16
|
+
device_panel_timer_add: any;
|
|
17
|
+
device_panel_schedule_alert: string;
|
|
18
|
+
device_panel_schedule_add: string;
|
|
19
|
+
ic_arrows_nav_clear: any;
|
|
20
|
+
ic_info: any;
|
|
21
|
+
ic_warning_amber: any;
|
|
22
|
+
ic_check: string;
|
|
23
|
+
ic_uncheck: any;
|
|
24
|
+
rn_ic_download: string;
|
|
25
|
+
scheduleEmpty: any;
|
|
26
|
+
summary_icon1: any;
|
|
27
|
+
summary_icon2: any;
|
|
28
|
+
summary_icon3: any;
|
|
29
|
+
energy_consumption_right: any;
|
|
30
|
+
energy_consumption_chart: any;
|
|
31
|
+
energy_consumption_cash: any;
|
|
32
|
+
energy_consumption_greenery: any;
|
|
33
|
+
app_music_check: any;
|
|
34
|
+
co2Icon: any;
|
|
35
|
+
download_icon: any;
|
|
36
|
+
energy_consumption_empty: any;
|
|
37
|
+
rhythm_icon1: string;
|
|
38
|
+
rhythm_icon2: string;
|
|
39
|
+
rhythm_icon3: string;
|
|
40
|
+
rhythm_icon4: string;
|
|
41
|
+
color_temperature_wheel: string;
|
|
42
|
+
color_wheel: string;
|
|
43
|
+
scene_goodnight: string;
|
|
44
|
+
scene_reading: string;
|
|
45
|
+
scene_work: string;
|
|
46
|
+
scene_leisure: string;
|
|
47
|
+
scene_custom1: string;
|
|
48
|
+
scene_custom2: string;
|
|
49
|
+
biorhythm_plan_timer: string;
|
|
50
|
+
add: string;
|
|
51
|
+
delete: string;
|
|
52
|
+
icon_edit_scene: string;
|
|
53
|
+
light_on: any;
|
|
54
|
+
light_off: any;
|
|
55
|
+
rn_image_contact_sensor_open: string;
|
|
56
|
+
rn_image_contact_sensor_close: string;
|
|
57
|
+
rn_image_motion_detected: string;
|
|
58
|
+
rn_image_no_motion_detected: string;
|
|
59
|
+
sensor_status: any;
|
|
60
|
+
automation_status: any;
|
|
61
|
+
ic_colorize: any;
|
|
62
|
+
ic_mood_del: any;
|
|
63
|
+
ic_paint_bucket: any;
|
|
64
|
+
ic_text_field_input_error: any;
|
|
65
|
+
ic_minus: any;
|
|
66
|
+
ic_plus: any;
|
|
67
|
+
ic_disabled_light: any;
|
|
68
|
+
ic_top_arrow: any;
|
|
69
|
+
};
|
|
70
|
+
export default _default;
|