@enonic-types/lib-event 0.1.1 → 7.11.0-B1
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/event.d.ts +84 -84
- package/package.json +32 -32
package/event.d.ts
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
interface XpLibraries {
|
|
3
|
-
'/lib/xp/event': typeof import('./event');
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
export interface ListenerParams<EventData extends object = EnonicEventData> {
|
|
7
|
-
/**
|
|
8
|
-
* Event type pattern
|
|
9
|
-
*/
|
|
10
|
-
type: EnonicEventTypes;
|
|
11
|
-
/**
|
|
12
|
-
* Callback event listener
|
|
13
|
-
*/
|
|
14
|
-
callback: (event: EnonicEvent<EventData>) => void;
|
|
15
|
-
/**
|
|
16
|
-
* Local events only (default to false)
|
|
17
|
-
*/
|
|
18
|
-
localOnly?: boolean;
|
|
19
|
-
}
|
|
20
|
-
export interface SendParams {
|
|
21
|
-
/**
|
|
22
|
-
* Event type
|
|
23
|
-
*/
|
|
24
|
-
type: EnonicEventTypes;
|
|
25
|
-
/**
|
|
26
|
-
* `true` if it should be distributed in cluster
|
|
27
|
-
*/
|
|
28
|
-
distributed?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Additional data for event.
|
|
31
|
-
*/
|
|
32
|
-
data?: object;
|
|
33
|
-
}
|
|
34
|
-
export interface EnonicEvent<EventData extends object = EnonicEventData> {
|
|
35
|
-
readonly type: EnonicEventTypes;
|
|
36
|
-
readonly timestamp: number;
|
|
37
|
-
readonly localOrigin: boolean;
|
|
38
|
-
readonly distributed: boolean;
|
|
39
|
-
readonly data: EventData;
|
|
40
|
-
}
|
|
41
|
-
export interface EnonicEventData {
|
|
42
|
-
readonly nodes: ReadonlyArray<EnonicEventDataNode>;
|
|
43
|
-
readonly state?: string;
|
|
44
|
-
}
|
|
45
|
-
export interface EnonicEventDataNode {
|
|
46
|
-
readonly id: string;
|
|
47
|
-
readonly path: string;
|
|
48
|
-
readonly branch: string;
|
|
49
|
-
readonly repo: string;
|
|
50
|
-
readonly newPath?: string;
|
|
51
|
-
}
|
|
52
|
-
declare type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
|
|
53
|
-
export declare type EnonicEventTypes = LiteralUnion<string>;
|
|
54
|
-
/**
|
|
55
|
-
* Event functions.
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* var eventLib = require('/lib/xp/event');
|
|
59
|
-
*
|
|
60
|
-
* @module event
|
|
61
|
-
*/
|
|
62
|
-
/**
|
|
63
|
-
* This function adds a event listener.
|
|
64
|
-
*
|
|
65
|
-
* @example-ref examples/event/listener.js
|
|
66
|
-
*
|
|
67
|
-
* @param {object} params Listener parameters.
|
|
68
|
-
* @param {string} params.type Event type pattern.
|
|
69
|
-
* @param {function} params.callback Callback event listener.
|
|
70
|
-
* @param {boolean} params.localOnly Local events only (default to false).
|
|
71
|
-
*/
|
|
72
|
-
export declare function listener<EventData extends object = EnonicEventData>(params: ListenerParams<EventData>): void;
|
|
73
|
-
/**
|
|
74
|
-
* This function sends a custom event. All custom events are prefixed 'custom.'.
|
|
75
|
-
*
|
|
76
|
-
* @example-ref examples/event/send.js
|
|
77
|
-
*
|
|
78
|
-
* @param {object} event Event to send.
|
|
79
|
-
* @param {string} event.type Event type.
|
|
80
|
-
* @param {boolean} event.distributed True if it should be distributed in cluster.
|
|
81
|
-
* @param {object} event.data Additional data for event.
|
|
82
|
-
*/
|
|
83
|
-
export declare function send(event: SendParams): void;
|
|
84
|
-
export {};
|
|
1
|
+
declare global {
|
|
2
|
+
interface XpLibraries {
|
|
3
|
+
'/lib/xp/event': typeof import('./event');
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export interface ListenerParams<EventData extends object = EnonicEventData> {
|
|
7
|
+
/**
|
|
8
|
+
* Event type pattern
|
|
9
|
+
*/
|
|
10
|
+
type: EnonicEventTypes;
|
|
11
|
+
/**
|
|
12
|
+
* Callback event listener
|
|
13
|
+
*/
|
|
14
|
+
callback: (event: EnonicEvent<EventData>) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Local events only (default to false)
|
|
17
|
+
*/
|
|
18
|
+
localOnly?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface SendParams {
|
|
21
|
+
/**
|
|
22
|
+
* Event type
|
|
23
|
+
*/
|
|
24
|
+
type: EnonicEventTypes;
|
|
25
|
+
/**
|
|
26
|
+
* `true` if it should be distributed in cluster
|
|
27
|
+
*/
|
|
28
|
+
distributed?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Additional data for event.
|
|
31
|
+
*/
|
|
32
|
+
data?: object;
|
|
33
|
+
}
|
|
34
|
+
export interface EnonicEvent<EventData extends object = EnonicEventData> {
|
|
35
|
+
readonly type: EnonicEventTypes;
|
|
36
|
+
readonly timestamp: number;
|
|
37
|
+
readonly localOrigin: boolean;
|
|
38
|
+
readonly distributed: boolean;
|
|
39
|
+
readonly data: EventData;
|
|
40
|
+
}
|
|
41
|
+
export interface EnonicEventData {
|
|
42
|
+
readonly nodes: ReadonlyArray<EnonicEventDataNode>;
|
|
43
|
+
readonly state?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface EnonicEventDataNode {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly path: string;
|
|
48
|
+
readonly branch: string;
|
|
49
|
+
readonly repo: string;
|
|
50
|
+
readonly newPath?: string;
|
|
51
|
+
}
|
|
52
|
+
declare type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
|
|
53
|
+
export declare type EnonicEventTypes = LiteralUnion<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Event functions.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* var eventLib = require('/lib/xp/event');
|
|
59
|
+
*
|
|
60
|
+
* @module event
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* This function adds a event listener.
|
|
64
|
+
*
|
|
65
|
+
* @example-ref examples/event/listener.js
|
|
66
|
+
*
|
|
67
|
+
* @param {object} params Listener parameters.
|
|
68
|
+
* @param {string} params.type Event type pattern.
|
|
69
|
+
* @param {function} params.callback Callback event listener.
|
|
70
|
+
* @param {boolean} params.localOnly Local events only (default to false).
|
|
71
|
+
*/
|
|
72
|
+
export declare function listener<EventData extends object = EnonicEventData>(params: ListenerParams<EventData>): void;
|
|
73
|
+
/**
|
|
74
|
+
* This function sends a custom event. All custom events are prefixed 'custom.'.
|
|
75
|
+
*
|
|
76
|
+
* @example-ref examples/event/send.js
|
|
77
|
+
*
|
|
78
|
+
* @param {object} event Event to send.
|
|
79
|
+
* @param {string} event.type Event type.
|
|
80
|
+
* @param {boolean} event.distributed True if it should be distributed in cluster.
|
|
81
|
+
* @param {object} event.data Additional data for event.
|
|
82
|
+
*/
|
|
83
|
+
export declare function send(event: SendParams): void;
|
|
84
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@enonic-types/lib-event",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Type definitions for lib-event.",
|
|
5
|
-
"types": "event.d.ts",
|
|
6
|
-
"files": [
|
|
7
|
-
"event.d.ts"
|
|
8
|
-
],
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/enonic/xp.git#master"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"enonic",
|
|
15
|
-
"enonic-xp",
|
|
16
|
-
"lib-event",
|
|
17
|
-
"event",
|
|
18
|
-
"types",
|
|
19
|
-
"typescript"
|
|
20
|
-
],
|
|
21
|
-
"contributors": [
|
|
22
|
-
"Mikita Taukachou <edloidas@gmail.com> (https://edloidas.github.io/)"
|
|
23
|
-
],
|
|
24
|
-
"license": "Apache-2.0",
|
|
25
|
-
"bugs": {
|
|
26
|
-
"url": "https://github.com/enonic/xp/issues"
|
|
27
|
-
},
|
|
28
|
-
"homepage": "https://github.com/enonic/xp/tree/master#readme",
|
|
29
|
-
"publishConfig": {
|
|
30
|
-
"access": "public"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@enonic-types/lib-event",
|
|
3
|
+
"version": "7.11.0-B1",
|
|
4
|
+
"description": "Type definitions for lib-event.",
|
|
5
|
+
"types": "event.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"event.d.ts"
|
|
8
|
+
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/enonic/xp.git#master"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"enonic",
|
|
15
|
+
"enonic-xp",
|
|
16
|
+
"lib-event",
|
|
17
|
+
"event",
|
|
18
|
+
"types",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
"contributors": [
|
|
22
|
+
"Mikita Taukachou <edloidas@gmail.com> (https://edloidas.github.io/)"
|
|
23
|
+
],
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/enonic/xp/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/enonic/xp/tree/master#readme",
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
}
|
|
32
|
+
}
|