openfin-notifications 1.25.1 → 2.0.0-alpha-2680
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 +2 -0
- package/dist/client/EventRouter.d.ts +6 -1
- package/dist/client/actions.d.ts +6 -11
- package/dist/client/auto-launch.d.ts +1 -0
- package/dist/client/channel-client.d.ts +7 -0
- package/dist/client/channel-client.spec.d.ts +1 -0
- package/dist/client/connection.d.ts +3 -21
- package/dist/client/controls.d.ts +3 -9
- package/dist/client/index.d.ts +2 -392
- package/dist/client/indicator.d.ts +0 -2
- package/dist/client/internal.d.ts +20 -14
- package/dist/client/log.d.ts +11 -0
- package/dist/client/log.spec.d.ts +1 -0
- package/dist/client/main.d.ts +392 -0
- package/dist/client/openfin-notifications.js +1 -1
- package/dist/client/register.d.ts +27 -0
- package/dist/client/register.spec.d.ts +1 -0
- package/dist/client/templates/BaseNotificationOptions.d.ts +6 -8
- package/dist/client/templates/BaseUpdatableNotificationOptions.d.ts +1 -1
- package/dist/client/templates/templates.d.ts +5 -9
- package/dist/client/without-auto-launch.d.ts +2 -0
- package/dist/client/without-auto-launch.js +1 -0
- package/package.json +20 -5
- package/dist/client/platform.d.ts +0 -77
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# OpenFin Notification Center
|
|
4
4
|
|
|
5
|
+
### This library is deprecated. We will stop publishing updates to it after July 2024. Use [@openfin/workspace/notifications](https://www.npmjs.com/package/@openfin/workspace) instead.
|
|
6
|
+
|
|
5
7
|
## Overview
|
|
6
8
|
|
|
7
9
|
The OpenFin Notification Center provides developers with a uniform way to create, display and organize desktop notifications as well as responding to notification events.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Acts as a central point for routing all events received from the provider.
|
|
7
7
|
*/
|
|
8
8
|
import { EventEmitter } from 'events';
|
|
9
|
-
import { TransportMappings, TransportMemberMappings } from './internal';
|
|
9
|
+
import { TransportMappings, TransportMemberMappings, Events } from './internal';
|
|
10
10
|
export interface EventSpecification {
|
|
11
11
|
type: string;
|
|
12
12
|
}
|
|
@@ -41,4 +41,9 @@ export declare class EventRouter<E extends EventSpecification> {
|
|
|
41
41
|
registerDeserializer<T extends E>(eventType: T['type'], deserializer: EventDeserializer<E, T>): void;
|
|
42
42
|
dispatchEvent<T extends E>(event: Targeted<Transport<T>>): void;
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* The event emitter to emit events received from the service. All addEventListeners will tap into this.
|
|
46
|
+
*/
|
|
47
|
+
export declare const eventEmitter: EventEmitter;
|
|
48
|
+
export declare function getEventRouter(): EventRouter<Events>;
|
|
44
49
|
export {};
|
package/dist/client/actions.d.ts
CHANGED
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
*
|
|
97
97
|
* @hidden
|
|
98
98
|
*/
|
|
99
|
-
import { CustomData } from '
|
|
99
|
+
import { CustomData } from './main';
|
|
100
100
|
/**
|
|
101
101
|
* Denotes a field as being an action. Defining this field (with a non-`undefined` value) will result in actions being
|
|
102
102
|
* raised and sent back to the source application when the corresponding event happens.
|
|
@@ -104,12 +104,8 @@ import { CustomData } from '.';
|
|
|
104
104
|
* For example, providing a value for the `onClick` field of {@link ButtonOptions} will result in a
|
|
105
105
|
* {@link NotificationActionEvent|`notification-action`} event being fired when that button is clicked.
|
|
106
106
|
*
|
|
107
|
-
*
|
|
108
|
-
* and must
|
|
109
|
-
* limited programmatic creation of these results, for use in situations where static result data isn't sufficient.
|
|
110
|
-
*
|
|
111
|
-
* The generic parameters of this type are for future expansion. Future versions of the service will allow for more
|
|
112
|
-
* control over the handling of actions.
|
|
107
|
+
* The `NotificationActionResult returned back to an application is static
|
|
108
|
+
* and must be defined at the point where the notification is created.
|
|
113
109
|
*/
|
|
114
110
|
export declare type ActionDeclaration<T extends never, E extends never> = NotificationActionResult;
|
|
115
111
|
/**
|
|
@@ -120,7 +116,7 @@ export declare type ActionDeclaration<T extends never, E extends never> = Notifi
|
|
|
120
116
|
* Since this type is entirely application-specific, the type is used in these definitions. However, there is an
|
|
121
117
|
* optional generic argument here, which can be used if an application were to define its own conventions for the shape
|
|
122
118
|
* of this field (which is recommended). To make use of this, define a `notification-action` handler that includes the
|
|
123
|
-
* application-defined type as a template argument. This type is then
|
|
119
|
+
* application-defined type as a template argument. This type is then propagated up to {@link NotificationActionEvent}.
|
|
124
120
|
* The example below demonstrates this, using the same use-case as at the top of this page.
|
|
125
121
|
*
|
|
126
122
|
* ```ts
|
|
@@ -153,8 +149,7 @@ export declare type NotificationActionResult<T = CustomData> = T;
|
|
|
153
149
|
*/
|
|
154
150
|
export declare enum ActionTrigger {
|
|
155
151
|
/**
|
|
156
|
-
* The user interacted with one of the controls
|
|
157
|
-
* other control types will be added in future releases.
|
|
152
|
+
* The user interacted with one of the controls in the notification: a button or an actionable fragment.
|
|
158
153
|
*/
|
|
159
154
|
CONTROL = "control",
|
|
160
155
|
/**
|
|
@@ -173,7 +168,7 @@ export declare enum ActionTrigger {
|
|
|
173
168
|
/**
|
|
174
169
|
* The action was triggered programmatically by an application.
|
|
175
170
|
*
|
|
176
|
-
* *Not currently supported
|
|
171
|
+
* *Not currently supported*
|
|
177
172
|
*/
|
|
178
173
|
PROGRAMMATIC = "programmatic"
|
|
179
174
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type OpenFin from '@openfin/core';
|
|
2
|
+
export declare const initAwaitedChannelClient: () => {
|
|
3
|
+
channelClientPromise: Promise<OpenFin.ChannelClient>;
|
|
4
|
+
isInit: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const clearAwaitedChannelClient: () => void;
|
|
7
|
+
export declare const getChannelClient: () => Promise<OpenFin.ChannelClient>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type OpenFin from '@openfin/core';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* File contains vars used to establish service connection between client and provider.
|
|
8
|
-
*
|
|
9
|
-
* These are separated out from 'internal.ts' as including these from provider code will cause the provider to connect
|
|
10
|
-
* to itself.
|
|
11
|
-
*
|
|
12
|
-
* These types are a part of the client, but are not required by applications wishing to interact with the service.
|
|
13
|
-
* This file is excluded from the public-facing TypeScript documentation.
|
|
14
|
-
*/
|
|
15
|
-
import { EventEmitter } from 'events';
|
|
16
|
-
import { APITopic, API, Events } from './internal';
|
|
17
|
-
import { EventRouter } from './EventRouter';
|
|
18
|
-
/**
|
|
19
|
-
* The event emitter to emit events received from the service. All addEventListeners will tap into this.
|
|
20
|
-
*/
|
|
21
|
-
export declare const eventEmitter: EventEmitter;
|
|
2
|
+
import { APITopic, API } from './internal';
|
|
3
|
+
export declare function connectToNotifications(): void;
|
|
4
|
+
export declare function launchSystemApp(): Promise<void>;
|
|
22
5
|
export declare function getServicePromise(): Promise<OpenFin.ChannelClient>;
|
|
23
6
|
/**
|
|
24
7
|
* Wrapper around service.dispatch to help with type checking
|
|
@@ -26,4 +9,3 @@ export declare function getServicePromise(): Promise<OpenFin.ChannelClient>;
|
|
|
26
9
|
* @param payload Data payload to send to the provider.
|
|
27
10
|
*/
|
|
28
11
|
export declare function tryServiceDispatch<T extends APITopic>(action: T, payload: API[T][0]): Promise<API[T][1]>;
|
|
29
|
-
export declare function getEventRouter(): EventRouter<Events>;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Notifications allow additional UI components to be specified by applications. The service
|
|
2
|
+
* Notifications allow additional UI components to be specified by applications. The service controls the
|
|
3
3
|
* positioning and styling of these components.
|
|
4
4
|
*
|
|
5
|
-
* In this version of the service, only buttons are supported. Additional control types will be added in future
|
|
6
|
-
* releases.
|
|
7
|
-
*
|
|
8
5
|
* @module Controls
|
|
9
6
|
*/
|
|
10
7
|
/**
|
|
@@ -39,11 +36,8 @@ export declare type ControlOptions = Required<PrimaryControlOptions | WithExplic
|
|
|
39
36
|
*/
|
|
40
37
|
export interface ButtonOptions {
|
|
41
38
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* This type declaration is optional, as the other control types will be declared in a slightly different way.
|
|
45
|
-
* Whilst this field is optional when specifiying options, it will be added by the service during creation (see
|
|
46
|
-
* {@link create}) - meaning it will always be present when receiving a `notification-action` event from a button.
|
|
39
|
+
* The type of the control. Optional, added automatically if `NotificationOptions.buttons` includes the `onClick`
|
|
40
|
+
* property and therefore generates a `notification-action` event.
|
|
47
41
|
*/
|
|
48
42
|
type?: 'button';
|
|
49
43
|
/**
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,392 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Need a comment block here so that the comment block above is interpreted as a file comment, and not a comment on the
|
|
6
|
-
* import below.
|
|
7
|
-
*
|
|
8
|
-
* @hidden
|
|
9
|
-
*/
|
|
10
|
-
import { NotificationActionResult, ActionTrigger } from './actions';
|
|
11
|
-
import { ButtonOptions, ControlOptions } from './controls';
|
|
12
|
-
import { DistributiveOmit } from './internal';
|
|
13
|
-
import * as provider from './provider';
|
|
14
|
-
import { NotificationSource } from './source';
|
|
15
|
-
import { NotificationIndicator, IndicatorType, IndicatorColor } from './indicator';
|
|
16
|
-
import { NotificationOptions } from './templates/templates';
|
|
17
|
-
import { UpdatableNotificationOptions } from './templates/update';
|
|
18
|
-
import * as actions from './actions';
|
|
19
|
-
export * from './actions';
|
|
20
|
-
export * from './controls';
|
|
21
|
-
export * from './source';
|
|
22
|
-
export * from './forms';
|
|
23
|
-
export * from './stream';
|
|
24
|
-
export * from './templates';
|
|
25
|
-
export * from './platform';
|
|
26
|
-
export { actions, provider, NotificationOptions };
|
|
27
|
-
export { NotificationIndicator, IndicatorColor, IndicatorType as NotificationIndicatorType };
|
|
28
|
-
/**
|
|
29
|
-
* The Notification Client library's version in semver format.
|
|
30
|
-
*
|
|
31
|
-
* This is the version which you are currently using.
|
|
32
|
-
*/
|
|
33
|
-
export declare const VERSION: string;
|
|
34
|
-
/**
|
|
35
|
-
* Application-defined context data that can be attached to buttons on notifications.
|
|
36
|
-
*/
|
|
37
|
-
export declare type CustomData = Record<string, any>;
|
|
38
|
-
/**
|
|
39
|
-
* A fully-hydrated form of {@link NotificationOptions}.
|
|
40
|
-
*
|
|
41
|
-
* After {@link create|creating} a notification, the service will return an object of this type. This will be the given
|
|
42
|
-
* options object, with any unspecified fields filled-in with default values.
|
|
43
|
-
*
|
|
44
|
-
* This object should be treated as immutable. Modifying its state will not have any effect on the notification or the
|
|
45
|
-
* state of the service.
|
|
46
|
-
*/
|
|
47
|
-
export declare type Notification<T extends NotificationOptions = NotificationOptions> = Readonly<Required<DistributiveOmit<T, 'buttons'>> & {
|
|
48
|
-
readonly buttons: ReadonlyArray<Required<ButtonOptions>>;
|
|
49
|
-
}>;
|
|
50
|
-
export declare type UpdatableNotification<T extends UpdatableNotificationOptions = UpdatableNotificationOptions> = Readonly<DistributiveOmit<T, 'buttons'> & {
|
|
51
|
-
readonly buttons?: ReadonlyArray<Required<ButtonOptions>>;
|
|
52
|
-
}>;
|
|
53
|
-
/**
|
|
54
|
-
* Event fired when an action is raised for a notification due to a specified trigger. It is important to note that
|
|
55
|
-
* applications will only receive these events if they indicate to the service that they want to receive these events.
|
|
56
|
-
* See {@link actions} for a full example of how actions are defined, and how an application can listen to and handle
|
|
57
|
-
* them.
|
|
58
|
-
*
|
|
59
|
-
* This can be fired due to interaction with notification buttons or the notification itself, the notification being
|
|
60
|
-
* closed (either by user interaction or by API call), or by the notification expiring. Later versions of the service
|
|
61
|
-
* will add additional control types that may raise actions from user interaction. All actions, for all control types,
|
|
62
|
-
* will be returned to the application via the same `notification-action` event type.
|
|
63
|
-
*
|
|
64
|
-
* The event object will contain the application-defined {@link NotificationActionResult|metadata} that allowed this
|
|
65
|
-
* action to be raised, and details on what triggered this action and which control the user interacted with.
|
|
66
|
-
*
|
|
67
|
-
* Unlike other event types, `notification-action` events will be buffered by the service until the application has
|
|
68
|
-
* added a listener for this event type, at which point it will receive all buffered `notification-action` events. The
|
|
69
|
-
* service will also attempt to restart the application if it is not running when the event is fired.
|
|
70
|
-
*
|
|
71
|
-
* This type includes a generic type argument, should applications wish to define their own interface for action
|
|
72
|
-
* results. See {@link NotificationActionResult} for details.
|
|
73
|
-
*
|
|
74
|
-
* @event "notification-action"
|
|
75
|
-
*/
|
|
76
|
-
export interface NotificationActionEvent<T = CustomData> {
|
|
77
|
-
type: 'notification-action';
|
|
78
|
-
/**
|
|
79
|
-
* The notification that created this action
|
|
80
|
-
*/
|
|
81
|
-
notification: Readonly<Notification>;
|
|
82
|
-
/**
|
|
83
|
-
* This property allows the application handling the action to identify where this notification originated.
|
|
84
|
-
*/
|
|
85
|
-
source: NotificationSource;
|
|
86
|
-
/**
|
|
87
|
-
* Indicates what triggered this action.
|
|
88
|
-
*
|
|
89
|
-
* Note that the `programmatic` trigger is not yet implemented.
|
|
90
|
-
*/
|
|
91
|
-
trigger: ActionTrigger;
|
|
92
|
-
/**
|
|
93
|
-
* The control whose interaction resulted in this action being raised. Will only be present when {@link trigger} is
|
|
94
|
-
* {@link ActionTrigger.CONTROL}.
|
|
95
|
-
*
|
|
96
|
-
* Future versions of the service will add additional controls beyond buttons, and interactions with these new
|
|
97
|
-
* control types will also come through this one event type. For best forward-compatibility, applications should
|
|
98
|
-
* always check the `type` property of this control, and not assume that the type will always be `'button'`.
|
|
99
|
-
*
|
|
100
|
-
* This field is marked optional as future versions of the service will also include alternate methods of raising
|
|
101
|
-
* `notification-action` events that do not originate from a button or other control.
|
|
102
|
-
*
|
|
103
|
-
* When present, the object here will always be strictly equal to one of the control definitions within
|
|
104
|
-
* `notification`. This means `indexOf` checks and other equality checks can be performed on this field if
|
|
105
|
-
* required, such as:
|
|
106
|
-
*
|
|
107
|
-
* ```ts
|
|
108
|
-
* function onNotificationAction(event: NotificationActionEvent): void {
|
|
109
|
-
* if (event.control && event.control.type === 'button') {
|
|
110
|
-
* const butttonIndex = event.notification.buttons.indexOf(event.control);
|
|
111
|
-
*
|
|
112
|
-
* // Handle button click
|
|
113
|
-
* // . . .
|
|
114
|
-
* }
|
|
115
|
-
* }
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
control?: Readonly<ControlOptions>;
|
|
119
|
-
/**
|
|
120
|
-
* Application-defined metadata that this event is passing back to the application.
|
|
121
|
-
*
|
|
122
|
-
* A `notification-action` event is only fired for a given trigger if the
|
|
123
|
-
* {@link NotificationOptions|notification options} included an action result for that trigger.
|
|
124
|
-
*
|
|
125
|
-
* See the comment on the {@link NotificationActionEvent} type for an example of buttons that do and don't raise
|
|
126
|
-
* actions.
|
|
127
|
-
*/
|
|
128
|
-
result: NotificationActionResult<T>;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Event fired whenever notification toast has been dismissed. This could be either by pressing notification dismiss `-` button or
|
|
132
|
-
* by clicking notification body if BODY_CLICK action has been set to "dismiss_event".
|
|
133
|
-
*
|
|
134
|
-
* @event "notification-toast-dismissed"
|
|
135
|
-
*/
|
|
136
|
-
export interface NotificationToastDismissedEvent {
|
|
137
|
-
type: 'notification-toast-dismissed';
|
|
138
|
-
notification: Notification;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Event fired whenever the notification has been closed.
|
|
142
|
-
*
|
|
143
|
-
* This event is fired regardless of how the notification was closed - i.e.: via a call to `clear`/`clearAll`, the
|
|
144
|
-
* notification expiring, or by a user clicking either the notification itself, the notification's close button, or
|
|
145
|
-
* a button on the notification.
|
|
146
|
-
*
|
|
147
|
-
* @event "notification-closed"
|
|
148
|
-
*/
|
|
149
|
-
export interface NotificationClosedEvent {
|
|
150
|
-
type: 'notification-closed';
|
|
151
|
-
/**
|
|
152
|
-
* The notification that has just been closed.
|
|
153
|
-
*
|
|
154
|
-
* This object will match what is returned from the `create` call when the notification was first created.
|
|
155
|
-
*/
|
|
156
|
-
notification: Notification;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Event fired whenever a new notification has been created.
|
|
160
|
-
*
|
|
161
|
-
* @event "notification-created"
|
|
162
|
-
*/
|
|
163
|
-
export interface NotificationCreatedEvent {
|
|
164
|
-
type: 'notification-created';
|
|
165
|
-
/**
|
|
166
|
-
* The notification that has just been created.
|
|
167
|
-
*
|
|
168
|
-
* This object will match what is returned from the `create` call.
|
|
169
|
-
*/
|
|
170
|
-
notification: Notification;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Event fired whenever a reminder has been created either via the Notifications API
|
|
174
|
-
* or by the user on the Notification Center UI
|
|
175
|
-
*
|
|
176
|
-
* @event "notification-reminder-created"
|
|
177
|
-
*/
|
|
178
|
-
export interface NotificationReminderCreatedEvent {
|
|
179
|
-
type: 'notification-reminder-created';
|
|
180
|
-
/**
|
|
181
|
-
* The reminder notification that has just been created.
|
|
182
|
-
*
|
|
183
|
-
* This object will match what is returned from the `create` call when the notification
|
|
184
|
-
* was first created.
|
|
185
|
-
*/
|
|
186
|
-
notification: Notification;
|
|
187
|
-
/**
|
|
188
|
-
* The reminder time-out timestamp.
|
|
189
|
-
*/
|
|
190
|
-
reminderDate: Date;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Event fired whenever a reminder has been canceled by the user, reminder notification is deleted or the reminder timeout has reached.
|
|
194
|
-
*
|
|
195
|
-
* @event "notification-reminder-removed"
|
|
196
|
-
*/
|
|
197
|
-
export interface NotificationReminderRemovedEvent {
|
|
198
|
-
type: 'notification-reminder-removed';
|
|
199
|
-
/**
|
|
200
|
-
* The notification associated with the reminder that has just been removed.
|
|
201
|
-
*
|
|
202
|
-
* This object will match what is returned from the `create` call when the notification was first created.
|
|
203
|
-
*/
|
|
204
|
-
notification: Notification;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Event fired whenever the total number of notifications from **all** sources changes.
|
|
208
|
-
*
|
|
209
|
-
* @event "notifications-count-changed"
|
|
210
|
-
*/
|
|
211
|
-
export interface NotificationsCountChanged {
|
|
212
|
-
type: 'notifications-count-changed';
|
|
213
|
-
/**
|
|
214
|
-
* Number of notifications in the Center.
|
|
215
|
-
*/
|
|
216
|
-
count: number;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Event fired whenever submit button is clicked on a notification form.
|
|
220
|
-
*
|
|
221
|
-
* @event "notifications-count-changed"
|
|
222
|
-
*/
|
|
223
|
-
export interface NotificationFormSubmittedEvent {
|
|
224
|
-
type: 'notification-form-submitted';
|
|
225
|
-
notification: Notification;
|
|
226
|
-
form: Record<string, unknown>;
|
|
227
|
-
}
|
|
228
|
-
export declare function addEventListener(eventType: 'notification-form-submitted', listener: (event: NotificationFormSubmittedEvent) => void): void;
|
|
229
|
-
export declare function addEventListener(eventType: 'notification-action', listener: (event: NotificationActionEvent) => void): void;
|
|
230
|
-
export declare function addEventListener(eventType: 'notification-created', listener: (event: NotificationCreatedEvent) => void): void;
|
|
231
|
-
export declare function addEventListener(eventType: 'notification-toast-dismissed', listener: (event: NotificationToastDismissedEvent) => void): void;
|
|
232
|
-
export declare function addEventListener(eventType: 'notification-closed', listener: (event: NotificationClosedEvent) => void): void;
|
|
233
|
-
export declare function addEventListener(eventType: 'notifications-count-changed', listener: (event: NotificationsCountChanged) => void): void;
|
|
234
|
-
export declare function addEventListener(eventType: 'notification-reminder-created', listener: (event: NotificationReminderCreatedEvent) => void): void;
|
|
235
|
-
export declare function addEventListener(eventType: 'notification-reminder-removed', listener: (event: NotificationReminderRemovedEvent) => void): void;
|
|
236
|
-
export declare function removeEventListener(eventType: 'notification-form-submitted', listener: (event: NotificationFormSubmittedEvent) => void): void;
|
|
237
|
-
export declare function removeEventListener(eventType: 'notification-action', listener: (event: NotificationActionEvent) => void): void;
|
|
238
|
-
export declare function removeEventListener(eventType: 'notification-created', listener: (event: NotificationCreatedEvent) => void): void;
|
|
239
|
-
export declare function removeEventListener(eventType: 'notification-toast-dismissed', listener: (event: NotificationToastDismissedEvent) => void): void;
|
|
240
|
-
export declare function removeEventListener(eventType: 'notification-closed', listener: (event: NotificationClosedEvent) => void): void;
|
|
241
|
-
export declare function removeEventListener(eventType: 'notifications-count-changed', listener: (event: NotificationsCountChanged) => void): void;
|
|
242
|
-
export declare function removeEventListener(eventType: 'notification-reminder-created', listener: (event: NotificationReminderCreatedEvent) => void): void;
|
|
243
|
-
export declare function removeEventListener(eventType: 'notification-reminder-removed', listener: (event: NotificationReminderRemovedEvent) => void): void;
|
|
244
|
-
/**
|
|
245
|
-
* Extended configuration options for the notification creation.
|
|
246
|
-
*/
|
|
247
|
-
export interface NotificationCreationOptions {
|
|
248
|
-
/**
|
|
249
|
-
* The date on which the notification will be removed from reminders category and recreated
|
|
250
|
-
* created as regular notification.
|
|
251
|
-
*
|
|
252
|
-
* If this date is earlier than the notification creation time, the notification will be created
|
|
253
|
-
* immediately.
|
|
254
|
-
* Cannot be earlier than the expiry date, if set.
|
|
255
|
-
*
|
|
256
|
-
*/
|
|
257
|
-
reminderDate?: Date;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Creates a new notification.
|
|
261
|
-
*
|
|
262
|
-
* If a reminder is not set, the notification will immediately appear in the Notification Center and as a toast if the Center is not visible.
|
|
263
|
-
* If a reminder is set, the notification will appear in the Center when the reminder date is reached.
|
|
264
|
-
*
|
|
265
|
-
* If a notification is created with an `id` of an already existing notification, the existing notification will be recreated with the new content.
|
|
266
|
-
*
|
|
267
|
-
* ```ts
|
|
268
|
-
* import {create} from 'openfin-notifications';
|
|
269
|
-
*
|
|
270
|
-
* create({
|
|
271
|
-
* id: 'uniqueNotificationId',
|
|
272
|
-
* title: 'Notification Title',
|
|
273
|
-
* body: 'Text to display within the notification body',
|
|
274
|
-
* icon: 'https://openfin.co/favicon.ico'
|
|
275
|
-
* }, {
|
|
276
|
-
* reminderDate: new Date('October 21, 2015 07:28:00');
|
|
277
|
-
* });
|
|
278
|
-
* ```
|
|
279
|
-
*
|
|
280
|
-
* @param options Notification configuration options.
|
|
281
|
-
* @param creationOptions Extended configuration options for the notification creation.
|
|
282
|
-
*/
|
|
283
|
-
export declare function create<T extends NotificationOptions>(options: T, creationOptions?: NotificationCreationOptions): Promise<Notification<T>>;
|
|
284
|
-
/**
|
|
285
|
-
* Updates an existing notification. Requires id of original Notification and one of:
|
|
286
|
-
* - buttons
|
|
287
|
-
* - customData
|
|
288
|
-
* - Template
|
|
289
|
-
*
|
|
290
|
-
* The updated Notification will then show in Notification Centre and in the Toast stack if not expired.
|
|
291
|
-
*
|
|
292
|
-
* Example:
|
|
293
|
-
* ```ts
|
|
294
|
-
* import {update} from 'openfin-notifications';
|
|
295
|
-
*
|
|
296
|
-
* update({
|
|
297
|
-
* id: uniqueNotificationId,
|
|
298
|
-
* body: 'i am an update! - ' + Date.now().toString(),
|
|
299
|
-
* template: 'markdown',
|
|
300
|
-
* });
|
|
301
|
-
* ```
|
|
302
|
-
* @param options
|
|
303
|
-
* @returns
|
|
304
|
-
*/
|
|
305
|
-
export declare function update<T extends UpdatableNotificationOptions>(options: T): Promise<Notification>;
|
|
306
|
-
/**
|
|
307
|
-
* Clears a specific notification from the Notification Center.
|
|
308
|
-
*
|
|
309
|
-
* Returns true if the notification was successfully cleared. Returns false if the notification was not cleared, without errors.
|
|
310
|
-
*
|
|
311
|
-
* ```ts
|
|
312
|
-
* import {clear} from 'openfin-notifications';
|
|
313
|
-
*
|
|
314
|
-
* clear('uniqueNotificationId');
|
|
315
|
-
* ```
|
|
316
|
-
*
|
|
317
|
-
* @param id ID of the notification to clear.
|
|
318
|
-
*/
|
|
319
|
-
export declare function clear(id: string): Promise<boolean>;
|
|
320
|
-
/**
|
|
321
|
-
* Retrieves all Notifications which were created by the calling application, including child windows.
|
|
322
|
-
*
|
|
323
|
-
* ```ts
|
|
324
|
-
* import {getAll} from 'openfin-notifications'
|
|
325
|
-
*
|
|
326
|
-
* getAll().then((notifications: Notification[]) => {
|
|
327
|
-
* console.log(`Service has ${notifications.length} notifications for this app:`, notifications);
|
|
328
|
-
* });
|
|
329
|
-
* ```
|
|
330
|
-
*
|
|
331
|
-
* There is deliberately no mechanism provided for fetching notifications that were created by a different application.
|
|
332
|
-
*/
|
|
333
|
-
export declare function getAll(): Promise<Notification[]>;
|
|
334
|
-
/**
|
|
335
|
-
* Clears all Notifications which were created by the calling application, including child windows.
|
|
336
|
-
*
|
|
337
|
-
* Returns the number of successfully cleared Notifications.
|
|
338
|
-
*
|
|
339
|
-
* ```ts
|
|
340
|
-
* import {clearAll} from 'openfin-notifications';
|
|
341
|
-
*
|
|
342
|
-
* clearAll();
|
|
343
|
-
* ```
|
|
344
|
-
*/
|
|
345
|
-
export declare function clearAll(): Promise<number>;
|
|
346
|
-
/**
|
|
347
|
-
* Toggles the visibility of the Notification Center.
|
|
348
|
-
*
|
|
349
|
-
* ```ts
|
|
350
|
-
* import {toggleNotificationCenter} from 'openfin-notifications';
|
|
351
|
-
*
|
|
352
|
-
* toggleNotificationCenter();
|
|
353
|
-
* ```
|
|
354
|
-
*/
|
|
355
|
-
export declare function toggleNotificationCenter(): Promise<void>;
|
|
356
|
-
/**
|
|
357
|
-
* Options to modify the Notification Center behaviour when show() API is called.
|
|
358
|
-
*/
|
|
359
|
-
export interface ShowOptions {
|
|
360
|
-
navigateToAll?: boolean;
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Sets the visibility of the Notification Center to true.
|
|
364
|
-
*
|
|
365
|
-
* ```ts
|
|
366
|
-
* import { show } from 'openfin-notifications';
|
|
367
|
-
*
|
|
368
|
-
* show({ navigateToAll: false });
|
|
369
|
-
* ```
|
|
370
|
-
* @param showOptions
|
|
371
|
-
*/
|
|
372
|
-
export declare function show(options?: ShowOptions): Promise<void>;
|
|
373
|
-
/**
|
|
374
|
-
* Sets the visibility of the Notification Center to false.
|
|
375
|
-
*
|
|
376
|
-
* ```ts
|
|
377
|
-
* import { hide } from 'openfin-notifications';
|
|
378
|
-
*
|
|
379
|
-
* hide();
|
|
380
|
-
* ```
|
|
381
|
-
*/
|
|
382
|
-
export declare function hide(): Promise<void>;
|
|
383
|
-
/**
|
|
384
|
-
* Get the total count of notifications from **all** applications.
|
|
385
|
-
*
|
|
386
|
-
* ```ts
|
|
387
|
-
* import {getNotificationsCount} from 'openfin-notifications';
|
|
388
|
-
*
|
|
389
|
-
* getNotificationsCount();
|
|
390
|
-
* ```
|
|
391
|
-
*/
|
|
392
|
-
export declare function getNotificationsCount(): Promise<number>;
|
|
1
|
+
import './auto-launch';
|
|
2
|
+
export * from './main';
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @deprecated
|
|
6
6
|
* Lists possible semantic use-cases for notifications, which can alter how the notification is presented to the user.
|
|
7
|
-
*
|
|
8
|
-
* Additional indicator types may be added in future releases.
|
|
9
7
|
*/
|
|
10
8
|
export declare enum IndicatorType {
|
|
11
9
|
FAILURE = "failure",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type OpenFin from '@openfin/core';
|
|
2
1
|
/**
|
|
3
2
|
* @hidden
|
|
4
3
|
*/
|
|
@@ -11,7 +10,7 @@ import type OpenFin from '@openfin/core';
|
|
|
11
10
|
import { NotificationActionResult, ActionTrigger } from './actions';
|
|
12
11
|
import { ProviderStatus } from './provider';
|
|
13
12
|
import { NotificationSource } from './source';
|
|
14
|
-
import { NotificationOptions, Notification, NotificationActionEvent, NotificationClosedEvent, NotificationCreatedEvent, NotificationsCountChanged, NotificationFormSubmittedEvent, UpdatableNotification,
|
|
13
|
+
import { NotificationOptions, Notification, NotificationActionEvent, NotificationClosedEvent, NotificationCreatedEvent, NotificationsCountChanged, NotificationFormSubmittedEvent, UpdatableNotification, UpdatableNotificationOptions, NotificationToastDismissedEvent, ShowOptions, NotificationReminderCreatedEvent, NotificationReminderRemovedEvent, ImageTemplateFragment, ContainerTemplateFragment, ActionableTextTemplateFragment, PlatformDeregisterPayload, PlatformRegisterPayload } from './main';
|
|
15
14
|
/**
|
|
16
15
|
* The identity of the main application window of the service provider
|
|
17
16
|
*/
|
|
@@ -34,10 +33,10 @@ export declare const enum APITopic {
|
|
|
34
33
|
REMOVE_EVENT_LISTENER = "remove-event-listener",
|
|
35
34
|
GET_PROVIDER_STATUS = "get-provider-status",
|
|
36
35
|
GET_NOTIFICATIONS_COUNT = "get-notifications-count",
|
|
37
|
-
REGISTER_PLATFORM = "register-notifications-platform",
|
|
38
|
-
DEREGISTER_PLATFORM = "deregister-notifications-platform",
|
|
39
36
|
SHOW_NOTIFICATION_CENTER = "show-notification-center",
|
|
40
|
-
HIDE_NOTIFICATION_CENTER = "hide-notification-center"
|
|
37
|
+
HIDE_NOTIFICATION_CENTER = "hide-notification-center",
|
|
38
|
+
REGISTER_PLATFORM = "register-notifications-platform",
|
|
39
|
+
DEREGISTER_PLATFORM = "deregister-notifications-platform"
|
|
41
40
|
}
|
|
42
41
|
export interface API {
|
|
43
42
|
[APITopic.CREATE_NOTIFICATION]: [CreatePayload, NotificationInternal];
|
|
@@ -50,13 +49,13 @@ export interface API {
|
|
|
50
49
|
[APITopic.REMOVE_EVENT_LISTENER]: [Events['type'], void];
|
|
51
50
|
[APITopic.GET_PROVIDER_STATUS]: [undefined, ProviderStatus];
|
|
52
51
|
[APITopic.GET_NOTIFICATIONS_COUNT]: [undefined, number];
|
|
52
|
+
[APITopic.SHOW_NOTIFICATION_CENTER]: [ShowPayload | undefined, void];
|
|
53
|
+
[APITopic.HIDE_NOTIFICATION_CENTER]: [undefined, void];
|
|
53
54
|
[APITopic.REGISTER_PLATFORM]: [
|
|
54
55
|
PlatformRegisterPayload,
|
|
55
56
|
Pick<RegistrationMetaInfo, 'notificationsVersion'> | undefined
|
|
56
57
|
];
|
|
57
58
|
[APITopic.DEREGISTER_PLATFORM]: [PlatformDeregisterPayload, void];
|
|
58
|
-
[APITopic.SHOW_NOTIFICATION_CENTER]: [ShowPayload | undefined, void];
|
|
59
|
-
[APITopic.HIDE_NOTIFICATION_CENTER]: [undefined, void];
|
|
60
59
|
}
|
|
61
60
|
export declare type Events = NotificationActionEvent | NotificationToastDismissedEvent | NotificationClosedEvent | NotificationCreatedEvent | NotificationsCountChanged | NotificationFormSubmittedEvent | NotificationReminderCreatedEvent | NotificationReminderRemovedEvent;
|
|
62
61
|
export declare type TransportMappings<T> = T extends NotificationActionEvent ? NotificationActionEventTransport : never;
|
|
@@ -72,9 +71,6 @@ export declare type NotificationInternal<T extends NotificationOptions = Notific
|
|
|
72
71
|
expires: number | null;
|
|
73
72
|
_fragments?: (ActionableTextTemplateFragment | ImageTemplateFragment | ContainerTemplateFragment)[];
|
|
74
73
|
};
|
|
75
|
-
export interface NotificationPlatformInternal extends NotificationPlatform {
|
|
76
|
-
platformIdentity: OpenFin.ApplicationIdentity;
|
|
77
|
-
}
|
|
78
74
|
export declare type UpdatableNotificationInternal<T extends UpdatableNotificationOptions = UpdatableNotificationOptions> = UpdatableNotification<T> & {
|
|
79
75
|
bodyText?: string;
|
|
80
76
|
body?: string;
|
|
@@ -83,10 +79,6 @@ export interface ClearPayload {
|
|
|
83
79
|
id: string;
|
|
84
80
|
}
|
|
85
81
|
export declare type ShowPayload = ShowOptions;
|
|
86
|
-
export declare type PlatformRegisterPayload<T extends NotificationPlatform = NotificationPlatform> = T;
|
|
87
|
-
export interface PlatformDeregisterPayload {
|
|
88
|
-
id: string;
|
|
89
|
-
}
|
|
90
82
|
export declare type ColorSchemeOption = 'light' | 'dark' | 'system';
|
|
91
83
|
export interface NotificationActionEventTransport {
|
|
92
84
|
type: 'notification-action';
|
|
@@ -102,3 +94,17 @@ export interface NotificationActionEventTransport {
|
|
|
102
94
|
* https://davidgomes.com/pick-omit-over-union-types-in-typescript/
|
|
103
95
|
*/
|
|
104
96
|
export declare type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
|
|
97
|
+
/**
|
|
98
|
+
* Data returned by the service when registering a platform.
|
|
99
|
+
*/
|
|
100
|
+
export interface RegistrationMetaInfo {
|
|
101
|
+
/**
|
|
102
|
+
* Version of the client API.
|
|
103
|
+
*/
|
|
104
|
+
clientAPIVersion: string;
|
|
105
|
+
/**
|
|
106
|
+
* Version of the notification service that is running.
|
|
107
|
+
* A response of 'unknown' indicates that an older version of the service is runningthat does not support returning the service version.
|
|
108
|
+
*/
|
|
109
|
+
notificationsVersion: string;
|
|
110
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal helper class that logs output both to console (when inspecting app or window) and runtime's debug.log file.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Log {
|
|
5
|
+
private static LOG_PREFIX;
|
|
6
|
+
static error(message: string): Promise<void>;
|
|
7
|
+
static warn(message: string): Promise<void>;
|
|
8
|
+
static info(message: string): Promise<void>;
|
|
9
|
+
private static getPrefixedMessage;
|
|
10
|
+
private static handleError;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|