@openfin/web-notifications-client 2.9.1-alpha-3948 → 2.9.1-alpha-3958

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.
@@ -1,5 +1,5 @@
1
1
  import OpenFin from '@openfin/core';
2
- import { ColorSchemeType, ThemeSet } from '@openfin/ui-library';
2
+ import { ThemeSet, ColorSchemeType } from '@openfin/ui-library';
3
3
  import { DefaultTheme } from 'styled-components';
4
4
 
5
5
  type NotificationProviderInfo = {
@@ -19,256 +19,12 @@ type NotificationProviderInfo = {
19
19
  * Icon url for the provider.
20
20
  */
21
21
  icon?: string;
22
- };
23
-
24
- /**
25
- * Actions are the mechanism through which notifications send messages back to the application that created them. The
26
- * service defines a number of ways in which actions can be raised (a notification being interacted with by the user,
27
- * being closed, expiring, etc.), and it is up to each application to decide if it wishes to be informed when each of
28
- * these triggers occur.
29
- *
30
- * For an action to be raised when one of these triggers occurs, the application must specify an
31
- * {@link NotificationActionResult|action result} for each trigger it is interested in. The application should then
32
- * listen for when these actions are raised by listening for the {@link NotificationActionEvent|`notification-action`}
33
- * event.
34
- *
35
- * This event is fired once each time an action is raised, and will contain the
36
- * {@link NotificationActionResult|action result} the application specified for that trigger. The application may then
37
- * use the {@link NotificationActionResult|action result} to determine which trigger occurred and respond appropriately.
38
- *
39
- * If an {@link NotificationActionResult|action result} is not specified for a particular trigger, or it is set to
40
- * `null`, the application will not receive a corresponding {@link NotificationActionEvent|`notification-action`} when
41
- * that trigger occurs.
42
- *
43
- * Unlike other event types, {@link NotificationActionEvent|`notification-action`} events will be buffered by the
44
- * service until the application has added a listener for this event type, at which point it will receive all buffered
45
- * {@link NotificationActionEvent|`notification-action`} events. The service will also attempt to restart the
46
- * application if it is not running when the event is fired.
47
- *
48
- * For an overview of actions, consider the sample notification below:
49
- * ```ts
50
- * import {addEventListener, create} from 'openfin-notifications';
51
- *
52
- * // Create a notification with two buttons
53
- * create({
54
- * // Basic info
55
- * title: 'Reminder',
56
- * body: 'Event "Weekly Meeting" is starting soon...',
57
- *
58
- * // We'll use the 'customData' field to store metadata about the event
59
- * customData: {eventId: '12345'},
60
- *
61
- * // We want the user clicking the notification to open the associated event, so register an 'onSelect' action
62
- * onSelect: {task: 'view-calendar-event', target: 'popup'},
63
- *
64
- * buttons: [
65
- * // A button that will schedule another reminder for 5 minutes from now. Since the application will be
66
- * // responsible for snoozing the event, it will need to know about the user clicking this button. By setting
67
- * // a NotificationActionResult for 'onClick', the service will raise a "notification-action" event when this
68
- * // button is clicked, and will pass the value of 'onClick' as the 'result' field within the event
69
- * {
70
- * title: 'Snooze for 5 minutes',
71
- * iconUrl: 'https://www.example.com/timer.png',
72
- * onClick: {
73
- * task: 'schedule-reminder',
74
- * intervalMs: 5 * 60 * 1000
75
- * }
76
- * },
77
- *
78
- * // A button that closes the notification and doesn't prompt the user about this event again. Since the
79
- * // application doesn't need to do anything when the user clicks this button, we leave 'onClick' undefined
80
- * // rather than specifying a NotificationActionResult. This means that no action will be raised when the
81
- * // button is clicked, and hence no "notification-action" event will be fired
82
- * {
83
- * title: 'Dismiss',
84
- * iconUrl: 'https://www.example.com/cancel.png'
85
- * }
86
- * ]
87
- * });
88
- *
89
- * // Create a listener that will be called for each action
90
- * // Note: This handler will be used for ALL actions, from ALL notifications that are created by this application.
91
- * addEventListener('notification-action', (event: NotificationActionEvent) => {
92
- * const {result, notification} = event;
93
- *
94
- * if (result['task'] === 'view-calendar-event') {
95
- * // Open a window with full details of the associated event
96
- * openEventDetails(notification.customData.eventId, result['target']);
97
- * } else if (result['task'] === 'schedule-reminder') {
98
- * // Schedule a new notification
99
- * scheduleReminder(notification.customData.eventId, Date.now() + result['intervalMs']);
100
- * } // Etc...
101
- * });
102
- * ```
103
- *
104
- * The example above uses `customData` to store details about the notification subject (in this case, a calendar
105
- * event), and `onClick` actions to inform the application about how it should respond when the user interacts with the
106
- * notification. This is our intended usage and recommended best-practice, but the service doesn't require applications
107
- * to follow this convention - application developers are free to decide how to manage notification state.
108
- *
109
- * Within the `notification-action` handler, the application must be able to understand which notification is being
110
- * handled, and how to decide what it should do next. The example above uses an application-defined `action` field to
111
- * determine the correct action, but the notification's `id`, `customData` and other fields are also useful
112
- * selectors.
113
- *
114
- * @module Actions
115
- */
116
- /**
117
- * Need a comment block here so that the comment block above is interpreted as a file comment, and not a comment on the
118
- * import below.
119
- *
120
- * @hidden
121
- */
122
-
123
- /**
124
- * Denotes a field as being an action. Defining this field (with a non-`undefined` value) will result in actions being
125
- * raised and sent back to the source application when the corresponding event happens.
126
- *
127
- * For example, providing a value for the `onClick` field of {@link ButtonOptions} will result in a
128
- * {@link NotificationActionEvent|`notification-action`} event being fired when that button is clicked.
129
- *
130
- * The `NotificationActionResult returned back to an application is static
131
- * and must be defined at the point where the notification is created.
132
- */
133
- type ActionDeclaration<T extends never, E extends never> = NotificationActionResult;
134
- /**
135
- * Data type used to represent the action result returned back to applications when an action is raised. Applications
136
- * capture these responses by adding a `notification-action` listener. The contents of this type are entirely
137
- * application-defined, the only requirement is that the item is serializable by `JSON.stringify`.
138
- *
139
- * Since this type is entirely application-specific, the type is used in these definitions. However, there is an
140
- * optional generic argument here, which can be used if an application were to define its own conventions for the shape
141
- * of this field (which is recommended). To make use of this, define a `notification-action` handler that includes the
142
- * application-defined type as a template argument. This type is then propagated up to {@link NotificationActionEvent}.
143
- * The example below demonstrates this, using the same use-case as at the top of this page.
144
- *
145
- * ```ts
146
- * interface MyAction = SnoozeAction | DetailsAction;
147
- *
148
- * interface SnoozeAction {
149
- * task: 'schedule-reminder';
150
- * intervalMs: number;
151
- * }
152
- *
153
- * interface DetailsAction {
154
- * task: 'view-calendar-event';
155
- * target: 'self'|'popup';
156
- * }
157
- *
158
- * addEventListener('notification-action', (event: NotificationActionEvent<MyAction>)) => {
159
- * if (event.result.task === 'schedule-reminder') {
160
- * // 'event.result' will now be strongly-typed as an instance of SnoozeAction
161
- * scheduleReminder(notification.customData.eventId, Date.now() + result.intervalMs);
162
- * }
163
- * // Etc...
164
- * };
165
- * ```
166
- */
167
- type NotificationActionResult<T = CustomData> = T;
168
- /**
169
- * Lists the different triggers that can raise an {@link Actions|action}. Each action that is raised will result in a
170
- * {@link NotificationActionEvent|`notification-action`} event, which can be captured by the application that created
171
- * the notification.
172
- */
173
- declare enum ActionTrigger {
174
- /**
175
- * The user interacted with one of the controls in the notification: a button or an actionable fragment.
176
- */
177
- CONTROL = "control",
178
- /**
179
- * The user clicked the body of the notification itself. Any clicks of the notification that don't hit a control
180
- * or the close button will fire an event with the `'select'` action trigger.
181
- */
182
- SELECT = "select",
183
- /**
184
- * The notification was closed, either by user interaction, programmatically by an application, or by the notification expiring.
185
- */
186
- CLOSE = "close",
187
- /**
188
- * The notification expired.
189
- */
190
- EXPIRE = "expire",
191
- /**
192
- * The action was triggered programmatically by an application.
193
- *
194
- * *Not currently supported*
195
- */
196
- PROGRAMMATIC = "programmatic"
197
- }
198
- /**
199
- * Noop action types see {@link ActionNoop|ActionNoop}.
200
- */
201
- declare enum ActionNoopType {
202
- /**
203
- * No event will be raised and no dismissal of the notification on action.
204
- */
205
- EVENT_DISMISS = "event_dismiss"
206
- }
207
- /**
208
- * BODY_CLICK action types see {@link ActionBodyClick|ActionBodyClick}.
209
- */
210
- declare enum ActionBodyClickType {
211
22
  /**
212
- * Dissmisal/Clearing event will be raised
23
+ * Unique identifier for the Notification Center instance.
24
+ * Must be a non-empty string that matches the `serviceId` used in the Web Notification Center instance.
213
25
  */
214
- DISMISS_EVENT = "dismiss_event"
215
- }
216
- /**
217
- * @depracated {__NOOP__} has been deprecated. Notifications now default to not triggering the dismiss action when the body is clicked
218
- *
219
- * Setting the `__NOOP__` field on an action with a {@link ActionNoopType|type} allows you to override default user interaction with a notification.
220
- *
221
- * @example
222
- * ```
223
- * const notification = {
224
- * //...
225
- * onSelect: {__NOOP__: ActionNoopType.EVENT_DISMISS}
226
- * };
227
- * ```
228
- *
229
- * When a user clicks the notification body, the notification will not be dismissed and no event will be raised to the client application.
230
- *
231
- * <li> Currently <code>ActionBodyClickType.DISMISS_EVENT</code> is only supported by <code>ActionTrigger.SELECT/onSelect</code></li>
232
- */
233
- interface ActionNoop {
234
- __NOOP__?: ActionNoopType;
235
- }
236
- /**
237
- * Set the `BODY_CLICK` field on an action with a {@link ActionBodyClickType|type} to allow the end-user to click the body of the notification to dismiss it. This was the default behavior in earlier releases. An event is also sent to the client application.
238
- *
239
- * Note the following restrictions:
240
- *
241
- * <ul>
242
- * <li>This override is ignored if buttons are passed to notification options.</li>
243
- * <li>The <code>ActionBodyClickType.DISMISS_EVENT</code> is supported only by <code>ActionTrigger.SELECT/onSelect</code></li>
244
- *
245
- * @example
246
- * ```
247
- * const notification = {
248
- * //...
249
- * onSelect: {BODY_CLICK: ActionBodyClickType.DISMISS_EVENT}
250
- * };
251
- * ```
252
- *
253
- */
254
- interface ActionBodyClick {
255
- BODY_CLICK?: ActionBodyClickType;
256
- }
257
-
258
- type actions_d_ActionBodyClick = ActionBodyClick;
259
- type actions_d_ActionBodyClickType = ActionBodyClickType;
260
- declare const actions_d_ActionBodyClickType: typeof ActionBodyClickType;
261
- type actions_d_ActionDeclaration<T extends never, E extends never> = ActionDeclaration<T, E>;
262
- type actions_d_ActionNoop = ActionNoop;
263
- type actions_d_ActionNoopType = ActionNoopType;
264
- declare const actions_d_ActionNoopType: typeof ActionNoopType;
265
- type actions_d_ActionTrigger = ActionTrigger;
266
- declare const actions_d_ActionTrigger: typeof ActionTrigger;
267
- type actions_d_NotificationActionResult<T = CustomData> = NotificationActionResult<T>;
268
- declare namespace actions_d {
269
- export { actions_d_ActionBodyClickType as ActionBodyClickType, actions_d_ActionNoopType as ActionNoopType, actions_d_ActionTrigger as ActionTrigger };
270
- export type { actions_d_ActionBodyClick as ActionBodyClick, actions_d_ActionDeclaration as ActionDeclaration, actions_d_ActionNoop as ActionNoop, actions_d_NotificationActionResult as NotificationActionResult };
271
- }
26
+ serviceId: string;
27
+ };
272
28
 
