@pmate/bridge 0.1.3 → 0.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/bridge",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "files": [
5
5
  "src",
6
6
  "global.d.ts"
package/src/index.ts CHANGED
@@ -6,6 +6,8 @@ export {
6
6
  disconnectBluetoothDevice,
7
7
  getBluetoothCapabilities,
8
8
  getConnectedBluetoothDevices,
9
+ getNotificationStatus,
10
+ getPushToken,
9
11
  onBluetoothEvent,
10
12
  readBluetooth,
11
13
  requestBluetoothPermission,
package/src/internal.ts CHANGED
@@ -12,8 +12,11 @@ import type {
12
12
  BluetoothSubscribeOptions,
13
13
  BluetoothWriteOptions,
14
14
  DeviceInfo,
15
+ NotificationStatus,
15
16
  PermissionResult,
16
17
  PickedFile,
18
+ PushTokenInfo,
19
+ PushTokenOptions,
17
20
  SafeInsets,
18
21
  } from "./types"
19
22
 
@@ -90,10 +93,28 @@ export async function requestPermissionsBridge(
90
93
  result ?? {
91
94
  requested: permissions,
92
95
  granted: false,
96
+ state: "unsupported",
93
97
  }
94
98
  )
95
99
  }
96
100
 
101
+ export async function getNotificationStatus(): Promise<NotificationStatus> {
102
+ const status = await callBridge<NotificationStatus>("notification.getStatus")
103
+ return (
104
+ status ?? {
105
+ supported: false,
106
+ permission: "unsupported",
107
+ providers: [],
108
+ }
109
+ )
110
+ }
111
+
112
+ export async function getPushToken(
113
+ options?: PushTokenOptions
114
+ ): Promise<PushTokenInfo | undefined> {
115
+ return callBridge<PushTokenInfo>("notification.getPushToken", options ?? null)
116
+ }
117
+
97
118
  export async function pickFileBridge(): Promise<PickedFile[]> {
98
119
  const files = await callBridge<PickedFile[]>("pickFile")
99
120
  return files ?? []
package/src/types.ts CHANGED
@@ -32,6 +32,33 @@ export interface PickedFile {
32
32
  export interface PermissionResult {
33
33
  requested: unknown
34
34
  granted: boolean
35
+ state?: PermissionState
36
+ }
37
+
38
+ export type PermissionState = "granted" | "denied" | "notDetermined" | "unsupported"
39
+ export type NotificationPermissionState = PermissionState
40
+ export type PushProvider = "apns" | "xiaomi"
41
+
42
+ export interface NotificationStatus {
43
+ supported: boolean
44
+ permission: NotificationPermissionState
45
+ providers: PushProvider[]
46
+ }
47
+
48
+ export interface PushTokenInfo {
49
+ platform: "ios" | "android"
50
+ provider: PushProvider
51
+ token: string
52
+ environment?: "sandbox" | "production"
53
+ region?: string
54
+ bundleId?: string
55
+ packageName?: string
56
+ permission: NotificationPermissionState
57
+ vendor?: Record<string, unknown>
58
+ }
59
+
60
+ export interface PushTokenOptions {
61
+ providers?: PushProvider[]
35
62
  }
36
63
 
37
64
  export type BluetoothTransport = "ble" | "classic"
@@ -82,7 +109,7 @@ export interface BluetoothScanOptions {
82
109
 
83
110
  export interface BluetoothScanResult {
84
111
  scanId: string
85
- devices: BluetoothDevice[]
112
+ devices?: BluetoothDevice[]
86
113
  active: boolean
87
114
  }
88
115