@livx.cc/native-kit 0.21.0 → 0.22.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livx.cc/native-kit",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "Isomorphic native-capabilities kit for PWAs — same API in browser and in an appwrap native shell. Zero dependencies.",
5
5
  "license": "MIT",
6
6
  "author": "Elya Livshitz",
@@ -49,6 +49,7 @@ export class WebAdapter implements NativeKitAdapter {
49
49
  device: 'web',
50
50
  clipboard: navigator.clipboard ? 'web' : 'none',
51
51
  notifications: 'Notification' in window ? 'web' : 'none',
52
+ badge: typeof (navigator as any).setAppBadge === 'function' ? 'web' : 'none', // Badging API (PWA icon badge)
52
53
  biometrics: 'none',
53
54
  geo: 'geolocation' in navigator ? 'web' : 'none',
54
55
  photos: 'web',
@@ -31,6 +31,22 @@ export class AppModule {
31
31
  return this.kit.capability('app');
32
32
  }
33
33
 
34
+ /** 'native' where the OS exposes an app-icon badge (iOS always; Android launcher-dependent →
35
+ * honest no-op) · 'web' where the Badging API exists · else 'none'. Branch on this, not try/catch. */
36
+ get badgeCapability() {
37
+ return this.kit.capability('badge');
38
+ }
39
+
40
+ /**
41
+ * Set (or clear, with `0`) the app-icon badge count — the small number on the home-screen icon.
42
+ * Convenience over the shared native badge path: iOS sets the springboard badge; Android is an
43
+ * honest no-op (launchers own badges); web uses the Badging API where present.
44
+ * Branch on {@link badgeCapability}.
45
+ */
46
+ badge(count: number): Promise<void> {
47
+ return this.kit.invoke('notifications.setBadge', { count });
48
+ }
49
+
34
50
  /** Install-level environment facts for analytics/identification (source, install id, timestamps). */
35
51
  environment(): Promise<AppEnvironment> {
36
52
  return this.kit.invoke('app.environment');