@ray-js/lamp-schedule-core 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/README.md +565 -0
- package/lib/config/dpCodes.d.ts +27 -0
- package/lib/config/dpCodes.js +30 -0
- package/lib/config/index.d.ts +2 -0
- package/lib/config/index.js +2 -0
- package/lib/config/rhythms/defaultValue.d.ts +18 -0
- package/lib/config/rhythms/defaultValue.js +72 -0
- package/lib/config/rhythms/index.d.ts +10 -0
- package/lib/config/rhythms/index.js +35 -0
- package/lib/conflict/ConflictResolver.d.ts +2 -0
- package/lib/conflict/ConflictResolver.js +284 -0
- package/lib/conflict/__test__/ConflictResolver.test.d.ts +1 -0
- package/lib/conflict/__test__/ConflictResolver.test.js +183 -0
- package/lib/conflict/__test__/index.test.d.ts +1 -0
- package/lib/conflict/__test__/index.test.js +385 -0
- package/lib/conflict/__test__/scheduleDataManager.test.d.ts +1 -0
- package/lib/conflict/__test__/scheduleDataManager.test.js +170 -0
- package/lib/conflict/__test__/transform.test.d.ts +1 -0
- package/lib/conflict/__test__/transform.test.js +454 -0
- package/lib/conflict/__test__/updateDeviceDp.d.ts +1 -0
- package/lib/conflict/__test__/updateDeviceDp.js +114 -0
- package/lib/conflict/index.d.ts +42 -0
- package/lib/conflict/index.js +103 -0
- package/lib/conflict/scheduleDataManager.d.ts +12 -0
- package/lib/conflict/scheduleDataManager.js +79 -0
- package/lib/conflict/transform.d.ts +71 -0
- package/lib/conflict/transform.js +251 -0
- package/lib/conflict/type.d.ts +55 -0
- package/lib/conflict/type.js +17 -0
- package/lib/conflict/updateDeviceDp.d.ts +1 -0
- package/lib/conflict/updateDeviceDp.js +41 -0
- package/lib/constant/index.d.ts +5 -0
- package/lib/constant/index.js +5 -0
- package/lib/context/index.d.ts +3 -0
- package/lib/context/index.js +3 -0
- package/lib/context/rhythms/actions.d.ts +20 -0
- package/lib/context/rhythms/actions.js +52 -0
- package/lib/context/rhythms/index.d.ts +5 -0
- package/lib/context/rhythms/index.js +51 -0
- package/lib/context/rhythms/reducer.d.ts +24 -0
- package/lib/context/rhythms/reducer.js +38 -0
- package/lib/context/schedule/actions.d.ts +7 -0
- package/lib/context/schedule/actions.js +51 -0
- package/lib/context/schedule/context.d.ts +6 -0
- package/lib/context/schedule/context.js +52 -0
- package/lib/context/schedule/index.d.ts +1 -0
- package/lib/context/schedule/index.js +1 -0
- package/lib/context/schedule/reducer.d.ts +16 -0
- package/lib/context/schedule/reducer.js +104 -0
- package/lib/context/schedule/type.d.ts +41 -0
- package/lib/context/schedule/type.js +11 -0
- package/lib/context/timer/actions.d.ts +8 -0
- package/lib/context/timer/actions.js +52 -0
- package/lib/context/timer/context.d.ts +10 -0
- package/lib/context/timer/context.js +53 -0
- package/lib/context/timer/index.d.ts +1 -0
- package/lib/context/timer/index.js +1 -0
- package/lib/context/timer/reducer.d.ts +15 -0
- package/lib/context/timer/reducer.js +70 -0
- package/lib/context/timer/type.d.ts +46 -0
- package/lib/context/timer/type.js +24 -0
- package/lib/dpParser/README.md +63 -0
- package/lib/dpParser/__test__/cycle.test.d.ts +1 -0
- package/lib/dpParser/__test__/cycle.test.js +258 -0
- package/lib/dpParser/__test__/random.test.d.ts +1 -0
- package/lib/dpParser/__test__/random.test.js +211 -0
- package/lib/dpParser/__test__/rhythms.test.d.ts +1 -0
- package/lib/dpParser/__test__/rhythms.test.js +71 -0
- package/lib/dpParser/__test__/rtcTimer.test.d.ts +1 -0
- package/lib/dpParser/__test__/rtcTimer.test.js +235 -0
- package/lib/dpParser/__test__/sleep.test.d.ts +1 -0
- package/lib/dpParser/__test__/sleep.test.js +71 -0
- package/lib/dpParser/__test__/sleepCommon.test.d.ts +1 -0
- package/lib/dpParser/__test__/sleepCommon.test.js +197 -0
- package/lib/dpParser/__test__/timerReport.test.d.ts +1 -0
- package/lib/dpParser/__test__/timerReport.test.js +100 -0
- package/lib/dpParser/__test__/wakeup.test.d.ts +1 -0
- package/lib/dpParser/__test__/wakeup.test.js +69 -0
- package/lib/dpParser/__test__/wakeupCommon.test.d.ts +1 -0
- package/lib/dpParser/__test__/wakeupCommon.test.js +131 -0
- package/lib/dpParser/cycle/index.d.ts +15 -0
- package/lib/dpParser/cycle/index.js +134 -0
- package/lib/dpParser/index.d.ts +23 -0
- package/lib/dpParser/index.js +43 -0
- package/lib/dpParser/random/index.d.ts +15 -0
- package/lib/dpParser/random/index.js +127 -0
- package/lib/dpParser/rhythms.d.ts +41 -0
- package/lib/dpParser/rhythms.js +116 -0
- package/lib/dpParser/rtcTimer.d.ts +17 -0
- package/lib/dpParser/rtcTimer.js +300 -0
- package/lib/dpParser/sleep/index.d.ts +9 -0
- package/lib/dpParser/sleep/index.js +29 -0
- package/lib/dpParser/sleep/sleepCommon.d.ts +11 -0
- package/lib/dpParser/sleep/sleepCommon.js +117 -0
- package/lib/dpParser/sleep/sleepSigmesh.d.ts +0 -0
- package/lib/dpParser/sleep/sleepSigmesh.js +101 -0
- package/lib/dpParser/timerReport.d.ts +11 -0
- package/lib/dpParser/timerReport.js +43 -0
- package/lib/dpParser/utils.d.ts +27 -0
- package/lib/dpParser/utils.js +53 -0
- package/lib/dpParser/wakeup/index.d.ts +10 -0
- package/lib/dpParser/wakeup/index.js +34 -0
- package/lib/dpParser/wakeup/wakeupCommon.d.ts +11 -0
- package/lib/dpParser/wakeup/wakeupCommon.js +106 -0
- package/lib/dpParser/wakeup/wakeupSigmesh.d.ts +15 -0
- package/lib/dpParser/wakeup/wakeupSigmesh.js +86 -0
- package/lib/hooks/__test__/useCommon.test.d.ts +1 -0
- package/lib/hooks/__test__/useCommon.test.js +72 -0
- package/lib/hooks/__test__/useCountdownDp.test.d.ts +1 -0
- package/lib/hooks/__test__/useCountdownDp.test.js +82 -0
- package/lib/hooks/__test__/useCycleDp.test.d.ts +1 -0
- package/lib/hooks/__test__/useCycleDp.test.js +92 -0
- package/lib/hooks/__test__/useRandomDp.test.d.ts +1 -0
- package/lib/hooks/__test__/useRandomDp.test.js +88 -0
- package/lib/hooks/__test__/useRhythmsDp.test.d.ts +1 -0
- package/lib/hooks/__test__/useRhythmsDp.test.js +81 -0
- package/lib/hooks/__test__/useSleepDp.test.d.ts +1 -0
- package/lib/hooks/__test__/useSleepDp.test.js +127 -0
- package/lib/hooks/__test__/useTimeFlush.test.d.ts +1 -0
- package/lib/hooks/__test__/useTimeFlush.test.js +109 -0
- package/lib/hooks/__test__/useTimerDp.test.d.ts +1 -0
- package/lib/hooks/__test__/useTimerDp.test.js +79 -0
- package/lib/hooks/__test__/useTimerOperate.test.d.ts +1 -0
- package/lib/hooks/__test__/useTimerOperate.test.js +286 -0
- package/lib/hooks/__test__/useTimerOperateCloud.test.d.ts +1 -0
- package/lib/hooks/__test__/useTimerOperateCloud.test.js +190 -0
- package/lib/hooks/__test__/useTimerOperateLocal.test.d.ts +1 -0
- package/lib/hooks/__test__/useTimerOperateLocal.test.js +216 -0
- package/lib/hooks/__test__/useTimerReportDp.test.d.ts +1 -0
- package/lib/hooks/__test__/useTimerReportDp.test.js +93 -0
- package/lib/hooks/__test__/useTimerSupport.test.d.ts +1 -0
- package/lib/hooks/__test__/useTimerSupport.test.js +110 -0
- package/lib/hooks/__test__/useWakeUpDp.test.d.ts +1 -0
- package/lib/hooks/__test__/useWakeUpDp.test.js +129 -0
- package/lib/hooks/useBaseLightDp.d.ts +21 -0
- package/lib/hooks/useBaseLightDp.js +165 -0
- package/lib/hooks/useCommon.d.ts +29 -0
- package/lib/hooks/useCommon.js +59 -0
- package/lib/hooks/useCommonSupport.d.ts +25 -0
- package/lib/hooks/useCommonSupport.js +241 -0
- package/lib/hooks/useCountdownDp.d.ts +13 -0
- package/lib/hooks/useCountdownDp.js +28 -0
- package/lib/hooks/useCountdownSupport.d.ts +9 -0
- package/lib/hooks/useCountdownSupport.js +13 -0
- package/lib/hooks/useCycleDp.d.ts +7 -0
- package/lib/hooks/useCycleDp.js +21 -0
- package/lib/hooks/useCycleSupport.d.ts +12 -0
- package/lib/hooks/useCycleSupport.js +16 -0
- package/lib/hooks/useRandomDp.d.ts +7 -0
- package/lib/hooks/useRandomDp.js +21 -0
- package/lib/hooks/useRandomSupport.d.ts +12 -0
- package/lib/hooks/useRandomSupport.js +16 -0
- package/lib/hooks/useRhythmsDp.d.ts +7 -0
- package/lib/hooks/useRhythmsDp.js +23 -0
- package/lib/hooks/useSleepDp.d.ts +6 -0
- package/lib/hooks/useSleepDp.js +21 -0
- package/lib/hooks/useSleepSupport.d.ts +8 -0
- package/lib/hooks/useSleepSupport.js +13 -0
- package/lib/hooks/useTimeFlush.d.ts +8 -0
- package/lib/hooks/useTimeFlush.js +31 -0
- package/lib/hooks/useTimerDp.d.ts +5 -0
- package/lib/hooks/useTimerDp.js +25 -0
- package/lib/hooks/useTimerFlushList.d.ts +11 -0
- package/lib/hooks/useTimerFlushList.js +53 -0
- package/lib/hooks/useTimerOperate.d.ts +68 -0
- package/lib/hooks/useTimerOperate.js +403 -0
- package/lib/hooks/useTimerOperateCloud.d.ts +31 -0
- package/lib/hooks/useTimerOperateCloud.js +233 -0
- package/lib/hooks/useTimerOperateLocal.d.ts +40 -0
- package/lib/hooks/useTimerOperateLocal.js +310 -0
- package/lib/hooks/useTimerReportDp.d.ts +15 -0
- package/lib/hooks/useTimerReportDp.js +48 -0
- package/lib/hooks/useTimerSupport.d.ts +13 -0
- package/lib/hooks/useTimerSupport.js +38 -0
- package/lib/hooks/useWakeUpDp.d.ts +6 -0
- package/lib/hooks/useWakeUpDp.js +21 -0
- package/lib/hooks/useWakeUpSupport.d.ts +8 -0
- package/lib/hooks/useWakeUpSupport.js +13 -0
- package/lib/hooks/useWakeupDp.d.ts +6 -0
- package/lib/hooks/useWakeupDp.js +21 -0
- package/lib/hooks/useWakeupSupport.d.ts +8 -0
- package/lib/hooks/useWakeupSupport.js +13 -0
- package/lib/i18n/index.d.ts +142 -0
- package/lib/i18n/index.js +7 -0
- package/lib/i18n/rhythms.d.ts +73 -0
- package/lib/i18n/rhythms.js +72 -0
- package/lib/i18n/strings.d.ts +73 -0
- package/lib/i18n/strings.js +6 -0
- package/lib/index.d.ts +51 -0
- package/lib/index.js +64 -0
- package/lib/types/countdown.d.ts +3 -0
- package/lib/types/countdown.js +1 -0
- package/lib/types/cycle.d.ts +22 -0
- package/lib/types/cycle.js +1 -0
- package/lib/types/global.d.ts +9 -0
- package/lib/types/index.d.ts +331 -0
- package/lib/types/index.js +76 -0
- package/lib/types/random.d.ts +20 -0
- package/lib/types/random.js +1 -0
- package/lib/types/rhythms.d.ts +79 -0
- package/lib/types/rhythms.js +15 -0
- package/lib/types/sleep.d.ts +36 -0
- package/lib/types/sleep.js +1 -0
- package/lib/types/timer.d.ts +107 -0
- package/lib/types/timer.js +1 -0
- package/lib/types/wakeup.d.ts +38 -0
- package/lib/types/wakeup.js +1 -0
- package/lib/utils/ScheduleCache.d.ts +19 -0
- package/lib/utils/ScheduleCache.js +39 -0
- package/lib/utils/ScheduleCloudProperty.d.ts +75 -0
- package/lib/utils/ScheduleCloudProperty.js +220 -0
- package/lib/utils/ScheduleDataSync.d.ts +82 -0
- package/lib/utils/ScheduleDataSync.js +127 -0
- package/lib/utils/ScheduleEmit.d.ts +67 -0
- package/lib/utils/ScheduleEmit.js +61 -0
- package/lib/utils/ScheduleLogger.d.ts +19 -0
- package/lib/utils/ScheduleLogger.js +71 -0
- package/lib/utils/ScheduleSupport.d.ts +131 -0
- package/lib/utils/ScheduleSupport.js +373 -0
- package/lib/utils/ScheduleUtils.d.ts +12 -0
- package/lib/utils/ScheduleUtils.js +51 -0
- package/lib/utils/__test__/ScheduleCloudProperty.test.d.ts +1 -0
- package/lib/utils/__test__/ScheduleCloudProperty.test.js +320 -0
- package/lib/utils/__test__/ScheduleSupport.test.d.ts +1 -0
- package/lib/utils/__test__/ScheduleSupport.test.js +211 -0
- package/lib/utils/__test__/ScheduleUtils.test.d.ts +1 -0
- package/lib/utils/__test__/ScheduleUtils.test.js +119 -0
- package/lib/utils/__test__/common.test.d.ts +1 -0
- package/lib/utils/__test__/common.test.js +147 -0
- package/lib/utils/__test__/storage.test.d.ts +1 -0
- package/lib/utils/__test__/storage.test.js +98 -0
- package/lib/utils/__test__/time.test.d.ts +1 -0
- package/lib/utils/__test__/time.test.js +146 -0
- package/lib/utils/common.d.ts +23 -0
- package/lib/utils/common.js +109 -0
- package/lib/utils/dpState.d.ts +5 -0
- package/lib/utils/dpState.js +27 -0
- package/lib/utils/getCachedSystemInfo.d.ts +39 -0
- package/lib/utils/getCachedSystemInfo.js +20 -0
- package/lib/utils/isInIDE.d.ts +1 -0
- package/lib/utils/isInIDE.js +5 -0
- package/lib/utils/storage.d.ts +5 -0
- package/lib/utils/storage.js +32 -0
- package/lib/utils/time.d.ts +40 -0
- package/lib/utils/time.js +84 -0
- package/package.json +78 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface TWakeUpNodeSigmesh {
|
|
2
|
+
onOff: boolean;
|
|
3
|
+
loops: string;
|
|
4
|
+
step: number;
|
|
5
|
+
hour: number;
|
|
6
|
+
minute: number;
|
|
7
|
+
brightness: number;
|
|
8
|
+
temperature: number;
|
|
9
|
+
duration: number;
|
|
10
|
+
index: number;
|
|
11
|
+
time?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface TWakeUpDataSigmesh {
|
|
14
|
+
version: number;
|
|
15
|
+
dataMode: '01' | '02' | '03';
|
|
16
|
+
length: number;
|
|
17
|
+
nodes: TWakeUpNodeSigmesh[];
|
|
18
|
+
}
|
|
19
|
+
export interface TWakeUpNode {
|
|
20
|
+
onOff: boolean;
|
|
21
|
+
loops: string;
|
|
22
|
+
step: number;
|
|
23
|
+
hour: number;
|
|
24
|
+
minute: number;
|
|
25
|
+
hue: number;
|
|
26
|
+
saturation: number;
|
|
27
|
+
value: number;
|
|
28
|
+
brightness: number;
|
|
29
|
+
temperature: number;
|
|
30
|
+
duration: number;
|
|
31
|
+
index: number;
|
|
32
|
+
time?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface TWakeUpData {
|
|
35
|
+
version: number;
|
|
36
|
+
number: 0 | 1 | 2 | 3 | 4;
|
|
37
|
+
nodes: TWakeUpNode[];
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const ScheduleCache: Map<string, any>;
|
|
2
|
+
export declare function getScheduleCache<T>(key: string): T;
|
|
3
|
+
export declare function getScheduleCacheAll(): Map<string, any>;
|
|
4
|
+
export declare function setScheduleCache<T>(key: string, value: T): void;
|
|
5
|
+
export declare function clearScheduleCache(): void;
|
|
6
|
+
export declare function removeScheduleCache(key: string): void;
|
|
7
|
+
type TDevIdOrGroupIdCache = {
|
|
8
|
+
devId: string;
|
|
9
|
+
groupId: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 获取设备id和分组id缓存数据
|
|
13
|
+
*/
|
|
14
|
+
export declare const devIdOrGroupIdCache: {
|
|
15
|
+
__value: TDevIdOrGroupIdCache;
|
|
16
|
+
set(devId: string, groupId?: string): void;
|
|
17
|
+
get(): TDevIdOrGroupIdCache;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { scheduleLogger as ScheduleLogger } from './ScheduleLogger';
|
|
2
|
+
export const ScheduleCache = new Map();
|
|
3
|
+
export function getScheduleCache(key) {
|
|
4
|
+
return ScheduleCache.get(key);
|
|
5
|
+
}
|
|
6
|
+
export function getScheduleCacheAll() {
|
|
7
|
+
return ScheduleCache;
|
|
8
|
+
}
|
|
9
|
+
export function setScheduleCache(key, value) {
|
|
10
|
+
ScheduleLogger.debug('setScheduleCache', `key=>${key}`, 'value=>', value);
|
|
11
|
+
ScheduleCache.set(key, value);
|
|
12
|
+
}
|
|
13
|
+
export function clearScheduleCache() {
|
|
14
|
+
ScheduleLogger.debug('clearScheduleCache');
|
|
15
|
+
ScheduleCache.clear();
|
|
16
|
+
}
|
|
17
|
+
export function removeScheduleCache(key) {
|
|
18
|
+
ScheduleLogger.debug('removeScheduleCache', key);
|
|
19
|
+
ScheduleCache.delete(key);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 获取设备id和分组id缓存数据
|
|
23
|
+
*/
|
|
24
|
+
export const devIdOrGroupIdCache = {
|
|
25
|
+
__value: {
|
|
26
|
+
devId: '',
|
|
27
|
+
groupId: ''
|
|
28
|
+
},
|
|
29
|
+
set(devId, groupId) {
|
|
30
|
+
ScheduleLogger.debug('set devIdOrGroupIdCache:', `devId => ${devId}, groupId => ${groupId}`);
|
|
31
|
+
this.__value = {
|
|
32
|
+
devId,
|
|
33
|
+
groupId
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
get() {
|
|
37
|
+
return this.__value;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { TTimerDataAdd, TTimerDataUpdate } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 保存云端定时任务列表
|
|
4
|
+
*/
|
|
5
|
+
export declare const saveList: (dataList: {
|
|
6
|
+
code: string;
|
|
7
|
+
value: any;
|
|
8
|
+
}[]) => Promise<boolean>;
|
|
9
|
+
export declare const save: (code: string, value: any) => Promise<boolean>;
|
|
10
|
+
export declare const update: (code: string, value: any) => Promise<boolean>;
|
|
11
|
+
export type IGetDevPropertyResponse = {
|
|
12
|
+
/**
|
|
13
|
+
* 业务类型
|
|
14
|
+
*/
|
|
15
|
+
bizType: number;
|
|
16
|
+
/**
|
|
17
|
+
* 设备自定义属性 code
|
|
18
|
+
*/
|
|
19
|
+
code: string;
|
|
20
|
+
/**
|
|
21
|
+
* 设备 ID
|
|
22
|
+
*/
|
|
23
|
+
devId: string;
|
|
24
|
+
/**
|
|
25
|
+
* 创建时间
|
|
26
|
+
*/
|
|
27
|
+
gmtCreate: number;
|
|
28
|
+
/**
|
|
29
|
+
* 修改时间
|
|
30
|
+
*/
|
|
31
|
+
gmtModified: number;
|
|
32
|
+
/**
|
|
33
|
+
* 唯一标识
|
|
34
|
+
*/
|
|
35
|
+
id: string;
|
|
36
|
+
/**
|
|
37
|
+
* 保存设备属性时的配置规则
|
|
38
|
+
*/
|
|
39
|
+
type: string;
|
|
40
|
+
/**
|
|
41
|
+
* 属性值
|
|
42
|
+
*/
|
|
43
|
+
value: string;
|
|
44
|
+
};
|
|
45
|
+
export declare const get: (code: string) => Promise<IGetDevPropertyResponse>;
|
|
46
|
+
export declare const getDevAllProperty: (params: {
|
|
47
|
+
code?: string;
|
|
48
|
+
devId: string;
|
|
49
|
+
} | {
|
|
50
|
+
code?: string;
|
|
51
|
+
groupId: string;
|
|
52
|
+
}) => Promise<any>;
|
|
53
|
+
export declare const getAll: () => Promise<{
|
|
54
|
+
properties: Record<string, any>;
|
|
55
|
+
}>;
|
|
56
|
+
export declare const remove: (timerId: string, code: string) => Promise<boolean>;
|
|
57
|
+
export declare const useCloudProperty: (code: string) => {
|
|
58
|
+
get: () => Promise<IGetDevPropertyResponse | null>;
|
|
59
|
+
getAll: () => Promise<{
|
|
60
|
+
properties: Record<string, any>;
|
|
61
|
+
}>;
|
|
62
|
+
remove: (timerId: string) => Promise<boolean>;
|
|
63
|
+
set: (value: TTimerDataAdd) => Promise<boolean>;
|
|
64
|
+
update: (value: TTimerDataUpdate) => Promise<boolean>;
|
|
65
|
+
};
|
|
66
|
+
export declare const useLocalTimerCloudProperty: (code?: string) => {
|
|
67
|
+
getAll: () => Promise<{
|
|
68
|
+
properties: Record<string, any>;
|
|
69
|
+
}>;
|
|
70
|
+
remove: (timerId: string) => Promise<boolean>;
|
|
71
|
+
set: (value: TTimerDataAdd, timerId: string) => Promise<boolean>;
|
|
72
|
+
update: (value: TTimerDataUpdate) => Promise<boolean>;
|
|
73
|
+
updateStatus: (timerId: string, status: boolean) => Promise<boolean>;
|
|
74
|
+
updateList: (value: TTimerDataUpdate[]) => Promise<boolean>;
|
|
75
|
+
};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
3
|
+
import "core-js/modules/esnext.iterator.filter.js";
|
|
4
|
+
import "core-js/modules/esnext.iterator.find.js";
|
|
5
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
|
6
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
7
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
8
|
+
import { getDevProperty, saveDevProperty, requestCloud, getDeviceProperty } from '@ray-js/ray';
|
|
9
|
+
import { useCallback } from 'react';
|
|
10
|
+
import { devIdOrGroupIdCache } from './ScheduleCache';
|
|
11
|
+
import { scheduleLogger as ScheduleLogger } from './ScheduleLogger';
|
|
12
|
+
import { getTimerState } from '../context/timer';
|
|
13
|
+
import { findMinMissingNum } from './common';
|
|
14
|
+
import { LOCAL_TIMER_CATEGORY } from '../constant';
|
|
15
|
+
const bizType = 99;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 保存云端定时任务列表
|
|
19
|
+
*/
|
|
20
|
+
export const saveList = dataList => {
|
|
21
|
+
const {
|
|
22
|
+
devId
|
|
23
|
+
} = devIdOrGroupIdCache.get();
|
|
24
|
+
const propertyList = JSON.stringify(dataList);
|
|
25
|
+
return saveDevProperty({
|
|
26
|
+
devId,
|
|
27
|
+
bizType,
|
|
28
|
+
propertyList
|
|
29
|
+
}).then(data => {
|
|
30
|
+
ScheduleLogger.debug('saveDevProperty code res: ', data);
|
|
31
|
+
return data;
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
export const save = (code, value) => {
|
|
35
|
+
const {
|
|
36
|
+
devId
|
|
37
|
+
} = devIdOrGroupIdCache.get();
|
|
38
|
+
const propertyList = JSON.stringify([{
|
|
39
|
+
code,
|
|
40
|
+
value
|
|
41
|
+
}]);
|
|
42
|
+
return saveDevProperty({
|
|
43
|
+
devId,
|
|
44
|
+
bizType,
|
|
45
|
+
propertyList
|
|
46
|
+
}).then(data => {
|
|
47
|
+
ScheduleLogger.debug('saveDevProperty code res: ', code, data);
|
|
48
|
+
return data;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
export const update = (code, value) => {
|
|
52
|
+
return save(code, value);
|
|
53
|
+
};
|
|
54
|
+
export const get = code => {
|
|
55
|
+
const {
|
|
56
|
+
devId
|
|
57
|
+
} = devIdOrGroupIdCache.get();
|
|
58
|
+
return getDevProperty({
|
|
59
|
+
devId,
|
|
60
|
+
code: code,
|
|
61
|
+
bizType
|
|
62
|
+
}).then(res => {
|
|
63
|
+
ScheduleLogger.debug('getDevProperty code res: ', code, res);
|
|
64
|
+
const _data = (res || []).filter(i => i.code === code && i.value !== null);
|
|
65
|
+
return _data && _data.length > 0 ? _data[0] : null;
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
export const getDevAllProperty = params => new Promise((resolve, reject) => {
|
|
69
|
+
const groupId = 'groupId' in params ? params.groupId : undefined;
|
|
70
|
+
const devId = 'devId' in params ? params.devId : undefined;
|
|
71
|
+
const bizType = groupId ? 1 : 0;
|
|
72
|
+
requestCloud({
|
|
73
|
+
api: 's.m.dev.property.get',
|
|
74
|
+
data: {
|
|
75
|
+
bizType,
|
|
76
|
+
devId: groupId || devId
|
|
77
|
+
},
|
|
78
|
+
version: '2.0',
|
|
79
|
+
success: resolve,
|
|
80
|
+
fail: reject
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
export const getAll = () => {
|
|
84
|
+
const {
|
|
85
|
+
devId,
|
|
86
|
+
groupId
|
|
87
|
+
} = devIdOrGroupIdCache.get();
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
// 对外使用
|
|
90
|
+
// getGroupProperty({
|
|
91
|
+
// groupId,
|
|
92
|
+
// success(res) {
|
|
93
|
+
// console.warn('getGroupProperty res:', res);
|
|
94
|
+
// resolve({
|
|
95
|
+
// properties: res?.result || res || {},
|
|
96
|
+
// });
|
|
97
|
+
// },
|
|
98
|
+
// fail(err) {
|
|
99
|
+
// console.warn('getGroupProperty err:', err);
|
|
100
|
+
// reject(err);
|
|
101
|
+
// },
|
|
102
|
+
// });
|
|
103
|
+
if (!groupId) {
|
|
104
|
+
getDeviceProperty({
|
|
105
|
+
deviceId: devId,
|
|
106
|
+
success: res => {
|
|
107
|
+
ScheduleLogger.debug('getDeviceProperty res: ', res);
|
|
108
|
+
resolve(res);
|
|
109
|
+
},
|
|
110
|
+
fail: error => {
|
|
111
|
+
ScheduleLogger.error('getDeviceProperty fail:', error);
|
|
112
|
+
reject(error);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
getDevAllProperty({
|
|
118
|
+
devId,
|
|
119
|
+
groupId
|
|
120
|
+
}).then(res => {
|
|
121
|
+
ScheduleLogger.debug('getDevAllProperty res: ', res);
|
|
122
|
+
resolve({
|
|
123
|
+
properties: (res === null || res === void 0 ? void 0 : res.properties) || res || {}
|
|
124
|
+
});
|
|
125
|
+
}).catch(err => {
|
|
126
|
+
ScheduleLogger.error('getDevAllProperty fail:', err);
|
|
127
|
+
reject(err);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
export const remove = (timerId, code) => {
|
|
132
|
+
const {
|
|
133
|
+
devId
|
|
134
|
+
} = devIdOrGroupIdCache.get();
|
|
135
|
+
ScheduleLogger.debug('remove', timerId, code);
|
|
136
|
+
const propertyList = JSON.stringify([{
|
|
137
|
+
code,
|
|
138
|
+
value: null
|
|
139
|
+
}]);
|
|
140
|
+
return saveDevProperty({
|
|
141
|
+
devId,
|
|
142
|
+
bizType,
|
|
143
|
+
propertyList
|
|
144
|
+
}).then(data => {
|
|
145
|
+
ScheduleLogger.debug('saveDevProperty code res: ', code, data);
|
|
146
|
+
return data;
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
export const useCloudProperty = code => {
|
|
150
|
+
const _get = useCallback(() => {
|
|
151
|
+
return get(code);
|
|
152
|
+
}, [code]);
|
|
153
|
+
const _getAll = useCallback(() => {
|
|
154
|
+
return getAll();
|
|
155
|
+
}, []);
|
|
156
|
+
const _set = useCallback(value => {
|
|
157
|
+
return save(code, value);
|
|
158
|
+
}, [code]);
|
|
159
|
+
const _update = useCallback(value => {
|
|
160
|
+
return update(code, value);
|
|
161
|
+
}, [code]);
|
|
162
|
+
const _remove = useCallback(timerId => {
|
|
163
|
+
return remove(timerId, code);
|
|
164
|
+
}, [code]);
|
|
165
|
+
return {
|
|
166
|
+
get: _get,
|
|
167
|
+
set: _set,
|
|
168
|
+
update: _update,
|
|
169
|
+
remove: _remove,
|
|
170
|
+
getAll: _getAll
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
export const useLocalTimerCloudProperty = function () {
|
|
174
|
+
let code = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : LOCAL_TIMER_CATEGORY;
|
|
175
|
+
const {
|
|
176
|
+
getAll
|
|
177
|
+
} = useCloudProperty(code);
|
|
178
|
+
return {
|
|
179
|
+
getAll,
|
|
180
|
+
remove: timerId => {
|
|
181
|
+
// 如果直接给 null 会报错失败
|
|
182
|
+
return save(`${code}_${timerId}`, 'null');
|
|
183
|
+
},
|
|
184
|
+
set: (value, timerId) => {
|
|
185
|
+
const {
|
|
186
|
+
rtcTimerList = []
|
|
187
|
+
} = getTimerState();
|
|
188
|
+
const minTimerId = timerId || findMinMissingNum(rtcTimerList.map(i => +i.timerId));
|
|
189
|
+
return save(`${code}_${minTimerId}`, value);
|
|
190
|
+
},
|
|
191
|
+
update: value => {
|
|
192
|
+
const {
|
|
193
|
+
timerId
|
|
194
|
+
} = value;
|
|
195
|
+
return save(`${code}_${timerId}`, value);
|
|
196
|
+
},
|
|
197
|
+
updateList: value => {
|
|
198
|
+
const arrList = [];
|
|
199
|
+
value.forEach(item => {
|
|
200
|
+
const {
|
|
201
|
+
timerId
|
|
202
|
+
} = item;
|
|
203
|
+
arrList.push({
|
|
204
|
+
code: `${code}_${timerId}`,
|
|
205
|
+
value: item
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
return saveList(arrList);
|
|
209
|
+
},
|
|
210
|
+
updateStatus: (timerId, status) => {
|
|
211
|
+
const {
|
|
212
|
+
rtcTimerList = []
|
|
213
|
+
} = getTimerState();
|
|
214
|
+
const current = rtcTimerList.find(i => i.timerId === timerId) || {};
|
|
215
|
+
return save(`${code}_${timerId}`, _objectSpread(_objectSpread({}, current), {}, {
|
|
216
|
+
status
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ERhythmsType } from '../types';
|
|
2
|
+
interface ExtraData {
|
|
3
|
+
rhythmsType?: ERhythmsType;
|
|
4
|
+
timerActionRoute?: string;
|
|
5
|
+
timerActionOpenDpList?: string[];
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 跳转到小程序计划功能页
|
|
10
|
+
* @param params {
|
|
11
|
+
* devId: string; // 设备 id
|
|
12
|
+
* groupId: string; // 群组 id
|
|
13
|
+
* }
|
|
14
|
+
* @param data 需要传递给功能页的数据, 可选, 当前支持 forceSupport、rhythmsType、timerActionRoute、timerActionOpenDpList, 默认 {}
|
|
15
|
+
*
|
|
16
|
+
* @example {
|
|
17
|
+
* const deviceId = 'vdevo174047627833704';
|
|
18
|
+
|
|
19
|
+
const transData = {
|
|
20
|
+
forceSupport: {
|
|
21
|
+
// 正常是根据 dp 是否存在来展示,支持强制不展示,不支持强制展示,因为如果没有对应 dp 的话 功能无法正常运行
|
|
22
|
+
countdown: false, // 倒计时
|
|
23
|
+
rhythms: false, // 生物节律
|
|
24
|
+
sleep: false, // 睡眠
|
|
25
|
+
wakeup: false, // 起床
|
|
26
|
+
cycle: false, // 循环
|
|
27
|
+
random: false, // 随机
|
|
28
|
+
},
|
|
29
|
+
// ERhythmsType.NoNature: 适合吸顶灯 UI 风格; Normal 为标准 UI 风格
|
|
30
|
+
rhythmsType: ERhythmsType.NoNature,
|
|
31
|
+
// 跳转定时执行行为的路由 类似 /pages/xxx/index
|
|
32
|
+
timerActionRoute: '/pages/second/index',
|
|
33
|
+
// 定时执行动作为开时页面传递的 dp 数据,会在 timerActionRoute 页面中获取到对应的 dp 值
|
|
34
|
+
timerActionOpenDpList: ['rtc_timer'],
|
|
35
|
+
};
|
|
36
|
+
navigateToSchedule(
|
|
37
|
+
{
|
|
38
|
+
deviceId,
|
|
39
|
+
groupId: '',
|
|
40
|
+
},
|
|
41
|
+
transData
|
|
42
|
+
);
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
export declare const navigateToSchedule: <T extends ExtraData>(params: {
|
|
47
|
+
deviceId: string;
|
|
48
|
+
groupId: string;
|
|
49
|
+
}, data: {
|
|
50
|
+
forceSupport?: {
|
|
51
|
+
countdown?: boolean;
|
|
52
|
+
rhythms?: boolean;
|
|
53
|
+
sleep?: boolean;
|
|
54
|
+
wakeup?: boolean;
|
|
55
|
+
random?: boolean;
|
|
56
|
+
cycle?: boolean;
|
|
57
|
+
timer?: boolean;
|
|
58
|
+
};
|
|
59
|
+
i18nKeyMap?: Record<string, string | number>;
|
|
60
|
+
timerActionRoute?: string;
|
|
61
|
+
timerActionOpenDpList?: string[];
|
|
62
|
+
}, eventsMap?: {
|
|
63
|
+
timerDataChange?: ((res: {
|
|
64
|
+
type: 'add' | 'delete' | 'edit' | 'cancel';
|
|
65
|
+
data: any;
|
|
66
|
+
}) => void) | undefined;
|
|
67
|
+
} | undefined) => void;
|
|
68
|
+
/**
|
|
69
|
+
* 获取小程序传递给功能页预设数据的 hook
|
|
70
|
+
* @returns Record<string, any>
|
|
71
|
+
*/
|
|
72
|
+
export declare const useScheduleDataFromMiniApp: <T extends ExtraData>() => T;
|
|
73
|
+
/**
|
|
74
|
+
* 功能页与小程序传递数据的事件 key 值
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
export declare const functionalTransDataEventKey = "functionalTransDataGet";
|
|
78
|
+
export declare const navigateToMainApp: (route: string, params?: Record<string, string>, callback?: ((data: {
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
dps: Record<string, any>;
|
|
81
|
+
}) => void) | undefined) => void;
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
|
3
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
4
|
+
import { usePageInstance, navigateTo } from '@ray-js/ray';
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
import { scheduleLogger } from './ScheduleLogger';
|
|
7
|
+
const SCHEDULE_FUNCTIONAL_URL = 'functional://LampScheduleSetFunction/home';
|
|
8
|
+
/**
|
|
9
|
+
* 跳转到小程序计划功能页
|
|
10
|
+
* @param params {
|
|
11
|
+
* devId: string; // 设备 id
|
|
12
|
+
* groupId: string; // 群组 id
|
|
13
|
+
* }
|
|
14
|
+
* @param data 需要传递给功能页的数据, 可选, 当前支持 forceSupport、rhythmsType、timerActionRoute、timerActionOpenDpList, 默认 {}
|
|
15
|
+
*
|
|
16
|
+
* @example {
|
|
17
|
+
* const deviceId = 'vdevo174047627833704';
|
|
18
|
+
|
|
19
|
+
const transData = {
|
|
20
|
+
forceSupport: {
|
|
21
|
+
// 正常是根据 dp 是否存在来展示,支持强制不展示,不支持强制展示,因为如果没有对应 dp 的话 功能无法正常运行
|
|
22
|
+
countdown: false, // 倒计时
|
|
23
|
+
rhythms: false, // 生物节律
|
|
24
|
+
sleep: false, // 睡眠
|
|
25
|
+
wakeup: false, // 起床
|
|
26
|
+
cycle: false, // 循环
|
|
27
|
+
random: false, // 随机
|
|
28
|
+
},
|
|
29
|
+
// ERhythmsType.NoNature: 适合吸顶灯 UI 风格; Normal 为标准 UI 风格
|
|
30
|
+
rhythmsType: ERhythmsType.NoNature,
|
|
31
|
+
// 跳转定时执行行为的路由 类似 /pages/xxx/index
|
|
32
|
+
timerActionRoute: '/pages/second/index',
|
|
33
|
+
// 定时执行动作为开时页面传递的 dp 数据,会在 timerActionRoute 页面中获取到对应的 dp 值
|
|
34
|
+
timerActionOpenDpList: ['rtc_timer'],
|
|
35
|
+
};
|
|
36
|
+
navigateToSchedule(
|
|
37
|
+
{
|
|
38
|
+
deviceId,
|
|
39
|
+
groupId: '',
|
|
40
|
+
},
|
|
41
|
+
transData
|
|
42
|
+
);
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
export const navigateToSchedule = (params, data, eventsMap) => {
|
|
47
|
+
const {
|
|
48
|
+
deviceId,
|
|
49
|
+
groupId
|
|
50
|
+
} = params;
|
|
51
|
+
if (!deviceId && !groupId) {
|
|
52
|
+
throw new Error('devId or groupId is required');
|
|
53
|
+
}
|
|
54
|
+
let scheduleUrl = `${SCHEDULE_FUNCTIONAL_URL}?deviceId=${deviceId}`;
|
|
55
|
+
if (groupId) {
|
|
56
|
+
scheduleUrl = `${SCHEDULE_FUNCTIONAL_URL}?groupId=${groupId}`;
|
|
57
|
+
}
|
|
58
|
+
// 设置预设数据
|
|
59
|
+
ty.presetFunctionalData({
|
|
60
|
+
url: scheduleUrl,
|
|
61
|
+
data
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// 跳转
|
|
65
|
+
navigateTo({
|
|
66
|
+
url: scheduleUrl,
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
events: eventsMap || {},
|
|
69
|
+
success(res) {
|
|
70
|
+
scheduleLogger.debug(' success:', res);
|
|
71
|
+
},
|
|
72
|
+
fail(err) {
|
|
73
|
+
scheduleLogger.error('navigateToSchedule fail:', err);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
let __presetData = null;
|
|
78
|
+
/**
|
|
79
|
+
* 获取小程序传递给功能页预设数据的 hook
|
|
80
|
+
* @returns Record<string, any>
|
|
81
|
+
*/
|
|
82
|
+
export const useScheduleDataFromMiniApp = () => {
|
|
83
|
+
const [data, setData] = useState(__presetData || {});
|
|
84
|
+
const page = usePageInstance();
|
|
85
|
+
const presetData = page.getPresetData();
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
var _Object$keys;
|
|
88
|
+
if (((_Object$keys = Object.keys(presetData || {})) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length) === 0) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
presetData && setData(presetData);
|
|
92
|
+
__presetData = presetData;
|
|
93
|
+
}, [presetData]);
|
|
94
|
+
return data;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 功能页与小程序传递数据的事件 key 值
|
|
99
|
+
*
|
|
100
|
+
*/
|
|
101
|
+
export const functionalTransDataEventKey = 'functionalTransDataGet';
|
|
102
|
+
export const navigateToMainApp = (route, params, callback) => {
|
|
103
|
+
if (!route.startsWith('/')) {
|
|
104
|
+
throw new Error('route must start with /');
|
|
105
|
+
}
|
|
106
|
+
let query = '';
|
|
107
|
+
if (params) {
|
|
108
|
+
Object.keys(params).forEach(key => {
|
|
109
|
+
query += `${key}=${params[key]}&`;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
navigateTo({
|
|
113
|
+
url: `${route}?${query}`,
|
|
114
|
+
// @ts-ignore
|
|
115
|
+
events: {
|
|
116
|
+
[functionalTransDataEventKey](data) {
|
|
117
|
+
callback && callback(data);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
success(res) {
|
|
121
|
+
scheduleLogger.debug('navigateToMainApp success: ', res);
|
|
122
|
+
},
|
|
123
|
+
fail(err) {
|
|
124
|
+
scheduleLogger.error('navigateToMainApp fail:', err);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
type EventHandler = (event?: any, ...args: any[]) => void;
|
|
2
|
+
type WildCardEventHandler = (type: string, event?: any) => void;
|
|
3
|
+
type EventHandlerList = Array<EventHandler>;
|
|
4
|
+
type WildCardEventHandlerList = Array<WildCardEventHandler>;
|
|
5
|
+
type EventHandlerMap = {
|
|
6
|
+
'*'?: WildCardEventHandlerList;
|
|
7
|
+
[type: string]: EventHandlerList;
|
|
8
|
+
};
|
|
9
|
+
/** EMitt: Tiny (~225b) functional event emitter / pubsub.
|
|
10
|
+
* @name emitt
|
|
11
|
+
* @returns {Emitt}
|
|
12
|
+
*/
|
|
13
|
+
export default function emitt(all?: EventHandlerMap): {
|
|
14
|
+
/**
|
|
15
|
+
* Register an event handler for the given type.
|
|
16
|
+
*
|
|
17
|
+
* @param {String} type Type of event to listen for, or `"*"` for all events
|
|
18
|
+
* @param {Function} handler Function to call in response to given event
|
|
19
|
+
* @memberOf emitt
|
|
20
|
+
*/
|
|
21
|
+
on(type: string, handler: EventHandler): void;
|
|
22
|
+
/**
|
|
23
|
+
* Remove an event handler for the given type.
|
|
24
|
+
*
|
|
25
|
+
* @param {String} type Type of event to unregister `handler` from, or `"*"`
|
|
26
|
+
* @param {Function} handler Handler function to remove
|
|
27
|
+
* @memberOf emitt
|
|
28
|
+
*/
|
|
29
|
+
off(type: string, handler: EventHandler): void;
|
|
30
|
+
/**
|
|
31
|
+
* Invoke all handlers for the given type.
|
|
32
|
+
* If present, `"*"` handlers are invoked after type-matched handlers.
|
|
33
|
+
*
|
|
34
|
+
* @param {String} type The event type to invoke
|
|
35
|
+
* @param {any[]} [...event_args] Any values (object is recommended and powerful), passed to each handler
|
|
36
|
+
* @memberOf emitt
|
|
37
|
+
*/
|
|
38
|
+
emit(type: string, ...args: any[]): void;
|
|
39
|
+
};
|
|
40
|
+
export declare const emitter: {
|
|
41
|
+
/**
|
|
42
|
+
* Register an event handler for the given type.
|
|
43
|
+
*
|
|
44
|
+
* @param {String} type Type of event to listen for, or `"*"` for all events
|
|
45
|
+
* @param {Function} handler Function to call in response to given event
|
|
46
|
+
* @memberOf emitt
|
|
47
|
+
*/
|
|
48
|
+
on(type: string, handler: EventHandler): void;
|
|
49
|
+
/**
|
|
50
|
+
* Remove an event handler for the given type.
|
|
51
|
+
*
|
|
52
|
+
* @param {String} type Type of event to unregister `handler` from, or `"*"`
|
|
53
|
+
* @param {Function} handler Handler function to remove
|
|
54
|
+
* @memberOf emitt
|
|
55
|
+
*/
|
|
56
|
+
off(type: string, handler: EventHandler): void;
|
|
57
|
+
/**
|
|
58
|
+
* Invoke all handlers for the given type.
|
|
59
|
+
* If present, `"*"` handlers are invoked after type-matched handlers.
|
|
60
|
+
*
|
|
61
|
+
* @param {String} type The event type to invoke
|
|
62
|
+
* @param {any[]} [...event_args] Any values (object is recommended and powerful), passed to each handler
|
|
63
|
+
* @memberOf emitt
|
|
64
|
+
*/
|
|
65
|
+
emit(type: string, ...args: any[]): void;
|
|
66
|
+
};
|
|
67
|
+
export {};
|