273
29
  /**
274
30
  * @module Notifications
@@ -442,130 +198,6 @@ type ToggleWidgetSpec = BaseWidgetSpec<typeof WidgetType['Toggle']>;
442
198
  type CheckboxWidgetSpec = BaseWidgetSpec<typeof WidgetType['Checkbox']>;
443
199
  type BooleanWidget = ToggleWidgetSpec | CheckboxWidgetSpec;
444
200
 
445
- /**
446
- * @module Provider
447
- */
448
- /**
449
- * Status object returned by the Provider.
450
- */
451
- interface ProviderStatus {
452
- /**
453
- * The current connection status from the Client to the Provider.
454
- */
455
- connected: boolean;
456
- /**
457
- * The version number of the Provider. If the Provider is not connected, this will be `null`.
458
- */
459
- version: string | null;
460
- /**
461
- * The version number of the Templates API. If the Provider is not connected, this will be `null`.
462
- */
463
- templateAPIVersion?: string | null;
464
- }
465
- /**
466
- * Retrieves the connection status and version semver of the Service Provider in the shape of a {@link ProviderStatus} object.
467
- *
468
- * If the Provider is connected, its' version number will be supplied in the returned object. If not, `version` will be `null`.
469
- *
470
- * ```ts
471
- * import {provider} from 'openfin-notifications';
472
- *
473
- * const status: ProviderStatus = provider.getStatus();
474
- * console.log(status.connected ? `Conencted to provider (version ${status.version})` : 'Not connected to provider');
475
- * ```
476
- *
477
- * Note: Connection status is only available when the connected provider is verison 0.11.2 or later. For earlier
478
- * versions, this API will indicate that the provider is disconnected.
479
- *
480
- * @since 0.11.2
481
- *
482
- * Note: Template API version is only available when the connected provider is verison 1.10.2 or later.
483
- *
484
- */
485
- declare function getStatus(): Promise<ProviderStatus>;
486
- /**
487
- * Evaluates the provided version against the Providers version.
488
- *
489
- * This will return `true` if the Provider version is greater than or equal to the provided version. If not, `false` will be returned.
490
- *
491
- * If the Provider is not connected, `false` will be returned.
492
- *
493
- * ```ts
494
- * import {provider, VERSION} from 'openfin-notifications';
495
- *
496
- * const hasMatchingProvider: boolean = provider.isConnectedToAtLeast(VERSION);
497
- * if (!hasMatchingProvider) {
498
- * console.warn('Connected to an older provider version. Some functionality may not be available.');
499
- * }
500
- * ```
501
- *
502
- * Note: Version information is only available when the connected provider is verison 0.11.2 or later. For earlier
503
- * versions, this API will indicate that the provider is disconnected.
504
- *
505
- * @param version Version to compare against the Provider version. This should be in semvar format.
506
- * @since 0.11.2
507
- */
508
- declare function isConnectedToAtLeast(version: string): Promise<boolean>;
509
-
510
- type provider_d_ProviderStatus = ProviderStatus;
511
- declare const provider_d_getStatus: typeof getStatus;
512
- declare const provider_d_isConnectedToAtLeast: typeof isConnectedToAtLeast;
513
- declare namespace provider_d {
514
- export { provider_d_getStatus as getStatus, provider_d_isConnectedToAtLeast as isConnectedToAtLeast };
515
- export type { provider_d_ProviderStatus as ProviderStatus };
516
- }
517
-
518
- /**
519
- * @hidden
520
- */
521
- /**
522
- * Need a comment block here so that the comment block above is interpreted as a file comment, and not a comment on the
523
- * import below.
524
- *
525
- * @hidden
526
- */
527
- /**
528
- * For notifications that have originated from an application running on the same machine as the provider.
529
- */
530
- interface NotificationSourceDesktop {
531
- type: 'desktop';
532
- /**
533
- * The identity of the window that raised this notification.
534
- *
535
- * This will always be a window of the current application - but
536
- * could have been raised by an instance of this application
537
- * running on a different machine.
538
- */
539
- identity: OpenFin.Identity;
540
- /**
541
- * The origin of the notification, which is the url of the window that raised the notification.
542
- * This property is optional to support backward compatibility with sources that do not have the origin starting with version 2.7.1.
543
- */
544
- origin?: string;
545
- }
546
- /**
547
- * Union of all possible notification sources.
548
- */
549
- type NotificationSource = NotificationSourceDesktop;
550
-
551
- /**
552
- * @hidden
553
- */
554
- /**
555
- * File contains types used to communicate between client and provider.
556
- *
557
- * These types are a part of the client, but are not required by applications wishing to interact with the service.
558
- * This file is excluded from the public-facing TypeScript documentation.
559
- */
560
-
561
- type ColorSchemeOption = ColorSchemeType;
562
- /**
563
- * Distribute Omit across all union types instead of Omitting the union.
564
- * https://davidgomes.com/pick-omit-over-union-types-in-typescript/
565
- */
566
- type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
567
- type MakePropertyRequired<T, Prop extends keyof T> = Omit<T, Prop> & Required<Pick<T, Prop>>;
568
-
569
201
  /**
570
202
  * When you make a form, you provide a list of [[FormFields]]. Each FormField contains the ingredients to make a single widget in the form.
571
203
  * The actual definitions of the widgets are derived from [[BaseWidgetSpec]].
@@ -1502,6 +1134,112 @@ interface ButtonOptions {
1502
1134
  } | null;
1503
1135
  }
1504
1136
 
1137
+ /**
1138
+ * @module Provider
1139
+ */
1140
+ /**
1141
+ * Status object returned by the Provider.
1142
+ */
1143
+ interface ProviderStatus {
1144
+ /**
1145
+ * The current connection status from the Client to the Provider.
1146
+ */
1147
+ connected: boolean;
1148
+ /**
1149
+ * The version number of the Provider. If the Provider is not connected, this will be `null`.
1150
+ */
1151
+ version: string | null;
1152
+ /**
1153
+ * The version number of the Templates API. If the Provider is not connected, this will be `null`.
1154
+ */
1155
+ templateAPIVersion?: string | null;
1156
+ }
1157
+ /**
1158
+ * Retrieves the connection status and version semver of the Service Provider in the shape of a {@link ProviderStatus} object.
1159
+ *
1160
+ * If the Provider is connected, its' version number will be supplied in the returned object. If not, `version` will be `null`.
1161
+ *
1162
+ * ```ts
1163
+ * import {provider} from 'openfin-notifications';
1164
+ *
1165
+ * const status: ProviderStatus = provider.getStatus();
1166
+ * console.log(status.connected ? `Conencted to provider (version ${status.version})` : 'Not connected to provider');
1167
+ * ```
1168
+ *
1169
+ * Note: Connection status is only available when the connected provider is verison 0.11.2 or later. For earlier
1170
+ * versions, this API will indicate that the provider is disconnected.
1171
+ *
1172
+ * @since 0.11.2
1173
+ *
1174
+ * Note: Template API version is only available when the connected provider is verison 1.10.2 or later.
1175
+ *
1176
+ */
1177
+ declare function getStatus(): Promise<ProviderStatus>;
1178
+ /**
1179
+ * Evaluates the provided version against the Providers version.
1180
+ *
1181
+ * This will return `true` if the Provider version is greater than or equal to the provided version. If not, `false` will be returned.
1182
+ *
1183
+ * If the Provider is not connected, `false` will be returned.
1184
+ *
1185
+ * ```ts
1186
+ * import {provider, VERSION} from 'openfin-notifications';
1187
+ *
1188
+ * const hasMatchingProvider: boolean = provider.isConnectedToAtLeast(VERSION);
1189
+ * if (!hasMatchingProvider) {
1190
+ * console.warn('Connected to an older provider version. Some functionality may not be available.');
1191
+ * }
1192
+ * ```
1193
+ *
1194
+ * Note: Version information is only available when the connected provider is verison 0.11.2 or later. For earlier
1195
+ * versions, this API will indicate that the provider is disconnected.
1196
+ *
1197
+ * @param version Version to compare against the Provider version. This should be in semvar format.
1198
+ * @since 0.11.2
1199
+ */
1200
+ declare function isConnectedToAtLeast(version: string): Promise<boolean>;
1201
+
1202
+ type provider_d_ProviderStatus = ProviderStatus;
1203
+ declare const provider_d_getStatus: typeof getStatus;
1204
+ declare const provider_d_isConnectedToAtLeast: typeof isConnectedToAtLeast;
1205
+ declare namespace provider_d {
1206
+ export { provider_d_getStatus as getStatus, provider_d_isConnectedToAtLeast as isConnectedToAtLeast };
1207
+ export type { provider_d_ProviderStatus as ProviderStatus };
1208
+ }
1209
+
1210
+ /**
1211
+ * @hidden
1212
+ */
1213
+ /**
1214
+ * Need a comment block here so that the comment block above is interpreted as a file comment, and not a comment on the
1215
+ * import below.
1216
+ *
1217
+ * @hidden
1218
+ */
1219
+ /**
1220
+ * For notifications that have originated from an application running on the same machine as the provider.
1221
+ */
1222
+ interface NotificationSourceDesktop {
1223
+ type: 'desktop';
1224
+ /**
1225
+ * The identity of the window that raised this notification.
1226
+ *
1227
+ * This will always be a window of the current application - but
1228
+ * could have been raised by an instance of this application
1229
+ * running on a different machine.
1230
+ */
1231
+ identity: OpenFin.Identity;
1232
+ /**
1233
+ * The origin of the notification, which is the url of the window that raised the notification.
1234
+ * This property is optional to support backward compatibility with sources that do not have the origin starting with version 2.7.1.
1235
+ */
1236
+ origin?: string;
1237
+ }
1238
+ /**
1239
+ * Union of all possible notification sources.
1240
+ */
1241
+ type NotificationSource = NotificationSourceDesktop;
1242
+
1505
1243
  /**
1506
1244
  * @module Notifications
1507
1245
  */
