@glassly/miniapp 0.1.0-dev.26
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 +275 -0
- package/dist/background/index.d.ts +64 -0
- package/dist/background/index.d.ts.map +1 -0
- package/dist/background/index.js +26 -0
- package/dist/background/index.js.map +1 -0
- package/dist/background/register.d.ts +39 -0
- package/dist/background/register.d.ts.map +1 -0
- package/dist/background/register.js +72 -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 +60 -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/hardware.d.ts +24 -0
- package/dist/hardware.d.ts.map +1 -0
- package/dist/hardware.js +20 -0
- package/dist/hardware.js.map +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/actions.d.ts +81 -0
- package/dist/modules/actions.d.ts.map +1 -0
- package/dist/modules/actions.js +137 -0
- package/dist/modules/actions.js.map +1 -0
- package/dist/modules/ai.d.ts +211 -0
- package/dist/modules/ai.d.ts.map +1 -0
- package/dist/modules/ai.js +117 -0
- package/dist/modules/ai.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 +183 -0
- package/dist/modules/camera.d.ts.map +1 -0
- package/dist/modules/camera.js +119 -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 +24 -0
- package/dist/modules/dashboard.d.ts.map +1 -0
- package/dist/modules/dashboard.js +39 -0
- package/dist/modules/dashboard.js.map +1 -0
- package/dist/modules/display.d.ts +174 -0
- package/dist/modules/display.d.ts.map +1 -0
- package/dist/modules/display.js +83 -0
- package/dist/modules/display.js.map +1 -0
- package/dist/modules/events.d.ts +178 -0
- package/dist/modules/events.d.ts.map +1 -0
- package/dist/modules/events.js +168 -0
- package/dist/modules/events.js.map +1 -0
- package/dist/modules/glasses.d.ts +36 -0
- package/dist/modules/glasses.d.ts.map +1 -0
- package/dist/modules/glasses.js +52 -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 +50 -0
- package/dist/modules/input.d.ts.map +1 -0
- package/dist/modules/input.js +70 -0
- package/dist/modules/input.js.map +1 -0
- package/dist/modules/keys.d.ts +30 -0
- package/dist/modules/keys.d.ts.map +1 -0
- package/dist/modules/keys.js +37 -0
- package/dist/modules/keys.js.map +1 -0
- package/dist/modules/languages.d.ts +42 -0
- package/dist/modules/languages.d.ts.map +1 -0
- package/dist/modules/languages.js +57 -0
- package/dist/modules/languages.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/memory.d.ts +126 -0
- package/dist/modules/memory.d.ts.map +1 -0
- package/dist/modules/memory.js +141 -0
- package/dist/modules/memory.js.map +1 -0
- package/dist/modules/mic.d.ts +61 -0
- package/dist/modules/mic.d.ts.map +1 -0
- package/dist/modules/mic.js +94 -0
- package/dist/modules/mic.js.map +1 -0
- package/dist/modules/miniapps.d.ts +82 -0
- package/dist/modules/miniapps.d.ts.map +1 -0
- package/dist/modules/miniapps.js +58 -0
- package/dist/modules/miniapps.js.map +1 -0
- package/dist/modules/navigation.d.ts +332 -0
- package/dist/modules/navigation.d.ts.map +1 -0
- package/dist/modules/navigation.js +387 -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 +95 -0
- package/dist/modules/phone.d.ts.map +1 -0
- package/dist/modules/phone.js +110 -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 +778 -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 +281 -0
- package/dist/modules/pivots/instructions.js.map +1 -0
- package/dist/modules/speaker.d.ts +175 -0
- package/dist/modules/speaker.d.ts.map +1 -0
- package/dist/modules/speaker.js +249 -0
- package/dist/modules/speaker.js.map +1 -0
- package/dist/modules/speakers.d.ts +29 -0
- package/dist/modules/speakers.d.ts.map +1 -0
- package/dist/modules/speakers.js +38 -0
- package/dist/modules/speakers.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 +133 -0
- package/dist/modules/stream.d.ts.map +1 -0
- package/dist/modules/stream.js +53 -0
- package/dist/modules/stream.js.map +1 -0
- package/dist/modules/system.d.ts +71 -0
- package/dist/modules/system.d.ts.map +1 -0
- package/dist/modules/system.js +65 -0
- package/dist/modules/system.js.map +1 -0
- package/dist/modules/transcription.d.ts +99 -0
- package/dist/modules/transcription.d.ts.map +1 -0
- package/dist/modules/transcription.js +126 -0
- package/dist/modules/transcription.js.map +1 -0
- package/dist/modules/translation.d.ts +65 -0
- package/dist/modules/translation.d.ts.map +1 -0
- package/dist/modules/translation.js +121 -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 +289 -0
- package/dist/modules/ui.js.map +1 -0
- package/dist/protocol.d.ts +390 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +419 -0
- package/dist/protocol.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/MiniappProvider.d.ts +33 -0
- package/dist/react/MiniappProvider.d.ts.map +1 -0
- package/dist/react/MiniappProvider.js +15 -0
- package/dist/react/MiniappProvider.js.map +1 -0
- package/dist/react/capsuleHeaderLayout.d.ts +3 -0
- package/dist/react/capsuleHeaderLayout.d.ts.map +1 -0
- package/dist/react/capsuleHeaderLayout.js +5 -0
- package/dist/react/capsuleHeaderLayout.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 +39 -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 +355 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +688 -0
- package/dist/session.js.map +1 -0
- package/dist/sub-path-types.test-d.d.ts +40 -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 +124 -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 +210 -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 +107 -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 +88 -0
- package/src/background/index.ts +177 -0
- package/src/background/register.ts +89 -0
- package/src/dev-reload.ts +59 -0
- package/src/envelope.ts +54 -0
- package/src/globals.ts +62 -0
- package/src/hardware.ts +25 -0
- package/src/index.ts +216 -0
- package/src/modules/actions.ts +189 -0
- package/src/modules/ai.ts +281 -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 +258 -0
- package/src/modules/cloud.ts +94 -0
- package/src/modules/dashboard.ts +51 -0
- package/src/modules/display.ts +214 -0
- package/src/modules/events.ts +318 -0
- package/src/modules/glasses.ts +58 -0
- package/src/modules/heading.ts +23 -0
- package/src/modules/imu.ts +44 -0
- package/src/modules/input.ts +87 -0
- package/src/modules/keys.ts +46 -0
- package/src/modules/languages.ts +72 -0
- package/src/modules/led.ts +61 -0
- package/src/modules/location.ts +39 -0
- package/src/modules/memory.ts +224 -0
- package/src/modules/mic.ts +103 -0
- package/src/modules/miniapps.ts +103 -0
- package/src/modules/navigation.ts +674 -0
- package/src/modules/permissions.ts +83 -0
- package/src/modules/phone.ts +155 -0
- package/src/modules/pivots/engine.ts +863 -0
- package/src/modules/pivots/geometry.ts +409 -0
- package/src/modules/pivots/instructions.ts +341 -0
- package/src/modules/speaker.ts +347 -0
- package/src/modules/speakers.ts +40 -0
- package/src/modules/storage.ts +109 -0
- package/src/modules/stream.ts +168 -0
- package/src/modules/system.ts +113 -0
- package/src/modules/transcription.ts +180 -0
- package/src/modules/translation.ts +156 -0
- package/src/modules/ui.ts +481 -0
- package/src/protocol.ts +482 -0
- package/src/react/MiniappHeader.tsx +114 -0
- package/src/react/MiniappProvider.tsx +50 -0
- package/src/react/capsuleHeaderLayout.ts +11 -0
- package/src/react/index.ts +12 -0
- package/src/react/useCapabilities.ts +29 -0
- package/src/react/useCapsuleHeaderStyle.ts +55 -0
- package/src/react/useColorScheme.ts +26 -0
- package/src/react/useConnected.ts +47 -0
- package/src/react/useRpc.ts +103 -0
- package/src/react/useSafeArea.ts +36 -0
- package/src/session.ts +969 -0
- package/src/sub-path-types.test-d.ts +60 -0
- package/src/transport/auto.ts +143 -0
- package/src/transport/dispatch.ts +106 -0
- package/src/transport/local-socket.ts +91 -0
- package/src/transport/mock.ts +255 -0
- package/src/transport/postmessage.ts +95 -0
- package/src/transport/types.ts +26 -0
- package/src/ui/index.ts +129 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview EventManager — internal subscription registry + escape hatch.
|
|
3
|
+
*
|
|
4
|
+
* Most miniapp authors should NOT touch this directly. Use the typed methods
|
|
5
|
+
* on domain modules instead:
|
|
6
|
+
* - session.transcription.on(...)
|
|
7
|
+
* - session.mic.onAudioChunk(...) / onVoiceActivity(...)
|
|
8
|
+
* - session.input.onButtonPress(...)
|
|
9
|
+
* - session.imu.onHeadPosition(...)
|
|
10
|
+
* - session.location.onUpdate(...)
|
|
11
|
+
* - session.glasses.onBattery(...) / onConnection(...)
|
|
12
|
+
* - session.phone.notifications.on(...) / session.phone.onBattery(...)
|
|
13
|
+
*
|
|
14
|
+
* This module's only public method is `subscribe(rawStreamType, handler)` —
|
|
15
|
+
* a forward-compat escape hatch for new event types not yet wrapped on a
|
|
16
|
+
* domain module. Officially undocumented; the typed methods on domain
|
|
17
|
+
* modules are the canonical surface.
|
|
18
|
+
*
|
|
19
|
+
* Internally, EventManager owns:
|
|
20
|
+
* 1. The ref-count map. Outbound SUBSCRIBE is only sent when a stream's
|
|
21
|
+
* ref count transitions 0↔1, so multiple components listening for the
|
|
22
|
+
* same stream issue one wire-level subscribe.
|
|
23
|
+
* 2. Inbound event fan-out via `_forwardEvent(streamType, data)`, called
|
|
24
|
+
* by MiniappSession.handleIncoming when an EVENT envelope arrives.
|
|
25
|
+
*
|
|
26
|
+
* Domain modules call back into the session via session._subscribe(...) which
|
|
27
|
+
* in turn delegates to this class — the session is the integration point;
|
|
28
|
+
* domain modules don't see this class directly.
|
|
29
|
+
*/
|
|
30
|
+
import { MiniappSession } from "../session";
|
|
31
|
+
export type UnsubscribeFn = () => void;
|
|
32
|
+
/** @internal Host-selected delivery target for a transcription event. */
|
|
33
|
+
export type TranscriptionEventRoute = "default" | "forceLocal" | "all";
|
|
34
|
+
export interface TranscriptionData {
|
|
35
|
+
text: string;
|
|
36
|
+
isFinal: boolean;
|
|
37
|
+
language?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Speaker id when the platform reports one. A stable enrolled-speaker id
|
|
40
|
+
* (`spk_…`) when on-device voice recognition resolved the voice, else
|
|
41
|
+
* the provider's anonymous diarization label (e.g. "1"), else absent.
|
|
42
|
+
* Enrolled display names are never exposed to miniapps — ids only.
|
|
43
|
+
*/
|
|
44
|
+
speakerId?: string;
|
|
45
|
+
/**
|
|
46
|
+
* On-device voice recognition against the device owner's enrolled voice
|
|
47
|
+
* (final segments only). true = the user themself spoke; false =
|
|
48
|
+
* confidently a different voice; absent = no confident determination
|
|
49
|
+
* (or voice recognition is off / not enrolled).
|
|
50
|
+
*/
|
|
51
|
+
isUser?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface TranslationData {
|
|
54
|
+
text: string;
|
|
55
|
+
isFinal: boolean;
|
|
56
|
+
sourceLanguage: string;
|
|
57
|
+
targetLanguage: string;
|
|
58
|
+
/** Source-language text of the same utterance, when the provider supplies it. */
|
|
59
|
+
originalText?: string;
|
|
60
|
+
/** Stable id correlating interim + final results of one utterance. */
|
|
61
|
+
utteranceId?: string;
|
|
62
|
+
/** Speaker id when the provider reports diarization. */
|
|
63
|
+
speakerId?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface ButtonPressData {
|
|
66
|
+
buttonId: string;
|
|
67
|
+
pressType: "short" | "long";
|
|
68
|
+
}
|
|
69
|
+
export interface HeadPositionData {
|
|
70
|
+
position: "up" | "down";
|
|
71
|
+
}
|
|
72
|
+
export interface AccelData {
|
|
73
|
+
/** Accelerometer axes in g (gravity-normalized). */
|
|
74
|
+
x: number;
|
|
75
|
+
y: number;
|
|
76
|
+
z: number;
|
|
77
|
+
/** Unix ms timestamp of the reading. */
|
|
78
|
+
timestamp: number;
|
|
79
|
+
}
|
|
80
|
+
export interface LocationData {
|
|
81
|
+
lat: number;
|
|
82
|
+
lng: number;
|
|
83
|
+
/** Accuracy in meters, if the platform reported it. */
|
|
84
|
+
accuracy?: number;
|
|
85
|
+
/** Unix ms timestamp of the fix. */
|
|
86
|
+
timestamp?: number;
|
|
87
|
+
/** Set when this event is a response to a single-location request. */
|
|
88
|
+
correlationId?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface HeadingData {
|
|
91
|
+
/** Compass heading in degrees, 0 = north, 90 = east. */
|
|
92
|
+
degrees: number;
|
|
93
|
+
}
|
|
94
|
+
export interface BatteryData {
|
|
95
|
+
level: number;
|
|
96
|
+
charging: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface ConnectionData {
|
|
99
|
+
connected: boolean;
|
|
100
|
+
modelName?: string;
|
|
101
|
+
}
|
|
102
|
+
/** Glasses Wi-Fi state. `connected` is false on glasses without Wi-Fi or when offline. */
|
|
103
|
+
export interface WifiData {
|
|
104
|
+
connected: boolean;
|
|
105
|
+
ssid?: string;
|
|
106
|
+
localIp?: string;
|
|
107
|
+
}
|
|
108
|
+
export interface PhoneNotificationData {
|
|
109
|
+
/** Stable id from the phone's notification listener. */
|
|
110
|
+
notificationId: string;
|
|
111
|
+
/** Human app name (e.g. "Messages"). */
|
|
112
|
+
app: string;
|
|
113
|
+
title: string;
|
|
114
|
+
content: string;
|
|
115
|
+
/** Android priority string; empty on iOS. */
|
|
116
|
+
priority: string;
|
|
117
|
+
timestamp: number;
|
|
118
|
+
/** Reverse-DNS package/bundle id of the originating app. */
|
|
119
|
+
packageName: string;
|
|
120
|
+
}
|
|
121
|
+
export interface NotificationDismissedData {
|
|
122
|
+
/** Same id as the matching post event from `notifications.on(...)`. */
|
|
123
|
+
notificationId: string;
|
|
124
|
+
/** Android NotificationKey. More stable than notificationId across reposts. */
|
|
125
|
+
notificationKey?: string;
|
|
126
|
+
/** Reverse-DNS package/bundle id of the originating app. */
|
|
127
|
+
packageName?: string;
|
|
128
|
+
/** Unix ms timestamp of the dismissal. */
|
|
129
|
+
timestamp: number;
|
|
130
|
+
}
|
|
131
|
+
export interface VadData {
|
|
132
|
+
/** True while the user is speaking (voice detected), false when silent. */
|
|
133
|
+
status: boolean;
|
|
134
|
+
}
|
|
135
|
+
export interface TouchData {
|
|
136
|
+
/**
|
|
137
|
+
* The gesture: single_tap, double_tap, triple_tap, long_press, swipe_up, or
|
|
138
|
+
* swipe_down — plus the raw press edges tap_start (finger down) and tap_end
|
|
139
|
+
* (finger up), which bracket every gesture on hardware that reports them.
|
|
140
|
+
*/
|
|
141
|
+
kind: "single_tap" | "double_tap" | "triple_tap" | "long_press" | "swipe_up" | "swipe_down" | "tap_start" | "tap_end" | string;
|
|
142
|
+
}
|
|
143
|
+
export interface AudioChunkData {
|
|
144
|
+
/** PCM or LC3, base64-encoded. Format depends on phone's mic mode. */
|
|
145
|
+
data: string;
|
|
146
|
+
sampleRate?: number;
|
|
147
|
+
format?: string;
|
|
148
|
+
}
|
|
149
|
+
export declare class EventManager {
|
|
150
|
+
private readonly session;
|
|
151
|
+
private readonly emitter;
|
|
152
|
+
/** Stream -> ref count. Outbound SUBSCRIBE tracks active streams and routing changes. */
|
|
153
|
+
private readonly refCounts;
|
|
154
|
+
/** Transcription stream -> refs that require on-device-only processing. */
|
|
155
|
+
private readonly forceLocalRefCounts;
|
|
156
|
+
constructor(session: MiniappSession);
|
|
157
|
+
/**
|
|
158
|
+
* Generic subscribe. `stream` is the raw wire value, including any language
|
|
159
|
+
* suffix like `"transcription:en-US"`. Forward-compat escape hatch for new
|
|
160
|
+
* event types not yet wrapped on a domain module. Most authors should use
|
|
161
|
+
* typed methods on domain modules instead.
|
|
162
|
+
*
|
|
163
|
+
* Stream names beginning with `_` (e.g. `_ui` for the session.ui bus) are
|
|
164
|
+
* INTERNAL — they ride the local _forwardEvent fan-out and never appear in
|
|
165
|
+
* the outbound SUBSCRIBE list. Native already knows to deliver UI envelopes
|
|
166
|
+
* via a separate envelope `type`; the EventManager only routes them
|
|
167
|
+
* locally.
|
|
168
|
+
*/
|
|
169
|
+
subscribe(stream: string, handler: (data: unknown) => void, options?: {
|
|
170
|
+
forceLocal?: boolean;
|
|
171
|
+
}): UnsubscribeFn;
|
|
172
|
+
/** Unsubscribe every handler on every stream this EventManager owns. */
|
|
173
|
+
unsubscribeAll(): void;
|
|
174
|
+
/** @internal */
|
|
175
|
+
_forwardEvent(stream: string, data: unknown, transcriptionRoute?: TranscriptionEventRoute): void;
|
|
176
|
+
private sendSubscriptionUpdate;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/modules/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAKH,OAAO,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AA;CACX;AAED,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAMD,qBAAa,YAAY;IAOX,OAAO,CAAC,QAAQ,CAAC,OAAO;IANpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,yFAAyF;IACzF,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4B;IACtD,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA4B;gBAEnC,OAAO,EAAE,cAAc;IAEpD;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,EAAE,OAAO,GAAE;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAM,GAAG,aAAa;IAgDhH,wEAAwE;IACxE,cAAc,IAAI,IAAI;IAWtB,gBAAgB;IAChB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,CAAC,EAAE,uBAAuB,GAAG,IAAI;IA4BhG,OAAO,CAAC,sBAAsB;CAmB/B"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview EventManager — internal subscription registry + escape hatch.
|
|
3
|
+
*
|
|
4
|
+
* Most miniapp authors should NOT touch this directly. Use the typed methods
|
|
5
|
+
* on domain modules instead:
|
|
6
|
+
* - session.transcription.on(...)
|
|
7
|
+
* - session.mic.onAudioChunk(...) / onVoiceActivity(...)
|
|
8
|
+
* - session.input.onButtonPress(...)
|
|
9
|
+
* - session.imu.onHeadPosition(...)
|
|
10
|
+
* - session.location.onUpdate(...)
|
|
11
|
+
* - session.glasses.onBattery(...) / onConnection(...)
|
|
12
|
+
* - session.phone.notifications.on(...) / session.phone.onBattery(...)
|
|
13
|
+
*
|
|
14
|
+
* This module's only public method is `subscribe(rawStreamType, handler)` —
|
|
15
|
+
* a forward-compat escape hatch for new event types not yet wrapped on a
|
|
16
|
+
* domain module. Officially undocumented; the typed methods on domain
|
|
17
|
+
* modules are the canonical surface.
|
|
18
|
+
*
|
|
19
|
+
* Internally, EventManager owns:
|
|
20
|
+
* 1. The ref-count map. Outbound SUBSCRIBE is only sent when a stream's
|
|
21
|
+
* ref count transitions 0↔1, so multiple components listening for the
|
|
22
|
+
* same stream issue one wire-level subscribe.
|
|
23
|
+
* 2. Inbound event fan-out via `_forwardEvent(streamType, data)`, called
|
|
24
|
+
* by MiniappSession.handleIncoming when an EVENT envelope arrives.
|
|
25
|
+
*
|
|
26
|
+
* Domain modules call back into the session via session._subscribe(...) which
|
|
27
|
+
* in turn delegates to this class — the session is the integration point;
|
|
28
|
+
* domain modules don't see this class directly.
|
|
29
|
+
*/
|
|
30
|
+
import { EventEmitter } from "eventemitter3";
|
|
31
|
+
import { MiniappRequestType, MiniappStreamType } from "../protocol";
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
// Registry
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
export class EventManager {
|
|
36
|
+
constructor(session) {
|
|
37
|
+
this.session = session;
|
|
38
|
+
this.emitter = new EventEmitter();
|
|
39
|
+
/** Stream -> ref count. Outbound SUBSCRIBE tracks active streams and routing changes. */
|
|
40
|
+
this.refCounts = new Map();
|
|
41
|
+
/** Transcription stream -> refs that require on-device-only processing. */
|
|
42
|
+
this.forceLocalRefCounts = new Map();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Generic subscribe. `stream` is the raw wire value, including any language
|
|
46
|
+
* suffix like `"transcription:en-US"`. Forward-compat escape hatch for new
|
|
47
|
+
* event types not yet wrapped on a domain module. Most authors should use
|
|
48
|
+
* typed methods on domain modules instead.
|
|
49
|
+
*
|
|
50
|
+
* Stream names beginning with `_` (e.g. `_ui` for the session.ui bus) are
|
|
51
|
+
* INTERNAL — they ride the local _forwardEvent fan-out and never appear in
|
|
52
|
+
* the outbound SUBSCRIBE list. Native already knows to deliver UI envelopes
|
|
53
|
+
* via a separate envelope `type`; the EventManager only routes them
|
|
54
|
+
* locally.
|
|
55
|
+
*/
|
|
56
|
+
subscribe(stream, handler, options = {}) {
|
|
57
|
+
const isInternal = stream.startsWith("_");
|
|
58
|
+
const forceLocal = options.forceLocal === true && stream.startsWith(`${MiniappStreamType.TRANSCRIPTION}:`);
|
|
59
|
+
const listener = (data, route) => {
|
|
60
|
+
if (stream.startsWith(`${MiniappStreamType.TRANSCRIPTION}:`)) {
|
|
61
|
+
// Hosts that predate routed transcription events omit `route`. Treat
|
|
62
|
+
// those events as the default/cloud path so a forceLocal listener can
|
|
63
|
+
// never accidentally receive cloud text.
|
|
64
|
+
if (forceLocal ? route !== "forceLocal" && route !== "all" : route === "forceLocal")
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
handler(data);
|
|
68
|
+
};
|
|
69
|
+
this.emitter.on(stream, listener);
|
|
70
|
+
if (!isInternal) {
|
|
71
|
+
const before = this.refCounts.get(stream) ?? 0;
|
|
72
|
+
this.refCounts.set(stream, before + 1);
|
|
73
|
+
const forceLocalBefore = this.forceLocalRefCounts.get(stream) ?? 0;
|
|
74
|
+
const defaultBefore = before - forceLocalBefore;
|
|
75
|
+
if (forceLocal)
|
|
76
|
+
this.forceLocalRefCounts.set(stream, forceLocalBefore + 1);
|
|
77
|
+
if (before === 0 || (forceLocal && forceLocalBefore === 0) || (!forceLocal && defaultBefore === 0)) {
|
|
78
|
+
this.sendSubscriptionUpdate();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return () => {
|
|
82
|
+
this.emitter.off(stream, listener);
|
|
83
|
+
if (isInternal)
|
|
84
|
+
return;
|
|
85
|
+
const current = this.refCounts.get(stream) ?? 0;
|
|
86
|
+
const forceLocalCurrent = this.forceLocalRefCounts.get(stream) ?? 0;
|
|
87
|
+
let subscriptionChanged = current <= 1;
|
|
88
|
+
if (current <= 1) {
|
|
89
|
+
this.refCounts.delete(stream);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this.refCounts.set(stream, current - 1);
|
|
93
|
+
}
|
|
94
|
+
if (forceLocal) {
|
|
95
|
+
if (forceLocalCurrent <= 1) {
|
|
96
|
+
this.forceLocalRefCounts.delete(stream);
|
|
97
|
+
subscriptionChanged = true;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
this.forceLocalRefCounts.set(stream, forceLocalCurrent - 1);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else if (current - forceLocalCurrent <= 1) {
|
|
104
|
+
subscriptionChanged = true;
|
|
105
|
+
}
|
|
106
|
+
if (subscriptionChanged)
|
|
107
|
+
this.sendSubscriptionUpdate();
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** Unsubscribe every handler on every stream this EventManager owns. */
|
|
111
|
+
unsubscribeAll() {
|
|
112
|
+
this.emitter.removeAllListeners();
|
|
113
|
+
this.refCounts.clear();
|
|
114
|
+
this.forceLocalRefCounts.clear();
|
|
115
|
+
this.sendSubscriptionUpdate();
|
|
116
|
+
}
|
|
117
|
+
// -------------------------------------------------------------------------
|
|
118
|
+
// Internal — called by MiniappSession when EVENT arrives from phone
|
|
119
|
+
// -------------------------------------------------------------------------
|
|
120
|
+
/** @internal */
|
|
121
|
+
_forwardEvent(stream, data, transcriptionRoute) {
|
|
122
|
+
this.emitter.emit(stream, data, transcriptionRoute);
|
|
123
|
+
// Wildcard fan-out: handlers register under wildcard patterns
|
|
124
|
+
// ("transcription:auto", "translation:*:<target>", …) but the host
|
|
125
|
+
// delivers events under the CONCRETE stream key
|
|
126
|
+
// ("transcription:en-US", "translation:en:es"). Re-emit on every
|
|
127
|
+
// pattern the concrete key satisfies — the same pattern set
|
|
128
|
+
// LocalMiniappRuntime.forwardEvent matches on the host side —
|
|
129
|
+
// otherwise a wildcard subscriber never fires.
|
|
130
|
+
if (stream.startsWith("transcription:") && stream !== "transcription:auto") {
|
|
131
|
+
this.emitter.emit("transcription:auto", data, transcriptionRoute);
|
|
132
|
+
}
|
|
133
|
+
else if (stream.startsWith("translation:")) {
|
|
134
|
+
const parts = stream.split(":");
|
|
135
|
+
const patterns = new Set(["translation:auto"]);
|
|
136
|
+
if (parts.length === 3) {
|
|
137
|
+
const [, source, target] = parts;
|
|
138
|
+
patterns.add("translation:*:*");
|
|
139
|
+
patterns.add(`translation:*:${target}`);
|
|
140
|
+
patterns.add(`translation:${source}:*`);
|
|
141
|
+
}
|
|
142
|
+
patterns.delete(stream); // exact key already emitted above
|
|
143
|
+
for (const pattern of patterns) {
|
|
144
|
+
this.emitter.emit(pattern, data);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
sendSubscriptionUpdate() {
|
|
149
|
+
const subscriptions = Array.from(this.refCounts.keys()).map((stream) => {
|
|
150
|
+
if (stream === MiniappStreamType.LOCATION_UPDATE)
|
|
151
|
+
return { stream: "location_stream", rate: "realtime" };
|
|
152
|
+
const forceLocalRefs = this.forceLocalRefCounts.get(stream) ?? 0;
|
|
153
|
+
if (forceLocalRefs === 0)
|
|
154
|
+
return stream;
|
|
155
|
+
const totalRefs = this.refCounts.get(stream) ?? 0;
|
|
156
|
+
return {
|
|
157
|
+
stream,
|
|
158
|
+
forceLocal: true,
|
|
159
|
+
...(totalRefs > forceLocalRefs ? { includeCloud: true } : {}),
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
this.session.sendOneShot({
|
|
163
|
+
type: MiniappRequestType.SUBSCRIBE,
|
|
164
|
+
subscriptions,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/modules/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;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gBACL,MAAM;gBACN,UAAU,EAAE,IAAI;gBAChB,GAAG,CAAC,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,EAAC,YAAY,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aAC5D,CAAA;QACH,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;YACvB,IAAI,EAAE,kBAAkB,CAAC,SAAS;YAClC,aAAa;SACd,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview GlassesModule — device-state events for the glasses themselves.
|
|
3
|
+
*
|
|
4
|
+
* Reports on the glasses hardware: battery level + charging state, connection
|
|
5
|
+
* status (connected/disconnected, model name). The phone has its own battery
|
|
6
|
+
* + connection events on `session.phone`.
|
|
7
|
+
*/
|
|
8
|
+
import { MiniappSession } from "../session";
|
|
9
|
+
import type { BatteryData, ConnectionData, UnsubscribeFn, WifiData } from "./events";
|
|
10
|
+
export declare class GlassesModule {
|
|
11
|
+
private readonly session;
|
|
12
|
+
constructor(session: MiniappSession);
|
|
13
|
+
onBattery(handler: (data: BatteryData) => void): UnsubscribeFn;
|
|
14
|
+
onConnection(handler: (data: ConnectionData) => void): UnsubscribeFn;
|
|
15
|
+
/**
|
|
16
|
+
* Subscribe to glasses Wi-Fi state. Fires the current state on subscribe and
|
|
17
|
+
* on every change. `connected` is false on glasses without Wi-Fi. Streaming
|
|
18
|
+
* requires Wi-Fi — pair this with {@link requestWifiSetup} to prompt the user.
|
|
19
|
+
*/
|
|
20
|
+
onWifi(handler: (data: WifiData) => void): UnsubscribeFn;
|
|
21
|
+
/**
|
|
22
|
+
* Ask the host to open the glasses Wi-Fi setup flow on the phone. Mirrors the
|
|
23
|
+
* cloud SDK's `session.requestWifiSetup(reason)`. `reason` is a user-facing
|
|
24
|
+
* line shown in the setup prompt (e.g. "Streaming needs your glasses on Wi-Fi").
|
|
25
|
+
*/
|
|
26
|
+
requestWifiSetup(reason?: string): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Enable or disable Wi-Fi ADB (wireless debugging) on Mentra Live.
|
|
29
|
+
* Persisted on the glasses; boot applies the saved preference (default off).
|
|
30
|
+
*
|
|
31
|
+
* SYSTEM-only — rejects with `NOT_PERMITTED` unless this miniapp is a system
|
|
32
|
+
* app. Third-party miniapps must not expose wireless debugging controls.
|
|
33
|
+
*/
|
|
34
|
+
setWifiAdbState(enabled: boolean): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=glasses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glasses.d.ts","sourceRoot":"","sources":["../../src/modules/glasses.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAC,MAAM,UAAU,CAAA;AAElF,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,SAAS,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,aAAa;IAI9D,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,GAAG,aAAa;IAIpE;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,GAAG,aAAa;IAIxD;;;;OAIG;IACG,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOtD;;;;;;OAMG;IACG,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAMvD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview GlassesModule — device-state events for the glasses themselves.
|
|
3
|
+
*
|
|
4
|
+
* Reports on the glasses hardware: battery level + charging state, connection
|
|
5
|
+
* status (connected/disconnected, model name). The phone has its own battery
|
|
6
|
+
* + connection events on `session.phone`.
|
|
7
|
+
*/
|
|
8
|
+
import { MiniappRequestType, MiniappStreamType } from "../protocol";
|
|
9
|
+
export class GlassesModule {
|
|
10
|
+
constructor(session) {
|
|
11
|
+
this.session = session;
|
|
12
|
+
}
|
|
13
|
+
onBattery(handler) {
|
|
14
|
+
return this.session._subscribe(MiniappStreamType.GLASSES_BATTERY, handler);
|
|
15
|
+
}
|
|
16
|
+
onConnection(handler) {
|
|
17
|
+
return this.session._subscribe(MiniappStreamType.GLASSES_CONNECTION, handler);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Subscribe to glasses Wi-Fi state. Fires the current state on subscribe and
|
|
21
|
+
* on every change. `connected` is false on glasses without Wi-Fi. Streaming
|
|
22
|
+
* requires Wi-Fi — pair this with {@link requestWifiSetup} to prompt the user.
|
|
23
|
+
*/
|
|
24
|
+
onWifi(handler) {
|
|
25
|
+
return this.session._subscribe(MiniappStreamType.GLASSES_WIFI, handler);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Ask the host to open the glasses Wi-Fi setup flow on the phone. Mirrors the
|
|
29
|
+
* cloud SDK's `session.requestWifiSetup(reason)`. `reason` is a user-facing
|
|
30
|
+
* line shown in the setup prompt (e.g. "Streaming needs your glasses on Wi-Fi").
|
|
31
|
+
*/
|
|
32
|
+
async requestWifiSetup(reason) {
|
|
33
|
+
await this.session.sendRequest({
|
|
34
|
+
type: MiniappRequestType.REQUEST_WIFI_SETUP,
|
|
35
|
+
reason,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Enable or disable Wi-Fi ADB (wireless debugging) on Mentra Live.
|
|
40
|
+
* Persisted on the glasses; boot applies the saved preference (default off).
|
|
41
|
+
*
|
|
42
|
+
* SYSTEM-only — rejects with `NOT_PERMITTED` unless this miniapp is a system
|
|
43
|
+
* app. Third-party miniapps must not expose wireless debugging controls.
|
|
44
|
+
*/
|
|
45
|
+
async setWifiAdbState(enabled) {
|
|
46
|
+
await this.session.sendRequest({
|
|
47
|
+
type: MiniappRequestType.SET_WIFI_ADB_STATE,
|
|
48
|
+
enabled,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=glasses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glasses.js","sourceRoot":"","sources":["../../src/modules/glasses.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAIjE,MAAM,OAAO,aAAa;IACxB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,SAAS,CAAC,OAAoC;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,eAAe,EAAE,OAAkC,CAAC,CAAA;IACvG,CAAC;IAED,YAAY,CAAC,OAAuC;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,OAAkC,CAAC,CAAA;IAC1G,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAiC;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,YAAY,EAAE,OAAkC,CAAC,CAAA;IACpG,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CAAC,MAAe;QACpC,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;YACnC,IAAI,EAAE,kBAAkB,CAAC,kBAAkB;YAC3C,MAAM;SACP,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe,CAAC,OAAgB;QACpC,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;YACnC,IAAI,EAAE,kBAAkB,CAAC,kBAAkB;YAC3C,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview HeadingModule — phone compass heading events.
|
|
3
|
+
*
|
|
4
|
+
* Works on both Android and iOS. LOCATION permission must be declared in miniapp.json.
|
|
5
|
+
*/
|
|
6
|
+
import { MiniappSession } from "../session";
|
|
7
|
+
import type { HeadingData, UnsubscribeFn } from "./events";
|
|
8
|
+
export declare class HeadingModule {
|
|
9
|
+
private readonly session;
|
|
10
|
+
constructor(session: MiniappSession);
|
|
11
|
+
/** True iff `LOCATION` is declared in the miniapp's manifest. */
|
|
12
|
+
get hasPermission(): boolean;
|
|
13
|
+
/** Subscribe to continuous compass heading updates. */
|
|
14
|
+
onUpdate(handler: (data: HeadingData) => void): UnsubscribeFn;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=heading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/modules/heading.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,WAAW,EAAE,aAAa,EAAC,MAAM,UAAU,CAAA;AAExD,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,iEAAiE;IACjE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,aAAa;CAG9D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview HeadingModule — phone compass heading events.
|
|
3
|
+
*
|
|
4
|
+
* Works on both Android and iOS. LOCATION permission must be declared in miniapp.json.
|
|
5
|
+
*/
|
|
6
|
+
import { MiniappStreamType } from "../protocol";
|
|
7
|
+
export class HeadingModule {
|
|
8
|
+
constructor(session) {
|
|
9
|
+
this.session = session;
|
|
10
|
+
}
|
|
11
|
+
/** True iff `LOCATION` is declared in the miniapp's manifest. */
|
|
12
|
+
get hasPermission() {
|
|
13
|
+
return this.session._hasManifestPermission("LOCATION");
|
|
14
|
+
}
|
|
15
|
+
/** Subscribe to continuous compass heading updates. */
|
|
16
|
+
onUpdate(handler) {
|
|
17
|
+
return this.session._subscribe(MiniappStreamType.HEADING_UPDATE, handler);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=heading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading.js","sourceRoot":"","sources":["../../src/modules/heading.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAI7C,MAAM,OAAO,aAAa;IACxB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,iEAAiE;IACjE,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAA;IACxD,CAAC;IAED,uDAAuD;IACvD,QAAQ,CAAC,OAAoC;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,cAAc,EAAE,OAAkC,CAAC,CAAA;IACtG,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview ImuModule — head position + motion events.
|
|
3
|
+
*
|
|
4
|
+
* Glasses' inertial measurement unit. Exposes head-up/down position and a
|
|
5
|
+
* raw accelerometer stream (`onAccel`). Gyroscope / magnetometer / fused
|
|
6
|
+
* orientation are future work — when added they'll surface as a combined IMU
|
|
7
|
+
* event rather than extending this single-sensor accel stream.
|
|
8
|
+
*/
|
|
9
|
+
import { MiniappSession } from "../session";
|
|
10
|
+
import type { AccelData, HeadPositionData, UnsubscribeFn } from "./events";
|
|
11
|
+
export declare class ImuModule {
|
|
12
|
+
private readonly session;
|
|
13
|
+
constructor(session: MiniappSession);
|
|
14
|
+
onHeadPosition(handler: (data: HeadPositionData) => void): UnsubscribeFn;
|
|
15
|
+
/**
|
|
16
|
+
* Subscribe to raw accelerometer readings (`{x, y, z}` in g) from the
|
|
17
|
+
* glasses IMU. G2 only today; on glasses without an exposed IMU stream the
|
|
18
|
+
* subscription succeeds but no events fire.
|
|
19
|
+
*/
|
|
20
|
+
onAccel(handler: (data: AccelData) => void): UnsubscribeFn;
|
|
21
|
+
/**
|
|
22
|
+
* Explicitly enable or disable raw accelerometer streaming on the glasses.
|
|
23
|
+
*
|
|
24
|
+
* Subscribing via `onAccel` already auto-enables the sensor and unsubscribing
|
|
25
|
+
* disables it, so most callers don't need this. Use it when you want to drive
|
|
26
|
+
* the IMU directly — e.g. a diagnostic toggle. G2 only today; a no-op on
|
|
27
|
+
* glasses without an exposed IMU stream.
|
|
28
|
+
*/
|
|
29
|
+
setEnabled(enabled: boolean): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=imu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imu.d.ts","sourceRoot":"","sources":["../../src/modules/imu.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAC,MAAM,UAAU,CAAA;AAExE,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,cAAc,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,GAAG,aAAa;IAIxE;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,GAAG,aAAa;IAI1D;;;;;;;OAOG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAM5C"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview ImuModule — head position + motion events.
|
|
3
|
+
*
|
|
4
|
+
* Glasses' inertial measurement unit. Exposes head-up/down position and a
|
|
5
|
+
* raw accelerometer stream (`onAccel`). Gyroscope / magnetometer / fused
|
|
6
|
+
* orientation are future work — when added they'll surface as a combined IMU
|
|
7
|
+
* event rather than extending this single-sensor accel stream.
|
|
8
|
+
*/
|
|
9
|
+
import { MiniappRequestType, MiniappStreamType } from "../protocol";
|
|
10
|
+
export class ImuModule {
|
|
11
|
+
constructor(session) {
|
|
12
|
+
this.session = session;
|
|
13
|
+
}
|
|
14
|
+
onHeadPosition(handler) {
|
|
15
|
+
return this.session._subscribe(MiniappStreamType.HEAD_POSITION, handler);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Subscribe to raw accelerometer readings (`{x, y, z}` in g) from the
|
|
19
|
+
* glasses IMU. G2 only today; on glasses without an exposed IMU stream the
|
|
20
|
+
* subscription succeeds but no events fire.
|
|
21
|
+
*/
|
|
22
|
+
onAccel(handler) {
|
|
23
|
+
return this.session._subscribe(MiniappStreamType.ACCEL_DATA, handler);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Explicitly enable or disable raw accelerometer streaming on the glasses.
|
|
27
|
+
*
|
|
28
|
+
* Subscribing via `onAccel` already auto-enables the sensor and unsubscribing
|
|
29
|
+
* disables it, so most callers don't need this. Use it when you want to drive
|
|
30
|
+
* the IMU directly — e.g. a diagnostic toggle. G2 only today; a no-op on
|
|
31
|
+
* glasses without an exposed IMU stream.
|
|
32
|
+
*/
|
|
33
|
+
setEnabled(enabled) {
|
|
34
|
+
return this.session.sendRequest({
|
|
35
|
+
type: MiniappRequestType.IMU_SET_ENABLED,
|
|
36
|
+
enabled,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=imu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imu.js","sourceRoot":"","sources":["../../src/modules/imu.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAIjE,MAAM,OAAO,SAAS;IACpB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,cAAc,CAAC,OAAyC;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,aAAa,EAAE,OAAkC,CAAC,CAAA;IACrG,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,OAAkC;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,UAAU,EAAE,OAAkC,CAAC,CAAA;IAClG,CAAC;IAED;;;;;;;OAOG;IACH,UAAU,CAAC,OAAgB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;YACpC,IAAI,EAAE,kBAAkB,CAAC,eAAe;YACxC,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview InputModule — physical control events on the glasses.
|
|
3
|
+
*
|
|
4
|
+
* Combines button + touch surfaces. Future input modes (gesture, voice
|
|
5
|
+
* command, eye tracking) will extend this module rather than spawning new
|
|
6
|
+
* top-level modules.
|
|
7
|
+
*
|
|
8
|
+
* Touch overloads:
|
|
9
|
+
*
|
|
10
|
+
* session.input.onTouch(handler)
|
|
11
|
+
* session.input.onTouch("single_tap", handler)
|
|
12
|
+
* session.input.onTouch(["swipe_up", "swipe_down"], handler)
|
|
13
|
+
*
|
|
14
|
+
* Per-gesture filtering rides on `touch_event:<gesture>` stream variants
|
|
15
|
+
* the phone runtime fans out alongside the bare `touch_event` stream.
|
|
16
|
+
*/
|
|
17
|
+
import { MiniappSession } from "../session";
|
|
18
|
+
import type { ButtonPressData, TouchData, UnsubscribeFn } from "./events";
|
|
19
|
+
export declare class InputModule {
|
|
20
|
+
private readonly session;
|
|
21
|
+
constructor(session: MiniappSession);
|
|
22
|
+
/**
|
|
23
|
+
* Declare the gestures this miniapp is handling itself, replacing any
|
|
24
|
+
* previous claim set. While a claimed gesture arrives and this app is
|
|
25
|
+
* FOREGROUND on the glasses, the host skips its default behavior for it —
|
|
26
|
+
* today that is `double_tap`, which otherwise opens the dashboard (or
|
|
27
|
+
* toggles head-up). The events themselves still arrive via `onTouch`
|
|
28
|
+
* either way; claiming only suppresses the system default.
|
|
29
|
+
*
|
|
30
|
+
* Pass `[]` to release every claim. Claims are cleared automatically when
|
|
31
|
+
* the miniapp stops, and are inert while the app is backgrounded — a
|
|
32
|
+
* background app never hijacks a system gesture.
|
|
33
|
+
*
|
|
34
|
+
* session.input.setClaimedGestures(["double_tap"]) // in-app back gesture
|
|
35
|
+
* session.input.setClaimedGestures([]) // back to system default
|
|
36
|
+
*/
|
|
37
|
+
setClaimedGestures(gestures: string[]): Promise<void>;
|
|
38
|
+
onButtonPress(handler: (data: ButtonPressData) => void): UnsubscribeFn;
|
|
39
|
+
/**
|
|
40
|
+
* Subscribe to touch events.
|
|
41
|
+
*
|
|
42
|
+
* onTouch(handler) — all touch events
|
|
43
|
+
* onTouch("single_tap", handler) — only single taps
|
|
44
|
+
* onTouch(["a","b"], handler) — multiple gestures, single subscription
|
|
45
|
+
*/
|
|
46
|
+
onTouch(handler: (data: TouchData) => void): UnsubscribeFn;
|
|
47
|
+
onTouch(gesture: string, handler: (data: TouchData) => void): UnsubscribeFn;
|
|
48
|
+
onTouch(gestures: string[], handler: (data: TouchData) => void): UnsubscribeFn;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/modules/input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,eAAe,EAAE,SAAS,EAAE,aAAa,EAAC,MAAM,UAAU,CAAA;AAEvE,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD;;;;;;;;;;;;;;OAcG;IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrD,aAAa,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,GAAG,aAAa;IAItE;;;;;;OAMG;IACH,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,GAAG,aAAa;IAC1D,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,GAAG,aAAa;IAC3E,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,GAAG,aAAa;CA4B/E"}
|