@molecule/app-push 1.0.0
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/LICENSE +115 -0
- package/README.md +612 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +72 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +83 -0
- package/dist/provider.js.map +1 -0
- package/dist/types.d.ts +286 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/web-provider.d.ts +13 -0
- package/dist/web-provider.d.ts.map +1 -0
- package/dist/web-provider.js +264 -0
- package/dist/web-provider.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web-based push provider using the Push API.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { t } from '@molecule/app-i18n';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a web push provider using the browser Push API and Notification API.
|
|
9
|
+
* @param vapidPublicKey - Optional VAPID public key for server-authenticated subscriptions.
|
|
10
|
+
* @returns A {@link PushProvider} backed by the Web Push API.
|
|
11
|
+
*/
|
|
12
|
+
export const createWebPushProvider = (vapidPublicKey) => {
|
|
13
|
+
const notificationReceivedListeners = new Set();
|
|
14
|
+
const notificationActionListeners = new Set();
|
|
15
|
+
const tokenChangeListeners = new Set();
|
|
16
|
+
let currentToken = null;
|
|
17
|
+
let registration = null;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the active service worker registration WITHOUT hanging.
|
|
20
|
+
*
|
|
21
|
+
* `navigator.serviceWorker.ready` never settles when no service worker is
|
|
22
|
+
* registered (the common case in dev builds — only production builds ship
|
|
23
|
+
* one), which used to freeze the enable-push UI forever. `getRegistration()`
|
|
24
|
+
* resolves immediately (`undefined` when none), so callers can fail fast or
|
|
25
|
+
* degrade gracefully; when a registration exists, awaiting `ready` is then
|
|
26
|
+
* safe (it settles once the worker activates).
|
|
27
|
+
*/
|
|
28
|
+
const getReadyRegistration = async () => {
|
|
29
|
+
const existing = await navigator.serviceWorker.getRegistration();
|
|
30
|
+
if (!existing)
|
|
31
|
+
return null;
|
|
32
|
+
return navigator.serviceWorker.ready;
|
|
33
|
+
};
|
|
34
|
+
// Convert VAPID key to Uint8Array
|
|
35
|
+
const urlBase64ToUint8Array = (base64String) => {
|
|
36
|
+
const padding = '='.repeat((4 - (base64String.length % 4)) % 4);
|
|
37
|
+
const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/');
|
|
38
|
+
const rawData = atob(base64);
|
|
39
|
+
const outputArray = new Uint8Array(rawData.length);
|
|
40
|
+
for (let i = 0; i < rawData.length; ++i) {
|
|
41
|
+
outputArray[i] = rawData.charCodeAt(i);
|
|
42
|
+
}
|
|
43
|
+
return outputArray;
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
async checkPermission() {
|
|
47
|
+
if (!('Notification' in window)) {
|
|
48
|
+
return 'denied';
|
|
49
|
+
}
|
|
50
|
+
return Notification.permission;
|
|
51
|
+
},
|
|
52
|
+
async requestPermission() {
|
|
53
|
+
if (!('Notification' in window)) {
|
|
54
|
+
return 'denied';
|
|
55
|
+
}
|
|
56
|
+
const result = await Notification.requestPermission();
|
|
57
|
+
return result;
|
|
58
|
+
},
|
|
59
|
+
async register(options) {
|
|
60
|
+
if (!('serviceWorker' in navigator) || !('PushManager' in window)) {
|
|
61
|
+
throw new Error(t('push.error.notSupported', undefined, {
|
|
62
|
+
defaultValue: 'Push notifications not supported',
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
// Fail fast (never hang) when no service worker is registered — dev
|
|
66
|
+
// builds don't ship one, and awaiting `.ready` would block forever.
|
|
67
|
+
registration = await getReadyRegistration();
|
|
68
|
+
if (!registration) {
|
|
69
|
+
throw new Error(t('push.error.noServiceWorker', undefined, {
|
|
70
|
+
defaultValue: 'No service worker is registered — push notifications require the production app build.',
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
// Subscribe to push
|
|
74
|
+
const subscribeOptions = {
|
|
75
|
+
userVisibleOnly: true,
|
|
76
|
+
};
|
|
77
|
+
// Runtime key (e.g. fetched from the api) wins over the constructor key.
|
|
78
|
+
const applicationServerKey = options?.vapidPublicKey ?? vapidPublicKey;
|
|
79
|
+
if (applicationServerKey) {
|
|
80
|
+
subscribeOptions.applicationServerKey = urlBase64ToUint8Array(applicationServerKey)
|
|
81
|
+
.buffer;
|
|
82
|
+
}
|
|
83
|
+
const subscription = await registration.pushManager.subscribe(subscribeOptions);
|
|
84
|
+
const token = {
|
|
85
|
+
value: JSON.stringify(subscription.toJSON()),
|
|
86
|
+
platform: 'web',
|
|
87
|
+
timestamp: Date.now(),
|
|
88
|
+
};
|
|
89
|
+
currentToken = token;
|
|
90
|
+
tokenChangeListeners.forEach((listener) => listener(token));
|
|
91
|
+
return token;
|
|
92
|
+
},
|
|
93
|
+
async unregister() {
|
|
94
|
+
if (!registration) {
|
|
95
|
+
registration = await getReadyRegistration();
|
|
96
|
+
}
|
|
97
|
+
if (!registration) {
|
|
98
|
+
// Nothing to unsubscribe from (no service worker → no subscription).
|
|
99
|
+
currentToken = null;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const subscription = await registration.pushManager.getSubscription();
|
|
103
|
+
if (subscription) {
|
|
104
|
+
await subscription.unsubscribe();
|
|
105
|
+
}
|
|
106
|
+
currentToken = null;
|
|
107
|
+
},
|
|
108
|
+
async getToken() {
|
|
109
|
+
if (currentToken)
|
|
110
|
+
return currentToken;
|
|
111
|
+
if (!('serviceWorker' in navigator) || !('PushManager' in window)) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
registration = await getReadyRegistration();
|
|
115
|
+
if (!registration)
|
|
116
|
+
return null;
|
|
117
|
+
const subscription = await registration.pushManager.getSubscription();
|
|
118
|
+
if (subscription) {
|
|
119
|
+
currentToken = {
|
|
120
|
+
value: JSON.stringify(subscription.toJSON()),
|
|
121
|
+
platform: 'web',
|
|
122
|
+
timestamp: Date.now(),
|
|
123
|
+
};
|
|
124
|
+
return currentToken;
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
},
|
|
128
|
+
onNotificationReceived(listener) {
|
|
129
|
+
notificationReceivedListeners.add(listener);
|
|
130
|
+
return () => notificationReceivedListeners.delete(listener);
|
|
131
|
+
},
|
|
132
|
+
onNotificationAction(listener) {
|
|
133
|
+
notificationActionListeners.add(listener);
|
|
134
|
+
return () => notificationActionListeners.delete(listener);
|
|
135
|
+
},
|
|
136
|
+
onTokenChange(listener) {
|
|
137
|
+
tokenChangeListeners.add(listener);
|
|
138
|
+
return () => tokenChangeListeners.delete(listener);
|
|
139
|
+
},
|
|
140
|
+
async scheduleLocal(options) {
|
|
141
|
+
const permission = await this.checkPermission();
|
|
142
|
+
if (permission !== 'granted') {
|
|
143
|
+
throw new Error(t('push.error.permissionNotGranted', undefined, {
|
|
144
|
+
defaultValue: 'Notification permission not granted',
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
const id = options.id || Math.random().toString(36).slice(2);
|
|
148
|
+
const showNotification = () => {
|
|
149
|
+
if (registration) {
|
|
150
|
+
const notificationOptions = {
|
|
151
|
+
body: options.body,
|
|
152
|
+
data: { id, ...options.extra },
|
|
153
|
+
badge: options.badge ? String(options.badge) : undefined,
|
|
154
|
+
tag: id,
|
|
155
|
+
};
|
|
156
|
+
if (options.actions) {
|
|
157
|
+
notificationOptions.actions = options.actions.map((a) => ({
|
|
158
|
+
action: a.id,
|
|
159
|
+
title: a.title,
|
|
160
|
+
icon: a.icon,
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
registration.showNotification(options.title, notificationOptions);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
new Notification(options.title, {
|
|
167
|
+
body: options.body,
|
|
168
|
+
data: { id, ...options.extra },
|
|
169
|
+
tag: id,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
if (options.at) {
|
|
174
|
+
const delay = options.at.getTime() - Date.now();
|
|
175
|
+
if (delay > 0) {
|
|
176
|
+
setTimeout(showNotification, delay);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
showNotification();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
showNotification();
|
|
184
|
+
}
|
|
185
|
+
return id;
|
|
186
|
+
},
|
|
187
|
+
async cancelLocal(_id) {
|
|
188
|
+
// Web API doesn't support canceling scheduled notifications easily
|
|
189
|
+
// This would require tracking timers
|
|
190
|
+
},
|
|
191
|
+
async cancelAllLocal() {
|
|
192
|
+
// Same limitation
|
|
193
|
+
},
|
|
194
|
+
async getPendingLocal() {
|
|
195
|
+
// Web API doesn't expose pending notifications
|
|
196
|
+
return [];
|
|
197
|
+
},
|
|
198
|
+
async getDelivered() {
|
|
199
|
+
if (!registration) {
|
|
200
|
+
registration = await getReadyRegistration();
|
|
201
|
+
}
|
|
202
|
+
if (!registration)
|
|
203
|
+
return [];
|
|
204
|
+
const notifications = await registration.getNotifications();
|
|
205
|
+
return notifications.map((n) => {
|
|
206
|
+
const extN = n;
|
|
207
|
+
return {
|
|
208
|
+
id: n.tag || Math.random().toString(36).slice(2),
|
|
209
|
+
title: n.title,
|
|
210
|
+
body: n.body || undefined,
|
|
211
|
+
data: n.data,
|
|
212
|
+
icon: n.icon || undefined,
|
|
213
|
+
image: extN.image || undefined,
|
|
214
|
+
tag: n.tag || undefined,
|
|
215
|
+
timestamp: extN.timestamp,
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
async removeDelivered(ids) {
|
|
220
|
+
if (!registration) {
|
|
221
|
+
registration = await getReadyRegistration();
|
|
222
|
+
}
|
|
223
|
+
if (!registration)
|
|
224
|
+
return;
|
|
225
|
+
const notifications = await registration.getNotifications();
|
|
226
|
+
for (const n of notifications) {
|
|
227
|
+
if (ids.includes(n.tag || '')) {
|
|
228
|
+
n.close();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
async removeAllDelivered() {
|
|
233
|
+
if (!registration) {
|
|
234
|
+
registration = await getReadyRegistration();
|
|
235
|
+
}
|
|
236
|
+
if (!registration)
|
|
237
|
+
return;
|
|
238
|
+
const notifications = await registration.getNotifications();
|
|
239
|
+
for (const n of notifications) {
|
|
240
|
+
n.close();
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
async setBadge(count) {
|
|
244
|
+
if ('setAppBadge' in navigator) {
|
|
245
|
+
await navigator.setAppBadge(count);
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
async getBadge() {
|
|
249
|
+
// Web API doesn't support reading badge
|
|
250
|
+
return 0;
|
|
251
|
+
},
|
|
252
|
+
async clearBadge() {
|
|
253
|
+
if ('clearAppBadge' in navigator) {
|
|
254
|
+
await navigator.clearAppBadge();
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
destroy() {
|
|
258
|
+
notificationReceivedListeners.clear();
|
|
259
|
+
notificationActionListeners.clear();
|
|
260
|
+
tokenChangeListeners.clear();
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
//# sourceMappingURL=web-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-provider.js","sourceRoot":"","sources":["../src/web-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AA+BtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,cAAuB,EAAgB,EAAE;IAC7E,MAAM,6BAA6B,GAAG,IAAI,GAAG,EAAgC,CAAA;IAC7E,MAAM,2BAA2B,GAAG,IAAI,GAAG,EAA8B,CAAA;IACzE,MAA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C9B,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC;oBAC9B,CAAC,CAAC,KAAK,EAAE,CAAA;gBACX,CAAC;YACH,CAAC;QACH,CAAC;QAED,KAAK,CAAC,kBAAkB;YACtB,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,YAAY,GAAG,MAAM,oBAAoB,EAAE,CAAA;YAC7C,CAAC;YACD,IAAI,CAAC,YAAY;gBAAE,OAAM;YAEzB,MAAM,aAAa,GAAG,MAAM,YAAY,CAAC,gBAAgB,EAAE,CAAA;YAC3D,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE,CAAC;gBAC9B,CAAC,CAAC,KAAK,EAAE,CAAA;YACX,CAAC;QACH,CAAC;QAED,KAAK,CAAC,QAAQ,CAAC,KAAa;YAC1B,IAAI,aAAa,IAAI,SAAS,EAAE,CAAC;gBAC/B,MAAO,SAAgC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;YAC5D,CAAC;QACH,CAAC;QAED,KAAK,CAAC,QAAQ;YACZ,wCAAwC;YACxC,OAAO,CAAC,CAAA;QACV,CAAC;QAED,KAAK,CAAC,UAAU;YACd,IAAI,eAAe,IAAI,SAAS,EAAE,CAAC;gBACjC,MAAO,SAAgC,CAAC,aAAa,EAAE,CAAA;YACzD,CAAC;QACH,CAAC;QAED,OAAO;YACL,6BAA6B,CAAC,KAAK,EAAE,CAAA;YACrC,2BAA2B,CAAC,KAAK,EAAE,CAAA;YACnC,oBAAoB,CAAC,KAAK,EAAE,CAAA;QAC9B,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@molecule/app-push",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Client-side push notifications interface for molecule.dev",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"test": "vitest run",
|
|
11
|
+
"test:watch": "vitest"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"molecule",
|
|
25
|
+
"push",
|
|
26
|
+
"notifications",
|
|
27
|
+
"push-notifications"
|
|
28
|
+
],
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@molecule/app-bond": "^1.0.0",
|
|
32
|
+
"@molecule/app-i18n": "^1.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@molecule/app-bond": "1.0.0",
|
|
36
|
+
"@molecule/app-i18n": "1.0.0",
|
|
37
|
+
"@types/node": "26.1.2",
|
|
38
|
+
"typescript": "6.0.3",
|
|
39
|
+
"vitest": "4.1.10"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
44
|
+
"directory": "packages/app/native/push"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/molecule-dev/molecule/tree/main/packages/app/native/push",
|
|
47
|
+
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
}
|
|
51
|
+
}
|