@@ -2149,19 +1887,328 @@ declare function getUserSettingStatus<T extends UserSettings>(setting: UserSetti
2149
1887
  */
2150
1888
  declare const setAllowedOrigins: (allowedOrigins: string[]) => Promise<void>;
2151
1889
 
2152
- type NotificationProviderConfig = NotificationProviderInfo & {
2153
- /**
2154
- * Unique identifier for the Notification Center instance.
2155
- * Must be a non-empty string that matches the `serviceId` used in the Web Notification Center instance.
2156
- */
2157
- serviceId: string;
2158
- /**
2159
- * `fin` entry point for the Here Core Web.
2160
- * For setup instructions, see: https://www.npmjs.com/package/@openfin/core-web
2161
- */
2162
- finContext: OpenFin.Fin<'external connection'>;
1890
+ /**
1891
+ * Actions are the mechanism through which notifications send messages back to the application that created them. The
1892
+ * service defines a number of ways in which actions can be raised (a notification being interacted with by the user,
1893
+ * being closed, expiring, etc.), and it is up to each application to decide if it wishes to be informed when each of
1894
+ * these triggers occur.
1895
+ *
1896
+ * For an action to be raised when one of these triggers occurs, the application must specify an
1897
+ * {@link NotificationActionResult|action result} for each trigger it is interested in. The application should then
1898
+ * listen for when these actions are raised by listening for the {@link NotificationActionEvent|`notification-action`}
1899
+ * event.
1900
+ *
1901
+ * This event is fired once each time an action is raised, and will contain the
1902
+ * {@link NotificationActionResult|action result} the application specified for that trigger. The application may then
1903
+ * use the {@link NotificationActionResult|action result} to determine which trigger occurred and respond appropriately.
1904
+ *
1905
+ * If an {@link NotificationActionResult|action result} is not specified for a particular trigger, or it is set to
1906
+ * `null`, the application will not receive a corresponding {@link NotificationActionEvent|`notification-action`} when
1907
+ * that trigger occurs.
1908
+ *
1909
+ * Unlike other event types, {@link NotificationActionEvent|`notification-action`} events will be buffered by the
1910
+ * service until the application has added a listener for this event type, at which point it will receive all buffered
1911
+ * {@link NotificationActionEvent|`notification-action`} events. The service will also attempt to restart the
1912
+ * application if it is not running when the event is fired.
1913
+ *
1914
+ * For an overview of actions, consider the sample notification below:
1915
+ * ```ts
1916
+ * import {addEventListener, create} from 'openfin-notifications';
1917
+ *
1918
+ * // Create a notification with two buttons
1919
+ * create({
1920
+ * // Basic info
1921
+ * title: 'Reminder',
1922
+ * body: 'Event "Weekly Meeting" is starting soon...',
1923
+ *
1924
+ * // We'll use the 'customData' field to store metadata about the event
1925
+ * customData: {eventId: '12345'},
1926
+ *
1927
+ * // We want the user clicking the notification to open the associated event, so register an 'onSelect' action
1928
+ * onSelect: {task: 'view-calendar-event', target: 'popup'},
1929
+ *
1930
+ * buttons: [
1931
+ * // A button that will schedule another reminder for 5 minutes from now. Since the application will be
1932
+ * // responsible for snoozing the event, it will need to know about the user clicking this button. By setting
1933
+ * // a NotificationActionResult for 'onClick', the service will raise a "notification-action" event when this
1934
+ * // button is clicked, and will pass the value of 'onClick' as the 'result' field within the event
1935
+ * {
1936
+ * title: 'Snooze for 5 minutes',
1937
+ * iconUrl: 'https://www.example.com/timer.png',
1938
+ * onClick: {
1939
+ * task: 'schedule-reminder',
1940
+ * intervalMs: 5 * 60 * 1000
1941
+ * }
1942
+ * },
1943
+ *
1944
+ * // A button that closes the notification and doesn't prompt the user about this event again. Since the
1945
+ * // application doesn't need to do anything when the user clicks this button, we leave 'onClick' undefined
1946
+ * // rather than specifying a NotificationActionResult. This means that no action will be raised when the
1947
+ * // button is clicked, and hence no "notification-action" event will be fired
1948
+ * {
1949
+ * title: 'Dismiss',
1950
+ * iconUrl: 'https://www.example.com/cancel.png'
1951
+ * }
1952
+ * ]
1953
+ * });
1954
+ *
1955
+ * // Create a listener that will be called for each action
1956
+ * // Note: This handler will be used for ALL actions, from ALL notifications that are created by this application.
1957
+ * addEventListener('notification-action', (event: NotificationActionEvent) => {
1958
+ * const {result, notification} = event;
1959
+ *
1960
+ * if (result['task'] === 'view-calendar-event') {
1961
+ * // Open a window with full details of the associated event
1962
+ * openEventDetails(notification.customData.eventId, result['target']);
1963
+ * } else if (result['task'] === 'schedule-reminder') {
1964
+ * // Schedule a new notification
1965
+ * scheduleReminder(notification.customData.eventId, Date.now() + result['intervalMs']);
1966
+ * } // Etc...
1967
+ * });
1968
+ * ```
1969
+ *
1970
+ * The example above uses `customData` to store details about the notification subject (in this case, a calendar
1971
+ * event), and `onClick` actions to inform the application about how it should respond when the user interacts with the
1972
+ * notification. This is our intended usage and recommended best-practice, but the service doesn't require applications
1973
+ * to follow this convention - application developers are free to decide how to manage notification state.
1974
+ *
1975
+ * Within the `notification-action` handler, the application must be able to understand which notification is being
1976
+ * handled, and how to decide what it should do next. The example above uses an application-defined `action` field to
1977
+ * determine the correct action, but the notification's `id`, `customData` and other fields are also useful
1978
+ * selectors.
1979
+ *
1980
+ * @module Actions
1981
+ */
1982
+ /**
1983
+ * Need a comment block here so that the comment block above is interpreted as a file comment, and not a comment on the
1984
+ * import below.
1985
+ *
1986
+ * @hidden
1987
+ */
1988
+
1989
+ /**
1990
+ * Denotes a field as being an action. Defining this field (with a non-`undefined` value) will result in actions being
1991
+ * raised and sent back to the source application when the corresponding event happens.
1992
+ *
1993
+ * For example, providing a value for the `onClick` field of {@link ButtonOptions} will result in a
1994
+ * {@link NotificationActionEvent|`notification-action`} event being fired when that button is clicked.
1995
+ *
1996
+ * The `NotificationActionResult returned back to an application is static
1997
+ * and must be defined at the point where the notification is created.
1998
+ */
1999
+ type ActionDeclaration<T extends never, E extends never> = NotificationActionResult;
2000
+ /**
2001
+ * Data type used to represent the action result returned back to applications when an action is raised. Applications
2002
+ * capture these responses by adding a `notification-action` listener. The contents of this type are entirely
2003
+ * application-defined, the only requirement is that the item is serializable by `JSON.stringify`.
2004
+ *
2005
+ * Since this type is entirely application-specific, the type is used in these definitions. However, there is an
2006
+ * optional generic argument here, which can be used if an application were to define its own conventions for the shape
2007
+ * of this field (which is recommended). To make use of this, define a `notification-action` handler that includes the
2008
+ * application-defined type as a template argument. This type is then propagated up to {@link NotificationActionEvent}.
2009
+ * The example below demonstrates this, using the same use-case as at the top of this page.
2010
+ *
2011
+ * ```ts
2012
+ * interface MyAction = SnoozeAction | DetailsAction;
2013
+ *
2014
+ * interface SnoozeAction {
2015
+ * task: 'schedule-reminder';
2016
+ * intervalMs: number;
2017
+ * }
2018
+ *
2019
+ * interface DetailsAction {
2020
+ * task: 'view-calendar-event';
2021
+ * target: 'self'|'popup';
2022
+ * }
2023
+ *
2024
+ * addEventListener('notification-action', (event: NotificationActionEvent<MyAction>)) => {
2025
+ * if (event.result.task === 'schedule-reminder') {
2026
+ * // 'event.result' will now be strongly-typed as an instance of SnoozeAction
2027
+ * scheduleReminder(notification.customData.eventId, Date.now() + result.intervalMs);
2028
+ * }
2029
+ * // Etc...
2030
+ * };
2031
+ * ```
2032
+ */
2033
+ type NotificationActionResult<T = CustomData> = T;
2034
+ /**
2035
+ * Lists the different triggers that can raise an {@link Actions|action}. Each action that is raised will result in a
2036
+ * {@link NotificationActionEvent|`notification-action`} event, which can be captured by the application that created
2037
+ * the notification.
2038
+ */
2039
+ declare enum ActionTrigger {
2040
+ /**
2041
+ * The user interacted with one of the controls in the notification: a button or an actionable fragment.
2042
+ */
2043
+ CONTROL = "control",
2044
+ /**
2045
+ * The user clicked the body of the notification itself. Any clicks of the notification that don't hit a control
2046
+ * or the close button will fire an event with the `'select'` action trigger.
2047
+ */
2048
+ SELECT = "select",
2049
+ /**
2050
+ * The notification was closed, either by user interaction, programmatically by an application, or by the notification expiring.
2051
+ */
2052
+ CLOSE = "close",
2053
+ /**
2054
+ * The notification expired.
2055
+ */
2056
+ EXPIRE = "expire",
2057
+ /**
2058
+ * The action was triggered programmatically by an application.
2059
+ *
2060
+ * *Not currently supported*
2061
+ */
2062
+ PROGRAMMATIC = "programmatic"
2063
+ }
2064
+ /**
2065
+ * Noop action types see {@link ActionNoop|ActionNoop}.
2066
+ */
2067
+ declare enum ActionNoopType {
2068
+ /**
2069
+ * No event will be raised and no dismissal of the notification on action.
2070
+ */
2071
+ EVENT_DISMISS = "event_dismiss"
2072
+ }
2073
+ /**
2074
+ * BODY_CLICK action types see {@link ActionBodyClick|ActionBodyClick}.
2075
+ */
2076
+ declare enum ActionBodyClickType {
2077
+ /**
2078
+ * Dissmisal/Clearing event will be raised
2079
+ */
2080
+ DISMISS_EVENT = "dismiss_event"
2081
+ }
2082
+ /**
2083
+ * @depracated {__NOOP__} has been deprecated. Notifications now default to not triggering the dismiss action when the body is clicked
2084
+ *
2085
+ * Setting the `__NOOP__` field on an action with a {@link ActionNoopType|type} allows you to override default user interaction with a notification.
2086
+ *
2087
+ * @example
2088
+ * ```
2089
+ * const notification = {
2090
+ * //...
2091
+ * onSelect: {__NOOP__: ActionNoopType.EVENT_DISMISS}
2092
+ * };
2093
+ * ```
2094
+ *
2095
+ * When a user clicks the notification body, the notification will not be dismissed and no event will be raised to the client application.
2096
+ *
2097
+ * <li> Currently <code>ActionBodyClickType.DISMISS_EVENT</code> is only supported by <code>ActionTrigger.SELECT/onSelect</code></li>
2098
+ */
2099
+ interface ActionNoop {
2100
+ __NOOP__?: ActionNoopType;
2101
+ }
2102
+ /**
2103
+ * Set the `BODY_CLICK` field on an action with a {@link ActionBodyClickType|type} to allow the end-user to click the body of the notification to dismiss it. This was the default behavior in earlier releases. An event is also sent to the client application.
2104
+ *
2105
+ * Note the following restrictions:
2106
+ *
2107
+ * <ul>
2108
+ * <li>This override is ignored if buttons are passed to notification options.</li>
2109
+ * <li>The <code>ActionBodyClickType.DISMISS_EVENT</code> is supported only by <code>ActionTrigger.SELECT/onSelect</code></li>
2110
+ *
2111
+ * @example
2112
+ * ```
2113
+ * const notification = {
2114
+ * //...
2115
+ * onSelect: {BODY_CLICK: ActionBodyClickType.DISMISS_EVENT}
2116
+ * };
2117
+ * ```
2118
+ *
2119
+ */
2120
+ interface ActionBodyClick {
2121
+ BODY_CLICK?: ActionBodyClickType;
2122
+ }
2123
+
2124
+ type actions_d_ActionBodyClick = ActionBodyClick;
2125
+ type actions_d_ActionBodyClickType = ActionBodyClickType;
2126
+ declare const actions_d_ActionBodyClickType: typeof ActionBodyClickType;
2127
+ type actions_d_ActionDeclaration<T extends never, E extends never> = ActionDeclaration<T, E>;
2128
+ type actions_d_ActionNoop = ActionNoop;
2129
+ type actions_d_ActionNoopType = ActionNoopType;
2130
+ declare const actions_d_ActionNoopType: typeof ActionNoopType;
2131
+ type actions_d_ActionTrigger = ActionTrigger;
2132
+ declare const actions_d_ActionTrigger: typeof ActionTrigger;
2133
+ type actions_d_NotificationActionResult<T = CustomData> = NotificationActionResult<T>;
2134
+ declare namespace actions_d {
2135
+ export { actions_d_ActionBodyClickType as ActionBodyClickType, actions_d_ActionNoopType as ActionNoopType, actions_d_ActionTrigger as ActionTrigger };
2136
+ export type { actions_d_ActionBodyClick as ActionBodyClick, actions_d_ActionDeclaration as ActionDeclaration, actions_d_ActionNoop as ActionNoop, actions_d_NotificationActionResult as NotificationActionResult };
2137
+ }
2138
+
2139
+ /**
2140
+ * @hidden
2141
+ */
2142
+ /**
2143
+ * File contains types used to communicate between client and provider.
2144
+ *
2145
+ * These types are a part of the client, but are not required by applications wishing to interact with the service.
2146
+ * This file is excluded from the public-facing TypeScript documentation.
2147
+ */
2148
+
2149
+ type ColorSchemeOption = ColorSchemeType;
2150
+ /**
2151
+ * Distribute Omit across all union types instead of Omitting the union.
2152
+ * https://davidgomes.com/pick-omit-over-union-types-in-typescript/
2153
+ */
2154
+ type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
2155
+ type MakePropertyRequired<T, Prop extends keyof T> = Omit<T, Prop> & Required<Pick<T, Prop>>;
2156
+
2157
+ /**
2158
+ * Data returned by the service when registering a platform.
2159
+ */
2160
+ interface NotificationsRegistration {
2161
+ /**
2162
+ * Version of the client API.
2163
+ */
2164
+ clientAPIVersion: string;
2165
+ /**
2166
+ * Version of the notification service that is running.
2167
+ * A response of 'unknown' indicates that an older version of the service is running that does not support returning the service version.
2168
+ */
2169
+ notificationsVersion: string;
2170
+ }
2171
+ /**
2172
+ * Options for using privately hosted notification service.
2173
+ */
2174
+ type CustomManifestOptions = {
2175
+ /**
2176
+ * A custom manifest location to start the notification service from.
2177
+ * The UUID cannot be OpenFin hosted Notification Service UUID, 'notifications-service'.
2178
+ */
2179
+ manifestUrl: string;
2180
+ /**
2181
+ * The UUID of the provided custom notifications service manifest.
2182
+ * This value **MUST** match the UUID of the manifest provided in `manifestUrl`.
2183
+ */
2184
+ manifestUuid: string;
2185
+ };
2186
+ /**
2187
+ * Options for registering the notification service.
2188
+ * @property customManifest - Options for using privately hosted notification service.
2189
+ * @property toggleNotificationCenterHotkey - The hotkey combination to toggle the notification center.
2190
+ */
2191
+ type RegistrationOptions = {
2192
+ customManifest?: CustomManifestOptions;
2193
+ };
2194
+
2195
+ type WebNotificationProviderConfig = NotificationProviderInfo & {
2196
+ environment?: 'web';
2197
+ /**
2198
+ * `fin` entry point for the Here Core Web.
2199
+ * For setup instructions, see: https://www.npmjs.com/package/@openfin/core-web
2200
+ */
2201
+ finContext: OpenFin.Fin<'external connection'>;
2202
+ };
2203
+ type DesktopNotificationProviderConfig = RegistrationOptions & {
2204
+ environment: 'desktop';
2205
+ /**
2206
+ * `fin` entry point for the Here Core.
2207
+ */
2208
+ finContext: OpenFin.Fin<'window' | 'view'>;
2163
2209
  };
2164
- declare function connectToNotifications(config: NotificationProviderConfig): Promise<void>;
2210
+ type NotificationProviderConfig = DesktopNotificationProviderConfig | WebNotificationProviderConfig;
2211
+ declare function connectToNotifications(config: NotificationProviderConfig): Promise<NotificationsRegistration>;
2165
2212
 
2166
2213
  export { ActionBodyClickType, ActionNoopType, ActionTrigger, BooleanWidgetType, CheckboxGroupWidgetType, ContainerTemplateFragmentNames, DateWidgetType, FieldType, IndicatorColor, IndicatorType as NotificationIndicatorType, NumberWidgetType, PresentationTemplateFragmentNames, RadioGroupWidgetType, StringWidgetType, TemplateFragmentNames, TemplateNames, TimeWidgetType, UserSettings, VERSION, WidgetType, actions_d as actions, addEventListener, clear, clearAll, connectToNotifications, create, getAll, getNotificationsCount, getUserSettingStatus, hide, provider_d as provider, removeEventListener, setAllowedOrigins, setDefaultPlatformShortcut, show, toggleNotificationCenter, update };
2167
- export type { ActionBodyClick, ActionDeclaration, ActionNoop, ActionableFragment, ActionableTextTemplateFragment, AnyFormField, BaseField, BaseNotificationOptions, BaseTemplateFragment, BaseUpdatableNotificationOptions, BaseWidgetSpec, BodyTemplateOptions, BooleanField, BooleanWidget, ButtonOptions, ButtonTemplateOptions, CheckboxGroupField, CheckboxGroupWidget, CheckboxGroupWidgetSpec, CheckboxWidgetSpec, ContainerTemplateFragment, ControlOptions, CustomData, CustomTemplateData, CustomTemplateOptions, CustomValidationError, DateField, DateFieldValue, DateWidget, DateWidgetSpec, DropdownWidget, DropdownWidgetSpec, Form, FormField, FormFieldWithRequiredLabel, FormSettings, FormStatus, FormStatusOptions, ImageTemplateFragment, IndicatorTemplateOptions, ListPairs, ListTemplateFragment, Notification, NotificationActionEvent, NotificationActionResult, NotificationClosedEvent, NotificationCreatedEvent, NotificationCreationOptions, NotificationFormData, NotificationFormDataWithRequiredLabel, NotificationFormSubmittedEvent, NotificationFormValuesChangedEvent, NotificationIndicator, NotificationIndicatorWithCustomColor, NotificationOptions, NotificationProviderConfig, NotificationReminderCreatedEvent, NotificationReminderRemovedEvent, NotificationSoundOptions, NotificationSource, NotificationSourceDesktop, NotificationStream, NotificationToastDismissedEvent, NotificationsCountChanged, NumberField, NumberWidget, NumberWidgetSpec, PlatformDeregisterPayload, PlatformRegisterPayload, PresentationTemplateFragment, PrimaryControlOptions, RadioGroupField, RadioGroupWidget, RadioGroupWidgetSpec, SectionAlignment, ShowOptions, StringField, StringWidget, TemplateComposition, TemplateCustom, TemplateFragment, TemplateList, TemplateMarkdown, TextTemplateFragment, TextWidgetSpec, TimeField, TimeFieldValue, TimeWidget, TimeWidgetSpec, ToggleNotificationSound, ToggleWidgetSpec, UpdatableNotification, UpdatableNotificationOptions, UpdatableNotificationTemplateCustom, UpdatableNotificationTemplateList, UpdatableNotificationTemplateMarkdown, UserSettingStatus, ValidationEntry, Widget };
2214
+ export type { ActionBodyClick, ActionDeclaration, ActionNoop, ActionableFragment, ActionableTextTemplateFragment, AnyFormField, BaseField, BaseNotificationOptions, BaseTemplateFragment, BaseUpdatableNotificationOptions, BaseWidgetSpec, BodyTemplateOptions, BooleanField, BooleanWidget, ButtonOptions, ButtonTemplateOptions, CheckboxGroupField, CheckboxGroupWidget, CheckboxGroupWidgetSpec, CheckboxWidgetSpec, ContainerTemplateFragment, ControlOptions, CustomData, CustomTemplateData, CustomTemplateOptions, CustomValidationError, DateField, DateFieldValue, DateWidget, DateWidgetSpec, DesktopNotificationProviderConfig, DropdownWidget, DropdownWidgetSpec, Form, FormField, FormFieldWithRequiredLabel, FormSettings, FormStatus, FormStatusOptions, ImageTemplateFragment, IndicatorTemplateOptions, ListPairs, ListTemplateFragment, Notification, NotificationActionEvent, NotificationActionResult, NotificationClosedEvent, NotificationCreatedEvent, NotificationCreationOptions, NotificationFormData, NotificationFormDataWithRequiredLabel, NotificationFormSubmittedEvent, NotificationFormValuesChangedEvent, NotificationIndicator, NotificationIndicatorWithCustomColor, NotificationOptions, NotificationProviderConfig, NotificationReminderCreatedEvent, NotificationReminderRemovedEvent, NotificationSoundOptions, NotificationSource, NotificationSourceDesktop, NotificationStream, NotificationToastDismissedEvent, NotificationsCountChanged, NumberField, NumberWidget, NumberWidgetSpec, PlatformDeregisterPayload, PlatformRegisterPayload, PresentationTemplateFragment, PrimaryControlOptions, RadioGroupField, RadioGroupWidget, RadioGroupWidgetSpec, SectionAlignment, ShowOptions, StringField, StringWidget, TemplateComposition, TemplateCustom, TemplateFragment, TemplateList, TemplateMarkdown, TextTemplateFragment, TextWidgetSpec, TimeField, TimeFieldValue, TimeWidget, TimeWidgetSpec, ToggleNotificationSound, ToggleWidgetSpec, UpdatableNotification, UpdatableNotificationOptions, UpdatableNotificationTemplateCustom, UpdatableNotificationTemplateList, UpdatableNotificationTemplateMarkdown, UserSettingStatus, ValidationEntry, WebNotificationProviderConfig, Widget };
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["here-web-notifications-client"]=t():e["here-web-notifications-client"]=t()}(this,(()=>(()=>{"use strict";var e={2:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),r(i(637),t),r(i(536),t)},7:e=>{var t,i="object"==typeof Reflect?Reflect:null,n=i&&"function"==typeof i.apply?i.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};t=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(i,n){function r(i){e.removeListener(t,o),n(i)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",r),i([].slice.call(arguments))}m(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&m(e,"error",t,{once:!0})}(e,r)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,i,n){var r,o,s,u;if(a(i),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),o=e._events),s=o[t]),void 0===s)s=o[t]=i,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[i,s]:[s,i]:n?s.unshift(i):s.push(i),(r=c(e))>0&&s.length>r&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=l.bind(n);return r.listener=i,n.wrapFn=r,r}function f(e,t,i){var n=e._events;if(void 0===n)return[];var r=n[t];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(r):v(r,r.length)}function p(e){var t=this._events;if(void 0!==t){var i=t[e];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function v(e,t){for(var i=new Array(t),n=0;n<t;++n)i[n]=e[n];return i}function m(e,t,i,n){if("function"==typeof e.on)n.once?e.once(t,i):e.on(t,i);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function r(o){n.once&&e.removeEventListener(t,r),i(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r="error"===e,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var u=c.length,l=v(c,u);for(i=0;i<u;++i)n(l[i],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,d(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,d(this,e,t)),this},o.prototype.removeListener=function(e,t){var i,n,r,o,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(i=n[e]))return this;if(i===t||i.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(r=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){s=i[o].listener,r=o;break}if(r<0)return this;0===r?i.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(i,r),1===i.length&&(n[e]=i[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,i,n;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[e]),this;if(0===arguments.length){var r,o=Object.keys(i);for(n=0;n<o.length;++n)"removeListener"!==(r=o[n])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=i[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return f(this,e,!0)},o.prototype.rawListeners=function(e){return f(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},93:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},96:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},134:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},155:e=>{e.exports=void 0},217:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isConnectedToAtLeast=t.getStatus=void 0;const r=n(i(667)),o=i(155),s=i(902),a=i(349);function c(){return(0,o.withStrictTimeout)(500,(0,s.tryServiceDispatch)(a.APITopic.GET_PROVIDER_STATUS,void 0),"").catch((()=>({connected:!1,version:null,templateAPIVersion:null})))}t.getStatus=c,t.isConnectedToAtLeast=async function(e){const t=await c();if(t.connected&&null!==t.version){const i=(0,r.default)(t.version,e);if(0===i||1===i)return!0}return!1}},349:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.APITopic=t.getChannelName=t.SERVICE_CHANNEL=t.SERVICE_IDENTITY=void 0,t.SERVICE_IDENTITY={uuid:"notifications-service",name:"notifications-service"},t.SERVICE_CHANNEL="of-notifications-service-v1",t.getChannelName=e=>e===t.SERVICE_IDENTITY.uuid?t.SERVICE_CHANNEL:`${e}-${t.SERVICE_CHANNEL}`,(i=t.APITopic||(t.APITopic={})).CREATE_NOTIFICATION="create-notification",i.UPDATE_NOTIFICATION="update-notification",i.CLEAR_NOTIFICATION="clear-notification",i.GET_APP_NOTIFICATIONS="fetch-app-notifications",i.CLEAR_APP_NOTIFICATIONS="clear-app-notifications",i.TOGGLE_NOTIFICATION_CENTER="toggle-notification-center",i.ADD_EVENT_LISTENER="add-event-listener",i.REMOVE_EVENT_LISTENER="remove-event-listener",i.GET_PROVIDER_STATUS="get-provider-status",i.GET_NOTIFICATIONS_COUNT="get-notifications-count",i.SHOW_NOTIFICATION_CENTER="show-notification-center",i.HIDE_NOTIFICATION_CENTER="hide-notification-center",i.REGISTER_PLATFORM="register-notifications-platform",i.DEREGISTER_PLATFORM="deregister-notifications-platform",i.SET_FORM_STATUS_OPTIONS="set-form-status-options",i.SET_FORM_VALIDATION_ERRORS="set-form-validation-errors",i.GET_USER_SETTINGS_STATUS="get-user-settings-status",i.SET_DEFAULT_PLATFORM_SHORTCUT="set-default-platform-shortcut",i.SET_NOTIFICATION_SECURITY_RULE="set-notification-security-rule"},403:(e,t)=>{var i,n;Object.defineProperty(t,"__esModule",{value:!0}),t.IndicatorColor=t.IndicatorType=void 0,(n=t.IndicatorType||(t.IndicatorType={})).FAILURE="failure",n.WARNING="warning",n.SUCCESS="success",(i=t.IndicatorColor||(t.IndicatorColor={})).RED="red",i.GREEN="green",i.YELLOW="yellow",i.BLUE="blue",i.PURPLE="purple",i.GRAY="gray",i.ORANGE="orange",i.MAGENTA="magenta",i.TEAL="teal"},405:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},s=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)},a=this&&this.__rest||function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(i[n[r]]=e[n[r]])}return i};Object.defineProperty(t,"__esModule",{value:!0}),t.setAllowedOrigins=t.getUserSettingStatus=t.UserSettings=t.getNotificationsCount=t.hide=t.show=t.setDefaultPlatformShortcut=t.toggleNotificationCenter=t.clearAll=t.getAll=t.clear=t.update=t.create=t.removeEventListener=t.addEventListener=t.VERSION=t.NotificationIndicatorType=t.IndicatorColor=t.NotificationIndicatorWithCustomColor=t.NotificationIndicator=t.NotificationOptions=t.provider=t.actions=void 0;const c=i(777),u=i(902),l=i(349),d=i(471),f=o(i(217));t.provider=f;const p=i(855),v=i(403);Object.defineProperty(t,"NotificationIndicator",{enumerable:!0,get:function(){return v.NotificationIndicator}}),Object.defineProperty(t,"NotificationIndicatorWithCustomColor",{enumerable:!0,get:function(){return v.NotificationIndicatorWithCustomColor}}),Object.defineProperty(t,"NotificationIndicatorType",{enumerable:!0,get:function(){return v.IndicatorType}}),Object.defineProperty(t,"IndicatorColor",{enumerable:!0,get:function(){return v.IndicatorColor}});const m=i(965);Object.defineProperty(t,"NotificationOptions",{enumerable:!0,get:function(){return m.NotificationOptions}});const h=o(i(777));t.actions=h,s(i(777),t),s(i(578),t),s(i(93),t),s(i(2),t),s(i(520),t),s(i(96),t),s(i(470),t),t.VERSION="2.9.1-alpha-3948";const g=(0,d.getEventRouter)();function y(e){const{notification:t}=e;return Object.assign(Object.assign({},e),{notification:Object.assign(Object.assign({},t),{date:new Date(t.date),expires:null!==t.expires?new Date(t.expires):null})})}g.registerDeserializer("notification-created",(e=>y(e))),g.registerDeserializer("notification-toast-dismissed",(e=>y(e))),g.registerDeserializer("notification-closed",(e=>y(e))),g.registerDeserializer("notification-action",(e=>{var t;const i=y(e),{controlSource:n,controlIndex:r}=i,o=a(i,["controlSource","controlIndex"]);return e.trigger===c.ActionTrigger.CONTROL?Object.assign(Object.assign({},o),{control:null===(t=e.notification[n])||void 0===t?void 0:t[r]}):o})),g.registerDeserializer("notifications-count-changed",(e=>e)),g.registerDeserializer("notification-reminder-created",(e=>{const t=y(e),{reminderDate:i}=t,n=a(t,["reminderDate"]);return Object.assign(Object.assign({},n),{reminderDate:new Date(i)})})),g.registerDeserializer("notification-reminder-removed",(e=>y(e))),g.registerDeserializer("notification-sound-toggled",(e=>e)),t.addEventListener=async function(e,t){(0,p.validateEnvironment)(),e=(0,p.sanitizeEventType)(e),t=(0,p.sanitizeFunction)(t);const i=d.eventEmitter.listenerCount(e);"notification-form-submitted"===e&&(t=function(e){return t=>{const i=t.notification.id;t.setFormStatus=e=>(0,u.tryServiceDispatch)(l.APITopic.SET_FORM_STATUS_OPTIONS,Object.assign(Object.assign({},e),{_notificationId:i})),e(t)}}(t)),"notification-form-values-changed"===e&&(t=function(e){return t=>{t.setErrors=e=>(0,u.tryServiceDispatch)(l.APITopic.SET_FORM_VALIDATION_ERRORS,{errors:e,notificationId:t.notification.id}),e(t)}}(t)),d.eventEmitter.addListener(e,t),0===i&&1===d.eventEmitter.listenerCount(e)&&await(0,u.tryServiceDispatch)(l.APITopic.ADD_EVENT_LISTENER,e)},t.removeEventListener=async function(e,t){(0,p.validateEnvironment)(),e=(0,p.sanitizeEventType)(e),t=(0,p.sanitizeFunction)(t),1===d.eventEmitter.listenerCount(e)&&d.eventEmitter.listeners(e)[0]===t&&await(0,u.tryServiceDispatch)(l.APITopic.REMOVE_EVENT_LISTENER,e),d.eventEmitter.removeListener(e,t)},t.create=async function(e,t){if("object"!=typeof e||null===e)throw new Error("Invalid argument passed to create: argument must be an object and must not be null");if(void 0!==e.date&&!(e.date instanceof Date))throw new Error('Invalid argument passed to create: "date" must be a valid Date object');if(void 0!==e.expires&&null!==e.expires&&!(e.expires instanceof Date))throw new Error('Invalid argument passed to create: "expires" must be null or a valid Date object');if(t&&t.reminderDate){if(!1===e.allowReminder)throw new Error('You must not specify a reminder date for a notification with "allowReminder" option set to false.');if(!(t.reminderDate instanceof Date))throw new Error('Invalid argument passed to reminder Options: "date" must a valid Date object');if(e.expires&&e.expires.getTime()<t.reminderDate.getTime())throw new Error("Expiration date must not be earlier than reminder date.")}void 0!==e.category&&null!==e.category||(e.category="default");const i=await(0,u.tryServiceDispatch)(l.APITopic.CREATE_NOTIFICATION,Object.assign(Object.assign({},e),{date:e.date&&e.date.valueOf(),expires:e.expires&&e.expires.valueOf(),reminder:(null==t?void 0:t.reminderDate)&&t.reminderDate.valueOf()}));return Object.assign(Object.assign({},i),{date:new Date(i.date),expires:null!==i.expires?new Date(i.expires):null})},t.update=async function(e){if("object"!=typeof e||null===e)throw new Error("Invalid argument passed to create: argument must be an object and must not be null");if(!e.id)throw new Error('Invalid argument passed to create: "id" must be Id of previously created Notification');const t=await(0,u.tryServiceDispatch)(l.APITopic.UPDATE_NOTIFICATION,Object.assign({},e));return Object.assign({},t)},t.clear=async function(e){return(0,u.tryServiceDispatch)(l.APITopic.CLEAR_NOTIFICATION,{id:e})},t.getAll=async function(){return(await(0,u.tryServiceDispatch)(l.APITopic.GET_APP_NOTIFICATIONS,void 0)).map((e=>Object.assign(Object.assign({},e),{indicator:e.indicator||null,date:new Date(e.date),expires:null!==e.expires?new Date(e.expires):null})))},t.clearAll=async function(){return(0,u.tryServiceDispatch)(l.APITopic.CLEAR_APP_NOTIFICATIONS,void 0)},t.toggleNotificationCenter=async function(){return(0,u.tryServiceDispatch)(l.APITopic.TOGGLE_NOTIFICATION_CENTER,void 0)},t.setDefaultPlatformShortcut=function(e){return(0,u.tryServiceDispatch)(l.APITopic.SET_DEFAULT_PLATFORM_SHORTCUT,e)},t.show=async function(e){return(0,u.tryServiceDispatch)(l.APITopic.SHOW_NOTIFICATION_CENTER,e)},t.hide=async function(){return(0,u.tryServiceDispatch)(l.APITopic.HIDE_NOTIFICATION_CENTER,void 0)},t.getNotificationsCount=async function(){return(0,u.tryServiceDispatch)(l.APITopic.GET_NOTIFICATIONS_COUNT,void 0)},(t.UserSettings||(t.UserSettings={})).SOUND_ENABLED="soundEnabled",t.getUserSettingStatus=async function(e){return(0,u.tryServiceDispatch)(l.APITopic.GET_USER_SETTINGS_STATUS,e)},t.setAllowedOrigins=async e=>(0,u.tryServiceDispatch)(l.APITopic.SET_NOTIFICATION_SECURITY_RULE,{allowedOrigins:e})},468:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},470:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),r(i(134),t),r(i(468),t),r(i(965),t),r(i(929),t)},471:function(e,t,i){var n=this&&this.__rest||function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(i[n[r]]=e[n[r]])}return i};Object.defineProperty(t,"__esModule",{value:!0}),t.getEventRouter=t.eventEmitter=t.EventRouter=void 0;const r=i(7),o=i(902),s=i(349);class a{constructor(e){this._emitterProviders={},this._deserializers={},this._defaultEmitter=e}registerEmitterProvider(e,t){this._emitterProviders[e]=t}registerDeserializer(e,t){this._deserializers[e]=t}dispatchEvent(e){const{type:t,target:i}=e,r=n(e,["type","target"]);let a;if(!i)throw new Error("Invalid event, no target specified");if("default"===i)a=this._defaultEmitter;else{if(!this._emitterProviders[i.type])throw new Error(`Invalid target, no provider registered for '${i.type}'`);a=this._emitterProviders[i.type](i.id)}const c=Object.assign({type:t},r),u=this._deserializers[t];u?a.emit(t,u(c)):"notification-form-submitted"===t?function(e,t){let i=!1;e.preventDefault=()=>i=!0,t.emit("notification-form-submitted",e),i||(0,o.tryServiceDispatch)(s.APITopic.SET_FORM_STATUS_OPTIONS,{formStatus:"submitted",_notificationId:e.notification.id})}(c,a):a.emit(t,c)}}let c;t.EventRouter=a,t.eventEmitter=new r.EventEmitter,t.getEventRouter=function(){return c||(c=new a(t.eventEmitter)),c}},520:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},536:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetType=t.TimeWidgetType=t.DateWidgetType=t.RadioGroupWidgetType=t.CheckboxGroupWidgetType=t.BooleanWidgetType=t.NumberWidgetType=t.StringWidgetType=void 0,t.StringWidgetType={Text:"Text",Dropdown:"Dropdown"},t.NumberWidgetType={Number:"Number"},t.BooleanWidgetType={Toggle:"Toggle",Checkbox:"Checkbox"},t.CheckboxGroupWidgetType={CheckboxGroup:"CheckboxGroup"},t.RadioGroupWidgetType={RadioGroup:"RadioGroup"},t.DateWidgetType={Date:"Date"},t.TimeWidgetType={Time:"Time"},t.WidgetType=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t.StringWidgetType),t.NumberWidgetType),t.BooleanWidgetType),t.CheckboxGroupWidgetType),t.RadioGroupWidgetType),t.DateWidgetType),t.TimeWidgetType)},578:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},637:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FieldType=void 0,t.FieldType={string:"string",number:"number",boolean:"boolean",date:"date",checkboxGroup:"checkboxGroup",radioGroup:"radioGroup",time:"time"}},667:e=>{e.exports=void 0},683:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),t.connectToNotifications=void 0;const o=i(902),s=i(855),a=i(471);let c;r(i(405),t);const u=async(e,t)=>{if(!c)throw new Error("Not connected to the notification center. Did you call connectToNotifications()?.");return c.dispatch(e,t)};t.connectToNotifications=async function e(t){(e=>{if(!e)throw new Error("Provider config must be provided.");if(!e.id)throw new Error("id must be a non-zero length and must be a unique identifier of the provider.");if(!e.title)throw new Error("title must be a non-zero length.");if(!e.serviceId)throw new Error("serviceId must be a non-zero length and must match the service id of the Web Notification Center instance.");if(!e.finContext)throw new Error("fin context must be provided.")})(t),(0,s.setValidationMethod)((()=>{})),(0,o.setDispatchMethod)(u);const i={id:t.id,title:t.title,icon:t.icon};console.log("Connecting to the Notification Center..."),c=await t.finContext.InterApplicationBus.Channel.connect(t.serviceId,{wait:!0,payload:{version:"2.9.1-alpha-3948",providerInfo:i}}),console.log("Connected to the Notification Center.");const n=(0,a.getEventRouter)();c.setDefaultAction((()=>!1)),c.register("WARN",(e=>console.warn(e))),c.register("event",(e=>{n.dispatchEvent(e)})),c.onDisconnection((()=>{console.warn("Disconnected from the Notification Center"),c=null,setTimeout((()=>{console.log("Attempting to reconnect to the Notification Center"),e(t)}),300)}))}},777:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.ActionBodyClickType=t.ActionNoopType=t.ActionTrigger=void 0,(i=t.ActionTrigger||(t.ActionTrigger={})).CONTROL="control",i.SELECT="select",i.CLOSE="close",i.EXPIRE="expire",i.PROGRAMMATIC="programmatic",(t.ActionNoopType||(t.ActionNoopType={})).EVENT_DISMISS="event_dismiss",(t.ActionBodyClickType||(t.ActionBodyClickType={})).DISMISS_EVENT="dismiss_event"},855:(e,t)=>{function i(e,t){let i;try{i=JSON.stringify(e)}catch(e){i=t}return i}Object.defineProperty(t,"__esModule",{value:!0}),t.setValidationMethod=t.validateEnvironment=t.safeStringify=t.sanitizeEventType=t.sanitizeFunction=void 0,t.sanitizeFunction=function(e){if("function"!=typeof e)throw new Error(`Invalid argument passed: ${i(e,"The provided value")} is not a valid function`);return e},t.sanitizeEventType=function(e){if("notification-action"===e||"notification-created"===e||"notification-toast-dismissed"===e||"notification-closed"===e||"notifications-count-changed"===e||"notification-form-submitted"===e||"notification-reminder-created"===e||"notification-reminder-removed"===e||"notification-form-values-changed"===e||"notification-sound-toggled"===e)return e;throw new Error(`Invalid argument passed: ${i(e,"The provided event type")} is not a valid Notifications event type`)},t.safeStringify=i,t.validateEnvironment=()=>{throw new Error("fin is not defined. The openfin-notifications module is only intended for use in an OpenFin application.")},t.setValidationMethod=e=>{t.validateEnvironment=e}},902:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDispatchMethod=t.tryServiceDispatch=void 0,t.tryServiceDispatch=async(e,t)=>{throw new Error("Environment is not initialized..")},t.setDispatchMethod=e=>{t.tryServiceDispatch=e}},929:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},965:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TemplateFragmentNames=t.PresentationTemplateFragmentNames=t.ContainerTemplateFragmentNames=t.TemplateNames=void 0,t.TemplateNames={markdown:"markdown",list:"list",custom:"custom"},t.ContainerTemplateFragmentNames={container:"container"},t.PresentationTemplateFragmentNames={text:"text",image:"image",list:"list",actionableText:"actionableText"},t.TemplateFragmentNames=Object.assign(Object.assign({},t.ContainerTemplateFragmentNames),t.PresentationTemplateFragmentNames)}},t={};return function i(n){var r=t[n];if(void 0!==r)return r.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,i),o.exports}(683)})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["here-web-notifications-client"]=t():e["here-web-notifications-client"]=t()}(this,(()=>(()=>{"use strict";var e={2:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(637),t),r(n(155),t)},7:e=>{var t,n="object"==typeof Reflect?Reflect:null,i=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(n,i){function r(n){e.removeListener(t,o),i(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",r),n([].slice.call(arguments))}h(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&h(e,"error",t,{once:!0})}(e,r)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function s(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function l(e,t,n,i){var r,o,a,l;if(s(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),void 0===a)a=o[t]=n,++e._eventsCount;else if("function"==typeof a?a=o[t]=i?[n,a]:[a,n]:i?a.unshift(n):a.push(n),(r=c(e))>0&&a.length>r&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,l=u,console&&console.warn&&console.warn(l)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=u.bind(i);return r.listener=n,i.wrapFn=r,r}function d(e,t,n){var i=e._events;if(void 0===i)return[];var r=i[t];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(r):v(r,r.length)}function p(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function v(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}function h(e,t,n,i){if("function"==typeof e.on)i.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function r(o){i.once&&e.removeEventListener(t,r),n(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)i(c,this,t);else{var l=c.length,u=v(c,l);for(n=0;n<l;++n)i(u[n],this,t)}return!0},o.prototype.addListener=function(e,t){return l(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return l(this,e,t,!0)},o.prototype.once=function(e,t){return s(t),this.on(e,f(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return s(t),this.prependListener(e,f(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,i,r,o,a;if(s(t),void 0===(i=this._events))return this;if(void 0===(n=i[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(r=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,r=o;break}if(r<0)return this;0===r?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,r),1===n.length&&(i[e]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",e,a||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var r,o=Object.keys(n);for(i=0;i<o.length;++i)"removeListener"!==(r=o[i])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},o.prototype.listeners=function(e){return d(this,e,!0)},o.prototype.rawListeners=function(e){return d(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},36:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Log=void 0;const i=n(329);class r{static async error(e){try{const t=r.getPrefixedMessage(e);console.error(t),await i.finContext.System.log("error",t)}catch(e){r.handleError(e,"Failed to log error")}}static async warn(e){try{const t=r.getPrefixedMessage(e);console.warn(t),await i.finContext.System.log("warning",t)}catch(e){r.handleError(e,"Failed to log warning")}}static async info(e){try{const t=r.getPrefixedMessage(e);console.info(t),await i.finContext.System.log("info",t)}catch(e){r.handleError(e,"Failed to log info")}}static getPrefixedMessage(e){return`${r.LOG_PREFIX} ${e}`}static handleError(e,t){e instanceof Error?console.error(`${t} - ${e.name}: ${e.message}`):console.error(`${t} - ${JSON.stringify(e)}`)}}t.Log=r,r.LOG_PREFIX="[openfin-notifications]"},89:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DeferredPromise=class{constructor(){const e=new Promise(((e,t)=>{this._resolve=e,this._reject=t}));this._promise=e}get promise(){return this._promise}get resolve(){return this._resolve}get reject(){return this._reject}}},93:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},96:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},134:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},155:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetType=t.TimeWidgetType=t.DateWidgetType=t.RadioGroupWidgetType=t.CheckboxGroupWidgetType=t.BooleanWidgetType=t.NumberWidgetType=t.StringWidgetType=void 0,t.StringWidgetType={Text:"Text",Dropdown:"Dropdown"},t.NumberWidgetType={Number:"Number"},t.BooleanWidgetType={Toggle:"Toggle",Checkbox:"Checkbox"},t.CheckboxGroupWidgetType={CheckboxGroup:"CheckboxGroup"},t.RadioGroupWidgetType={RadioGroup:"RadioGroup"},t.DateWidgetType={Date:"Date"},t.TimeWidgetType={Time:"Time"},t.WidgetType=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t.StringWidgetType),t.NumberWidgetType),t.BooleanWidgetType),t.CheckboxGroupWidgetType),t.RadioGroupWidgetType),t.DateWidgetType),t.TimeWidgetType)},158:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ActionBodyClickType=t.ActionNoopType=t.ActionTrigger=void 0,(n=t.ActionTrigger||(t.ActionTrigger={})).CONTROL="control",n.SELECT="select",n.CLOSE="close",n.EXPIRE="expire",n.PROGRAMMATIC="programmatic",(t.ActionNoopType||(t.ActionNoopType={})).EVENT_DISMISS="event_dismiss",(t.ActionBodyClickType||(t.ActionBodyClickType={})).DISMISS_EVENT="dismiss_event"},217:function(e,t,n){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isConnectedToAtLeast=t.getStatus=void 0;const r=i(n(667)),o=n(785),a=n(902),s=n(349);function c(){return(0,o.withStrictTimeout)(500,(0,a.tryServiceDispatch)(s.APITopic.GET_PROVIDER_STATUS,void 0),"").catch((()=>({connected:!1,version:null,templateAPIVersion:null})))}t.getStatus=c,t.isConnectedToAtLeast=async function(e){const t=await c();if(t.connected&&null!==t.version){const n=(0,r.default)(t.version,e);if(0===n||1===n)return!0}return!1}},329:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setFinContext=t.finContext=void 0,t.setFinContext=e=>{t.finContext=e}},349:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.APITopic=t.getChannelName=t.SERVICE_CHANNEL=t.SERVICE_IDENTITY=void 0,t.SERVICE_IDENTITY={uuid:"notifications-service",name:"notifications-service"},t.SERVICE_CHANNEL="of-notifications-service-v1",t.getChannelName=e=>e===t.SERVICE_IDENTITY.uuid?t.SERVICE_CHANNEL:`${e}-${t.SERVICE_CHANNEL}`,(n=t.APITopic||(t.APITopic={})).CREATE_NOTIFICATION="create-notification",n.UPDATE_NOTIFICATION="update-notification",n.CLEAR_NOTIFICATION="clear-notification",n.GET_APP_NOTIFICATIONS="fetch-app-notifications",n.CLEAR_APP_NOTIFICATIONS="clear-app-notifications",n.TOGGLE_NOTIFICATION_CENTER="toggle-notification-center",n.ADD_EVENT_LISTENER="add-event-listener",n.REMOVE_EVENT_LISTENER="remove-event-listener",n.GET_PROVIDER_STATUS="get-provider-status",n.GET_NOTIFICATIONS_COUNT="get-notifications-count",n.SHOW_NOTIFICATION_CENTER="show-notification-center",n.HIDE_NOTIFICATION_CENTER="hide-notification-center",n.REGISTER_PLATFORM="register-notifications-platform",n.DEREGISTER_PLATFORM="deregister-notifications-platform",n.SET_FORM_STATUS_OPTIONS="set-form-status-options",n.SET_FORM_VALIDATION_ERRORS="set-form-validation-errors",n.GET_USER_SETTINGS_STATUS="get-user-settings-status",n.SET_DEFAULT_PLATFORM_SHORTCUT="set-default-platform-shortcut",n.SET_NOTIFICATION_SECURITY_RULE="set-notification-security-rule"},403:(e,t)=>{var n,i;Object.defineProperty(t,"__esModule",{value:!0}),t.IndicatorColor=t.IndicatorType=void 0,(i=t.IndicatorType||(t.IndicatorType={})).FAILURE="failure",i.WARNING="warning",i.SUCCESS="success",(n=t.IndicatorColor||(t.IndicatorColor={})).RED="red",n.GREEN="green",n.YELLOW="yellow",n.BLUE="blue",n.PURPLE="purple",n.GRAY="gray",n.ORANGE="orange",n.MAGENTA="magenta",n.TEAL="teal"},405:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&i(t,e,n);return r(t,e),t},a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)},s=this&&this.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.setAllowedOrigins=t.getUserSettingStatus=t.UserSettings=t.getNotificationsCount=t.hide=t.show=t.setDefaultPlatformShortcut=t.toggleNotificationCenter=t.clearAll=t.getAll=t.clear=t.update=t.create=t.removeEventListener=t.addEventListener=t.VERSION=t.NotificationIndicatorType=t.IndicatorColor=t.NotificationIndicatorWithCustomColor=t.NotificationIndicator=t.NotificationOptions=t.provider=t.actions=void 0;const c=n(158),l=n(902),u=n(349),f=n(471),d=o(n(217));t.provider=d;const p=n(855),v=n(403);Object.defineProperty(t,"NotificationIndicator",{enumerable:!0,get:function(){return v.NotificationIndicator}}),Object.defineProperty(t,"NotificationIndicatorWithCustomColor",{enumerable:!0,get:function(){return v.NotificationIndicatorWithCustomColor}}),Object.defineProperty(t,"NotificationIndicatorType",{enumerable:!0,get:function(){return v.IndicatorType}}),Object.defineProperty(t,"IndicatorColor",{enumerable:!0,get:function(){return v.IndicatorColor}});const h=n(965);Object.defineProperty(t,"NotificationOptions",{enumerable:!0,get:function(){return h.NotificationOptions}});const m=o(n(158));t.actions=m,a(n(158),t),a(n(578),t),a(n(93),t),a(n(2),t),a(n(520),t),a(n(96),t),a(n(470),t),t.VERSION="2.9.1-alpha-3958";const g=(0,f.getEventRouter)();function y(e){const{notification:t}=e;return Object.assign(Object.assign({},e),{notification:Object.assign(Object.assign({},t),{date:new Date(t.date),expires:null!==t.expires?new Date(t.expires):null})})}g.registerDeserializer("notification-created",(e=>y(e))),g.registerDeserializer("notification-toast-dismissed",(e=>y(e))),g.registerDeserializer("notification-closed",(e=>y(e))),g.registerDeserializer("notification-action",(e=>{var t;const n=y(e),{controlSource:i,controlIndex:r}=n,o=s(n,["controlSource","controlIndex"]);return e.trigger===c.ActionTrigger.CONTROL?Object.assign(Object.assign({},o),{control:null===(t=e.notification[i])||void 0===t?void 0:t[r]}):o})),g.registerDeserializer("notifications-count-changed",(e=>e)),g.registerDeserializer("notification-reminder-created",(e=>{const t=y(e),{reminderDate:n}=t,i=s(t,["reminderDate"]);return Object.assign(Object.assign({},i),{reminderDate:new Date(n)})})),g.registerDeserializer("notification-reminder-removed",(e=>y(e))),g.registerDeserializer("notification-sound-toggled",(e=>e)),t.addEventListener=async function(e,t){(0,p.validateEnvironment)(),e=(0,p.sanitizeEventType)(e),t=(0,p.sanitizeFunction)(t);const n=f.eventEmitter.listenerCount(e);"notification-form-submitted"===e&&(t=function(e){return t=>{const n=t.notification.id;t.setFormStatus=e=>(0,l.tryServiceDispatch)(u.APITopic.SET_FORM_STATUS_OPTIONS,Object.assign(Object.assign({},e),{_notificationId:n})),e(t)}}(t)),"notification-form-values-changed"===e&&(t=function(e){return t=>{t.setErrors=e=>(0,l.tryServiceDispatch)(u.APITopic.SET_FORM_VALIDATION_ERRORS,{errors:e,notificationId:t.notification.id}),e(t)}}(t)),f.eventEmitter.addListener(e,t),0===n&&1===f.eventEmitter.listenerCount(e)&&await(0,l.tryServiceDispatch)(u.APITopic.ADD_EVENT_LISTENER,e)},t.removeEventListener=async function(e,t){(0,p.validateEnvironment)(),e=(0,p.sanitizeEventType)(e),t=(0,p.sanitizeFunction)(t),1===f.eventEmitter.listenerCount(e)&&f.eventEmitter.listeners(e)[0]===t&&await(0,l.tryServiceDispatch)(u.APITopic.REMOVE_EVENT_LISTENER,e),f.eventEmitter.removeListener(e,t)},t.create=async function(e,t){if("object"!=typeof e||null===e)throw new Error("Invalid argument passed to create: argument must be an object and must not be null");if(void 0!==e.date&&!(e.date instanceof Date))throw new Error('Invalid argument passed to create: "date" must be a valid Date object');if(void 0!==e.expires&&null!==e.expires&&!(e.expires instanceof Date))throw new Error('Invalid argument passed to create: "expires" must be null or a valid Date object');if(t&&t.reminderDate){if(!1===e.allowReminder)throw new Error('You must not specify a reminder date for a notification with "allowReminder" option set to false.');if(!(t.reminderDate instanceof Date))throw new Error('Invalid argument passed to reminder Options: "date" must a valid Date object');if(e.expires&&e.expires.getTime()<t.reminderDate.getTime())throw new Error("Expiration date must not be earlier than reminder date.")}void 0!==e.category&&null!==e.category||(e.category="default");const n=await(0,l.tryServiceDispatch)(u.APITopic.CREATE_NOTIFICATION,Object.assign(Object.assign({},e),{date:e.date&&e.date.valueOf(),expires:e.expires&&e.expires.valueOf(),reminder:(null==t?void 0:t.reminderDate)&&t.reminderDate.valueOf()}));return Object.assign(Object.assign({},n),{date:new Date(n.date),expires:null!==n.expires?new Date(n.expires):null})},t.update=async function(e){if("object"!=typeof e||null===e)throw new Error("Invalid argument passed to create: argument must be an object and must not be null");if(!e.id)throw new Error('Invalid argument passed to create: "id" must be Id of previously created Notification');const t=await(0,l.tryServiceDispatch)(u.APITopic.UPDATE_NOTIFICATION,Object.assign({},e));return Object.assign({},t)},t.clear=async function(e){return(0,l.tryServiceDispatch)(u.APITopic.CLEAR_NOTIFICATION,{id:e})},t.getAll=async function(){return(await(0,l.tryServiceDispatch)(u.APITopic.GET_APP_NOTIFICATIONS,void 0)).map((e=>Object.assign(Object.assign({},e),{indicator:e.indicator||null,date:new Date(e.date),expires:null!==e.expires?new Date(e.expires):null})))},t.clearAll=async function(){return(0,l.tryServiceDispatch)(u.APITopic.CLEAR_APP_NOTIFICATIONS,void 0)},t.toggleNotificationCenter=async function(){return(0,l.tryServiceDispatch)(u.APITopic.TOGGLE_NOTIFICATION_CENTER,void 0)},t.setDefaultPlatformShortcut=function(e){return(0,l.tryServiceDispatch)(u.APITopic.SET_DEFAULT_PLATFORM_SHORTCUT,e)},t.show=async function(e){return(0,l.tryServiceDispatch)(u.APITopic.SHOW_NOTIFICATION_CENTER,e)},t.hide=async function(){return(0,l.tryServiceDispatch)(u.APITopic.HIDE_NOTIFICATION_CENTER,void 0)},t.getNotificationsCount=async function(){return(0,l.tryServiceDispatch)(u.APITopic.GET_NOTIFICATIONS_COUNT,void 0)},(t.UserSettings||(t.UserSettings={})).SOUND_ENABLED="soundEnabled",t.getUserSettingStatus=async function(e){return(0,l.tryServiceDispatch)(u.APITopic.GET_USER_SETTINGS_STATUS,e)},t.setAllowedOrigins=async e=>(0,l.tryServiceDispatch)(u.APITopic.SET_NOTIFICATION_SECURITY_RULE,{allowedOrigins:e})},468:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},470:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(134),t),r(n(468),t),r(n(965),t),r(n(929),t)},471:function(e,t,n){var i=this&&this.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.getEventRouter=t.eventEmitter=t.EventRouter=void 0;const r=n(7),o=n(902),a=n(349);class s{constructor(e){this._emitterProviders={},this._deserializers={},this._defaultEmitter=e}registerEmitterProvider(e,t){this._emitterProviders[e]=t}registerDeserializer(e,t){this._deserializers[e]=t}dispatchEvent(e){const{type:t,target:n}=e,r=i(e,["type","target"]);let s;if(!n)throw new Error("Invalid event, no target specified");if("default"===n)s=this._defaultEmitter;else{if(!this._emitterProviders[n.type])throw new Error(`Invalid target, no provider registered for '${n.type}'`);s=this._emitterProviders[n.type](n.id)}const c=Object.assign({type:t},r),l=this._deserializers[t];l?s.emit(t,l(c)):"notification-form-submitted"===t?function(e,t){let n=!1;e.preventDefault=()=>n=!0,t.emit("notification-form-submitted",e),n||(0,o.tryServiceDispatch)(a.APITopic.SET_FORM_STATUS_OPTIONS,{formStatus:"submitted",_notificationId:e.notification.id})}(c,s):s.emit(t,c)}}let c;t.EventRouter=s,t.eventEmitter=new r.EventEmitter,t.getEventRouter=function(){return c||(c=new s(t.eventEmitter)),c}},520:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},578:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},610:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultValidateEnvironment=t.defaultDispatch=void 0;const i=n(793),r=n(329);t.defaultDispatch=async function(e,t){return(await(0,i.getChannelClient)()).dispatch(e,t)},t.defaultValidateEnvironment=function(){if(void 0===r.finContext)throw new Error("fin is not defined. The openfin-notifications module is only intended for use in an OpenFin application.")}},637:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FieldType=void 0,t.FieldType={string:"string",number:"number",boolean:"boolean",date:"date",checkboxGroup:"checkboxGroup",radioGroup:"radioGroup",time:"time"}},667:e=>{e.exports=void 0},683:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.connectToNotifications=void 0;const o=n(902),a=n(855),s=n(471),c=n(797),l=n(217),u=n(329),f=n(610);let d;r(n(405),t);const p=async(e,t)=>{if(!d)throw new Error("Not connected to the notification center. Did you call connectToNotifications()?.");return d.dispatch(e,t)};t.connectToNotifications=async function e(t){if(!t)throw new Error("Provider config must be provided.");if(!t.finContext)throw new Error("fin context must be provided.");if("desktop"===t.environment){if(!t.finContext.me.isOpenFin)throw new Error("You must be in Here environment when you provide a desktop config.");return(0,u.setFinContext)(t.finContext),(0,a.setValidationMethod)(f.defaultValidateEnvironment),(0,o.setDispatchMethod)(f.defaultDispatch),(0,c.register)(t)}{(e=>{if(!e.id)throw new Error("id must be a non-zero length and must be a unique identifier of the provider.");if(!e.title)throw new Error("title must be a non-zero length.");if(!e.serviceId)throw new Error("serviceId must be a non-zero length and must match the service id of the Web Notification Center instance.")})(t),(0,a.setValidationMethod)((()=>{})),(0,o.setDispatchMethod)(p);const n={id:t.id,title:t.title,icon:t.icon};console.log("Connecting to the Notification Center..."),d=await t.finContext.InterApplicationBus.Channel.connect(t.serviceId,{wait:!0,payload:{version:"2.9.1-alpha-3958",providerInfo:n}}),console.log("Connected to the Notification Center.");const i=(0,s.getEventRouter)();return d.setDefaultAction((()=>!1)),d.register("WARN",(e=>console.warn(e))),d.register("event",(e=>{i.dispatchEvent(e)})),d.onDisconnection((()=>{console.warn("Disconnected from the Notification Center"),d=null,setTimeout((()=>{console.log("Attempting to reconnect to the Notification Center"),e(t)}),300)})),{clientAPIVersion:"2.9.1-alpha-3958",notificationsVersion:(await(0,l.getStatus)()).version||"unknown"}}}},777:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=n(89);async function r(e,t){let n=0;for(const i of e)await t(i,n,e),n++}async function o(e,t){await Promise.all(e.map(t))}function a(e,t,n){const r=new i.DeferredPromise,o=e.add(((...e)=>{t(...e)&&(o.remove(),r.resolve())}));return n&&n.catch((e=>{o.remove(),r.reject(e)})),s(r.promise)}function s(e){return e.catch((()=>{})),e}t.serialForEach=r,t.serialMap=async function(e,t){const n=[];return await r(e,(async(e,i,r)=>{n.push(await t(e,i,r))})),n},t.serialFilter=async function(e,t){const n=[];return await r(e,(async(e,i,r)=>{await t(e,i,r)&&n.push(e)})),n},t.parallelForEach=o,t.parallelMap=async function(e,t){const n=[];return await o(e,(async(e,i,r)=>{n[i]=await t(e,i,r)})),n},t.parallelFilter=async function(e,t){const n=[];return await o(e,(async(e,i,r)=>{n[i]=await t(e,i,r)})),e.filter(((e,t)=>n[t]))},t.withStrictTimeout=function(e,t,n){const i=new Promise(((t,i)=>setTimeout((()=>i(new Error(n))),e)));return s(Promise.race([i,t]))},t.withTimeout=function(e,t){const n=new Promise((t=>setTimeout((()=>t([!0,void 0])),e))),i=t.then((e=>[!1,e]));return Promise.race([n,i])},t.untilTrue=function(e,t,n){return t()?Promise.resolve():a(e,t,n)},t.untilSignal=a,t.allowReject=s},785:(e,t,n)=>{function i(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),i(n(777)),i(n(89))},793:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getChannelClient=t.clearAwaitedChannelClient=t.initAwaitedChannelClient=t.ChannelClientConfig=void 0;const i=n(349),r=n(36),o=n(329);t.ChannelClientConfig={serviceChannel:i.SERVICE_CHANNEL};const a=async({wait:e})=>{await r.Log.info("Connecting to Notifications...");const n=await o.finContext.InterApplicationBus.Channel.connect(t.ChannelClientConfig.serviceChannel,{wait:e,payload:{version:"2.9.1-alpha-3958"}});return await r.Log.info("Successfully connected to Notifications."),n};let s,c;t.initAwaitedChannelClient=()=>s?{channelClientPromise:s,isInit:!1}:(s=a({wait:!0}),s.catch((e=>(0,t.clearAwaitedChannelClient)())),{channelClientPromise:s,isInit:!0}),t.clearAwaitedChannelClient=()=>{s=null},t.getChannelClient=async()=>s||(async()=>{if(!c){try{c=await a({wait:!1}),c.setDefaultAction((()=>!1))}catch(e){throw await r.Log.error('Could not find channel provider. Did you call "notifications.register()"?'),e}c.onDisconnection((()=>{c=null}))}return c})()},797:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.register=t.ChannelClientHandlers=void 0;const i=n(349),r=n(471),o=n(36),a=n(793),s=n(217),c=n(329);class l{}t.ChannelClientHandlers=l,l.handleDefaultAction=()=>!1,l.handleEventAction=e=>{(0,r.getEventRouter)().dispatchEvent(e)},l.handleWarnAction=async e=>{await o.Log.warn(e)},l.handleDisconnection=async()=>{(0,a.getChannelClient)()&&(await o.Log.warn("Disconnected from Notifications. Reconnecting..."),(0,a.clearAwaitedChannelClient)(),await d(),await p())};let u=null;t.register=async e=>{if(u)return u;try{return u=f(e),await u}finally{u=null}};const f=async e=>{if(null==e?void 0:e.customManifest){if(!e.customManifest.manifestUrl)throw new Error("manifestUrl must be provided.");if(!e.customManifest.manifestUuid)throw new Error("manifestUuid must be provided and must not be an empty string.");if(e.customManifest.manifestUuid===i.SERVICE_CHANNEL)throw new Error(`manifestUuid must not be ${i.SERVICE_CHANNEL}`);a.ChannelClientConfig.serviceChannel=`${e.customManifest.manifestUuid}-${i.SERVICE_CHANNEL}`,await d(e.customManifest.manifestUrl)}else a.ChannelClientConfig.serviceChannel=i.SERVICE_CHANNEL,await d();return await p(),{clientAPIVersion:"2.9.1-alpha-3958",notificationsVersion:(await(0,s.getStatus)()).version||"unknown"}},d=async e=>{try{const t=window.navigator.userAgent.toLowerCase().includes("windows"),n=e||"fins://system-apps/notification-center";t?(await o.Log.info("Launching Notifications via fin.System.launchManifest..."),await c.finContext.System.launchManifest(n,{noUi:!0})):(await o.Log.info("Launching Notifications via fin.System.openUrlWithBrowser..."),await c.finContext.System.openUrlWithBrowser(n))}catch(e){throw e instanceof Error?await o.Log.error(`Failed to launch Notifications - ${e.name}: ${e.message}`):await o.Log.error(`Failed to launch Notifications - ${JSON.stringify(e)}`),e}},p=async()=>{try{const{channelClientPromise:e,isInit:t}=(0,a.initAwaitedChannelClient)(),n=await e;t&&(n.setDefaultAction(l.handleDefaultAction),n.register("event",l.handleEventAction),n.register("WARN",l.handleWarnAction),n.onDisconnection(l.handleDisconnection),c.finContext.Window.wrapSync(i.SERVICE_IDENTITY).once("closed",l.handleDisconnection))}catch(e){throw e instanceof Error?await o.Log.error(`Failed to connect to Notifications - ${e.name}: ${e.message}`):await o.Log.error(`Failed to connect to Notifications - ${JSON.stringify(e)}`),e}}},855:(e,t)=>{function n(e,t){let n;try{n=JSON.stringify(e)}catch(e){n=t}return n}Object.defineProperty(t,"__esModule",{value:!0}),t.setValidationMethod=t.validateEnvironment=t.safeStringify=t.sanitizeEventType=t.sanitizeFunction=void 0,t.sanitizeFunction=function(e){if("function"!=typeof e)throw new Error(`Invalid argument passed: ${n(e,"The provided value")} is not a valid function`);return e},t.sanitizeEventType=function(e){if("notification-action"===e||"notification-created"===e||"notification-toast-dismissed"===e||"notification-closed"===e||"notifications-count-changed"===e||"notification-form-submitted"===e||"notification-reminder-created"===e||"notification-reminder-removed"===e||"notification-form-values-changed"===e||"notification-sound-toggled"===e)return e;throw new Error(`Invalid argument passed: ${n(e,"The provided event type")} is not a valid Notifications event type`)},t.safeStringify=n,t.validateEnvironment=()=>{throw new Error("fin is not defined. The openfin-notifications module is only intended for use in an OpenFin application.")},t.setValidationMethod=e=>{t.validateEnvironment=e}},902:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDispatchMethod=t.tryServiceDispatch=void 0,t.tryServiceDispatch=async(e,t)=>{throw new Error("Environment is not initialized..")},t.setDispatchMethod=e=>{t.tryServiceDispatch=e}},929:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},965:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TemplateFragmentNames=t.PresentationTemplateFragmentNames=t.ContainerTemplateFragmentNames=t.TemplateNames=void 0,t.TemplateNames={markdown:"markdown",list:"list",custom:"custom"},t.ContainerTemplateFragmentNames={container:"container"},t.PresentationTemplateFragmentNames={text:"text",image:"image",list:"list",actionableText:"actionableText"},t.TemplateFragmentNames=Object.assign(Object.assign({},t.ContainerTemplateFragmentNames),t.PresentationTemplateFragmentNames)}},t={};return function n(i){var r=t[i];if(void 0!==r)return r.exports;var o=t[i]={exports:{}};return e[i].call(o.exports,o,o.exports,n),o.exports}(683)})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/web-notifications-client",
3
- "version": "2.9.1-alpha-3948",
3
+ "version": "2.9.1-alpha-3958",
4
4
  "description": "Here™ Web Notification Center Client API",
5
5
  "main": "dist/client/index.js",
6
6
  "types": "dist/client/web/index.d.ts",
@@ -18,8 +18,6 @@
18
18
  "license": "SEE LICENSE IN LICENSE.MD",
19
19
  "homepage": "https://www.here.io/",
20
20
  "peerDependencies": {
21
- "openfin-service-async": ">= 1.0.1 < 2.0.0",
22
- "openfin-service-signal": ">= 1.0.0 < 2.0.0",
23
21
  "semver-compare": ">= 1.0.0 < 2.0.0",
24
22
  "@openfin/core": "41.100.117"
25
23
  }