@lunora/notify 1.0.0-alpha.24 → 1.0.0-alpha.26
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/dist/web.d.mts +0 -15
- package/dist/web.d.ts +0 -15
- package/dist/web.mjs +1 -1
- package/package.json +2 -2
package/dist/web.d.mts
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@lunora/notify/web` — the browser-side helper for registering a service-worker
|
|
3
|
-
* Web Push subscription. Runs in the browser (Push API + `navigator.serviceWorker`),
|
|
4
|
-
* has no server imports, and returns a plain, JSON-serialisable subscription you
|
|
5
|
-
* hand to a Lunora mutation calling `ctx.push.register({ subscription, userId })`.
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* import { subscribeToPush } from "@lunora/notify/web";
|
|
9
|
-
*
|
|
10
|
-
* const subscription = await subscribeToPush({ serviceWorkerUrl: "/sw.js", vapidPublicKey });
|
|
11
|
-
* await client.mutation("registerDevice", { subscription });
|
|
12
|
-
* ```
|
|
13
|
-
* @packageDocumentation
|
|
14
|
-
*/
|
|
15
|
-
/** A plain, JSON-serialisable Web Push subscription (the shape `ctx.push.register` accepts). */
|
|
16
1
|
interface SerializedPushSubscription {
|
|
17
2
|
endpoint: string;
|
|
18
3
|
expirationTime: number | null;
|
package/dist/web.d.ts
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@lunora/notify/web` — the browser-side helper for registering a service-worker
|
|
3
|
-
* Web Push subscription. Runs in the browser (Push API + `navigator.serviceWorker`),
|
|
4
|
-
* has no server imports, and returns a plain, JSON-serialisable subscription you
|
|
5
|
-
* hand to a Lunora mutation calling `ctx.push.register({ subscription, userId })`.
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* import { subscribeToPush } from "@lunora/notify/web";
|
|
9
|
-
*
|
|
10
|
-
* const subscription = await subscribeToPush({ serviceWorkerUrl: "/sw.js", vapidPublicKey });
|
|
11
|
-
* await client.mutation("registerDevice", { subscription });
|
|
12
|
-
* ```
|
|
13
|
-
* @packageDocumentation
|
|
14
|
-
*/
|
|
15
|
-
/** A plain, JSON-serialisable Web Push subscription (the shape `ctx.push.register` accepts). */
|
|
16
1
|
interface SerializedPushSubscription {
|
|
17
2
|
endpoint: string;
|
|
18
3
|
expirationTime: number | null;
|
package/dist/web.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const l=r=>{const e=atob(r),s=new Uint8Array(e.length);for(let t=0;t<e.length;t+=1)s[t]=e.codePointAt(t)??0;return s},u=r=>{const e=r.replaceAll("-","+").replaceAll("_","/"),s=e+"=".repeat((4-e.length%4)%4);return l(s)},o=r=>u(r),b=(r,e)=>r.length===e.length&&r.every((s,t)=>s===e[t]),g=(r,e)=>{const s=r.options.applicationServerKey;return s===null?!1:b(new Uint8Array(s),o(e))},n=globalThis,a=()=>n.navigator?.serviceWorker!==void 0&&n.PushManager!==void 0,d=async r=>{if(!a())throw new Error("@lunora/notify: Web Push is not supported in this browser (needs service workers + PushManager)");let e;if(r.serviceWorkerUrl===void 0)e=await navigator.serviceWorker.ready;else{const c=r.scope===void 0?void 0:{scope:r.scope};e=await navigator.serviceWorker.register(r.serviceWorkerUrl,c)}const s=await Notification.requestPermission();if(s!=="granted")throw new Error(`@lunora/notify: notification permission was not granted (got "${s}")`);const t=await e.pushManager.getSubscription();let i=null;return t!==null&&(g(t,r.vapidPublicKey)?i=t:await t.unsubscribe()),(i??await e.pushManager.subscribe({applicationServerKey:o(r.vapidPublicKey),userVisibleOnly:!0})).toJSON()},v=async()=>{if(!a())return!1;const e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();return e===null?!1:e.unsubscribe()};export{a as isPushSupported,d as subscribeToPush,v as unsubscribeFromPush};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/notify",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.26",
|
|
4
4
|
"description": "Multi-channel notifications for Lunora — ctx.notify / ctx.push over @visulima/notification: edge-safe Web Push + FCM, plus chat, in-app inbox and webhook channels, with subscription storage and queue-backed fan-out",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
52
|
+
"@lunora/errors": "1.0.0-alpha.24",
|
|
53
53
|
"@visulima/notification": "1.0.12"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|