@mentra/miniapp 0.3.0-dev.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/README.md +259 -0
- package/dist/background/index.d.ts +59 -0
- package/dist/background/index.d.ts.map +1 -0
- package/dist/background/index.js +25 -0
- package/dist/background/index.js.map +1 -0
- package/dist/background/register.d.ts +38 -0
- package/dist/background/register.d.ts.map +1 -0
- package/dist/background/register.js +75 -0
- package/dist/background/register.js.map +1 -0
- package/dist/dev-reload.d.ts +21 -0
- package/dist/dev-reload.d.ts.map +1 -0
- package/dist/dev-reload.js +62 -0
- package/dist/dev-reload.js.map +1 -0
- package/dist/envelope.d.ts +23 -0
- package/dist/envelope.d.ts.map +1 -0
- package/dist/envelope.js +47 -0
- package/dist/envelope.js.map +1 -0
- package/dist/globals.d.ts +54 -0
- package/dist/globals.d.ts.map +1 -0
- package/dist/globals.js +12 -0
- package/dist/globals.js.map +1 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/actions.d.ts +54 -0
- package/dist/modules/actions.d.ts.map +1 -0
- package/dist/modules/actions.js +122 -0
- package/dist/modules/actions.js.map +1 -0
- package/dist/modules/auth.d.ts +25 -0
- package/dist/modules/auth.d.ts.map +1 -0
- package/dist/modules/auth.js +52 -0
- package/dist/modules/auth.js.map +1 -0
- package/dist/modules/base64.d.ts +16 -0
- package/dist/modules/base64.d.ts.map +1 -0
- package/dist/modules/base64.js +92 -0
- package/dist/modules/base64.js.map +1 -0
- package/dist/modules/blob.d.ts +161 -0
- package/dist/modules/blob.d.ts.map +1 -0
- package/dist/modules/blob.js +277 -0
- package/dist/modules/blob.js.map +1 -0
- package/dist/modules/camera.d.ts +137 -0
- package/dist/modules/camera.d.ts.map +1 -0
- package/dist/modules/camera.js +104 -0
- package/dist/modules/camera.js.map +1 -0
- package/dist/modules/cloud.d.ts +34 -0
- package/dist/modules/cloud.d.ts.map +1 -0
- package/dist/modules/cloud.js +70 -0
- package/dist/modules/cloud.js.map +1 -0
- package/dist/modules/dashboard.d.ts +16 -0
- package/dist/modules/dashboard.d.ts.map +1 -0
- package/dist/modules/dashboard.js +27 -0
- package/dist/modules/dashboard.js.map +1 -0
- package/dist/modules/display.d.ts +106 -0
- package/dist/modules/display.d.ts.map +1 -0
- package/dist/modules/display.js +57 -0
- package/dist/modules/display.js.map +1 -0
- package/dist/modules/events.d.ts +167 -0
- package/dist/modules/events.d.ts.map +1 -0
- package/dist/modules/events.js +123 -0
- package/dist/modules/events.js.map +1 -0
- package/dist/modules/glasses.d.ts +28 -0
- package/dist/modules/glasses.d.ts.map +1 -0
- package/dist/modules/glasses.js +39 -0
- package/dist/modules/glasses.js.map +1 -0
- package/dist/modules/heading.d.ts +16 -0
- package/dist/modules/heading.d.ts.map +1 -0
- package/dist/modules/heading.js +20 -0
- package/dist/modules/heading.js.map +1 -0
- package/dist/modules/imu.d.ts +31 -0
- package/dist/modules/imu.d.ts.map +1 -0
- package/dist/modules/imu.js +40 -0
- package/dist/modules/imu.js.map +1 -0
- package/dist/modules/input.d.ts +34 -0
- package/dist/modules/input.d.ts.map +1 -0
- package/dist/modules/input.js +50 -0
- package/dist/modules/input.js.map +1 -0
- package/dist/modules/led.d.ts +35 -0
- package/dist/modules/led.d.ts.map +1 -0
- package/dist/modules/led.js +39 -0
- package/dist/modules/led.js.map +1 -0
- package/dist/modules/location.d.ts +27 -0
- package/dist/modules/location.d.ts.map +1 -0
- package/dist/modules/location.js +35 -0
- package/dist/modules/location.js.map +1 -0
- package/dist/modules/mic.d.ts +44 -0
- package/dist/modules/mic.d.ts.map +1 -0
- package/dist/modules/mic.js +67 -0
- package/dist/modules/mic.js.map +1 -0
- package/dist/modules/miniapps.d.ts +72 -0
- package/dist/modules/miniapps.d.ts.map +1 -0
- package/dist/modules/miniapps.js +48 -0
- package/dist/modules/miniapps.js.map +1 -0
- package/dist/modules/navigation.d.ts +326 -0
- package/dist/modules/navigation.d.ts.map +1 -0
- package/dist/modules/navigation.js +386 -0
- package/dist/modules/navigation.js.map +1 -0
- package/dist/modules/permissions.d.ts +58 -0
- package/dist/modules/permissions.d.ts.map +1 -0
- package/dist/modules/permissions.js +66 -0
- package/dist/modules/permissions.js.map +1 -0
- package/dist/modules/phone.d.ts +61 -0
- package/dist/modules/phone.d.ts.map +1 -0
- package/dist/modules/phone.js +94 -0
- package/dist/modules/phone.js.map +1 -0
- package/dist/modules/pivots/engine.d.ts +169 -0
- package/dist/modules/pivots/engine.d.ts.map +1 -0
- package/dist/modules/pivots/engine.js +779 -0
- package/dist/modules/pivots/engine.js.map +1 -0
- package/dist/modules/pivots/geometry.d.ts +84 -0
- package/dist/modules/pivots/geometry.d.ts.map +1 -0
- package/dist/modules/pivots/geometry.js +371 -0
- package/dist/modules/pivots/geometry.js.map +1 -0
- package/dist/modules/pivots/instructions.d.ts +139 -0
- package/dist/modules/pivots/instructions.d.ts.map +1 -0
- package/dist/modules/pivots/instructions.js +280 -0
- package/dist/modules/pivots/instructions.js.map +1 -0
- package/dist/modules/speaker.d.ts +163 -0
- package/dist/modules/speaker.d.ts.map +1 -0
- package/dist/modules/speaker.js +250 -0
- package/dist/modules/speaker.js.map +1 -0
- package/dist/modules/storage.d.ts +50 -0
- package/dist/modules/storage.d.ts.map +1 -0
- package/dist/modules/storage.js +99 -0
- package/dist/modules/storage.js.map +1 -0
- package/dist/modules/stream.d.ts +129 -0
- package/dist/modules/stream.d.ts.map +1 -0
- package/dist/modules/stream.js +52 -0
- package/dist/modules/stream.js.map +1 -0
- package/dist/modules/system.d.ts +45 -0
- package/dist/modules/system.d.ts.map +1 -0
- package/dist/modules/system.js +42 -0
- package/dist/modules/system.js.map +1 -0
- package/dist/modules/transcription.d.ts +67 -0
- package/dist/modules/transcription.d.ts.map +1 -0
- package/dist/modules/transcription.js +106 -0
- package/dist/modules/transcription.js.map +1 -0
- package/dist/modules/translation.d.ts +59 -0
- package/dist/modules/translation.d.ts.map +1 -0
- package/dist/modules/translation.js +119 -0
- package/dist/modules/translation.js.map +1 -0
- package/dist/modules/ui.d.ts +186 -0
- package/dist/modules/ui.d.ts.map +1 -0
- package/dist/modules/ui.js +293 -0
- package/dist/modules/ui.js.map +1 -0
- package/dist/protocol.d.ts +294 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +320 -0
- package/dist/protocol.js.map +1 -0
- package/dist/react/MentraProvider.d.ts +33 -0
- package/dist/react/MentraProvider.d.ts.map +1 -0
- package/dist/react/MentraProvider.js +15 -0
- package/dist/react/MentraProvider.js.map +1 -0
- package/dist/react/MiniappHeader.d.ts +44 -0
- package/dist/react/MiniappHeader.d.ts.map +1 -0
- package/dist/react/MiniappHeader.js +32 -0
- package/dist/react/MiniappHeader.js.map +1 -0
- package/dist/react/index.d.ts +13 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +9 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/useCapabilities.d.ts +26 -0
- package/dist/react/useCapabilities.d.ts.map +1 -0
- package/dist/react/useCapabilities.js +27 -0
- package/dist/react/useCapabilities.js.map +1 -0
- package/dist/react/useCapsuleHeaderStyle.d.ts +27 -0
- package/dist/react/useCapsuleHeaderStyle.d.ts.map +1 -0
- package/dist/react/useCapsuleHeaderStyle.js +36 -0
- package/dist/react/useCapsuleHeaderStyle.js.map +1 -0
- package/dist/react/useColorScheme.d.ts +18 -0
- package/dist/react/useColorScheme.d.ts.map +1 -0
- package/dist/react/useColorScheme.js +24 -0
- package/dist/react/useColorScheme.js.map +1 -0
- package/dist/react/useConnected.d.ts +17 -0
- package/dist/react/useConnected.d.ts.map +1 -0
- package/dist/react/useConnected.js +39 -0
- package/dist/react/useConnected.js.map +1 -0
- package/dist/react/useRpc.d.ts +29 -0
- package/dist/react/useRpc.d.ts.map +1 -0
- package/dist/react/useRpc.js +82 -0
- package/dist/react/useRpc.js.map +1 -0
- package/dist/react/useSafeArea.d.ts +21 -0
- package/dist/react/useSafeArea.d.ts.map +1 -0
- package/dist/react/useSafeArea.js +22 -0
- package/dist/react/useSafeArea.js.map +1 -0
- package/dist/session.d.ts +310 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +653 -0
- package/dist/session.js.map +1 -0
- package/dist/sub-path-types.test-d.d.ts +28 -0
- package/dist/sub-path-types.test-d.d.ts.map +1 -0
- package/dist/sub-path-types.test-d.js +37 -0
- package/dist/sub-path-types.test-d.js.map +1 -0
- package/dist/transport/auto.d.ts +35 -0
- package/dist/transport/auto.d.ts.map +1 -0
- package/dist/transport/auto.js +125 -0
- package/dist/transport/auto.js.map +1 -0
- package/dist/transport/dispatch.d.ts +43 -0
- package/dist/transport/dispatch.d.ts.map +1 -0
- package/dist/transport/dispatch.js +91 -0
- package/dist/transport/dispatch.js.map +1 -0
- package/dist/transport/local-socket.d.ts +28 -0
- package/dist/transport/local-socket.d.ts.map +1 -0
- package/dist/transport/local-socket.js +80 -0
- package/dist/transport/local-socket.js.map +1 -0
- package/dist/transport/mock.d.ts +54 -0
- package/dist/transport/mock.d.ts.map +1 -0
- package/dist/transport/mock.js +205 -0
- package/dist/transport/mock.js.map +1 -0
- package/dist/transport/postmessage.d.ts +36 -0
- package/dist/transport/postmessage.d.ts.map +1 -0
- package/dist/transport/postmessage.js +78 -0
- package/dist/transport/postmessage.js.map +1 -0
- package/dist/transport/types.d.ts +25 -0
- package/dist/transport/types.d.ts.map +1 -0
- package/dist/transport/types.js +11 -0
- package/dist/transport/types.js.map +1 -0
- package/dist/ui/index.d.ts +98 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +32 -0
- package/dist/ui/index.js.map +1 -0
- package/package.json +75 -0
- package/src/background/index.ts +152 -0
- package/src/background/register.ts +85 -0
- package/src/dev-reload.ts +60 -0
- package/src/envelope.ts +54 -0
- package/src/globals.ts +62 -0
- package/src/index.ts +171 -0
- package/src/modules/actions.ts +156 -0
- package/src/modules/auth.ts +68 -0
- package/src/modules/base64.ts +87 -0
- package/src/modules/blob.ts +341 -0
- package/src/modules/camera.ts +196 -0
- package/src/modules/cloud.ts +94 -0
- package/src/modules/dashboard.ts +31 -0
- package/src/modules/display.ts +122 -0
- package/src/modules/events.ts +264 -0
- package/src/modules/glasses.ts +44 -0
- package/src/modules/heading.ts +23 -0
- package/src/modules/imu.ts +44 -0
- package/src/modules/input.ts +71 -0
- package/src/modules/led.ts +61 -0
- package/src/modules/location.ts +39 -0
- package/src/modules/mic.ts +74 -0
- package/src/modules/miniapps.ts +90 -0
- package/src/modules/navigation.ts +670 -0
- package/src/modules/permissions.ts +84 -0
- package/src/modules/phone.ts +120 -0
- package/src/modules/pivots/engine.ts +863 -0
- package/src/modules/pivots/geometry.ts +409 -0
- package/src/modules/pivots/instructions.ts +343 -0
- package/src/modules/speaker.ts +328 -0
- package/src/modules/storage.ts +109 -0
- package/src/modules/stream.ts +163 -0
- package/src/modules/system.ts +76 -0
- package/src/modules/transcription.ts +128 -0
- package/src/modules/translation.ts +149 -0
- package/src/modules/ui.ts +498 -0
- package/src/protocol.ts +371 -0
- package/src/react/MentraProvider.tsx +50 -0
- package/src/react/MiniappHeader.tsx +122 -0
- package/src/react/index.ts +12 -0
- package/src/react/useCapabilities.ts +29 -0
- package/src/react/useCapsuleHeaderStyle.ts +54 -0
- package/src/react/useColorScheme.ts +26 -0
- package/src/react/useConnected.ts +47 -0
- package/src/react/useRpc.ts +106 -0
- package/src/react/useSafeArea.ts +40 -0
- package/src/session.ts +878 -0
- package/src/sub-path-types.test-d.ts +49 -0
- package/src/transport/auto.ts +143 -0
- package/src/transport/dispatch.ts +106 -0
- package/src/transport/local-socket.ts +93 -0
- package/src/transport/mock.ts +248 -0
- package/src/transport/postmessage.ts +95 -0
- package/src/transport/types.ts +26 -0
- package/src/ui/index.ts +122 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview PermissionsModule — manifest-declared permission introspection.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors cloud SDK v3's PermissionsManager surface and semantics:
|
|
5
|
+
* permissions.has(type) — synchronous boolean
|
|
6
|
+
* permissions.getAll() — full PermissionRecord
|
|
7
|
+
* permissions.onUpdate(handler) — fires on cache change
|
|
8
|
+
* permissions.onPermissionError(handler) — typed handler for the existing
|
|
9
|
+
* PERMISSION_NOT_DECLARED error
|
|
10
|
+
*
|
|
11
|
+
* What "permission" means here. Same as v3: this module tracks
|
|
12
|
+
* **manifest-declared** permissions. `permissions.has("microphone") === true`
|
|
13
|
+
* means the miniapp's manifest.json declared MICROPHONE — it does NOT mean
|
|
14
|
+
* the user actually granted the OS permission. To detect OS-grant state,
|
|
15
|
+
* observe whether your subscriptions actually deliver events.
|
|
16
|
+
*
|
|
17
|
+
* OS-level grant state and `request(...)` are deferred to a future round.
|
|
18
|
+
* Their additions will land additively on this same module — `isGranted(...)`
|
|
19
|
+
* / `request(...)` alongside the existing `has(...)` / `getAll(...)` —
|
|
20
|
+
* without renaming today's surface.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import {MiniappErrorCode} from "../protocol"
|
|
24
|
+
import type {MiniappRequestError} from "../session"
|
|
25
|
+
import {MiniappSession} from "../session"
|
|
26
|
+
import type {PermissionRecord, PermissionType} from "../session"
|
|
27
|
+
import type {UnsubscribeFn} from "./events"
|
|
28
|
+
|
|
29
|
+
export interface PermissionErrorEvent {
|
|
30
|
+
/** The error code. Always PERMISSION_NOT_DECLARED today; reserved for future codes. */
|
|
31
|
+
code: string
|
|
32
|
+
message: string
|
|
33
|
+
/** The manifest permission name (UPPER_CASE) that was missing. */
|
|
34
|
+
permission?: string
|
|
35
|
+
/** The subscription / operation that triggered the rejection. */
|
|
36
|
+
subscription?: string
|
|
37
|
+
operation?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export class PermissionsModule {
|
|
41
|
+
/** Local handlers for onUpdate. Session emitter handles the fan-out. */
|
|
42
|
+
constructor(private readonly session: MiniappSession) {}
|
|
43
|
+
|
|
44
|
+
/** True iff the named permission is declared in the miniapp's manifest. */
|
|
45
|
+
has(type: PermissionType): boolean {
|
|
46
|
+
return this.session._getPermissions()[type] === true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Full record of declared permissions. Fresh shallow copy. */
|
|
50
|
+
getAll(): PermissionRecord {
|
|
51
|
+
return this.session._getPermissions()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Subscribe to declared-permission updates. Fires when the cached record
|
|
56
|
+
* changes — usually on CONNECT_ACK, or when the phone pushes a
|
|
57
|
+
* PERMISSIONS_UPDATE (e.g. dev miniapp re-scanned with updated manifest).
|
|
58
|
+
*
|
|
59
|
+
* Does NOT fire immediately with the current value — call getAll()
|
|
60
|
+
* separately if you want the seed.
|
|
61
|
+
*/
|
|
62
|
+
onUpdate(handler: (perms: PermissionRecord) => void): UnsubscribeFn {
|
|
63
|
+
return this.session.on("permissions", handler)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Subscribe to typed PERMISSION_NOT_DECLARED errors. Sugar over the
|
|
68
|
+
* existing session "error" event, filtered to the permission-error code.
|
|
69
|
+
*/
|
|
70
|
+
onPermissionError(handler: (err: PermissionErrorEvent) => void): UnsubscribeFn {
|
|
71
|
+
return this.session.on("error", (e) => {
|
|
72
|
+
const maybe = e as Error & Partial<MiniappRequestError> & Record<string, unknown>
|
|
73
|
+
if (maybe?.code === MiniappErrorCode.PERMISSION_NOT_DECLARED) {
|
|
74
|
+
handler({
|
|
75
|
+
code: String(maybe.code),
|
|
76
|
+
message: String(maybe.message ?? ""),
|
|
77
|
+
permission: maybe.permission as string | undefined,
|
|
78
|
+
subscription: maybe.subscription as string | undefined,
|
|
79
|
+
operation: maybe.operation as string | undefined,
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview PhoneModule — phone device-state events.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors cloud SDK v3's PhoneManager structure. Sub-namespaced by concern:
|
|
5
|
+
*
|
|
6
|
+
* session.phone.notifications.{on, hasPermission, stop}
|
|
7
|
+
* session.phone.calendar.{on, hasPermission, stop}
|
|
8
|
+
* session.phone.onBattery(...) // stays flat
|
|
9
|
+
*
|
|
10
|
+
* Imperative phone-OS calls (share, openUrl, copyToClipboard, download) live
|
|
11
|
+
* on `session.system` — different shape (one-shot calls vs. event subs) so
|
|
12
|
+
* we don't conflate them.
|
|
13
|
+
*
|
|
14
|
+
* `phone.notifications.onDismissed` is Android-only. iOS doesn't expose
|
|
15
|
+
* notification-dismiss callbacks to apps (Apple privacy restriction);
|
|
16
|
+
* subscribing on iOS is a no-op even though the API is present.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import {MiniappStreamType} from "../protocol"
|
|
20
|
+
import {MiniappSession} from "../session"
|
|
21
|
+
import type {
|
|
22
|
+
BatteryData,
|
|
23
|
+
CalendarEventData,
|
|
24
|
+
NotificationDismissedData,
|
|
25
|
+
PhoneNotificationData,
|
|
26
|
+
UnsubscribeFn,
|
|
27
|
+
} from "./events"
|
|
28
|
+
|
|
29
|
+
class TrackedSubs {
|
|
30
|
+
private readonly unsubs = new Set<UnsubscribeFn>()
|
|
31
|
+
|
|
32
|
+
protected track(unsub: UnsubscribeFn): UnsubscribeFn {
|
|
33
|
+
this.unsubs.add(unsub)
|
|
34
|
+
return () => {
|
|
35
|
+
this.unsubs.delete(unsub)
|
|
36
|
+
unsub()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
stop(): void {
|
|
41
|
+
for (const u of this.unsubs) {
|
|
42
|
+
try {
|
|
43
|
+
u()
|
|
44
|
+
} catch {
|
|
45
|
+
/* ignore */
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
this.unsubs.clear()
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class PhoneNotificationsModule extends TrackedSubs {
|
|
53
|
+
constructor(private readonly session: MiniappSession) {
|
|
54
|
+
super()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
on(handler: (data: PhoneNotificationData) => void): UnsubscribeFn {
|
|
58
|
+
return this.track(
|
|
59
|
+
this.session._subscribe(MiniappStreamType.PHONE_NOTIFICATION, handler as (data: unknown) => void),
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Subscribe to dismiss events for phone notifications. Fires when the user
|
|
65
|
+
* dismisses (swipes away or clears) a notification.
|
|
66
|
+
*
|
|
67
|
+
* **Android only.** iOS does not expose dismiss callbacks to apps (Apple
|
|
68
|
+
* privacy restriction); subscribing on iOS succeeds but no events ever
|
|
69
|
+
* fire. The matching `notifications.on()` post-event still works on both
|
|
70
|
+
* platforms.
|
|
71
|
+
*/
|
|
72
|
+
onDismissed(handler: (data: NotificationDismissedData) => void): UnsubscribeFn {
|
|
73
|
+
return this.track(
|
|
74
|
+
this.session._subscribe(
|
|
75
|
+
MiniappStreamType.PHONE_NOTIFICATION_DISMISSED,
|
|
76
|
+
handler as (data: unknown) => void,
|
|
77
|
+
),
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** True iff `READ_NOTIFICATIONS` is declared in the miniapp's manifest. */
|
|
82
|
+
get hasPermission(): boolean {
|
|
83
|
+
return this.session._hasManifestPermission("READ_NOTIFICATIONS")
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export class PhoneCalendarModule extends TrackedSubs {
|
|
88
|
+
constructor(private readonly session: MiniappSession) {
|
|
89
|
+
super()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
on(handler: (data: CalendarEventData) => void): UnsubscribeFn {
|
|
93
|
+
return this.track(
|
|
94
|
+
this.session._subscribe(MiniappStreamType.CALENDAR_EVENT, handler as (data: unknown) => void),
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** True iff `CALENDAR` is declared in the miniapp's manifest. */
|
|
99
|
+
get hasPermission(): boolean {
|
|
100
|
+
return this.session._hasManifestPermission("CALENDAR")
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export class PhoneModule {
|
|
105
|
+
public readonly notifications: PhoneNotificationsModule
|
|
106
|
+
public readonly calendar: PhoneCalendarModule
|
|
107
|
+
|
|
108
|
+
constructor(private readonly session: MiniappSession) {
|
|
109
|
+
this.notifications = new PhoneNotificationsModule(session)
|
|
110
|
+
this.calendar = new PhoneCalendarModule(session)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Phone battery events. Stays flat (not sub-namespaced) — single event,
|
|
115
|
+
* no extra surface.
|
|
116
|
+
*/
|
|
117
|
+
onBattery(handler: (data: BatteryData) => void): UnsubscribeFn {
|
|
118
|
+
return this.session._subscribe(MiniappStreamType.PHONE_BATTERY, handler as (data: unknown) => void)
|
|
119
|
+
}
|
|
120
|
+
}
|