web-push-notifications 3.44.7 → 3.44.8

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.
Files changed (224) hide show
  1. package/core/Pushwoosh.d.ts +199 -0
  2. package/core/Pushwoosh.types.d.ts +213 -0
  3. package/core/Safari.types.d.ts +17 -0
  4. package/core/constants.d.ts +41 -0
  5. package/core/events.types.d.ts +55 -0
  6. package/core/functions.d.ts +5 -0
  7. package/core/legacyEventsMap.d.ts +5 -0
  8. package/core/logger.d.ts +14 -0
  9. package/core/modules/EventBus/EventBus.d.ts +10 -0
  10. package/core/storage.d.ts +27 -0
  11. package/helpers/logger.d.ts +11 -0
  12. package/helpers/pwlogger/Logger.constants.d.ts +21 -0
  13. package/helpers/pwlogger/Logger.d.ts +37 -0
  14. package/helpers/pwlogger/Logger.types.d.ts +44 -0
  15. package/helpers/pwlogger/handlers/handler-console/handler-console.d.ts +2 -0
  16. package/{src/helpers/unescape.ts → helpers/unescape.d.ts} +1 -18
  17. package/models/InboxMessages.d.ts +82 -0
  18. package/models/InboxMessages.types.d.ts +83 -0
  19. package/models/NotificationPayload.d.ts +39 -0
  20. package/models/NotificationPayload.types.d.ts +63 -0
  21. package/modules/Api/Api.d.ts +45 -0
  22. package/modules/Api/Api.types.d.ts +7 -0
  23. package/modules/ApiClient/ApiClient.d.ts +29 -0
  24. package/modules/ApiClient/ApiClient.types.d.ts +188 -0
  25. package/modules/Data/Data.d.ts +76 -0
  26. package/modules/DateModule.d.ts +27 -0
  27. package/modules/InboxMessagesPublic.d.ts +64 -0
  28. package/modules/PlatformChecker/PlatformChecker.d.ts +45 -0
  29. package/modules/PlatformChecker/PlatformChecker.types.d.ts +5 -0
  30. package/modules/storage/Storage.d.ts +63 -0
  31. package/{src/modules/storage/Storage.types.ts → modules/storage/Storage.types.d.ts} +7 -25
  32. package/modules/storage/Store.d.ts +22 -0
  33. package/modules/storage/migrations/26-11-2018.d.ts +2 -0
  34. package/modules/storage/migrations/MigrationExecutor.d.ts +9 -0
  35. package/modules/storage/migrations/Migrations.d.ts +15 -0
  36. package/modules/storage/migrations/constants.d.ts +6 -0
  37. package/modules/storage/migrations/helpers.d.ts +7 -0
  38. package/modules/storage/migrations/initial.d.ts +2 -0
  39. package/modules/storage/version.d.ts +2 -0
  40. package/npm.js +2 -0
  41. package/npm.js.map +1 -0
  42. package/package.json +1 -1
  43. package/service-worker.d.ts +1 -0
  44. package/service-worker.js +2 -0
  45. package/service-worker.js.map +1 -0
  46. package/services/PushService/PushService.types.d.ts +64 -0
  47. package/services/PushService/drivers/PushServiceDefault/PushServiceDefault.d.ts +29 -0
  48. package/{src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.types.ts → services/PushService/drivers/PushServiceDefault/PushServiceDefault.types.d.ts} +1 -1
  49. package/services/PushService/drivers/PushServiceSafari/PushServiceSafari.d.ts +21 -0
  50. package/services/PushService/drivers/PushServiceSafari/PushServiceSafari.types.d.ts +4 -0
  51. package/widget-inbox.js +2 -0
  52. package/widget-inbox.js.map +1 -0
  53. package/widget-subscribe-popup.js +2 -0
  54. package/widget-subscribe-popup.js.map +1 -0
  55. package/widget-subscription-button.js +2 -0
  56. package/widget-subscription-button.js.map +1 -0
  57. package/widget-subscription-prompt.d.ts +2 -0
  58. package/widget-subscription-prompt.js +2 -0
  59. package/widget-subscription-prompt.js.map +1 -0
  60. package/widgets/Inbox/InboxWidget.d.ts +49 -0
  61. package/widgets/Inbox/constants.d.ts +7 -0
  62. package/widgets/Inbox/helpers.d.ts +4 -0
  63. package/widgets/Inbox/inbox_widget.types.d.ts +34 -0
  64. package/widgets/Inbox/widgetTemplates.d.ts +4 -0
  65. package/widgets/SubscribePopup/SubscribePopup.d.ts +20 -0
  66. package/widgets/SubscribePopup/constants.d.ts +6 -0
  67. package/widgets/SubscribePopup/helpers.d.ts +1 -0
  68. package/widgets/SubscribePopup/popupTemplates.d.ts +9 -0
  69. package/widgets/SubscribePopup/types/subscribe-popup.d.ts +43 -0
  70. package/widgets/SubscriptionButton/bell.d.ts +2 -0
  71. package/widgets/SubscriptionButton/constants.d.ts +7 -0
  72. package/widgets/SubscriptionButton/index.d.ts +90 -0
  73. package/widgets/SubscriptionButton/positioning.d.ts +11 -0
  74. package/widgets/SubscriptionButton/subscribe_widget.types.d.ts +35 -0
  75. package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.constants.d.ts +1 -0
  76. package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.d.ts +14 -0
  77. package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.helpers.d.ts +3 -0
  78. package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.types.d.ts +19 -0
  79. package/widgets/SubscriptionPrompt/constants.d.ts +21 -0
  80. package/widgets/SubscriptionPrompt/helpers.d.ts +5 -0
  81. package/worker/global.d.ts +16 -0
  82. package/worker/notification.d.ts +9 -0
  83. package/worker/worker.types.d.ts +4 -0
  84. package/.editorconfig +0 -11
  85. package/.gitlab-ci.yml +0 -193
  86. package/babel.config.js +0 -7
  87. package/ci/cdn/Dockerfile +0 -12
  88. package/ci/dev/Dockerfile +0 -30
  89. package/ci/dev/rootfs/entrypoint.sh +0 -18
  90. package/ci/dev/rootfs/entrypoint.sh.d/nginx.sh +0 -6
  91. package/ci/dev/rootfs/entrypoint.sh.d/supervisor.sh +0 -5
  92. package/ci/dev/rootfs/etc/nginx/_real_ip.conf +0 -2
  93. package/ci/dev/rootfs/etc/nginx/conf.d/default.conf +0 -20
  94. package/ci/dev/rootfs/etc/supervisor.d/nginx.ini +0 -11
  95. package/ci/github/Dockerfile +0 -59
  96. package/ci/github/release-zip.js +0 -61
  97. package/ci/npm/Dockerfile +0 -22
  98. package/config/config.js +0 -24
  99. package/config/configBuilder.js +0 -126
  100. package/config/helpers.js +0 -9
  101. package/config/index.js +0 -1
  102. package/develop/README.md +0 -42
  103. package/develop/favicon.png +0 -0
  104. package/develop/index.html +0 -511
  105. package/eslint.config.mjs +0 -114
  106. package/public/index.d.ts +0 -337
  107. package/scripts/zip.js +0 -26
  108. package/src/core/Pushwoosh.ts +0 -768
  109. package/src/core/Pushwoosh.types.ts +0 -254
  110. package/src/core/Safari.types.ts +0 -26
  111. package/src/core/constants.ts +0 -58
  112. package/src/core/events.types.ts +0 -46
  113. package/src/core/functions.ts +0 -33
  114. package/src/core/legacyEventsMap.ts +0 -64
  115. package/src/core/logger.ts +0 -64
  116. package/src/core/modules/EventBus/EventBus.ts +0 -66
  117. package/src/core/storage.ts +0 -254
  118. package/src/helpers/logger.ts +0 -81
  119. package/src/helpers/pwlogger/Logger.constants.ts +0 -31
  120. package/src/helpers/pwlogger/Logger.ts +0 -218
  121. package/src/helpers/pwlogger/Logger.types.ts +0 -66
  122. package/src/helpers/pwlogger/handlers/handler-console/handler-console.ts +0 -40
  123. package/src/models/InboxMessages.ts +0 -202
  124. package/src/models/InboxMessages.types.ts +0 -111
  125. package/src/models/NotificationPayload.ts +0 -216
  126. package/src/models/NotificationPayload.types.ts +0 -65
  127. package/src/modules/Api/Api.ts +0 -386
  128. package/src/modules/Api/Api.types.ts +0 -7
  129. package/src/modules/ApiClient/ApiClient.ts +0 -153
  130. package/src/modules/ApiClient/ApiClient.types.ts +0 -222
  131. package/src/modules/Data/Data.ts +0 -345
  132. package/src/modules/DateModule.ts +0 -53
  133. package/src/modules/InboxMessagesPublic.ts +0 -222
  134. package/src/modules/PlatformChecker/PlatformChecker.ts +0 -170
  135. package/src/modules/PlatformChecker/PlatformChecker.types.ts +0 -5
  136. package/src/modules/storage/Storage.ts +0 -164
  137. package/src/modules/storage/Store.ts +0 -104
  138. package/src/modules/storage/migrations/26-11-2018.ts +0 -25
  139. package/src/modules/storage/migrations/MigrationExecutor.ts +0 -31
  140. package/src/modules/storage/migrations/Migrations.ts +0 -41
  141. package/src/modules/storage/migrations/constants.ts +0 -8
  142. package/src/modules/storage/migrations/helpers.ts +0 -16
  143. package/src/modules/storage/migrations/initial.ts +0 -47
  144. package/src/modules/storage/version.ts +0 -2
  145. package/src/pushwoosh-web-notifications.ts +0 -47
  146. package/src/pushwoosh-widget-inbox.ts +0 -8
  147. package/src/pushwoosh-widget-subscribe-popup.ts +0 -9
  148. package/src/pushwoosh-widget-subscription-button.ts +0 -8
  149. package/src/pushwoosh-widget-subscription-prompt.ts +0 -6
  150. package/src/service-worker.ts +0 -455
  151. package/src/services/PushService/PushService.types.ts +0 -74
  152. package/src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.ts +0 -235
  153. package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.ts +0 -125
  154. package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.types.ts +0 -4
  155. package/src/widget-subscription-prompt.ts +0 -33
  156. package/src/widgets/Inbox/InboxWidget.ts +0 -564
  157. package/src/widgets/Inbox/constants.ts +0 -49
  158. package/src/widgets/Inbox/css/inboxWidgetStyle.css +0 -274
  159. package/src/widgets/Inbox/helpers.ts +0 -63
  160. package/src/widgets/Inbox/inbox.d.ts +0 -9
  161. package/src/widgets/Inbox/inbox_widget.types.ts +0 -41
  162. package/src/widgets/Inbox/widgetTemplates.ts +0 -55
  163. package/src/widgets/SubscribePopup/SubscribePopup.ts +0 -241
  164. package/src/widgets/SubscribePopup/constants.ts +0 -66
  165. package/src/widgets/SubscribePopup/helpers.ts +0 -11
  166. package/src/widgets/SubscribePopup/popupTemplates.ts +0 -24
  167. package/src/widgets/SubscribePopup/styles/popup.css +0 -226
  168. package/src/widgets/SubscribePopup/types/subscribe-popup.ts +0 -68
  169. package/src/widgets/SubscriptionButton/assets/css/main.css +0 -205
  170. package/src/widgets/SubscriptionButton/bell.ts +0 -67
  171. package/src/widgets/SubscriptionButton/constants.ts +0 -28
  172. package/src/widgets/SubscriptionButton/index.ts +0 -377
  173. package/src/widgets/SubscriptionButton/positioning.ts +0 -165
  174. package/src/widgets/SubscriptionButton/subscribe_widget.types.ts +0 -53
  175. package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.constants.ts +0 -1
  176. package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.helpers.ts +0 -110
  177. package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.ts +0 -102
  178. package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.types.ts +0 -23
  179. package/src/widgets/SubscriptionPrompt/constants.ts +0 -22
  180. package/src/widgets/SubscriptionPrompt/helpers.ts +0 -42
  181. package/src/widgets/widgets.d.ts +0 -4
  182. package/src/worker/global.ts +0 -36
  183. package/src/worker/notification.ts +0 -34
  184. package/src/worker/worker.types.ts +0 -4
  185. package/test/__helpers__/apiHelpers.ts +0 -22
  186. package/test/__helpers__/keyValueHelpers.ts +0 -15
  187. package/test/__helpers__/platformHelpers.ts +0 -54
  188. package/test/__helpers__/sinonHelpers.ts +0 -7
  189. package/test/__helpers__/storageHelpers.ts +0 -56
  190. package/test/__mocks__/apiRequests.ts +0 -26
  191. package/test/__mocks__/idbMock.ts +0 -12
  192. package/test/__mocks__/idbObjectStoreMock.ts +0 -38
  193. package/test/__mocks__/inboxMessages.ts +0 -292
  194. package/test/__mocks__/models/inboxModel.ts +0 -71
  195. package/test/__mocks__/modules/apiClientModule.ts +0 -18
  196. package/test/__mocks__/modules/dateModule.ts +0 -34
  197. package/test/__mocks__/modules/inboxParamsModule.ts +0 -21
  198. package/test/__mocks__/modules/paramsBuilder.ts +0 -12
  199. package/test/__mocks__/modules/paramsModule.ts +0 -35
  200. package/test/__mocks__/modules/payloadBuilderModule.ts +0 -15
  201. package/test/__mocks__/modules/storageModule.ts +0 -58
  202. package/test/__mocks__/navigator.ts +0 -38
  203. package/test/__mocks__/notification.ts +0 -84
  204. package/test/__mocks__/pushwoosh.ts +0 -12
  205. package/test/__mocks__/userAgents +0 -8
  206. package/test/functions.test.ts +0 -22
  207. package/test/ignore-html.js +0 -6
  208. package/test/mocha.opts +0 -6
  209. package/test/modules/DateModule/unit.test.ts +0 -80
  210. package/test/modules/storage/Storage/unit.test.ts +0 -180
  211. package/test/modules/storage/Store/unit.test.ts +0 -192
  212. package/testRegister.js +0 -24
  213. package/tsconfig.json +0 -31
  214. package/webpack.config.js +0 -163
  215. /package/{src/core/modules/EventBus/index.ts → core/modules/EventBus/index.d.ts} +0 -0
  216. /package/{src/helpers/pwlogger/index.ts → helpers/pwlogger/index.d.ts} +0 -0
  217. /package/{src/modules/PlatformChecker/index.ts → modules/PlatformChecker/index.d.ts} +0 -0
  218. /package/{src/npm.ts → npm.d.ts} +0 -0
  219. /package/{src/services/PushService/PushService.ts → services/PushService/PushService.d.ts} +0 -0
  220. /package/{src/widget-inbox.ts → widget-inbox.d.ts} +0 -0
  221. /package/{src/widget-subscribe-popup.ts → widget-subscribe-popup.d.ts} +0 -0
  222. /package/{src/widget-subscription-button.ts → widget-subscription-button.d.ts} +0 -0
  223. /package/{src/widgets/Inbox/index.ts → widgets/Inbox/index.d.ts} +0 -0
  224. /package/{src/widgets/SubscribePopup/index.ts → widgets/SubscribePopup/index.d.ts} +0 -0
