web-push-notifications 3.44.7 → 3.44.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/Pushwoosh.d.ts +199 -0
- package/core/Pushwoosh.types.d.ts +213 -0
- package/core/Safari.types.d.ts +17 -0
- package/core/constants.d.ts +41 -0
- package/core/events.types.d.ts +55 -0
- package/core/functions.d.ts +5 -0
- package/core/legacyEventsMap.d.ts +5 -0
- package/core/logger.d.ts +14 -0
- package/core/modules/EventBus/EventBus.d.ts +10 -0
- package/core/storage.d.ts +27 -0
- package/helpers/logger.d.ts +11 -0
- package/helpers/pwlogger/Logger.constants.d.ts +21 -0
- package/helpers/pwlogger/Logger.d.ts +37 -0
- package/helpers/pwlogger/Logger.types.d.ts +44 -0
- package/helpers/pwlogger/handlers/handler-console/handler-console.d.ts +2 -0
- package/{src/helpers/unescape.ts → helpers/unescape.d.ts} +1 -18
- package/models/InboxMessages.d.ts +82 -0
- package/models/InboxMessages.types.d.ts +83 -0
- package/models/NotificationPayload.d.ts +39 -0
- package/models/NotificationPayload.types.d.ts +63 -0
- package/modules/Api/Api.d.ts +45 -0
- package/modules/Api/Api.types.d.ts +7 -0
- package/modules/ApiClient/ApiClient.d.ts +29 -0
- package/modules/ApiClient/ApiClient.types.d.ts +188 -0
- package/modules/Data/Data.d.ts +76 -0
- package/modules/DateModule.d.ts +27 -0
- package/modules/InboxMessagesPublic.d.ts +64 -0
- package/modules/PlatformChecker/PlatformChecker.d.ts +45 -0
- package/modules/PlatformChecker/PlatformChecker.types.d.ts +5 -0
- package/modules/storage/Storage.d.ts +63 -0
- package/{src/modules/storage/Storage.types.ts → modules/storage/Storage.types.d.ts} +7 -25
- package/modules/storage/Store.d.ts +22 -0
- package/modules/storage/migrations/26-11-2018.d.ts +2 -0
- package/modules/storage/migrations/MigrationExecutor.d.ts +9 -0
- package/modules/storage/migrations/Migrations.d.ts +15 -0
- package/modules/storage/migrations/constants.d.ts +6 -0
- package/modules/storage/migrations/helpers.d.ts +7 -0
- package/modules/storage/migrations/initial.d.ts +2 -0
- package/modules/storage/version.d.ts +2 -0
- package/npm.js +2 -0
- package/npm.js.map +1 -0
- package/package.json +1 -1
- package/service-worker.d.ts +1 -0
- package/service-worker.js +2 -0
- package/service-worker.js.map +1 -0
- package/services/PushService/PushService.types.d.ts +64 -0
- package/services/PushService/drivers/PushServiceDefault/PushServiceDefault.d.ts +29 -0
- package/{src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.types.ts → services/PushService/drivers/PushServiceDefault/PushServiceDefault.types.d.ts} +1 -1
- package/services/PushService/drivers/PushServiceSafari/PushServiceSafari.d.ts +21 -0
- package/services/PushService/drivers/PushServiceSafari/PushServiceSafari.types.d.ts +4 -0
- package/widget-inbox.js +2 -0
- package/widget-inbox.js.map +1 -0
- package/widget-subscribe-popup.js +2 -0
- package/widget-subscribe-popup.js.map +1 -0
- package/widget-subscription-button.js +2 -0
- package/widget-subscription-button.js.map +1 -0
- package/widget-subscription-prompt.d.ts +2 -0
- package/widget-subscription-prompt.js +2 -0
- package/widget-subscription-prompt.js.map +1 -0
- package/widgets/Inbox/InboxWidget.d.ts +49 -0
- package/widgets/Inbox/constants.d.ts +7 -0
- package/widgets/Inbox/helpers.d.ts +4 -0
- package/widgets/Inbox/inbox_widget.types.d.ts +34 -0
- package/widgets/Inbox/widgetTemplates.d.ts +4 -0
- package/widgets/SubscribePopup/SubscribePopup.d.ts +20 -0
- package/widgets/SubscribePopup/constants.d.ts +6 -0
- package/widgets/SubscribePopup/helpers.d.ts +1 -0
- package/widgets/SubscribePopup/popupTemplates.d.ts +9 -0
- package/widgets/SubscribePopup/types/subscribe-popup.d.ts +43 -0
- package/widgets/SubscriptionButton/bell.d.ts +2 -0
- package/widgets/SubscriptionButton/constants.d.ts +7 -0
- package/widgets/SubscriptionButton/index.d.ts +90 -0
- package/widgets/SubscriptionButton/positioning.d.ts +11 -0
- package/widgets/SubscriptionButton/subscribe_widget.types.d.ts +35 -0
- package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.constants.d.ts +1 -0
- package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.d.ts +14 -0
- package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.helpers.d.ts +3 -0
- package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.types.d.ts +19 -0
- package/widgets/SubscriptionPrompt/constants.d.ts +21 -0
- package/widgets/SubscriptionPrompt/helpers.d.ts +5 -0
- package/worker/global.d.ts +16 -0
- package/worker/notification.d.ts +9 -0
- package/worker/worker.types.d.ts +4 -0
- package/.editorconfig +0 -11
- package/.gitlab-ci.yml +0 -193
- package/babel.config.js +0 -7
- package/ci/cdn/Dockerfile +0 -12
- package/ci/dev/Dockerfile +0 -30
- package/ci/dev/rootfs/entrypoint.sh +0 -18
- package/ci/dev/rootfs/entrypoint.sh.d/nginx.sh +0 -6
- package/ci/dev/rootfs/entrypoint.sh.d/supervisor.sh +0 -5
- package/ci/dev/rootfs/etc/nginx/_real_ip.conf +0 -2
- package/ci/dev/rootfs/etc/nginx/conf.d/default.conf +0 -20
- package/ci/dev/rootfs/etc/supervisor.d/nginx.ini +0 -11
- package/ci/github/Dockerfile +0 -59
- package/ci/github/release-zip.js +0 -61
- package/ci/npm/Dockerfile +0 -22
- package/config/config.js +0 -24
- package/config/configBuilder.js +0 -126
- package/config/helpers.js +0 -9
- package/config/index.js +0 -1
- package/develop/README.md +0 -42
- package/develop/favicon.png +0 -0
- package/develop/index.html +0 -511
- package/eslint.config.mjs +0 -114
- package/public/index.d.ts +0 -337
- package/scripts/zip.js +0 -26
- package/src/core/Pushwoosh.ts +0 -768
- package/src/core/Pushwoosh.types.ts +0 -254
- package/src/core/Safari.types.ts +0 -26
- package/src/core/constants.ts +0 -58
- package/src/core/events.types.ts +0 -46
- package/src/core/functions.ts +0 -33
- package/src/core/legacyEventsMap.ts +0 -64
- package/src/core/logger.ts +0 -64
- package/src/core/modules/EventBus/EventBus.ts +0 -66
- package/src/core/storage.ts +0 -254
- package/src/helpers/logger.ts +0 -81
- package/src/helpers/pwlogger/Logger.constants.ts +0 -31
- package/src/helpers/pwlogger/Logger.ts +0 -218
- package/src/helpers/pwlogger/Logger.types.ts +0 -66
- package/src/helpers/pwlogger/handlers/handler-console/handler-console.ts +0 -40
- package/src/models/InboxMessages.ts +0 -202
- package/src/models/InboxMessages.types.ts +0 -111
- package/src/models/NotificationPayload.ts +0 -216
- package/src/models/NotificationPayload.types.ts +0 -65
- package/src/modules/Api/Api.ts +0 -386
- package/src/modules/Api/Api.types.ts +0 -7
- package/src/modules/ApiClient/ApiClient.ts +0 -153
- package/src/modules/ApiClient/ApiClient.types.ts +0 -222
- package/src/modules/Data/Data.ts +0 -345
- package/src/modules/DateModule.ts +0 -53
- package/src/modules/InboxMessagesPublic.ts +0 -222
- package/src/modules/PlatformChecker/PlatformChecker.ts +0 -170
- package/src/modules/PlatformChecker/PlatformChecker.types.ts +0 -5
- package/src/modules/storage/Storage.ts +0 -164
- package/src/modules/storage/Store.ts +0 -104
- package/src/modules/storage/migrations/26-11-2018.ts +0 -25
- package/src/modules/storage/migrations/MigrationExecutor.ts +0 -31
- package/src/modules/storage/migrations/Migrations.ts +0 -41
- package/src/modules/storage/migrations/constants.ts +0 -8
- package/src/modules/storage/migrations/helpers.ts +0 -16
- package/src/modules/storage/migrations/initial.ts +0 -47
- package/src/modules/storage/version.ts +0 -2
- package/src/pushwoosh-web-notifications.ts +0 -47
- package/src/pushwoosh-widget-inbox.ts +0 -8
- package/src/pushwoosh-widget-subscribe-popup.ts +0 -9
- package/src/pushwoosh-widget-subscription-button.ts +0 -8
- package/src/pushwoosh-widget-subscription-prompt.ts +0 -6
- package/src/service-worker.ts +0 -455
- package/src/services/PushService/PushService.types.ts +0 -74
- package/src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.ts +0 -235
- package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.ts +0 -125
- package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.types.ts +0 -4
- package/src/widget-subscription-prompt.ts +0 -33
- package/src/widgets/Inbox/InboxWidget.ts +0 -564
- package/src/widgets/Inbox/constants.ts +0 -49
- package/src/widgets/Inbox/css/inboxWidgetStyle.css +0 -274
- package/src/widgets/Inbox/helpers.ts +0 -63
- package/src/widgets/Inbox/inbox.d.ts +0 -9
- package/src/widgets/Inbox/inbox_widget.types.ts +0 -41
- package/src/widgets/Inbox/widgetTemplates.ts +0 -55
- package/src/widgets/SubscribePopup/SubscribePopup.ts +0 -241
- package/src/widgets/SubscribePopup/constants.ts +0 -66
- package/src/widgets/SubscribePopup/helpers.ts +0 -11
- package/src/widgets/SubscribePopup/popupTemplates.ts +0 -24
- package/src/widgets/SubscribePopup/styles/popup.css +0 -226
- package/src/widgets/SubscribePopup/types/subscribe-popup.ts +0 -68
- package/src/widgets/SubscriptionButton/assets/css/main.css +0 -205
- package/src/widgets/SubscriptionButton/bell.ts +0 -67
- package/src/widgets/SubscriptionButton/constants.ts +0 -28
- package/src/widgets/SubscriptionButton/index.ts +0 -377
- package/src/widgets/SubscriptionButton/positioning.ts +0 -165
- package/src/widgets/SubscriptionButton/subscribe_widget.types.ts +0 -53
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.constants.ts +0 -1
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.helpers.ts +0 -110
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.ts +0 -102
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.types.ts +0 -23
- package/src/widgets/SubscriptionPrompt/constants.ts +0 -22
- package/src/widgets/SubscriptionPrompt/helpers.ts +0 -42
- package/src/widgets/widgets.d.ts +0 -4
- package/src/worker/global.ts +0 -36
- package/src/worker/notification.ts +0 -34
- package/src/worker/worker.types.ts +0 -4
- package/test/__helpers__/apiHelpers.ts +0 -22
- package/test/__helpers__/keyValueHelpers.ts +0 -15
- package/test/__helpers__/platformHelpers.ts +0 -54
- package/test/__helpers__/sinonHelpers.ts +0 -7
- package/test/__helpers__/storageHelpers.ts +0 -56
- package/test/__mocks__/apiRequests.ts +0 -26
- package/test/__mocks__/idbMock.ts +0 -12
- package/test/__mocks__/idbObjectStoreMock.ts +0 -38
- package/test/__mocks__/inboxMessages.ts +0 -292
- package/test/__mocks__/models/inboxModel.ts +0 -71
- package/test/__mocks__/modules/apiClientModule.ts +0 -18
- package/test/__mocks__/modules/dateModule.ts +0 -34
- package/test/__mocks__/modules/inboxParamsModule.ts +0 -21
- package/test/__mocks__/modules/paramsBuilder.ts +0 -12
- package/test/__mocks__/modules/paramsModule.ts +0 -35
- package/test/__mocks__/modules/payloadBuilderModule.ts +0 -15
- package/test/__mocks__/modules/storageModule.ts +0 -58
- package/test/__mocks__/navigator.ts +0 -38
- package/test/__mocks__/notification.ts +0 -84
- package/test/__mocks__/pushwoosh.ts +0 -12
- package/test/__mocks__/userAgents +0 -8
- package/test/functions.test.ts +0 -22
- package/test/ignore-html.js +0 -6
- package/test/mocha.opts +0 -6
- package/test/modules/DateModule/unit.test.ts +0 -80
- package/test/modules/storage/Storage/unit.test.ts +0 -180
- package/test/modules/storage/Store/unit.test.ts +0 -192
- package/testRegister.js +0 -24
- package/tsconfig.json +0 -31
- package/webpack.config.js +0 -163
- /package/{src/core/modules/EventBus/index.ts → core/modules/EventBus/index.d.ts} +0 -0
- /package/{src/helpers/pwlogger/index.ts → helpers/pwlogger/index.d.ts} +0 -0
- /package/{src/modules/PlatformChecker/index.ts → modules/PlatformChecker/index.d.ts} +0 -0
- /package/{src/npm.ts → npm.d.ts} +0 -0
- /package/{src/services/PushService/PushService.ts → services/PushService/PushService.d.ts} +0 -0
- /package/{src/widget-inbox.ts → widget-inbox.d.ts} +0 -0
- /package/{src/widget-subscribe-popup.ts → widget-subscribe-popup.d.ts} +0 -0
- /package/{src/widget-subscription-button.ts → widget-subscription-button.d.ts} +0 -0
- /package/{src/widgets/Inbox/index.ts → widgets/Inbox/index.d.ts} +0 -0
- /package/{src/widgets/SubscribePopup/index.ts → widgets/SubscribePopup/index.d.ts} +0 -0
package/develop/index.html
DELETED
|
@@ -1,511 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>Web SDK test server</title>
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
-
<link rel="shortcut icon" href="develop/favicon.png" type="image/x-icon" />
|
|
8
|
-
<script>
|
|
9
|
-
var Pushwoosh = Pushwoosh || [];
|
|
10
|
-
Pushwoosh.push(["init", <%=htmlWebpackPlugin.options.externals.initParams%>]);
|
|
11
|
-
</script>
|
|
12
|
-
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&subset=cyrillic" rel="stylesheet">
|
|
13
|
-
<style>
|
|
14
|
-
body {
|
|
15
|
-
font-family: 'Open Sans', sans-serif;
|
|
16
|
-
margin: 50px 25px;
|
|
17
|
-
}
|
|
18
|
-
.permission-status,
|
|
19
|
-
.subscription-status {
|
|
20
|
-
display: none;
|
|
21
|
-
}
|
|
22
|
-
.success {
|
|
23
|
-
color: green;
|
|
24
|
-
}
|
|
25
|
-
.error {
|
|
26
|
-
color: red;
|
|
27
|
-
}
|
|
28
|
-
textarea {
|
|
29
|
-
width: 100%;
|
|
30
|
-
box-sizing: border-box;
|
|
31
|
-
}
|
|
32
|
-
fieldset {
|
|
33
|
-
margin: 30px 0;
|
|
34
|
-
}
|
|
35
|
-
input, button, textarea {
|
|
36
|
-
font-family: inherit;
|
|
37
|
-
}
|
|
38
|
-
#actionSubscribe,
|
|
39
|
-
#denied {color: red;}
|
|
40
|
-
#actionUnsubscribe,
|
|
41
|
-
#granted {color: green;}
|
|
42
|
-
#prompt {color: blue;}
|
|
43
|
-
|
|
44
|
-
.page {
|
|
45
|
-
font-size: 14px;
|
|
46
|
-
padding: 0 20px;
|
|
47
|
-
margin: auto;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
pre {
|
|
51
|
-
font-size: 12px;
|
|
52
|
-
}
|
|
53
|
-
</style>
|
|
54
|
-
</head>
|
|
55
|
-
<body>
|
|
56
|
-
<div class="page">
|
|
57
|
-
<h1><a href="/">Pushwoosh Web SDK</a> <span id="pwInbox">🔔</span></h1>
|
|
58
|
-
|
|
59
|
-
<p><em>Status === subscribed, when notifications permission granted and device registered.</em></p>
|
|
60
|
-
|
|
61
|
-
<p>
|
|
62
|
-
Permission:
|
|
63
|
-
<b id="prompt" class="permission-status">Prompt</b>
|
|
64
|
-
<b id="denied" class="permission-status">Denied</b>
|
|
65
|
-
<b id="granted" class="permission-status">Granted</b>
|
|
66
|
-
</p>
|
|
67
|
-
<p>
|
|
68
|
-
Status:
|
|
69
|
-
<b id="actionSubscribe" class="subscription-status">
|
|
70
|
-
Unsubscribed <br><br><button onclick="Pushwoosh.subscribe()">Subscribe</button>
|
|
71
|
-
</b>
|
|
72
|
-
<b id="actionUnsubscribe" class="subscription-status">
|
|
73
|
-
Subscribed <br><br><button onclick="Pushwoosh.unsubscribe()">Unsubscribe</button>
|
|
74
|
-
</b>
|
|
75
|
-
</p>
|
|
76
|
-
|
|
77
|
-
<p>Params:</p>
|
|
78
|
-
<table id="deviceParams" border="1" cellpadding="5" cellspacing="0" bordercolor="lightgrey">
|
|
79
|
-
<tbody></tbody>
|
|
80
|
-
</table>
|
|
81
|
-
|
|
82
|
-
<fieldset>
|
|
83
|
-
<legend>GDPR communication</legend>
|
|
84
|
-
<p>
|
|
85
|
-
<label for="GDPRSetCommunicationEnabled">
|
|
86
|
-
<input type="checkbox" id="GDPRSetCommunicationEnabled">
|
|
87
|
-
Set Communication Enabled
|
|
88
|
-
</label>
|
|
89
|
-
</p>
|
|
90
|
-
<button id="GDPRRemoveAllDeviceData">Remove All Device Data</button>
|
|
91
|
-
</fieldset>
|
|
92
|
-
|
|
93
|
-
<fieldset>
|
|
94
|
-
<legend>/postEvent</legend>
|
|
95
|
-
<form id="postEventForm">
|
|
96
|
-
<div class="success"></div>
|
|
97
|
-
<div class="error"></div>
|
|
98
|
-
<p>
|
|
99
|
-
<input type="text" name="event" placeholder="Specify event name..." required>
|
|
100
|
-
</p>
|
|
101
|
-
<p>
|
|
102
|
-
<textarea name="attributes" placeholder="Specify valid JSON with attributes..." cols="30" rows="10" required></textarea>
|
|
103
|
-
</p>
|
|
104
|
-
<button type="submit">Submit</button>
|
|
105
|
-
</form>
|
|
106
|
-
</fieldset>
|
|
107
|
-
|
|
108
|
-
<fieldset>
|
|
109
|
-
<legend>/registerUser</legend>
|
|
110
|
-
<form id="registerUserForm">
|
|
111
|
-
<div class="success"></div>
|
|
112
|
-
<div class="error"></div>
|
|
113
|
-
<p>
|
|
114
|
-
<input type="text" name="userId" placeholder="Specify userId..." required>
|
|
115
|
-
<button type="submit">Submit</button>
|
|
116
|
-
</p>
|
|
117
|
-
</form>
|
|
118
|
-
</fieldset>
|
|
119
|
-
|
|
120
|
-
<fieldset>
|
|
121
|
-
<legend>/registerEmail</legend>
|
|
122
|
-
<form id="registerEmailForm">
|
|
123
|
-
<div class="success"></div>
|
|
124
|
-
<div class="error"></div>
|
|
125
|
-
<p>
|
|
126
|
-
<input type="text" name="email" placeholder="Specify email..." required>
|
|
127
|
-
<button type="submit">Submit</button>
|
|
128
|
-
</p>
|
|
129
|
-
</form>
|
|
130
|
-
</fieldset>
|
|
131
|
-
|
|
132
|
-
<fieldset>
|
|
133
|
-
<legend>/setTags</legend>
|
|
134
|
-
<form id="setTagsForm">
|
|
135
|
-
<div class="success"></div>
|
|
136
|
-
<div class="error"></div>
|
|
137
|
-
<p>
|
|
138
|
-
<textarea
|
|
139
|
-
name="tags"
|
|
140
|
-
placeholder="Specify valid JSON..."
|
|
141
|
-
cols="30"
|
|
142
|
-
rows="10"
|
|
143
|
-
required
|
|
144
|
-
></textarea>
|
|
145
|
-
</p>
|
|
146
|
-
<button type="submit">Submit</button>
|
|
147
|
-
</form>
|
|
148
|
-
</fieldset>
|
|
149
|
-
|
|
150
|
-
<script>
|
|
151
|
-
// On Load Event
|
|
152
|
-
Pushwoosh.push(['onLoad', function () {
|
|
153
|
-
console.log('Pushwoosh load!');
|
|
154
|
-
}]);
|
|
155
|
-
|
|
156
|
-
// Ready Event
|
|
157
|
-
Pushwoosh.push(function (api) {
|
|
158
|
-
console.log('Pushwoosh ready!');
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// Subscribe Event
|
|
162
|
-
Pushwoosh.push(['onLoad', function (api) {
|
|
163
|
-
Pushwoosh.addEventHandler('subscribe', function (payload) {
|
|
164
|
-
console.log('Triggered event: subscribe');
|
|
165
|
-
});
|
|
166
|
-
}]);
|
|
167
|
-
|
|
168
|
-
// Unsubscribe Event
|
|
169
|
-
Pushwoosh.push(['onLoad', function (api) {
|
|
170
|
-
Pushwoosh.addEventHandler('unsubscribe', function (payload) {
|
|
171
|
-
console.log('Triggered event: unsubscribe');
|
|
172
|
-
});
|
|
173
|
-
}]);
|
|
174
|
-
|
|
175
|
-
// Subscription Widget Events
|
|
176
|
-
Pushwoosh.push(['onLoad', function (api) {
|
|
177
|
-
Pushwoosh.addEventHandler('show-subscription-widget', function (payload) {
|
|
178
|
-
console.log('Triggered event: show-subscription-widget');
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
Pushwoosh.addEventHandler('hide-subscription-widget', function (payload) {
|
|
182
|
-
console.log('Triggered event: hide-subscription-widget');
|
|
183
|
-
});
|
|
184
|
-
}]);
|
|
185
|
-
|
|
186
|
-
// Notification Permission Dialog Events
|
|
187
|
-
Pushwoosh.push(['onLoad', function (api) {
|
|
188
|
-
Pushwoosh.addEventHandler('show-notification-permission-dialog', function (payload) {
|
|
189
|
-
console.log('Triggered event: show-notification-permission-dialog');
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
Pushwoosh.addEventHandler('hide-notification-permission-dialog', function (payload) {
|
|
193
|
-
console.log('Triggered event: hide-notification-permission-dialog', payload.permission);
|
|
194
|
-
});
|
|
195
|
-
}]);
|
|
196
|
-
|
|
197
|
-
// Permission Events
|
|
198
|
-
Pushwoosh.push(['onLoad', function (api) {
|
|
199
|
-
Pushwoosh.addEventHandler('permission-default', function () {
|
|
200
|
-
console.log('Triggered event: permission-default');
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
Pushwoosh.addEventHandler('permission-denied', function () {
|
|
204
|
-
console.log('Triggered event: permission-denied');
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
Pushwoosh.addEventHandler('permission-granted', function () {
|
|
208
|
-
console.log('Triggered event: permission-granted');
|
|
209
|
-
});
|
|
210
|
-
}]);
|
|
211
|
-
|
|
212
|
-
// Receive Push Event
|
|
213
|
-
Pushwoosh.push(['onLoad', function (api) {
|
|
214
|
-
Pushwoosh.addEventHandler('receive-push', function (payload) {
|
|
215
|
-
console.log('Triggered event: receive-push', payload.notification);
|
|
216
|
-
});
|
|
217
|
-
}]);
|
|
218
|
-
|
|
219
|
-
// Notification Events
|
|
220
|
-
Pushwoosh.push(['onLoad', function (api) {
|
|
221
|
-
Pushwoosh.addEventHandler('open-notification', function (payload) {
|
|
222
|
-
console.log('Triggered event: open-notification', payload.notification);
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
Pushwoosh.addEventHandler('hide-notification', function (payload) {
|
|
226
|
-
console.log('Triggered event: hide-notification', payload.notification);
|
|
227
|
-
});
|
|
228
|
-
}]);
|
|
229
|
-
|
|
230
|
-
// In-Box Events
|
|
231
|
-
Pushwoosh.push(['onLoad', function (api) {
|
|
232
|
-
Pushwoosh.addEventHandler('receive-inbox-message', function (payload) {
|
|
233
|
-
console.log('Triggered event: receive-inbox-message', payload.message);
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
Pushwoosh.addEventHandler('update-inbox-messages', function (payload) {
|
|
237
|
-
console.log('Triggered event: receive-inbox-message', payload.messages);
|
|
238
|
-
});
|
|
239
|
-
}]);
|
|
240
|
-
|
|
241
|
-
Pushwoosh.push(function(api) {
|
|
242
|
-
console.log('EVENT: onReady', api);
|
|
243
|
-
|
|
244
|
-
Pushwoosh.isCommunicationEnabled().then(function(isEnabled) {
|
|
245
|
-
document.querySelector('#GDPRSetCommunicationEnabled').checked = isEnabled;
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
document.querySelector('#GDPRSetCommunicationEnabled').addEventListener('click', function (event) {
|
|
249
|
-
event.preventDefault();
|
|
250
|
-
Pushwoosh.setCommunicationEnabled(event.target.checked);
|
|
251
|
-
}, false);
|
|
252
|
-
|
|
253
|
-
document.querySelector('#GDPRRemoveAllDeviceData').addEventListener('click', function() {
|
|
254
|
-
Pushwoosh.removeAllDeviceData();
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
checkSubscription();
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
Pushwoosh.push(['onChangeCommunicationEnabled', function(api, isEnabled) {
|
|
261
|
-
console.log('EVENT: onChangeCommunicationEnabled', isEnabled);
|
|
262
|
-
document.querySelector('#GDPRSetCommunicationEnabled').checked = isEnabled;
|
|
263
|
-
}]);
|
|
264
|
-
|
|
265
|
-
Pushwoosh.push(['onSubscribe', function(api) {
|
|
266
|
-
console.log('EVENT: onSubscribe', api);
|
|
267
|
-
checkSubscription();
|
|
268
|
-
}]);
|
|
269
|
-
|
|
270
|
-
Pushwoosh.push(['onUnsubscribe', function(api) {
|
|
271
|
-
console.log('EVENT: onUnsubscribe', api);
|
|
272
|
-
checkSubscription();
|
|
273
|
-
}]);
|
|
274
|
-
|
|
275
|
-
Pushwoosh.push(['onRegister', function(api) {
|
|
276
|
-
console.log('EVENT: onRegister', api);
|
|
277
|
-
checkSubscription();
|
|
278
|
-
}]);
|
|
279
|
-
|
|
280
|
-
Pushwoosh.push(['onPermissionPrompt', function(api) {
|
|
281
|
-
console.log('EVENT: onPermissionPrompt', api);
|
|
282
|
-
toggleNodesVisibility('.permission-status', 'prompt');
|
|
283
|
-
}]);
|
|
284
|
-
|
|
285
|
-
Pushwoosh.push(['onPermissionDenied', function(api) {
|
|
286
|
-
console.log('EVENT: onPermissionDenied', api);
|
|
287
|
-
toggleNodesVisibility('.permission-status', 'denied');
|
|
288
|
-
checkSubscription();
|
|
289
|
-
}]);
|
|
290
|
-
|
|
291
|
-
Pushwoosh.push(['onPermissionGranted', function(api) {
|
|
292
|
-
console.log('EVENT: onPermissionGranted', api);
|
|
293
|
-
toggleNodesVisibility('.permission-status', 'granted');
|
|
294
|
-
checkSubscription();
|
|
295
|
-
}]);
|
|
296
|
-
|
|
297
|
-
Pushwoosh.push(['onPushDelivery', function(api, params) {
|
|
298
|
-
console.log('EVENT: onPushDelivery', api, params);
|
|
299
|
-
}]);
|
|
300
|
-
|
|
301
|
-
Pushwoosh.push(['onNotificationClick', function(api, params) {
|
|
302
|
-
console.log('EVENT: onNotificationClick', api, params);
|
|
303
|
-
}]);
|
|
304
|
-
|
|
305
|
-
Pushwoosh.push(['onNotificationClose', function(api, params) {
|
|
306
|
-
console.log('EVENT: onNotificationClose', api, params);
|
|
307
|
-
}]);
|
|
308
|
-
|
|
309
|
-
Pushwoosh.push(['onSWInitError', function(api) {
|
|
310
|
-
console.log('EVENT: onSWInitError', api);
|
|
311
|
-
}]);
|
|
312
|
-
|
|
313
|
-
Pushwoosh.push(['onPutNewMessageToInboxStore', function(api, message) {
|
|
314
|
-
console.log('EVENT: onPutNewMessageToInboxStore', message);
|
|
315
|
-
}]);
|
|
316
|
-
|
|
317
|
-
Pushwoosh.push(['onUpdateInboxMessages', function(api, pwinbox) {
|
|
318
|
-
pwinbox.loadMessages().then(function(messages) {
|
|
319
|
-
console.log('EVENT: onUpdateInboxMessages', messages);
|
|
320
|
-
})
|
|
321
|
-
}]);
|
|
322
|
-
|
|
323
|
-
Pushwoosh.push(['onShowNotificationPermissionDialog', function(api) {
|
|
324
|
-
console.log('EVENT: onShowNotificationPermissionDialog');
|
|
325
|
-
}]);
|
|
326
|
-
|
|
327
|
-
Pushwoosh.push(['onShowSubscriptionWidget', function(api) {
|
|
328
|
-
console.log('EVENT: onShowSubscriptionWidget');
|
|
329
|
-
}]);
|
|
330
|
-
|
|
331
|
-
Pushwoosh.push(['onHideSubscriptionWidget', function(api) {
|
|
332
|
-
console.log('EVENT: onHideSubscriptionWidget');
|
|
333
|
-
}]);
|
|
334
|
-
|
|
335
|
-
Pushwoosh.push(['onHideNotificationPermissionDialog', function(api, permission) {
|
|
336
|
-
console.log('EVENT: onHideNotificationPermissionDialog', permission);
|
|
337
|
-
checkSubscription();
|
|
338
|
-
}]);
|
|
339
|
-
|
|
340
|
-
function checkSubscription() {
|
|
341
|
-
Pushwoosh.isSubscribed().then(function (res) {
|
|
342
|
-
toggleNodesVisibility('.subscription-status', res ? 'actionUnsubscribe' : 'actionSubscribe');
|
|
343
|
-
}).catch(function (err) {
|
|
344
|
-
console.error('Is subscribed error', err);
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
Pushwoosh.getParams().then(function (params) {
|
|
348
|
-
var table = document.querySelector('#deviceParams tbody');
|
|
349
|
-
table.innerHTML = '';
|
|
350
|
-
Object.keys(params).map(function(key) {
|
|
351
|
-
var row = '<tr><td>'+key+'</td><td><pre>'+JSON.stringify(params[key], null, 2) || ''+'</pre></td></tr>';
|
|
352
|
-
table.insertAdjacentHTML('beforeend', row);
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
function toggleNodesVisibility(selector, id) {
|
|
358
|
-
var nodes = document.querySelectorAll(selector);
|
|
359
|
-
[].forEach.call(nodes, function (el) {
|
|
360
|
-
el.style.display = el.id === id ? 'inline' : 'none';
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
function toggleNodesVisibility(selector, id) {
|
|
365
|
-
var nodes = document.querySelectorAll(selector);
|
|
366
|
-
[].forEach.call(nodes, function(el) {
|
|
367
|
-
el.style.display = el.id === id ? 'inline' : 'none';
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
document.querySelector('#registerUserForm').addEventListener('submit', function(e) {
|
|
372
|
-
e.preventDefault();
|
|
373
|
-
var form = this;
|
|
374
|
-
var button = form.querySelector('button');
|
|
375
|
-
var input = form.querySelector('[name="userId"]');
|
|
376
|
-
var successNode = form.querySelector('.success');
|
|
377
|
-
var errorNode = form.querySelector('.error');
|
|
378
|
-
var userId = input.value;
|
|
379
|
-
button.setAttribute('disabled', 'disabled');
|
|
380
|
-
Pushwoosh.api.registerUser(userId)
|
|
381
|
-
.then(function() {
|
|
382
|
-
input.value = '';
|
|
383
|
-
errorNode.innerHTML = '';
|
|
384
|
-
successNode.innerHTML = 'Data successfully submitted ' + new Date();
|
|
385
|
-
})
|
|
386
|
-
.catch(function(err) {
|
|
387
|
-
successNode.innerHTML = '';
|
|
388
|
-
console.error(err);
|
|
389
|
-
errorNode.innerHTML = 'Got some error on submit. Check console for details.';
|
|
390
|
-
})
|
|
391
|
-
.then(function() {
|
|
392
|
-
button.removeAttribute('disabled');
|
|
393
|
-
});
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
document.querySelector('#registerEmailForm').addEventListener('submit', function(e) {
|
|
397
|
-
e.preventDefault();
|
|
398
|
-
var form = this;
|
|
399
|
-
var button = form.querySelector('button');
|
|
400
|
-
var input = form.querySelector('[name="email"]');
|
|
401
|
-
var successNode = form.querySelector('.success');
|
|
402
|
-
var errorNode = form.querySelector('.error');
|
|
403
|
-
var email = input.value;
|
|
404
|
-
button.setAttribute('disabled', 'disabled');
|
|
405
|
-
Pushwoosh.api.registerEmail(email)
|
|
406
|
-
.then(function() {
|
|
407
|
-
input.value = '';
|
|
408
|
-
errorNode.innerHTML = '';
|
|
409
|
-
successNode.innerHTML = 'Data successfully submitted ' + new Date();
|
|
410
|
-
})
|
|
411
|
-
.catch(function(err) {
|
|
412
|
-
successNode.innerHTML = '';
|
|
413
|
-
console.error(err);
|
|
414
|
-
errorNode.innerHTML = 'Got some error on submit. Check console for details.';
|
|
415
|
-
})
|
|
416
|
-
.then(function() {
|
|
417
|
-
button.removeAttribute('disabled');
|
|
418
|
-
});
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
document.querySelector('#setTagsForm').addEventListener('submit', function(e) {
|
|
422
|
-
e.preventDefault();
|
|
423
|
-
var form = this;
|
|
424
|
-
var button = form.querySelector('button');
|
|
425
|
-
var input = form.querySelector('[name="tags"]');
|
|
426
|
-
var successNode = form.querySelector('.success');
|
|
427
|
-
var errorNode = form.querySelector('.error');
|
|
428
|
-
var tags = input.value;
|
|
429
|
-
|
|
430
|
-
try {
|
|
431
|
-
tags = JSON.parse(tags);
|
|
432
|
-
errorNode.innerHTML = '';
|
|
433
|
-
}
|
|
434
|
-
catch (err) {
|
|
435
|
-
successNode.innerHTML = '';
|
|
436
|
-
console.error(err);
|
|
437
|
-
errorNode.innerHTML = 'JSON.parse error. Expected object: {[k: string]: any}';
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
button.setAttribute('disabled', 'disabled');
|
|
442
|
-
Pushwoosh.api.setTags(tags)
|
|
443
|
-
.then(function(res) {
|
|
444
|
-
var skipped = res && res.skipped || null;
|
|
445
|
-
if (!skipped || !skipped.length) {
|
|
446
|
-
input.value = '';
|
|
447
|
-
errorNode.innerHTML = '';
|
|
448
|
-
successNode.innerHTML = 'Data successfully submitted ' + new Date();
|
|
449
|
-
} else {
|
|
450
|
-
successNode.innerHTML = '';
|
|
451
|
-
errorNode.innerHTML = skipped.map(function(item) {
|
|
452
|
-
return 'Skipped tag "' + item.tag + '", reason "' + item.reason + '".';
|
|
453
|
-
}).join('n\ ');
|
|
454
|
-
}
|
|
455
|
-
})
|
|
456
|
-
.catch(function(err) {
|
|
457
|
-
console.error(err);
|
|
458
|
-
successNode.innerHTML = '';
|
|
459
|
-
errorNode.innerHTML = 'Got some error on submit. Check console for details.';
|
|
460
|
-
})
|
|
461
|
-
.then(function() {
|
|
462
|
-
button.removeAttribute('disabled');
|
|
463
|
-
});
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
document.querySelector('#postEventForm').addEventListener('submit', function(e) {
|
|
467
|
-
e.preventDefault();
|
|
468
|
-
var form = this;
|
|
469
|
-
var button = form.querySelector('button');
|
|
470
|
-
var eventControl = form.querySelector('[name="event"]');
|
|
471
|
-
var attributesControl = form.querySelector('[name="attributes"]');
|
|
472
|
-
var successNode = form.querySelector('.success');
|
|
473
|
-
var errorNode = form.querySelector('.error');
|
|
474
|
-
var attributes = attributesControl.value;
|
|
475
|
-
var event = eventControl.value;
|
|
476
|
-
|
|
477
|
-
successNode.innerHTML = '';
|
|
478
|
-
errorNode.innerHTML = '';
|
|
479
|
-
|
|
480
|
-
if (!event) {
|
|
481
|
-
errorNode.innerHTML += 'Event name is required.';
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
try {
|
|
486
|
-
attributes = JSON.parse(attributes);
|
|
487
|
-
}
|
|
488
|
-
catch (err) {
|
|
489
|
-
console.error(err);
|
|
490
|
-
errorNode.innerHTML = 'JSON.parse error. Expected object: {[k: string]: any}';
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
button.setAttribute('disabled', 'disabled');
|
|
495
|
-
|
|
496
|
-
Pushwoosh.api.postEvent(event, attributes)
|
|
497
|
-
.then(function() {
|
|
498
|
-
successNode.innerHTML = 'Data successfully submitted ' + new Date();
|
|
499
|
-
})
|
|
500
|
-
.catch(function(err) {
|
|
501
|
-
errorNode.innerHTML += 'Got some error on submit. Check console for details.';
|
|
502
|
-
console.error(err);
|
|
503
|
-
})
|
|
504
|
-
.then(function() {
|
|
505
|
-
button.removeAttribute('disabled');
|
|
506
|
-
});
|
|
507
|
-
});
|
|
508
|
-
</script>
|
|
509
|
-
</div>
|
|
510
|
-
</body>
|
|
511
|
-
</html>
|
package/eslint.config.mjs
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import eslint from '@eslint/js';
|
|
4
|
-
import stylistic from '@stylistic/eslint-plugin';
|
|
5
|
-
import stylisticTs from '@stylistic/eslint-plugin-ts';
|
|
6
|
-
import importPlugin from 'eslint-plugin-import';
|
|
7
|
-
import tseslint from 'typescript-eslint';
|
|
8
|
-
|
|
9
|
-
export default tseslint.config(
|
|
10
|
-
eslint.configs.recommended,
|
|
11
|
-
importPlugin.flatConfigs.recommended,
|
|
12
|
-
...tseslint.configs.recommended,
|
|
13
|
-
stylistic.configs.customize({
|
|
14
|
-
indent: 2,
|
|
15
|
-
quotes: 'single',
|
|
16
|
-
semi: true,
|
|
17
|
-
jsx: true,
|
|
18
|
-
braceStyle: '1tbs',
|
|
19
|
-
blockSpacing: true,
|
|
20
|
-
quoteProps: 'as-needed',
|
|
21
|
-
commaDangle: 'always-multiline',
|
|
22
|
-
arrowParens: 'always',
|
|
23
|
-
}),
|
|
24
|
-
{
|
|
25
|
-
plugins: {
|
|
26
|
-
// '@stylistic': stylistic.configs.customize(),
|
|
27
|
-
'@stylistic/ts': stylisticTs,
|
|
28
|
-
},
|
|
29
|
-
rules: {
|
|
30
|
-
'max-len': [
|
|
31
|
-
'error',
|
|
32
|
-
{
|
|
33
|
-
code: 160,
|
|
34
|
-
tabWidth: 2,
|
|
35
|
-
ignoreUrls: true,
|
|
36
|
-
ignoreComments: true,
|
|
37
|
-
ignoreStrings: true,
|
|
38
|
-
ignoreTemplateLiterals: true,
|
|
39
|
-
ignoreRegExpLiterals: true,
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
'@stylistic/no-mixed-operators': 'off',
|
|
43
|
-
'@stylistic/multiline-ternary': 'off',
|
|
44
|
-
'@stylistic/ts/member-delimiter-style': [
|
|
45
|
-
'error',
|
|
46
|
-
{
|
|
47
|
-
multiline: {
|
|
48
|
-
delimiter: 'semi',
|
|
49
|
-
requireLast: true,
|
|
50
|
-
},
|
|
51
|
-
singleline: {
|
|
52
|
-
delimiter: 'semi',
|
|
53
|
-
requireLast: false,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
'@typescript-eslint/ban-ts-comment': 'off',
|
|
58
|
-
'@typescript-eslint/consistent-type-imports': ['error', {
|
|
59
|
-
prefer: 'type-imports',
|
|
60
|
-
disallowTypeAnnotations: true,
|
|
61
|
-
fixStyle: 'inline-type-imports',
|
|
62
|
-
}],
|
|
63
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
64
|
-
'@typescript-eslint/no-unused-vars': [
|
|
65
|
-
'error',
|
|
66
|
-
{
|
|
67
|
-
argsIgnorePattern: '^_',
|
|
68
|
-
caughtErrorsIgnorePattern: '^_',
|
|
69
|
-
destructuredArrayIgnorePattern: '^_',
|
|
70
|
-
varsIgnorePattern: '^_',
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
'import/no-named-as-default': 'off',
|
|
74
|
-
'import/no-unresolved': 'off',
|
|
75
|
-
'import/order': [
|
|
76
|
-
'error',
|
|
77
|
-
{
|
|
78
|
-
groups: [
|
|
79
|
-
'builtin',
|
|
80
|
-
'external',
|
|
81
|
-
'internal',
|
|
82
|
-
['parent', 'sibling'],
|
|
83
|
-
'index',
|
|
84
|
-
],
|
|
85
|
-
pathGroups: [
|
|
86
|
-
{
|
|
87
|
-
pattern: '@*',
|
|
88
|
-
group: 'external',
|
|
89
|
-
position: 'after',
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
pattern: '@pushwoosh/**',
|
|
93
|
-
group: 'external',
|
|
94
|
-
position: 'after',
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
pattern: '~/**',
|
|
98
|
-
group: 'internal',
|
|
99
|
-
position: 'after',
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
pathGroupsExcludedImportTypes: ['builtin'],
|
|
103
|
-
'newlines-between': 'always',
|
|
104
|
-
alphabetize: {
|
|
105
|
-
order: 'asc',
|
|
106
|
-
caseInsensitive: true,
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
'no-nested-ternary': 'error',
|
|
111
|
-
'no-console': 'off',
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
);
|