@burdenoff/fe-libs 2026.1012.3 → 2026.1012.5

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.
@@ -10,6 +10,7 @@ export interface PushOptInDeps {
10
10
  isRealNativePlatform: () => boolean;
11
11
  isWebPushSupported: () => boolean;
12
12
  getWebPushSubscription: () => Promise<unknown>;
13
+ checkNativePermission: () => Promise<string | null>;
13
14
  requestNativePermission: () => Promise<boolean>;
14
15
  requestWebPermission: () => Promise<unknown>;
15
16
  unsubscribeWeb: () => Promise<boolean>;
@@ -1,62 +1,63 @@
1
1
  import { unregisterPushDevice as e } from "../shared/native/push-registration.js";
2
2
  import { registerPushOptInController as t } from "../shared/native/push-optin.js";
3
3
  import { isRealNativePlatform as n } from "./platform.js";
4
- import { requestPushPermission as r } from "./push.js";
5
- import { getWebPushSubscription as i, isWebPushSupported as a, requestWebPushPermission as o, unsubscribeWebPush as s } from "./web-push.js";
4
+ import { checkPushPermission as r, requestPushPermission as i } from "./push.js";
5
+ import { getWebPushSubscription as a, isWebPushSupported as o, requestWebPushPermission as s, unsubscribeWebPush as c } from "./web-push.js";
6
6
  //#region src/shell-native/push-optin.ts
7
- var c = /* @__PURE__ */ new Set(), l = "unsupported";
8
- function u(e) {
9
- l = e;
10
- for (let t of c) try {
7
+ var l = /* @__PURE__ */ new Set(), u = "unsupported";
8
+ function d(e) {
9
+ u = e;
10
+ for (let t of l) try {
11
11
  t(e);
12
12
  } catch {}
13
13
  }
14
- function d() {
14
+ function f() {
15
15
  return typeof Notification > "u" ? null : Notification.permission;
16
16
  }
17
- async function f() {
18
- if (h.isRealNativePlatform()) {
19
- let e = d();
17
+ async function p() {
18
+ if (g.isRealNativePlatform()) {
19
+ let e = await g.checkNativePermission();
20
20
  return e === "denied" ? "denied" : e === "granted" ? "enabled" : "default";
21
21
  }
22
- if (!h.isWebPushSupported()) return "unsupported";
23
- let e = d();
24
- return e === "denied" ? "denied" : e === "granted" ? await h.getWebPushSubscription() ? "enabled" : "disabled" : "default";
22
+ if (!g.isWebPushSupported()) return "unsupported";
23
+ let e = f();
24
+ return e === "denied" ? "denied" : e === "granted" ? await g.getWebPushSubscription() ? "enabled" : "disabled" : "default";
25
25
  }
26
- async function p() {
27
- let e = await f();
28
- return u(e), e;
26
+ async function m() {
27
+ let e = await p();
28
+ return d(e), e;
29
29
  }
30
- var m = {
30
+ var h = {
31
31
  isRealNativePlatform: n,
32
- isWebPushSupported: a,
33
- getWebPushSubscription: i,
34
- requestNativePermission: r,
35
- requestWebPermission: o,
36
- unsubscribeWeb: s,
32
+ isWebPushSupported: o,
33
+ getWebPushSubscription: a,
34
+ checkNativePermission: r,
35
+ requestNativePermission: i,
36
+ requestWebPermission: s,
37
+ unsubscribeWeb: c,
37
38
  unregisterDevice: e
38
- }, h = m, g = {
39
- getState: () => l,
39
+ }, g = h, _ = {
40
+ getState: () => u,
40
41
  async enable() {
41
- return h.isRealNativePlatform() ? await h.requestNativePermission() : await h.requestWebPermission(), p();
42
+ return g.isRealNativePlatform() ? await g.requestNativePermission() : await g.requestWebPermission(), m();
42
43
  },
43
44
  async disable() {
44
- return h.isRealNativePlatform() || await h.unsubscribeWeb(), await h.unregisterDevice(), p();
45
+ return g.isRealNativePlatform() || await g.unsubscribeWeb(), await g.unregisterDevice(), m();
45
46
  },
46
47
  subscribe(e) {
47
- return c.add(e), () => c.delete(e);
48
+ return l.add(e), () => l.delete(e);
48
49
  }
49
50
  };
50
- function _(e) {
51
- h = e ? {
52
- ...m,
51
+ function v(e) {
52
+ g = e ? {
53
+ ...h,
53
54
  ...e
54
- } : m, t(g), p(), typeof window < "u" && window.addEventListener("burdenoff:pushToken", () => {
55
- p();
55
+ } : h, t(_), m(), typeof window < "u" && window.addEventListener("burdenoff:pushToken", () => {
56
+ m();
56
57
  });
57
58
  }
58
- function v() {
59
- c.clear(), l = "unsupported", h = m, t(null);
59
+ function y() {
60
+ l.clear(), u = "unsupported", g = h, t(null);
60
61
  }
61
62
  //#endregion
62
- export { _ as installPushOptIn, v as resetPushOptInForTests };
63
+ export { v as installPushOptIn, y as resetPushOptInForTests };
@@ -1,5 +1,5 @@
1
1
  import { PushTokenEventDetail } from '../shared/native/types';
2
- import { PushNotificationsLoader, PushOptions } from './types';
2
+ import { PushNotificationsLoader, PushOptions, PushPermissionStateLike } from './types';
3
3
  export declare const PUSH_TOKEN_EVENT = "burdenoff:pushToken";
4
4
  /**
5
5
  * Publish a push token to the rest of the app: `window.__burdenoffPushToken`
@@ -16,6 +16,16 @@ export declare function emitPushToken(value: string, platform: PushTokenEventDet
16
16
  * Does NOT prompt for permission — call `requestPushPermission()` for that.
17
17
  */
18
18
  export declare function installPushNotifications(loader: PushNotificationsLoader, options?: Pick<PushOptions, 'onToken' | 'onNotificationAction' | 'onNotificationReceived'>): Promise<void>;
19
+ /**
20
+ * Read current native permission state WITHOUT prompting.
21
+ *
22
+ * `push-optin.ts` needs this to answer "is push on?" for a real native
23
+ * platform — the Web `Notification` API (`push-optin.ts`'s `browserPermission()`)
24
+ * is a browser/PWA concept and reads as unset inside a Capacitor WKWebView, so
25
+ * using it there always reported `default` even after the user granted the
26
+ * native OS permission prompt, leaving the toggle stuck off.
27
+ */
28
+ export declare function checkPushPermission(): Promise<PushPermissionStateLike | null>;
19
29
  /**
20
30
  * Ask the user for push permission (call from an in-context UI affordance,
21
31
  * never at boot) and register for a token on grant.
@@ -42,12 +42,14 @@ async function l(t, r = {}) {
42
42
  let u = e();
43
43
  if (u !== "web") try {
44
44
  if (await l.addListener("tokenReceived", (e) => {
45
- i(e.token, u), r.onToken?.(e.token, u);
45
+ let t = e;
46
+ i(t.token, u), r.onToken?.(t.token, u);
46
47
  }), await l.addListener("notificationReceived", (e) => {
47
- r.onNotificationReceived?.(e.notification);
48
+ let t = e;
49
+ r.onNotificationReceived?.(t.notification);
48
50
  }), await l.addListener("notificationActionPerformed", (e) => {
49
- let t = c(e);
50
- t && n(t), r.onNotificationAction?.(e);
51
+ let t = e, i = c(t);
52
+ i && n(i), r.onNotificationAction?.(t);
51
53
  }), (await l.checkPermissions()).receive === "granted") {
52
54
  let { token: e } = await l.getToken();
53
55
  i(e, u), r.onToken?.(e, u);
@@ -55,6 +57,15 @@ async function l(t, r = {}) {
55
57
  } catch {}
56
58
  }
57
59
  async function u() {
60
+ let e = await s();
61
+ if (!e) return null;
62
+ try {
63
+ return (await e.checkPermissions()).receive;
64
+ } catch {
65
+ return null;
66
+ }
67
+ }
68
+ async function d() {
58
69
  let t = await s();
59
70
  if (!t) return !1;
60
71
  try {
@@ -67,4 +78,4 @@ async function u() {
67
78
  }
68
79
  }
69
80
  //#endregion
70
- export { r as PUSH_TOKEN_EVENT, i as emitPushToken, l as installPushNotifications, u as requestPushPermission };
81
+ export { r as PUSH_TOKEN_EVENT, u as checkPushPermission, i as emitPushToken, l as installPushNotifications, d as requestPushPermission };
@@ -194,11 +194,7 @@ export interface PushNotificationsLike {
194
194
  getToken(): Promise<{
195
195
  token: string;
196
196
  }>;
197
- addListener(eventName: 'tokenReceived', listener: (token: PushTokenLike) => void): Promise<CapacitorListenerHandleLike>;
198
- addListener(eventName: 'notificationReceived', listener: (event: {
199
- notification: PushNotificationSchemaLike;
200
- }) => void): Promise<CapacitorListenerHandleLike>;
201
- addListener(eventName: 'notificationActionPerformed', listener: (action: PushActionPerformedLike) => void): Promise<CapacitorListenerHandleLike>;
197
+ addListener(eventName: 'tokenReceived' | 'notificationReceived' | 'notificationActionPerformed', listener: (payload: unknown) => void): Promise<CapacitorListenerHandleLike>;
202
198
  }
203
199
  export type UpdaterLoader = () => Promise<{
204
200
  CapacitorUpdater: CapacitorUpdaterLike;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/fe-libs",
3
- "version": "2026.1012.3",
3
+ "version": "2026.1012.5",
4
4
  "description": "Burdenoff frontend primitives and domain libraries",
5
5
  "type": "module",
6
6
  "bin": {