@mentra/sdk 2.1.31-beta.6 → 3.0.0-alpha.3
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 +54 -9
- package/dist/MiniAppServer.d.ts +58 -0
- package/dist/MiniAppServer.d.ts.map +1 -0
- package/dist/app/server/index.d.ts +143 -88
- package/dist/app/server/index.d.ts.map +1 -1
- package/dist/app/session/events.d.ts +20 -3
- package/dist/app/session/events.d.ts.map +1 -1
- package/dist/app/session/index.d.ts +56 -3
- package/dist/app/session/index.d.ts.map +1 -1
- package/dist/app/session/modules/audio-output-stream.d.ts +108 -0
- package/dist/app/session/modules/audio-output-stream.d.ts.map +1 -0
- package/dist/app/session/modules/audio.d.ts +36 -1
- package/dist/app/session/modules/audio.d.ts.map +1 -1
- package/dist/app/session/modules/camera-managed-extension.d.ts +37 -33
- package/dist/app/session/modules/camera-managed-extension.d.ts.map +1 -1
- package/dist/app/session/modules/camera.d.ts +108 -50
- package/dist/app/session/modules/camera.d.ts.map +1 -1
- package/dist/app/session/modules/index.d.ts +4 -3
- package/dist/app/session/modules/index.d.ts.map +1 -1
- package/dist/app/session/modules/led.d.ts.map +1 -1
- package/dist/app/session/modules/location.d.ts.map +1 -1
- package/dist/app/session/settings.d.ts +5 -1
- package/dist/app/session/settings.d.ts.map +1 -1
- package/dist/app/webview/index.d.ts +67 -9
- package/dist/app/webview/index.d.ts.map +1 -1
- package/dist/constants/log-messages/updates.d.ts +32 -9
- package/dist/constants/log-messages/updates.d.ts.map +1 -1
- package/dist/constants/log-messages/warning.d.ts +12 -0
- package/dist/constants/log-messages/warning.d.ts.map +1 -1
- package/dist/display-utils.d.ts +3 -1
- package/dist/display-utils.d.ts.map +1 -1
- package/dist/display-utils.js +443 -26
- package/dist/display-utils.js.map +10 -6
- package/dist/index.d.ts +22 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8877 -4236
- package/dist/index.js.map +63 -31
- package/dist/internal/_SessionManager.d.ts +76 -0
- package/dist/internal/_SessionManager.d.ts.map +1 -0
- package/dist/logging/clean-transport.d.ts +50 -0
- package/dist/logging/clean-transport.d.ts.map +1 -0
- package/dist/logging/errors.d.ts +90 -0
- package/dist/logging/errors.d.ts.map +1 -0
- package/dist/logging/logger.d.ts +72 -1
- package/dist/logging/logger.d.ts.map +1 -1
- package/dist/logging/telemetry-transport.d.ts +51 -0
- package/dist/logging/telemetry-transport.d.ts.map +1 -0
- package/dist/session/DataStreamRouter.d.ts +219 -0
- package/dist/session/DataStreamRouter.d.ts.map +1 -0
- package/dist/session/MentraSession.d.ts +102 -0
- package/dist/session/MentraSession.d.ts.map +1 -0
- package/dist/session/index.d.ts +2 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/internal/_ConnectionManager.d.ts +43 -0
- package/dist/session/internal/_ConnectionManager.d.ts.map +1 -0
- package/dist/session/internal/_MessageRouter.d.ts +11 -0
- package/dist/session/internal/_MessageRouter.d.ts.map +1 -0
- package/dist/session/internal/_SubscriptionManager.d.ts +32 -0
- package/dist/session/internal/_SubscriptionManager.d.ts.map +1 -0
- package/dist/session/internal/_V2AudioStreamShim.d.ts +12 -0
- package/dist/session/internal/_V2AudioStreamShim.d.ts.map +1 -0
- package/dist/session/internal/_V2CameraShim.d.ts +51 -0
- package/dist/session/internal/_V2CameraShim.d.ts.map +1 -0
- package/dist/session/internal/_V2EventManagerShim.d.ts +51 -0
- package/dist/session/internal/_V2EventManagerShim.d.ts.map +1 -0
- package/dist/session/internal/_V2SessionShim.d.ts +165 -0
- package/dist/session/internal/_V2SessionShim.d.ts.map +1 -0
- package/dist/session/internal/_V2SettingsShim.d.ts +17 -0
- package/dist/session/internal/_V2SettingsShim.d.ts.map +1 -0
- package/dist/session/managers/CameraManager.d.ts +197 -0
- package/dist/session/managers/CameraManager.d.ts.map +1 -0
- package/dist/session/managers/DashboardManager.d.ts +131 -0
- package/dist/session/managers/DashboardManager.d.ts.map +1 -0
- package/dist/session/managers/DeviceManager.d.ts +332 -0
- package/dist/session/managers/DeviceManager.d.ts.map +1 -0
- package/dist/session/managers/DisplayManager.d.ts +171 -0
- package/dist/session/managers/DisplayManager.d.ts.map +1 -0
- package/dist/session/managers/LedManager.d.ts +131 -0
- package/dist/session/managers/LedManager.d.ts.map +1 -0
- package/dist/session/managers/LocationManager.d.ts +255 -0
- package/dist/session/managers/LocationManager.d.ts.map +1 -0
- package/dist/session/managers/MicManager.d.ts +252 -0
- package/dist/session/managers/MicManager.d.ts.map +1 -0
- package/dist/session/managers/PermissionsManager.d.ts +182 -0
- package/dist/session/managers/PermissionsManager.d.ts.map +1 -0
- package/dist/session/managers/PhoneManager.d.ts +295 -0
- package/dist/session/managers/PhoneManager.d.ts.map +1 -0
- package/dist/session/managers/SpeakerManager.d.ts +285 -0
- package/dist/session/managers/SpeakerManager.d.ts.map +1 -0
- package/dist/session/managers/StorageManager.d.ts +289 -0
- package/dist/session/managers/StorageManager.d.ts.map +1 -0
- package/dist/session/managers/TimeUtils.d.ts +175 -0
- package/dist/session/managers/TimeUtils.d.ts.map +1 -0
- package/dist/session/managers/TranscriptionManager.d.ts +195 -0
- package/dist/session/managers/TranscriptionManager.d.ts.map +1 -0
- package/dist/session/managers/TranslationManager.d.ts +189 -0
- package/dist/session/managers/TranslationManager.d.ts.map +1 -0
- package/dist/session.d.ts +41 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +4168 -0
- package/dist/session.js.map +44 -0
- package/dist/transport/Transport.d.ts +119 -0
- package/dist/transport/Transport.d.ts.map +1 -0
- package/dist/transport/WebSocketTransport.d.ts +73 -0
- package/dist/transport/WebSocketTransport.d.ts.map +1 -0
- package/dist/types/index.d.ts +31 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/message-types.d.ts +25 -9
- package/dist/types/message-types.d.ts.map +1 -1
- package/dist/types/messages/app-to-cloud.d.ts +113 -16
- package/dist/types/messages/app-to-cloud.d.ts.map +1 -1
- package/dist/types/messages/cloud-to-app.d.ts +50 -4
- package/dist/types/messages/cloud-to-app.d.ts.map +1 -1
- package/dist/types/messages/cloud-to-glasses.d.ts +43 -14
- package/dist/types/messages/cloud-to-glasses.d.ts.map +1 -1
- package/dist/types/messages/glasses-to-cloud.d.ts +5 -5
- package/dist/types/messages/glasses-to-cloud.d.ts.map +1 -1
- package/dist/types/models.d.ts +17 -0
- package/dist/types/models.d.ts.map +1 -1
- package/dist/types/rtmp-stream.d.ts +4 -4
- package/dist/types/rtmp-stream.d.ts.map +1 -1
- package/dist/types/streams.d.ts +6 -1
- package/dist/types/streams.d.ts.map +1 -1
- package/dist/types/webhooks.d.ts +11 -0
- package/dist/types/webhooks.d.ts.map +1 -1
- package/dist/utils/error-utils.d.ts +139 -0
- package/dist/utils/error-utils.d.ts.map +1 -0
- package/dist/utils/permissions-utils.d.ts +30 -7
- package/dist/utils/permissions-utils.d.ts.map +1 -1
- package/node_modules/@mentra/types/dist/applet.d.ts +5 -1
- package/node_modules/@mentra/types/dist/applet.d.ts.map +1 -1
- package/node_modules/@mentra/types/dist/capabilities/even-realities-g2.d.ts +12 -0
- package/node_modules/@mentra/types/dist/capabilities/even-realities-g2.d.ts.map +1 -0
- package/node_modules/@mentra/types/dist/capabilities/even-realities-g2.js +61 -0
- package/node_modules/@mentra/types/dist/capabilities/mentra-display.d.ts +12 -0
- package/node_modules/@mentra/types/dist/capabilities/mentra-display.d.ts.map +1 -0
- package/node_modules/@mentra/types/dist/capabilities/mentra-display.js +54 -0
- package/node_modules/@mentra/types/dist/capabilities/none.d.ts +13 -0
- package/node_modules/@mentra/types/dist/capabilities/none.d.ts.map +1 -0
- package/node_modules/@mentra/types/dist/capabilities/none.js +67 -0
- package/node_modules/@mentra/types/dist/enums.d.ts +8 -2
- package/node_modules/@mentra/types/dist/enums.d.ts.map +1 -1
- package/node_modules/@mentra/types/dist/enums.js +9 -2
- package/node_modules/@mentra/types/dist/hardware.d.ts +3 -1
- package/node_modules/@mentra/types/dist/hardware.d.ts.map +1 -1
- package/node_modules/@mentra/types/dist/hardware.js +12 -2
- package/node_modules/@mentra/types/dist/index.d.ts +1 -1
- package/node_modules/@mentra/types/dist/index.d.ts.map +1 -1
- package/node_modules/@mentra/types/dist/index.js +2 -1
- package/node_modules/@mentra/types/package.json +2 -2
- package/package.json +24 -12
- package/dist/examples/managed-rtmp-streaming-example.d.ts +0 -2
- package/dist/examples/managed-rtmp-streaming-example.d.ts.map +0 -1
- package/dist/examples/managed-rtmp-streaming-with-restream-example.d.ts +0 -11
- package/dist/examples/managed-rtmp-streaming-with-restream-example.d.ts.map +0 -1
- package/dist/examples/rtmp-streaming-example.d.ts +0 -2
- package/dist/examples/rtmp-streaming-example.d.ts.map +0 -1
- package/node_modules/@mentra/types/src/applet.ts +0 -51
- package/node_modules/@mentra/types/src/capabilities/even-realities-g1.ts +0 -63
- package/node_modules/@mentra/types/src/capabilities/mentra-live.ts +0 -103
- package/node_modules/@mentra/types/src/capabilities/simulated-glasses.ts +0 -76
- package/node_modules/@mentra/types/src/capabilities/vuzix-z100.ts +0 -60
- package/node_modules/@mentra/types/src/cli.ts +0 -169
- package/node_modules/@mentra/types/src/device.ts +0 -43
- package/node_modules/@mentra/types/src/enums.ts +0 -36
- package/node_modules/@mentra/types/src/hardware.ts +0 -172
- package/node_modules/@mentra/types/src/index.ts +0 -64
- package/node_modules/@mentra/types/tsconfig.json +0 -22
- package/node_modules/@mentra/types/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PhoneManager — Phone-Scoped Event Management
|
|
3
|
+
*
|
|
4
|
+
* Consolidates all phone-related data streams into a single manager
|
|
5
|
+
* with purpose-built sub-managers:
|
|
6
|
+
*
|
|
7
|
+
* - **notifications** — Phone notification events and dismissals
|
|
8
|
+
* - **calendar** — Calendar event stream
|
|
9
|
+
*
|
|
10
|
+
* Each sub-manager exposes a `hasPermission` getter that delegates to
|
|
11
|
+
* the {@link PermissionsManager}, giving callers a convenient way to
|
|
12
|
+
* check access before subscribing.
|
|
13
|
+
*
|
|
14
|
+
* All handler registrations return a cleanup function. Subscriptions
|
|
15
|
+
* are managed automatically — `addSubscription` is called when the
|
|
16
|
+
* first handler for a stream is registered, and `removeSubscription`
|
|
17
|
+
* when the last handler is removed.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* // Notifications (with permission check)
|
|
22
|
+
* if (phone.notifications.hasPermission) {
|
|
23
|
+
* phone.notifications.on((n) => {
|
|
24
|
+
* console.log(`${n.app}: ${n.title}`);
|
|
25
|
+
* });
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* // Calendar events
|
|
29
|
+
* if (phone.calendar.hasPermission) {
|
|
30
|
+
* phone.calendar.on((event) => {
|
|
31
|
+
* console.log(event.title, event.start, "→", event.end);
|
|
32
|
+
* });
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @module
|
|
37
|
+
*/
|
|
38
|
+
import type { PermissionsManager } from "./PermissionsManager";
|
|
39
|
+
/**
|
|
40
|
+
* Phone notification event delivered from the companion app.
|
|
41
|
+
*/
|
|
42
|
+
export interface PhoneNotificationEvent {
|
|
43
|
+
/** Unique identifier for this notification. */
|
|
44
|
+
notificationId: string;
|
|
45
|
+
/** Source application package/name. */
|
|
46
|
+
app: string;
|
|
47
|
+
/** Notification title. */
|
|
48
|
+
title: string;
|
|
49
|
+
/** Notification body content. */
|
|
50
|
+
content: string;
|
|
51
|
+
/** Notification priority level. */
|
|
52
|
+
priority: "low" | "normal" | "high";
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Event emitted when a phone notification is dismissed by the user.
|
|
56
|
+
*/
|
|
57
|
+
export interface NotificationDismissedEvent {
|
|
58
|
+
/** Unique identifier of the dismissed notification. */
|
|
59
|
+
notificationId: string;
|
|
60
|
+
/** Source application package/name. */
|
|
61
|
+
app: string;
|
|
62
|
+
/** Notification title. */
|
|
63
|
+
title: string;
|
|
64
|
+
/** Notification body content. */
|
|
65
|
+
content: string;
|
|
66
|
+
/** Platform-specific notification key. */
|
|
67
|
+
notificationKey: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Normalised calendar event data.
|
|
71
|
+
*
|
|
72
|
+
* Raw wire fields are normalised for a cleaner developer experience:
|
|
73
|
+
* - `dtStart` → `start`
|
|
74
|
+
* - `dtEnd` → `end`
|
|
75
|
+
* - `timeStamp` → `timestamp`
|
|
76
|
+
*/
|
|
77
|
+
export interface CalendarEventData {
|
|
78
|
+
/** Calendar event identifier. */
|
|
79
|
+
eventId: string;
|
|
80
|
+
/** Event title/summary. */
|
|
81
|
+
title: string;
|
|
82
|
+
/** Normalised start time (ISO string). */
|
|
83
|
+
start: string;
|
|
84
|
+
/** Normalised end time (ISO string). */
|
|
85
|
+
end: string;
|
|
86
|
+
/** Event timezone. */
|
|
87
|
+
timezone: string;
|
|
88
|
+
/** Normalised timestamp of the event update (ISO string). */
|
|
89
|
+
timestamp: string;
|
|
90
|
+
/** Any additional fields from the raw payload. */
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Dependencies injected by MentraSession into the PhoneManager.
|
|
95
|
+
*/
|
|
96
|
+
export interface PhoneManagerDeps {
|
|
97
|
+
/** DataStreamRouter — register for stream-type events. */
|
|
98
|
+
router: {
|
|
99
|
+
on(key: string, handler: (streamType: string, data: any, message: any) => void): () => void;
|
|
100
|
+
};
|
|
101
|
+
/** MessageHandlerRegistry — register for top-level message types. */
|
|
102
|
+
messageHandlers: {
|
|
103
|
+
register(type: string, handler: (msg: any) => void): () => void;
|
|
104
|
+
};
|
|
105
|
+
/** Subscribe to a data stream (sent to cloud). */
|
|
106
|
+
addSubscription: (stream: string) => void;
|
|
107
|
+
/** Unsubscribe from a data stream. */
|
|
108
|
+
removeSubscription: (stream: string) => void;
|
|
109
|
+
/** Send an arbitrary message to the cloud. */
|
|
110
|
+
sendMessage: (message: any) => void;
|
|
111
|
+
/** Session-scoped logger. */
|
|
112
|
+
logger: {
|
|
113
|
+
debug(...args: any[]): void;
|
|
114
|
+
info(...args: any[]): void;
|
|
115
|
+
warn(...args: any[]): void;
|
|
116
|
+
error(...args: any[]): void;
|
|
117
|
+
};
|
|
118
|
+
/** Returns the current app's package name. */
|
|
119
|
+
getPackageName: () => string;
|
|
120
|
+
/** Returns the active session ID. */
|
|
121
|
+
getSessionId: () => string;
|
|
122
|
+
/** PermissionsManager for gating protected streams. */
|
|
123
|
+
permissions: PermissionsManager;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Shared ref-counting logic for stream subscriptions.
|
|
127
|
+
*
|
|
128
|
+
* Tracks handler counts per stream key and calls `addSubscription` /
|
|
129
|
+
* `removeSubscription` at the appropriate lifecycle boundaries.
|
|
130
|
+
* Identical pattern to the `addStreamHandler` private method in DeviceManager,
|
|
131
|
+
* extracted here so all three PhoneManager sub-concerns can share it.
|
|
132
|
+
*/
|
|
133
|
+
declare class StreamHandlerTracker {
|
|
134
|
+
private router;
|
|
135
|
+
private addSubscription;
|
|
136
|
+
private removeSubscription;
|
|
137
|
+
/** Ref-counted handler totals keyed by stream string. */
|
|
138
|
+
private handlerCounts;
|
|
139
|
+
/** All cleanup functions for bulk teardown. */
|
|
140
|
+
private cleanups;
|
|
141
|
+
constructor(router: PhoneManagerDeps["router"], addSubscription: PhoneManagerDeps["addSubscription"], removeSubscription: PhoneManagerDeps["removeSubscription"]);
|
|
142
|
+
/**
|
|
143
|
+
* Register a handler on the DataStreamRouter for a given stream key,
|
|
144
|
+
* managing subscription lifecycle automatically.
|
|
145
|
+
*
|
|
146
|
+
* - Calls `addSubscription` when the first handler for a key is added.
|
|
147
|
+
* - Calls `removeSubscription` when the last handler for a key is removed.
|
|
148
|
+
*
|
|
149
|
+
* @param streamKey - The stream type string
|
|
150
|
+
* @param handler - The stream handler function
|
|
151
|
+
* @returns Cleanup function that unregisters the handler and manages subscription
|
|
152
|
+
*/
|
|
153
|
+
add(streamKey: string, handler: (streamType: string, data: any, message: any) => void): () => void;
|
|
154
|
+
/**
|
|
155
|
+
* Remove all tracked handlers and unsubscribe from all streams.
|
|
156
|
+
* Called during session teardown.
|
|
157
|
+
*/
|
|
158
|
+
destroyAll(): void;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Sub-manager for phone notification streams.
|
|
162
|
+
*
|
|
163
|
+
* Provides handlers for incoming notifications and notification dismissals,
|
|
164
|
+
* plus a convenience `hasPermission` check.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* if (phone.notifications.hasPermission) {
|
|
169
|
+
* phone.notifications.on((n) => {
|
|
170
|
+
* showOnGlasses(`${n.app}: ${n.title}`);
|
|
171
|
+
* });
|
|
172
|
+
*
|
|
173
|
+
* phone.notifications.onDismissed((e) => {
|
|
174
|
+
* removeFromGlasses(e.notificationId);
|
|
175
|
+
* });
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
export declare class NotificationSubManager {
|
|
180
|
+
private permissions;
|
|
181
|
+
private tracker;
|
|
182
|
+
private logger;
|
|
183
|
+
/** @internal */
|
|
184
|
+
constructor(permissions: PermissionsManager, tracker: StreamHandlerTracker, logger: PhoneManagerDeps["logger"]);
|
|
185
|
+
/**
|
|
186
|
+
* Whether the app has the `notifications` permission.
|
|
187
|
+
*
|
|
188
|
+
* Reads from the {@link PermissionsManager} — this is a live check,
|
|
189
|
+
* not a cached value.
|
|
190
|
+
*/
|
|
191
|
+
get hasPermission(): boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Listen for incoming phone notifications.
|
|
194
|
+
*
|
|
195
|
+
* @param handler - Called with {@link PhoneNotificationEvent} for each notification
|
|
196
|
+
* @returns Cleanup function to remove the handler
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* const stop = phone.notifications.on((n) => {
|
|
201
|
+
* console.log(`[${n.priority}] ${n.app}: ${n.title} — ${n.content}`);
|
|
202
|
+
* });
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
on(handler: (notification: PhoneNotificationEvent) => void): () => void;
|
|
206
|
+
/**
|
|
207
|
+
* Listen for notification dismissal events.
|
|
208
|
+
*
|
|
209
|
+
* Fired when the user dismisses a notification on their phone.
|
|
210
|
+
*
|
|
211
|
+
* @param handler - Called with {@link NotificationDismissedEvent} for each dismissal
|
|
212
|
+
* @returns Cleanup function to remove the handler
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```ts
|
|
216
|
+
* phone.notifications.onDismissed((e) => {
|
|
217
|
+
* console.log("Dismissed:", e.notificationId, "from", e.app);
|
|
218
|
+
* });
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
onDismissed(handler: (event: NotificationDismissedEvent) => void): () => void;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Sub-manager for calendar event streams.
|
|
225
|
+
*
|
|
226
|
+
* Normalises raw calendar data (e.g. `dtStart` → `start`) and provides
|
|
227
|
+
* a convenience `hasPermission` check.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```ts
|
|
231
|
+
* if (phone.calendar.hasPermission) {
|
|
232
|
+
* phone.calendar.on((event) => {
|
|
233
|
+
* console.log(`${event.title}: ${event.start} → ${event.end}`);
|
|
234
|
+
* });
|
|
235
|
+
* }
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
export declare class CalendarSubManager {
|
|
239
|
+
private permissions;
|
|
240
|
+
private tracker;
|
|
241
|
+
private logger;
|
|
242
|
+
/** @internal */
|
|
243
|
+
constructor(permissions: PermissionsManager, tracker: StreamHandlerTracker, logger: PhoneManagerDeps["logger"]);
|
|
244
|
+
/**
|
|
245
|
+
* Whether the app has the `calendar` permission.
|
|
246
|
+
*
|
|
247
|
+
* Reads from the {@link PermissionsManager} — this is a live check,
|
|
248
|
+
* not a cached value.
|
|
249
|
+
*/
|
|
250
|
+
get hasPermission(): boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Listen for calendar events from the phone.
|
|
253
|
+
*
|
|
254
|
+
* Raw fields are normalised:
|
|
255
|
+
* - `dtStart` → `start`
|
|
256
|
+
* - `dtEnd` → `end`
|
|
257
|
+
* - `timeStamp` → `timestamp`
|
|
258
|
+
*
|
|
259
|
+
* @param handler - Called with {@link CalendarEventData} for each event
|
|
260
|
+
* @returns Cleanup function to remove the handler
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```ts
|
|
264
|
+
* const stop = phone.calendar.on((event) => {
|
|
265
|
+
* console.log(`${event.title} at ${event.start} (${event.timezone})`);
|
|
266
|
+
* });
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
on(handler: (event: CalendarEventData) => void): () => void;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Manages all phone-related data streams for a MentraSession.
|
|
273
|
+
*
|
|
274
|
+
* Exposes sub-managers for notifications and calendar. Created by MentraSession and exposed as
|
|
275
|
+
* `session.phone`.
|
|
276
|
+
*/
|
|
277
|
+
export declare class PhoneManager {
|
|
278
|
+
/** Notification stream sub-manager. */
|
|
279
|
+
readonly notifications: NotificationSubManager;
|
|
280
|
+
/** Calendar event stream sub-manager. */
|
|
281
|
+
readonly calendar: CalendarSubManager;
|
|
282
|
+
private deps;
|
|
283
|
+
private permissions;
|
|
284
|
+
private tracker;
|
|
285
|
+
constructor(deps: PhoneManagerDeps);
|
|
286
|
+
/**
|
|
287
|
+
* Remove all registered handlers and unsubscribe from all streams.
|
|
288
|
+
*
|
|
289
|
+
* Called by MentraSession during disconnect/teardown.
|
|
290
|
+
* @internal
|
|
291
|
+
*/
|
|
292
|
+
destroy(): void;
|
|
293
|
+
}
|
|
294
|
+
export {};
|
|
295
|
+
//# sourceMappingURL=PhoneManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhoneManager.d.ts","sourceRoot":"","sources":["../../../src/session/managers/PhoneManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI/D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,uDAAuD;IACvD,cAAc,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAMD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0DAA0D;IAC1D,MAAM,EAAE;QACN,EAA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IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,MAAM,IAAI;CAW5D;AAID;;;;;GAKG;AACH,qBAAa,YAAY;IAGvB,uCAAuC;IACvC,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC;IAE/C,yCAAyC;IACzC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IAItC,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,OAAO,CAAuB;gBAE1B,IAAI,EAAE,gBAAgB;IAclC;;;;;OAKG;IACH,OAAO,IAAI,IAAI;CAIhB"}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🔊 SpeakerManager — Audio Output Control
|
|
3
|
+
*
|
|
4
|
+
* v3 manager that wraps the existing AudioManager output functionality.
|
|
5
|
+
* Handles audio playback, text-to-speech, and real-time audio streaming
|
|
6
|
+
* to the user's glasses speaker.
|
|
7
|
+
*
|
|
8
|
+
* Wire message formats are identical to v2 so the cloud receives the
|
|
9
|
+
* same AUDIO_PLAY_REQUEST, AUDIO_STOP_REQUEST, AUDIO_STREAM_START,
|
|
10
|
+
* AUDIO_STREAM_END, and binary frame protocol.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const speaker = new SpeakerManager(deps);
|
|
15
|
+
*
|
|
16
|
+
* // Play a URL
|
|
17
|
+
* const result = await speaker.play({ url: "https://example.com/sound.mp3" });
|
|
18
|
+
*
|
|
19
|
+
* // Text-to-speech
|
|
20
|
+
* await speaker.speak("Hello, world!", { volume: 0.8 });
|
|
21
|
+
*
|
|
22
|
+
* // Real-time streaming
|
|
23
|
+
* const stream = await speaker.createStream({ format: "mp3" });
|
|
24
|
+
* stream.write(mp3Chunk);
|
|
25
|
+
* await stream.end();
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Shared dependency bag injected by MentraSession.
|
|
30
|
+
* Keeps managers decoupled from the session implementation.
|
|
31
|
+
*/
|
|
32
|
+
export interface ManagerDeps {
|
|
33
|
+
/** DataStreamRouter — register for DATA_STREAM messages by streamType key. */
|
|
34
|
+
router: {
|
|
35
|
+
on(key: string, handler: (streamType: string, data: any, message: any) => void): () => void;
|
|
36
|
+
};
|
|
37
|
+
/** MessageHandlerRegistry — register for top-level message types. */
|
|
38
|
+
messageHandlers: {
|
|
39
|
+
register(type: string, handler: (msg: any) => void): () => void;
|
|
40
|
+
};
|
|
41
|
+
addSubscription: (stream: string) => void;
|
|
42
|
+
removeSubscription: (stream: string) => void;
|
|
43
|
+
sendMessage: (message: any) => void;
|
|
44
|
+
sendBinary: (data: ArrayBuffer | Uint8Array) => void;
|
|
45
|
+
logger: {
|
|
46
|
+
debug(...args: any[]): void;
|
|
47
|
+
info(...args: any[]): void;
|
|
48
|
+
warn(...args: any[]): void;
|
|
49
|
+
error(...args: any[]): void;
|
|
50
|
+
};
|
|
51
|
+
getPackageName: () => string;
|
|
52
|
+
getSessionId: () => string;
|
|
53
|
+
}
|
|
54
|
+
/** Audio track identifier. Multiple tracks can play simultaneously (mixing). */
|
|
55
|
+
export type TrackId = 0 | 1 | 2;
|
|
56
|
+
/**
|
|
57
|
+
* Options for playing an audio file from a URL.
|
|
58
|
+
*/
|
|
59
|
+
export interface PlayOptions {
|
|
60
|
+
/** URL of the audio file to play */
|
|
61
|
+
url: string;
|
|
62
|
+
/** Volume level 0.0–1.0. Default: 1.0 */
|
|
63
|
+
volume?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Track ID for playback.
|
|
66
|
+
* - 0: speaker (default audio playback)
|
|
67
|
+
* - 1: app_audio (app-specific audio)
|
|
68
|
+
* - 2: tts (text-to-speech audio)
|
|
69
|
+
* Default: 0
|
|
70
|
+
*/
|
|
71
|
+
trackId?: TrackId;
|
|
72
|
+
/** Whether starting playback should stop other audio. Default: false */
|
|
73
|
+
stopOtherAudio?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Result returned when audio playback completes.
|
|
77
|
+
*/
|
|
78
|
+
export interface PlayResult {
|
|
79
|
+
/** Duration of the audio in milliseconds (when available) */
|
|
80
|
+
duration: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Options for text-to-speech playback.
|
|
84
|
+
*/
|
|
85
|
+
export interface SpeakOptions {
|
|
86
|
+
/** ElevenLabs voice ID (optional — server picks a default) */
|
|
87
|
+
voiceId?: string;
|
|
88
|
+
/** ElevenLabs model ID (optional — defaults to eleven_flash_v2_5) */
|
|
89
|
+
modelId?: string;
|
|
90
|
+
/** Fine-grained voice settings */
|
|
91
|
+
voiceSettings?: {
|
|
92
|
+
stability?: number;
|
|
93
|
+
similarityBoost?: number;
|
|
94
|
+
style?: number;
|
|
95
|
+
speed?: number;
|
|
96
|
+
};
|
|
97
|
+
/** Volume level 0.0–1.0. Default: 1.0 */
|
|
98
|
+
volume?: number;
|
|
99
|
+
/**
|
|
100
|
+
* Track ID for playback. Default: 2 (tts)
|
|
101
|
+
*/
|
|
102
|
+
trackId?: TrackId;
|
|
103
|
+
/** Whether starting playback should stop other audio. Default: false */
|
|
104
|
+
stopOtherAudio?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Options for creating a real-time audio output stream.
|
|
108
|
+
*/
|
|
109
|
+
export interface StreamOptions {
|
|
110
|
+
/**
|
|
111
|
+
* Format of the audio being written.
|
|
112
|
+
* - "mp3": MP3 bytes passed through directly (ElevenLabs, OpenAI TTS, etc.)
|
|
113
|
+
* - "pcm16": Raw 16-bit signed PCM samples (SDK encodes to MP3 before sending)
|
|
114
|
+
* Default: "mp3"
|
|
115
|
+
*/
|
|
116
|
+
format?: "mp3" | "pcm16";
|
|
117
|
+
/** PCM sample rate in Hz (required when format is "pcm16"). Default: 24000 */
|
|
118
|
+
sampleRate?: number;
|
|
119
|
+
/** Number of audio channels. Default: 1 (mono) */
|
|
120
|
+
channels?: 1 | 2;
|
|
121
|
+
/** MP3 bitrate in kbps for PCM encoding. Default: 128 */
|
|
122
|
+
bitrate?: number;
|
|
123
|
+
/** Volume level 0.0–1.0. Default: 1.0 */
|
|
124
|
+
volume?: number;
|
|
125
|
+
/**
|
|
126
|
+
* Track ID for playback. Default: 1 (app_audio)
|
|
127
|
+
*/
|
|
128
|
+
trackId?: TrackId;
|
|
129
|
+
/** Whether starting the stream should stop other audio. Default: true */
|
|
130
|
+
stopOtherAudio?: boolean;
|
|
131
|
+
}
|
|
132
|
+
/** Lifecycle state of an AudioOutputStream */
|
|
133
|
+
export type AudioOutputStreamState = "created" | "streaming" | "ending" | "ended" | "error";
|
|
134
|
+
/**
|
|
135
|
+
* A real-time audio output stream.
|
|
136
|
+
*
|
|
137
|
+
* Audio data is sent as binary WebSocket frames with the protocol:
|
|
138
|
+
* [36 bytes: streamId UUID as ASCII] [N bytes: audio data]
|
|
139
|
+
*
|
|
140
|
+
* The cloud pipes those bytes into an HTTP chunked response that the
|
|
141
|
+
* phone's media player consumes like internet radio.
|
|
142
|
+
*/
|
|
143
|
+
export interface AudioOutputStream {
|
|
144
|
+
/** Unique stream identifier (UUID) */
|
|
145
|
+
readonly id: string;
|
|
146
|
+
/** Current lifecycle state */
|
|
147
|
+
readonly state: AudioOutputStreamState;
|
|
148
|
+
/** Write audio data to the stream */
|
|
149
|
+
write(chunk: Uint8Array): void;
|
|
150
|
+
/** Gracefully end the stream — phone finishes buffered audio */
|
|
151
|
+
end(): Promise<void>;
|
|
152
|
+
/** Flush/interrupt — discard buffered audio, silence immediately */
|
|
153
|
+
flush(): void;
|
|
154
|
+
/** Register a callback for state changes */
|
|
155
|
+
onStateChange(handler: (state: AudioOutputStreamState) => void): void;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Controls audio output on the user's glasses speaker.
|
|
159
|
+
*
|
|
160
|
+
* Provides methods for:
|
|
161
|
+
* - 🎵 Playing audio files from URLs
|
|
162
|
+
* - ⏹️ Stopping audio playback
|
|
163
|
+
* - 🗣️ Text-to-speech via ElevenLabs
|
|
164
|
+
* - 🎙️ Real-time audio streaming
|
|
165
|
+
*
|
|
166
|
+
* All messages use the same wire format as v2 AudioManager — the cloud
|
|
167
|
+
* and phone receive identical AUDIO_PLAY_REQUEST / AUDIO_STOP_REQUEST /
|
|
168
|
+
* AUDIO_STREAM_* messages.
|
|
169
|
+
*/
|
|
170
|
+
export declare class SpeakerManager {
|
|
171
|
+
private readonly deps;
|
|
172
|
+
/**
|
|
173
|
+
* Map of pending play requests awaiting AUDIO_PLAY_RESPONSE.
|
|
174
|
+
* Key: requestId, Value: promise resolve/reject pair.
|
|
175
|
+
*/
|
|
176
|
+
private pendingRequests;
|
|
177
|
+
/** Currently active output stream (at most one at a time) */
|
|
178
|
+
private activeStream;
|
|
179
|
+
/** Cached permission state */
|
|
180
|
+
private _hasPermission;
|
|
181
|
+
/** Cleanup function for the AUDIO_PLAY_RESPONSE message handler registration */
|
|
182
|
+
private responseHandlerCleanup;
|
|
183
|
+
constructor(deps: ManagerDeps);
|
|
184
|
+
/**
|
|
185
|
+
* Whether the app has speaker permission.
|
|
186
|
+
* Updated when the cloud sends permission state changes.
|
|
187
|
+
*/
|
|
188
|
+
get hasPermission(): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* 🎵 Play an audio file from a URL on the glasses speaker.
|
|
191
|
+
*
|
|
192
|
+
* If `stopOtherAudio` is false (default), resolves immediately in
|
|
193
|
+
* fire-and-forget mode so multiple tracks can play concurrently.
|
|
194
|
+
* If `stopOtherAudio` is true, waits for the cloud's AUDIO_PLAY_RESPONSE.
|
|
195
|
+
*
|
|
196
|
+
* @param opts - Playback options (url is required)
|
|
197
|
+
* @returns Promise resolving with playback result
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const result = await speaker.play({
|
|
202
|
+
* url: "https://example.com/sound.mp3",
|
|
203
|
+
* volume: 0.8,
|
|
204
|
+
* trackId: 0,
|
|
205
|
+
* });
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
play(opts: PlayOptions): Promise<PlayResult>;
|
|
209
|
+
/**
|
|
210
|
+
* ⏹️ Stop audio playback on the glasses.
|
|
211
|
+
*
|
|
212
|
+
* @param trackId - Specific track to stop. If omitted, stops all tracks.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```ts
|
|
216
|
+
* // Stop all audio
|
|
217
|
+
* await speaker.stop();
|
|
218
|
+
*
|
|
219
|
+
* // Stop only the TTS track
|
|
220
|
+
* await speaker.stop(2);
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
stop(trackId?: TrackId): Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* 🗣️ Convert text to speech and play it on the glasses speaker.
|
|
226
|
+
*
|
|
227
|
+
* Uses the server-side TTS endpoint which proxies to ElevenLabs.
|
|
228
|
+
* The generated audio URL is then played via the standard play() path.
|
|
229
|
+
*
|
|
230
|
+
* @param text - Text to speak (required)
|
|
231
|
+
* @param opts - TTS configuration (optional)
|
|
232
|
+
* @returns Promise resolving with playback result
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```ts
|
|
236
|
+
* await speaker.speak("Hello, world!");
|
|
237
|
+
*
|
|
238
|
+
* await speaker.speak("Good morning!", {
|
|
239
|
+
* voiceId: "custom_voice_id",
|
|
240
|
+
* voiceSettings: { stability: 0.5, speed: 1.2 },
|
|
241
|
+
* volume: 0.8,
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
speak(text: string, opts?: SpeakOptions): Promise<PlayResult>;
|
|
246
|
+
/**
|
|
247
|
+
* 🎙️ Create a real-time audio output stream.
|
|
248
|
+
*
|
|
249
|
+
* Opens a streaming relay on the cloud and tells the phone to play it.
|
|
250
|
+
* Write audio chunks to the returned stream and they play on the glasses
|
|
251
|
+
* speaker in real-time — like internet radio.
|
|
252
|
+
*
|
|
253
|
+
* Only one stream can be active at a time. Call `end()` or `flush()` on
|
|
254
|
+
* the current stream before creating a new one.
|
|
255
|
+
*
|
|
256
|
+
* @param opts - Stream configuration
|
|
257
|
+
* @returns The AudioOutputStream (already connected and playing)
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* // MP3 pass-through (most common)
|
|
262
|
+
* const stream = await speaker.createStream({ format: "mp3" });
|
|
263
|
+
* elevenLabs.on("chunk", (mp3) => stream.write(mp3));
|
|
264
|
+
* elevenLabs.on("end", () => stream.end());
|
|
265
|
+
*
|
|
266
|
+
* // Interrupt on user speech
|
|
267
|
+
* mic.onVoiceActivity((vad) => {
|
|
268
|
+
* if (vad.isSpeaking) stream.flush();
|
|
269
|
+
* });
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
createStream(opts?: StreamOptions): Promise<AudioOutputStream>;
|
|
273
|
+
/**
|
|
274
|
+
* Cancel all pending requests and end any active stream.
|
|
275
|
+
* Called by MentraSession during disconnect/cleanup.
|
|
276
|
+
* @internal
|
|
277
|
+
*/
|
|
278
|
+
destroy(): void;
|
|
279
|
+
/**
|
|
280
|
+
* Handle AUDIO_PLAY_RESPONSE from the cloud.
|
|
281
|
+
* Resolves or rejects the corresponding pending play() promise.
|
|
282
|
+
*/
|
|
283
|
+
private handleAudioPlayResponse;
|
|
284
|
+
}
|
|
285
|
+
//# sourceMappingURL=SpeakerManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpeakerManager.d.ts","sourceRoot":"","sources":["../../../src/session/managers/SpeakerManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAMH;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,8EAA8E;IAC9E,MAAM,EAAE;QACN,EAAE,CAAC,GAAG,EAAE,MAA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