@lunora/notify 1.0.0-alpha.25 → 1.0.0-alpha.27

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 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 a=e=>{const r="=".repeat((4-e.length%4)%4),i=(e+r).replaceAll("-","+").replaceAll("_","/"),t=atob(i),s=new Uint8Array(t.length);for(let n=0;n<t.length;n+=1)s[n]=t.codePointAt(n)??0;return s},l=(e,r)=>e.length===r.length&&e.every((i,t)=>i===r[t]),g=(e,r)=>{const i=e.options.applicationServerKey;return i===null?!1:l(new Uint8Array(i),a(r))},o=globalThis,c=()=>o.navigator?.serviceWorker!==void 0&&o.PushManager!==void 0,p=async e=>{if(!c())throw new Error("@lunora/notify: Web Push is not supported in this browser (needs service workers + PushManager)");let r;if(e.serviceWorkerUrl===void 0)r=await navigator.serviceWorker.ready;else{const u=e.scope===void 0?void 0:{scope:e.scope};r=await navigator.serviceWorker.register(e.serviceWorkerUrl,u)}const i=await Notification.requestPermission();if(i!=="granted")throw new Error(`@lunora/notify: notification permission was not granted (got "${i}")`);const t=await r.pushManager.getSubscription();let s=null;return t!==null&&(g(t,e.vapidPublicKey)?s=t:await t.unsubscribe()),(s??await r.pushManager.subscribe({applicationServerKey:a(e.vapidPublicKey),userVisibleOnly:!0})).toJSON()},b=async()=>{if(!c())return!1;const r=await(await navigator.serviceWorker.ready).pushManager.getSubscription();return r===null?!1:r.unsubscribe()};export{c as isPushSupported,p as subscribeToPush,b as unsubscribeFromPush};
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.25",
3
+ "version": "1.0.0-alpha.27",
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.24",
52
+ "@lunora/errors": "1.0.0-alpha.25",
53
53
  "@visulima/notification": "1.0.12"
54
54
  },
55
55
  "engines": {