@@ -0,0 +1,199 @@
1
+ import { type EventHandlerMap, type EventName } from './events.types';
2
+ import { type IInitParams, type PWInput } from './Pushwoosh.types';
3
+ import { Api } from '../modules/Api/Api';
4
+ import { Data } from '../modules/Data/Data';
5
+ import InboxMessagesPublic from '../modules/InboxMessagesPublic';
6
+ import { PlatformChecker } from '../modules/PlatformChecker';
7
+ import { type IPushService } from '../services/PushService/PushService.types';
8
+ export declare class Pushwoosh {
9
+ ready: boolean;
10
+ initParams: IInitParams;
11
+ private readonly eventBus;
12
+ readonly data: Data;
13
+ private readonly apiClient;
14
+ private isCommunicationDisabled?;
15
+ readonly api: Api;
16
+ driver: IPushService;
17
+ platformChecker: PlatformChecker;
18
+ pwinbox: InboxMessagesPublic;
19
+ private inboxModel;
20
+ moduleRegistry: Record<string, any>;
21
+ constructor();
22
+ /**
23
+ * Add Web SDK Event Handler.
24
+ * Alias to addEventHandler method of EventBus module.
25
+ *
26
+ * @public
27
+ * @readonly
28
+ *
29
+ * @param {string} name - name of Web SDK event.
30
+ * @param {function} handler - handler of Web SDK event.
31
+ *
32
+ * @returns {void}
33
+ */
34
+ addEventHandler: <Name extends EventName>(name: Name, handler: EventHandlerMap[Name]) => void;
35
+ /**
36
+ * Remove Web SDK Event Handler.
37
+ * Alias to removeEventHandler method of EventBus module.
38
+ *
39
+ * @public
40
+ * @readonly
41
+ *
42
+ * @param {string} name - name of Web SDK event.
43
+ * @param {function} handler - handler of Web SDK event.
44
+ *
45
+ * @returns {void}
46
+ */
47
+ removeEventHandler: <Name extends EventName>(name: Name, handler: EventHandlerMap[Name]) => void;
48
+ /**
49
+ * Dispatch Web SDK Event.
50
+ * Alias to dispatchEvent method of EventBus module.
51
+ *
52
+ * @public
53
+ * @readonly
54
+ *
55
+ * @param {string} name - name of Web SDK event.
56
+ * @param {object} payload - event payload.
57
+ *
58
+ * @returns {string} - event id.
59
+ */
60
+ dispatchEvent: <Name extends EventName>(name: Name, payload: Omit<Parameters<EventHandlerMap[Name]>[0], "eventId"> & {
61
+ eventId?: string;
62
+ }) => string;
63
+ /**
64
+ * Method that puts the stored error/info messages to browser console.
65
+ * @type {{showLog: (() => Promise<any>); showKeyValues: (() => Promise<any>); showMessages: (() => Promise<any>)}}
66
+ */
67
+ debug: {
68
+ showLog(): Promise<void>;
69
+ showKeyValues(): Promise<void>;
70
+ showMessages(): Promise<void>;
71
+ };
72
+ /**
73
+ * Polymorph PW method.
74
+ * Can get array in format [string, params | callback] or function.
75
+ *
76
+ * // with callback:
77
+ * Pushwoosh.push(['onNotificationClick', function(api, payload) {
78
+ * // click on the notificationn
79
+ * }]);
80
+ *
81
+ * // with function:
82
+ * Pushwoosh.push(function(api) {
83
+ * // this is a bit easier way to subscribe to onReady
84
+ * });
85
+ *
86
+ * // with params:
87
+ * // initiates Pushwoosh service and notification subscription
88
+ * Pushwoosh.push(['init', {
89
+ * applicationCode: 'XXXXX-XXXXX',
90
+ * // see more about params in documentation
91
+ * // https://docs.pushwoosh.com/docs/web-push-sdk-30#section-integration
92
+ * }]);
93
+ *
94
+ * @param command
95
+ */
96
+ push(command: PWInput): void;
97
+ /**
98
+ * Method initializes the permission dialog on the device
99
+ * and registers through the API in case the device hasn't been registered before.
100
+ * @returns {Promise<void>}
101
+ */
102
+ subscribe(isForceSubscribe?: boolean): Promise<void>;
103
+ /**
104
+ * Unsubscribe device.
105
+ * @returns {Promise<void>}
106
+ */
107
+ unsubscribe(): Promise<void>;
108
+ /**
109
+ * force subscribe if there was a manual unsubscribe
110
+ * @returns {Promise<void>}
111
+ */
112
+ forceSubscribe(): Promise<void>;
113
+ /**
114
+ * Check device's registration status
115
+ * @returns {boolean}
116
+ */
117
+ isDeviceRegistered(): boolean;
118
+ isDeviceUnregistered(): boolean;
119
+ /**
120
+ * Check device's subscription status
121
+ * @returns {Promise<boolean>}
122
+ */
123
+ isSubscribed(): Promise<boolean>;
124
+ /**
125
+ * Check current communication state
126
+ * @returns {Promise<boolean>}
127
+ */
128
+ isCommunicationEnabled(): Promise<boolean>;
129
+ /**
130
+ * Send "GDPRConsent" postEvent and depends on param "isEnabled"
131
+ * device will be registered/unregistered from all communication channels.
132
+ * @param {boolean} isEnabled
133
+ * @returns {Promise<void>}
134
+ */
135
+ setCommunicationEnabled(isEnabled?: boolean): Promise<void>;
136
+ /**
137
+ * Send "GDPRDelete" postEvent and remove all device device data from Pushwoosh.
138
+ * @returns {Promise<void>}
139
+ */
140
+ removeAllDeviceData(): Promise<void>;
141
+ /**
142
+ * Method returns hardware id.
143
+ * @returns {Promise<string>}
144
+ */
145
+ getHWID(): Promise<string>;
146
+ /**
147
+ * Method returns push token.
148
+ * @returns {Promise<string>}
149
+ */
150
+ getPushToken(): Promise<string | undefined>;
151
+ /**
152
+ * Method returns userId
153
+ * @returns {Promise<string | null>}
154
+ */
155
+ getUserId(): Promise<string | undefined>;
156
+ /**
157
+ * Method returns an object with all params.
158
+ * @returns {Promise<IPWParams>}
159
+ */
160
+ getParams(): Promise<any>;
161
+ /**
162
+ * Method returns true if notifications available.
163
+ * @returns {boolean}
164
+ */
165
+ isAvailableNotifications(): boolean;
166
+ sendStatisticsVisitedPage(): Promise<void>;
167
+ private initialize;
168
+ /**
169
+ * Default process during PW initialization.
170
+ * Init API. Subscription to notifications.
171
+ * Emit delayed events.
172
+ */
173
+ private defaultProcess;
174
+ /**
175
+ *
176
+ * @param {MessageEvent} event
177
+ */
178
+ private onServiceWorkerMessage;
179
+ /**
180
+ * Check device's session and call the appOpen method,
181
+ * no more than once an hour.
182
+ * Force need to Safari await subscribe status
183
+ * @param {boolean} isForce
184
+ * @returns {Promise<void>}
185
+ */
186
+ private open;
187
+ private onGetConfig;
188
+ private initPushNotifications;
189
+ private initDriver;
190
+ sendPostEventVisitedPage(): void;
191
+ /**
192
+ * @private
193
+ *
194
+ * @param {string} type - legacy event type
195
+ * @param {function} handler - legacy handler
196
+ */
197
+ private subscribeToLegacyEvents;
198
+ private emitLegacyEventsFromServiceWorker;
199
+ }
@@ -0,0 +1,213 @@
1
+ import { type INotificationButton } from '../models/NotificationPayload.types';
2
+ import { type ISubscribePopupConfig } from '../widgets/SubscribePopup/types/subscribe-popup';
3
+ export type PushwooshApiResponse = {
4
+ status_code: number;
5
+ status_message: string;
6
+ response?: any;
7
+ };
8
+ export type TPWPermission = 'denied' | 'granted' | 'default';
9
+ export interface IPWDriverAPIParams {
10
+ hwid: string;
11
+ pushToken?: string;
12
+ publicKey?: string;
13
+ authToken?: string;
14
+ }
15
+ export interface TPWAPIParams extends IPWDriverAPIParams {
16
+ applicationCode: string;
17
+ pushwooshApiUrl?: string;
18
+ deviceType: number;
19
+ deviceModel: string;
20
+ language: string;
21
+ userId?: string;
22
+ }
23
+ export interface TPWLastOpenMessage {
24
+ messageHash?: string;
25
+ expiry: number;
26
+ url?: string;
27
+ }
28
+ export interface PushManager {
29
+ permissionState(options: PushSubscriptionOptions): Promise<TPWPermission>;
30
+ }
31
+ export interface PushSubscription {
32
+ unsubscribe(): Promise<boolean>;
33
+ subscriptionId: string;
34
+ }
35
+ export interface IPWDriver {
36
+ initWorker?(): Promise<any>;
37
+ getPermission(): Promise<TPWPermission>;
38
+ isSubscribed(): Promise<boolean>;
39
+ askSubscribe(eventEmitter?: any): Promise<any>;
40
+ unsubscribe(): Promise<any>;
41
+ getAPIParams(): Promise<IPWDriverAPIParams>;
42
+ onApiReady?(api: any): void;
43
+ isNeedUnsubscribe?(): Promise<boolean>;
44
+ }
45
+ export interface ITooltipText {
46
+ successSubscribe?: string;
47
+ needSubscribe?: string;
48
+ blockSubscribe?: string;
49
+ alreadySubscribed?: string;
50
+ }
51
+ export interface ISubscribeWidget {
52
+ enable: boolean;
53
+ position?: string;
54
+ bgColor?: string;
55
+ bellColor?: string;
56
+ shadow?: string;
57
+ size?: string;
58
+ indent?: string;
59
+ zIndex?: string;
60
+ tooltipText?: ITooltipText;
61
+ buttonImage?: string;
62
+ contentImages?: Record<string, string>;
63
+ }
64
+ export type IWidgetPosition = 'left' | 'right' | 'top' | 'bottom';
65
+ export interface IInboxWidget {
66
+ enable: boolean;
67
+ triggerId?: string;
68
+ position?: IWidgetPosition;
69
+ appendTo?: string;
70
+ title?: string;
71
+ bgColor?: string;
72
+ textColor?: string;
73
+ fontFamily?: string;
74
+ borderRadius?: number;
75
+ borderColor?: string;
76
+ badgeBgColor?: string;
77
+ badgeTextColor?: string;
78
+ widgetWidth?: number;
79
+ zIndex?: number;
80
+ messageTitleColor?: string;
81
+ timeTextColor?: string;
82
+ emptyInboxTitle?: string;
83
+ emptyInboxText?: string;
84
+ emptyInboxIconUrl?: string;
85
+ emptyInboxTitleColor?: string;
86
+ emptyInboxTextColor?: string;
87
+ }
88
+ export interface IInitParams {
89
+ applicationCode: string;
90
+ apiToken?: string;
91
+ serviceWorkerUrl?: string | null;
92
+ safariWebsitePushID?: string;
93
+ autoSubscribe?: boolean;
94
+ pushwooshUrl?: string;
95
+ pushwooshApiUrl?: string;
96
+ defaultNotificationImage?: string;
97
+ defaultNotificationTitle?: string;
98
+ logLevel?: string;
99
+ userId?: string;
100
+ email?: string;
101
+ scope?: string;
102
+ tags?: {
103
+ [key: string]: any;
104
+ };
105
+ driversSettings?: {
106
+ worker?: {
107
+ serviceWorkerUrl?: string;
108
+ applicationServerPublicKey?: string;
109
+ };
110
+ };
111
+ subscribeWidget?: ISubscribeWidget;
112
+ inboxWidget?: IInboxWidget;
113
+ subscribePopup?: ISubscribePopupConfig;
114
+ }
115
+ export interface IInitParamsWithDefaults extends IInitParams {
116
+ autoSubscribe: boolean;
117
+ pushwooshUrl: string;
118
+ deviceType: number;
119
+ serviceWorkerUrl: string | null;
120
+ tags: {
121
+ Language: string;
122
+ 'Device Model': string;
123
+ [key: string]: any;
124
+ };
125
+ driversSettings: {
126
+ worker: {
127
+ serviceWorkerUrl: string;
128
+ applicationServerPublicKey?: string;
129
+ };
130
+ };
131
+ subscribeWidget: ISubscribeWidget;
132
+ inboxWidget: IInboxWidget;
133
+ subscribePopup: ISubscribePopupConfig;
134
+ hwid: string;
135
+ }
136
+ export interface IPWParams extends IInitParamsWithDefaults {
137
+ applicationCode: string;
138
+ apiToken?: string;
139
+ defaultNotificationImage?: string;
140
+ defaultNotificationTitle?: string;
141
+ logLevel?: 'error' | 'info' | 'debug';
142
+ pushwooshApiUrl?: string;
143
+ safariWebsitePushID?: string;
144
+ scope?: string;
145
+ userId?: string;
146
+ email?: string;
147
+ pushwooshUrl: string;
148
+ authToken?: string;
149
+ hwid: string;
150
+ publicKey?: string;
151
+ pushToken?: string;
152
+ }
153
+ export interface INotificationOptions extends NotificationOptions {
154
+ title: string;
155
+ messageHash: string;
156
+ openUrl: string;
157
+ url?: string;
158
+ inboxId: string;
159
+ image?: string;
160
+ code?: string;
161
+ buttons?: INotificationButton[];
162
+ customData?: {
163
+ [key: string]: any;
164
+ };
165
+ metaData?: {
166
+ [key: string]: any;
167
+ };
168
+ campaignCode?: string;
169
+ }
170
+ export type TPWCanWaitCallback = (f: any) => Promise<any> | any;
171
+ export interface IWorkerPushwooshGlobal {
172
+ push(listener: ['onPush', TPWCanWaitCallback]): void;
173
+ getListeners(eventName: string): TPWCanWaitCallback[];
174
+ eventBus: any;
175
+ api: any;
176
+ initApi: any;
177
+ }
178
+ export interface IPWBroadcastClientsParams {
179
+ type: string;
180
+ payload: any;
181
+ }
182
+ export type TWriteType = 'error' | 'apirequest' | 'info';
183
+ export interface ILogger {
184
+ setLevel(level: string): void;
185
+ error(...args: any[]): void;
186
+ info(...args: any[]): void;
187
+ debug(...args: any[]): void;
188
+ write(type: TWriteType, message: any, additional?: any): Promise<void>;
189
+ isManualLevel(): boolean;
190
+ [key: string]: any;
191
+ }
192
+ export type ListenerFn = (...args: Array<any>) => void | Promise<any>;
193
+ export type HandlerFn = (api: any, params?: any) => any;
194
+ export type TWorkerDriverParams = {
195
+ eventEmitter?: any;
196
+ scope?: string;
197
+ applicationCode: string;
198
+ serviceWorkerUrl: string | null;
199
+ applicationServerPublicKey?: string;
200
+ };
201
+ export type TWorkerSafariDriverParams = {
202
+ eventEmitter?: any;
203
+ applicationCode: string;
204
+ webSitePushID: string;
205
+ pushwooshUrl: string;
206
+ pushwooshApiUrl?: string;
207
+ };
208
+ export type TDoPushwooshMethod = (type: string, params: any, url?: string) => Promise<any>;
209
+ export type PWInput = PushOnReadyCallback | PushInitCallback | PushEventCallback;
210
+ export type PushOnReadyCallback = HandlerFn;
211
+ export type PushInitCallback = ['init', IInitParams];
212
+ export type PushEventCallback = [PWEvent, HandlerFn];
213
+ export type PWEvent = 'onLoad' | 'onReady' | 'onSubscribe' | 'onUnsubscribe' | 'onRegister' | 'onSWInitError' | 'onPermissionPrompt' | 'onPermissionDenied' | 'onPermissionGranted' | 'onNotificationClick' | 'onPushDelivery' | 'onNotificationClose' | 'onChangeCommunicationEnabled' | 'onPutNewMessageToInboxStore' | 'onUpdateInboxMessages' | 'onShowNotificationPermissionDialog' | 'onHideNotificationPermissionDialog' | 'onShowSubscriptionWidget' | 'onHideSubscriptionWidget';
@@ -0,0 +1,17 @@
1
+ interface IPushServiceSafariRequestPayload {
2
+ application: string;
3
+ hwid: string;
4
+ }
5
+ interface IPushServiceSafariInfo {
6
+ permission: NotificationPermission;
7
+ deviceToken?: string;
8
+ }
9
+ interface Window {
10
+ safari: {
11
+ pushNotification: {
12
+ permission(siteId: string): IPushServiceSafariInfo;
13
+ requestPermission(url: string, id: string, payload: IPushServiceSafariRequestPayload, cb: (permission: IPushServiceSafariInfo) => void): void;
14
+ };
15
+ };
16
+ }
17
+ declare const safari: typeof window.safari;
@@ -0,0 +1,41 @@
1
+ export declare const DEFAULT_SERVICE_WORKER_URL = "/pushwoosh-service-worker.js";
2
+ export declare const DEFAULT_API_URL = "https://cp.pushwoosh.com/json/1.3/";
3
+ export declare const PERIOD_SEND_APP_OPEN = 3600000;
4
+ export declare const PERIOD_GOAL_EVENT = 86400000;
5
+ export declare const DEFAULT_NOTIFICATION_TITLE = "Pushwoosh notification";
6
+ export declare const DEFAULT_NOTIFICATION_IMAGE = "https://cp.pushwoosh.com/img/logo-medium.png";
7
+ export declare const KEY_SHOW_SUBSCRIBE_WIDGET = "WIDGET_SHOWED";
8
+ export declare const KEY_CLICK_SUBSCRIBE_WIDGET = "WIDGET_CLICKED";
9
+ export declare const KEY_DEVICE_REGISTRATION_STATUS: string;
10
+ export declare const KEY_SAFARI_PREVIOUS_PERMISSION = "safariPreviousPermission";
11
+ export declare const MANUAL_SET_LOGGER_LEVEL = "PW_SET_LOGGER_LEVEL";
12
+ export declare const DEVICE_REGISTRATION_STATUS_REGISTERED: string;
13
+ export declare const DEVICE_REGISTRATION_STATUS_UNREGISTERED: string;
14
+ export declare const PERMISSION_DENIED = "denied";
15
+ export declare const PERMISSION_GRANTED = "granted";
16
+ export declare const PERMISSION_PROMPT = "default";
17
+ export declare const LEGACY_EVENT_ON_LOAD = "onLoad";
18
+ export declare const LEGACY_EVENT_ON_READY = "onReady";
19
+ export declare const LEGACY_EVENT_ON_SUBSCRIBE = "onSubscribe";
20
+ export declare const LEGACY_EVENT_ON_UNSUBSCRIBE = "onUnsubscribe";
21
+ export declare const LEGACY_EVENT_ON_REGISTER = "onRegister";
22
+ export declare const LEGACY_EVENT_ON_PERMISSION_PROMPT = "onPermissionPrompt";
23
+ export declare const LEGACY_EVENT_ON_PERMISSION_DENIED = "onPermissionDenied";
24
+ export declare const LEGACY_EVENT_ON_PERMISSION_GRANTED = "onPermissionGranted";
25
+ export declare const LEGACY_EVENT_ON_SW_INIT_ERROR = "onSWInitError";
26
+ export declare const LEGACY_EVENT_ON_PUSH_DELIVERY = "onPushDelivery";
27
+ export declare const LEGACY_EVENT_ON_NOTIFICATION_CLICK = "onNotificationClick";
28
+ export declare const LEGACY_EVENT_ON_NOTIFICATION_CLOSE = "onNotificationClose";
29
+ export declare const LEGACY_EVENT_ON_CHANGE_COMMUNICATION_ENABLED = "onChangeCommunicationEnabled";
30
+ export declare const LEGACY_EVENT_ON_PUT_NEW_MESSAGE_TO_INBOX_STORE = "onPutNewMessageToInboxStore";
31
+ export declare const LEGACY_EVENT_ON_UPDATE_INBOX_MESSAGES = "onUpdateInboxMessages";
32
+ export declare const LEGACY_EVENT_ON_SHOW_NOTIFICATION_PERMISSION_DIALOG = "onShowNotificationPermissionDialog";
33
+ export declare const LEGACY_EVENT_ON_HIDE_NOTIFICATION_PERMISSION_DIALOG = "onHideNotificationPermissionDialog";
34
+ export declare const LEGACY_EVENT_ON_SHOW_SUBSCRIPTION_WIDGET = "onShowSubscriptionWidget";
35
+ export declare const LEGACY_EVENT_ON_HIDE_SUBSCRIPTION_WIDGET = "onHideSubscriptionWidget";
36
+ export declare const EVENT_SHOW_SUBSCRIBE_BUTTON = "showSubscribeButton";
37
+ export declare const EVENT_CLICK_SUBSCRIBE_BUTTON = "clickSubscribeButton";
38
+ export declare const EVENT_GDPR_CONSENT = "GDPRConsent";
39
+ export declare const EVENT_GDPR_DELETE = "GDPRDelete";
40
+ export declare const EVENT_PW_SITE_OPENED = "PW_SiteOpened";
41
+ export declare const PAGE_VISITED_URL = "PAGE_VISITED_URL";
@@ -0,0 +1,55 @@
1
+ export type EventPayload<Parameters extends Record<string, unknown>> = Parameters & Record<'eventId', string>;
2
+ export type EventHandler<Payload extends EventPayload<Record<string, unknown>>> = (payload: Payload) => void | Promise<void>;
3
+ export interface EventHandlerMap {
4
+ ready: EventHandler<EventPayload<Record<string, never>>>;
5
+ 'change-enabled-communication': EventHandler<EventPayload<{
6
+ isEnabled: boolean;
7
+ }>>;
8
+ register: EventHandler<EventPayload<Record<string, never>>>;
9
+ unregister: EventHandler<EventPayload<Record<string, never>>>;
10
+ 'show-subscription-widget': EventHandler<EventPayload<Record<string, never>>>;
11
+ 'hide-subscription-widget': EventHandler<EventPayload<Record<string, never>>>;
12
+ 'show-notification-permission-dialog': EventHandler<EventPayload<Record<string, never>>>;
13
+ 'hide-notification-permission-dialog': EventHandler<EventPayload<{
14
+ permission: NotificationPermission;
15
+ }>>;
16
+ 'permission-default': EventHandler<EventPayload<Record<string, never>>>;
17
+ 'permission-denied': EventHandler<EventPayload<Record<string, never>>>;
18
+ 'permission-granted': EventHandler<EventPayload<Record<string, never>>>;
19
+ 'change-permission': EventHandler<EventPayload<{
20
+ permission: NotificationPermission;
21
+ }>>;
22
+ 'initialize-service-worker': EventHandler<EventPayload<Record<string, never>>>;
23
+ 'initialize-service-worker-error': EventHandler<EventPayload<{
24
+ error: Error;
25
+ }>>;
26
+ subscribe: EventHandler<EventPayload<Record<string, never>>>;
27
+ unsubscribe: EventHandler<EventPayload<Record<string, never>>>;
28
+ 'receive-push': EventHandler<EventPayload<{
29
+ notification: unknown;
30
+ }>>;
31
+ 'show-notification': EventHandler<EventPayload<{
32
+ notification: unknown;
33
+ }>>;
34
+ 'open-notification': EventHandler<EventPayload<{
35
+ notification: unknown;
36
+ }>>;
37
+ 'hide-notification': EventHandler<EventPayload<{
38
+ notification: unknown;
39
+ }>>;
40
+ 'receive-inbox-message': EventHandler<EventPayload<{
41
+ message: unknown;
42
+ }>>;
43
+ 'update-inbox-messages': EventHandler<EventPayload<{
44
+ messages: unknown;
45
+ }>>;
46
+ 'receive-in-app-code': EventHandler<EventPayload<{
47
+ code: string;
48
+ }>>;
49
+ 'subscribe-popup-ready': EventHandler<EventPayload<Record<string, never>>>;
50
+ 'subscribe-popup-show': EventHandler<EventPayload<Record<string, never>>>;
51
+ 'subscribe-popup-hide': EventHandler<EventPayload<Record<string, never>>>;
52
+ 'subscribe-popup-decline': EventHandler<EventPayload<Record<string, never>>>;
53
+ 'subscribe-popup-accept': EventHandler<EventPayload<Record<string, never>>>;
54
+ }
55
+ export type EventName = keyof EventHandlerMap;
@@ -0,0 +1,5 @@
1
+ export declare function getGlobal(): typeof globalThis;
2
+ export declare function getVersion(): string;
3
+ export declare function parseSerializedNotificationParams(param: any, defaultValue?: any): any;
4
+ export declare function v4(): `${string}-${string}-${string}-${string}-${string}`;
5
+ export declare const isFunction: (value: any) => value is ((...args: any[]) => any);
@@ -0,0 +1,5 @@
1
+ import type { EventName } from './events.types';
2
+ export declare const legacyEventsMap: Record<string, {
3
+ name: EventName;
4
+ prop?: string;
5
+ }>;
@@ -0,0 +1,14 @@
1
+ type TWriteType = 'error' | 'apirequest' | 'info';
2
+ interface ILogger {
3
+ setLevel(level: string): void;
4
+ error(...args: any[]): void;
5
+ info(...args: any[]): void;
6
+ debug(...args: any[]): void;
7
+ write(type: TWriteType, message: any, additional?: any): Promise<void>;
8
+ isManualLevel(): boolean;
9
+ [key: string]: any;
10
+ }
11
+ declare const Logger: ILogger;
12
+ export declare function logAndThrowError(error: string): void;
13
+ export declare function logAndRejectError(error: string, reject: (e: any) => void): void;
14
+ export { Logger };
@@ -0,0 +1,10 @@
1
+ import { type EventHandlerMap, type EventName } from '../../events.types';
2
+ export declare class EventBus {
3
+ private readonly handlers;
4
+ constructor();
5
+ addEventHandler: <Name extends EventName = EventName>(name: Name, handler: EventHandlerMap[Name]) => void;
6
+ removeEventHandler: <Name extends EventName = EventName>(name: Name, handler: EventHandlerMap[Name]) => void;
7
+ dispatchEvent: <Name extends EventName = EventName>(name: Name, payload: Omit<Parameters<EventHandlerMap[Name]>[0], "eventId"> & {
8
+ eventId?: string;
9
+ }) => string;
10
+ }
@@ -0,0 +1,27 @@
1
+ export declare function getInstance(): Promise<IDBDatabase>;
2
+ export declare abstract class LogBase {
3
+ protected abstract name: string;
4
+ protected abstract maxItems: number;
5
+ _add(obj: any): any;
6
+ delete(key: any): any;
7
+ getAll(): any;
8
+ }
9
+ export declare class LogLog extends LogBase {
10
+ protected name: "log";
11
+ protected maxItems: number;
12
+ protected environment: string;
13
+ add(type: string, message: any, additional?: any): any;
14
+ }
15
+ export declare class LogMessage extends LogBase {
16
+ protected name: "messages";
17
+ protected maxItems: number;
18
+ add(log: any): any;
19
+ }
20
+ export declare const keyValue: {
21
+ get<K extends string, D>(key: K, defaultValue?: D): any;
22
+ getAll(): any;
23
+ extend(key: string, value: any): Promise<void>;
24
+ set<K, D>(key: K, value: D): any;
25
+ };
26
+ export declare const log: LogLog;
27
+ export declare const message: LogMessage;
@@ -0,0 +1,11 @@
1
+ import { Logger } from './pwlogger';
2
+ type TLogMessage = {
3
+ message: string;
4
+ code: string;
5
+ error: any;
6
+ [key: string]: any;
7
+ };
8
+ declare const logger: Logger;
9
+ declare function sendFatalLogToRemoteServer(params: TLogMessage): Promise<void>;
10
+ declare function sendErrorLogToRemoteServer(params: TLogMessage): Promise<void>;
11
+ export { logger, sendFatalLogToRemoteServer, sendErrorLogToRemoteServer, };
@@ -0,0 +1,21 @@
1
+ import { type TLoggerLevelSilent, type TLoggerLevelFatal, type TLoggerLevelError, type TLoggerLevelWarn, type TLoggerLevelInfo, type TLoggerLevelDebug } from './Logger.types';
2
+ export declare const LOGGER_LEVEL_SILENT: TLoggerLevelSilent;
3
+ export declare const LOGGER_LEVEL_FATAL: TLoggerLevelFatal;
4
+ export declare const LOGGER_LEVEL_ERROR: TLoggerLevelError;
5
+ export declare const LOGGER_LEVEL_WARN: TLoggerLevelWarn;
6
+ export declare const LOGGER_LEVEL_INFO: TLoggerLevelInfo;
7
+ export declare const LOGGER_LEVEL_DEBUG: TLoggerLevelDebug;
8
+ export declare const LOGGER_LEVEL_VALUE_SILENT = 0;
9
+ export declare const LOGGER_LEVEL_VALUE_FATAL = 10;
10
+ export declare const LOGGER_LEVEL_VALUE_ERROR = 20;
11
+ export declare const LOGGER_LEVEL_VALUE_WARN = 30;
12
+ export declare const LOGGER_LEVEL_VALUE_INFO = 40;
13
+ export declare const LOGGER_LEVEL_VALUE_DEBUG = 50;
14
+ export declare const loggerRelationsMap: {
15
+ silent: number;
16
+ fatal: number;
17
+ error: number;
18
+ warn: number;
19
+ info: number;
20
+ debug: number;
21
+ };
@@ -0,0 +1,37 @@
1
+ import { loggerRelationsMap } from './Logger.constants';
2
+ import { type ILoggerConfig, type TLoggerLevels, type TLoggerApplicationType, type ILoggerLogOptions, type ILoggerLogParams, type TLoggerHandler, type ILoggerSubscriber, type TLoggerOutputLevels, type TReject } from './Logger.types';
3
+ export * from './Logger.types';
4
+ export * from './Logger.constants';
5
+ export declare class Logger {
6
+ readonly relations: typeof loggerRelationsMap;
7
+ applicationType: TLoggerApplicationType;
8
+ level: TLoggerLevels;
9
+ readonly subscribers: ILoggerSubscriber[];
10
+ applicationCode: string | undefined;
11
+ domain: string | undefined;
12
+ deviceInfo: {
13
+ [key: string]: any;
14
+ } | undefined;
15
+ constructor(config?: ILoggerConfig);
16
+ updateLogLevel(level: TLoggerLevels): void;
17
+ updateApplicationType(applicationType: TLoggerApplicationType): void;
18
+ updateApplicationCode(applicationCode: string): void;
19
+ updateDomain(domain: string): void;
20
+ updateDeviceInfo(deviceInfo: {
21
+ [key: string]: any;
22
+ }): void;
23
+ subscribe(level: TLoggerOutputLevels, handler: TLoggerHandler): void;
24
+ log(params: ILoggerLogParams): Promise<void>;
25
+ debug(text: string, options?: ILoggerLogOptions): Promise<void>;
26
+ info(text: string, options?: ILoggerLogOptions): Promise<void>;
27
+ warn(text: string, code?: string, options?: ILoggerLogOptions): Promise<void>;
28
+ error(text: string, code?: string, options?: ILoggerLogOptions): Promise<void>;
29
+ fatal(text: string, code?: string, options?: ILoggerLogOptions): Promise<void>;
30
+ errorAndThrow(text: string, code?: string, options?: ILoggerLogOptions): Promise<void>;
31
+ errorAndReject(cb: TReject, text: string, code?: string, options?: ILoggerLogOptions): Promise<void>;
32
+ fatalAndThrow(text: string, code?: string, options?: ILoggerLogOptions): Promise<void>;
33
+ fatalAndReject(cb: TReject, text: string, code?: string, options?: ILoggerLogOptions): Promise<void>;
34
+ private logAndThrow;
35
+ private logAndReject;
36
+ private getMessage;
37
+ }