@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.
Files changed (169) hide show
  1. package/README.md +54 -9
  2. package/dist/MiniAppServer.d.ts +58 -0
  3. package/dist/MiniAppServer.d.ts.map +1 -0
  4. package/dist/app/server/index.d.ts +143 -88
  5. package/dist/app/server/index.d.ts.map +1 -1
  6. package/dist/app/session/events.d.ts +20 -3
  7. package/dist/app/session/events.d.ts.map +1 -1
  8. package/dist/app/session/index.d.ts +56 -3
  9. package/dist/app/session/index.d.ts.map +1 -1
  10. package/dist/app/session/modules/audio-output-stream.d.ts +108 -0
  11. package/dist/app/session/modules/audio-output-stream.d.ts.map +1 -0
  12. package/dist/app/session/modules/audio.d.ts +36 -1
  13. package/dist/app/session/modules/audio.d.ts.map +1 -1
  14. package/dist/app/session/modules/camera-managed-extension.d.ts +37 -33
  15. package/dist/app/session/modules/camera-managed-extension.d.ts.map +1 -1
  16. package/dist/app/session/modules/camera.d.ts +108 -50
  17. package/dist/app/session/modules/camera.d.ts.map +1 -1
  18. package/dist/app/session/modules/index.d.ts +4 -3
  19. package/dist/app/session/modules/index.d.ts.map +1 -1
  20. package/dist/app/session/modules/led.d.ts.map +1 -1
  21. package/dist/app/session/modules/location.d.ts.map +1 -1
  22. package/dist/app/session/settings.d.ts +5 -1
  23. package/dist/app/session/settings.d.ts.map +1 -1
  24. package/dist/app/webview/index.d.ts +67 -9
  25. package/dist/app/webview/index.d.ts.map +1 -1
  26. package/dist/constants/log-messages/updates.d.ts +32 -9
  27. package/dist/constants/log-messages/updates.d.ts.map +1 -1
  28. package/dist/constants/log-messages/warning.d.ts +12 -0
  29. package/dist/constants/log-messages/warning.d.ts.map +1 -1
  30. package/dist/display-utils.d.ts +3 -1
  31. package/dist/display-utils.d.ts.map +1 -1
  32. package/dist/display-utils.js +443 -26
  33. package/dist/display-utils.js.map +10 -6
  34. package/dist/index.d.ts +22 -14
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +8877 -4236
  37. package/dist/index.js.map +63 -31
  38. package/dist/internal/_SessionManager.d.ts +76 -0
  39. package/dist/internal/_SessionManager.d.ts.map +1 -0
  40. package/dist/logging/clean-transport.d.ts +50 -0
  41. package/dist/logging/clean-transport.d.ts.map +1 -0
  42. package/dist/logging/errors.d.ts +90 -0
  43. package/dist/logging/errors.d.ts.map +1 -0
  44. package/dist/logging/logger.d.ts +72 -1
  45. package/dist/logging/logger.d.ts.map +1 -1
  46. package/dist/logging/telemetry-transport.d.ts +51 -0
  47. package/dist/logging/telemetry-transport.d.ts.map +1 -0
  48. package/dist/session/DataStreamRouter.d.ts +219 -0
  49. package/dist/session/DataStreamRouter.d.ts.map +1 -0
  50. package/dist/session/MentraSession.d.ts +102 -0
  51. package/dist/session/MentraSession.d.ts.map +1 -0
  52. package/dist/session/index.d.ts +2 -0
  53. package/dist/session/index.d.ts.map +1 -0
  54. package/dist/session/internal/_ConnectionManager.d.ts +43 -0
  55. package/dist/session/internal/_ConnectionManager.d.ts.map +1 -0
  56. package/dist/session/internal/_MessageRouter.d.ts +11 -0
  57. package/dist/session/internal/_MessageRouter.d.ts.map +1 -0
  58. package/dist/session/internal/_SubscriptionManager.d.ts +32 -0
  59. package/dist/session/internal/_SubscriptionManager.d.ts.map +1 -0
  60. package/dist/session/internal/_V2AudioStreamShim.d.ts +12 -0
  61. package/dist/session/internal/_V2AudioStreamShim.d.ts.map +1 -0
  62. package/dist/session/internal/_V2CameraShim.d.ts +51 -0
  63. package/dist/session/internal/_V2CameraShim.d.ts.map +1 -0
  64. package/dist/session/internal/_V2EventManagerShim.d.ts +51 -0
  65. package/dist/session/internal/_V2EventManagerShim.d.ts.map +1 -0
  66. package/dist/session/internal/_V2SessionShim.d.ts +165 -0
  67. package/dist/session/internal/_V2SessionShim.d.ts.map +1 -0
  68. package/dist/session/internal/_V2SettingsShim.d.ts +17 -0
  69. package/dist/session/internal/_V2SettingsShim.d.ts.map +1 -0
  70. package/dist/session/managers/CameraManager.d.ts +197 -0
  71. package/dist/session/managers/CameraManager.d.ts.map +1 -0
  72. package/dist/session/managers/DashboardManager.d.ts +131 -0
  73. package/dist/session/managers/DashboardManager.d.ts.map +1 -0
  74. package/dist/session/managers/DeviceManager.d.ts +332 -0
  75. package/dist/session/managers/DeviceManager.d.ts.map +1 -0
  76. package/dist/session/managers/DisplayManager.d.ts +171 -0
  77. package/dist/session/managers/DisplayManager.d.ts.map +1 -0
  78. package/dist/session/managers/LedManager.d.ts +131 -0
  79. package/dist/session/managers/LedManager.d.ts.map +1 -0
  80. package/dist/session/managers/LocationManager.d.ts +255 -0
  81. package/dist/session/managers/LocationManager.d.ts.map +1 -0
  82. package/dist/session/managers/MicManager.d.ts +252 -0
  83. package/dist/session/managers/MicManager.d.ts.map +1 -0
  84. package/dist/session/managers/PermissionsManager.d.ts +182 -0
  85. package/dist/session/managers/PermissionsManager.d.ts.map +1 -0
  86. package/dist/session/managers/PhoneManager.d.ts +295 -0
  87. package/dist/session/managers/PhoneManager.d.ts.map +1 -0
  88. package/dist/session/managers/SpeakerManager.d.ts +285 -0
  89. package/dist/session/managers/SpeakerManager.d.ts.map +1 -0
  90. package/dist/session/managers/StorageManager.d.ts +289 -0
  91. package/dist/session/managers/StorageManager.d.ts.map +1 -0
  92. package/dist/session/managers/TimeUtils.d.ts +175 -0
  93. package/dist/session/managers/TimeUtils.d.ts.map +1 -0
  94. package/dist/session/managers/TranscriptionManager.d.ts +195 -0
  95. package/dist/session/managers/TranscriptionManager.d.ts.map +1 -0
  96. package/dist/session/managers/TranslationManager.d.ts +189 -0
  97. package/dist/session/managers/TranslationManager.d.ts.map +1 -0
  98. package/dist/session.d.ts +41 -0
  99. package/dist/session.d.ts.map +1 -0
  100. package/dist/session.js +4168 -0
  101. package/dist/session.js.map +44 -0
  102. package/dist/transport/Transport.d.ts +119 -0
  103. package/dist/transport/Transport.d.ts.map +1 -0
  104. package/dist/transport/WebSocketTransport.d.ts +73 -0
  105. package/dist/transport/WebSocketTransport.d.ts.map +1 -0
  106. package/dist/types/index.d.ts +31 -5
  107. package/dist/types/index.d.ts.map +1 -1
  108. package/dist/types/message-types.d.ts +25 -9
  109. package/dist/types/message-types.d.ts.map +1 -1
  110. package/dist/types/messages/app-to-cloud.d.ts +113 -16
  111. package/dist/types/messages/app-to-cloud.d.ts.map +1 -1
  112. package/dist/types/messages/cloud-to-app.d.ts +50 -4
  113. package/dist/types/messages/cloud-to-app.d.ts.map +1 -1
  114. package/dist/types/messages/cloud-to-glasses.d.ts +43 -14
  115. package/dist/types/messages/cloud-to-glasses.d.ts.map +1 -1
  116. package/dist/types/messages/glasses-to-cloud.d.ts +5 -5
  117. package/dist/types/messages/glasses-to-cloud.d.ts.map +1 -1
  118. package/dist/types/models.d.ts +17 -0
  119. package/dist/types/models.d.ts.map +1 -1
  120. package/dist/types/rtmp-stream.d.ts +4 -4
  121. package/dist/types/rtmp-stream.d.ts.map +1 -1
  122. package/dist/types/streams.d.ts +6 -1
  123. package/dist/types/streams.d.ts.map +1 -1
  124. package/dist/types/webhooks.d.ts +11 -0
  125. package/dist/types/webhooks.d.ts.map +1 -1
  126. package/dist/utils/error-utils.d.ts +139 -0
  127. package/dist/utils/error-utils.d.ts.map +1 -0
  128. package/dist/utils/permissions-utils.d.ts +30 -7
  129. package/dist/utils/permissions-utils.d.ts.map +1 -1
  130. package/node_modules/@mentra/types/dist/applet.d.ts +5 -1
  131. package/node_modules/@mentra/types/dist/applet.d.ts.map +1 -1
  132. package/node_modules/@mentra/types/dist/capabilities/even-realities-g2.d.ts +12 -0
  133. package/node_modules/@mentra/types/dist/capabilities/even-realities-g2.d.ts.map +1 -0
  134. package/node_modules/@mentra/types/dist/capabilities/even-realities-g2.js +61 -0
  135. package/node_modules/@mentra/types/dist/capabilities/mentra-display.d.ts +12 -0
  136. package/node_modules/@mentra/types/dist/capabilities/mentra-display.d.ts.map +1 -0
  137. package/node_modules/@mentra/types/dist/capabilities/mentra-display.js +54 -0
  138. package/node_modules/@mentra/types/dist/capabilities/none.d.ts +13 -0
  139. package/node_modules/@mentra/types/dist/capabilities/none.d.ts.map +1 -0
  140. package/node_modules/@mentra/types/dist/capabilities/none.js +67 -0
  141. package/node_modules/@mentra/types/dist/enums.d.ts +8 -2
  142. package/node_modules/@mentra/types/dist/enums.d.ts.map +1 -1
  143. package/node_modules/@mentra/types/dist/enums.js +9 -2
  144. package/node_modules/@mentra/types/dist/hardware.d.ts +3 -1
  145. package/node_modules/@mentra/types/dist/hardware.d.ts.map +1 -1
  146. package/node_modules/@mentra/types/dist/hardware.js +12 -2
  147. package/node_modules/@mentra/types/dist/index.d.ts +1 -1
  148. package/node_modules/@mentra/types/dist/index.d.ts.map +1 -1
  149. package/node_modules/@mentra/types/dist/index.js +2 -1
  150. package/node_modules/@mentra/types/package.json +2 -2
  151. package/package.json +24 -12
  152. package/dist/examples/managed-rtmp-streaming-example.d.ts +0 -2
  153. package/dist/examples/managed-rtmp-streaming-example.d.ts.map +0 -1
  154. package/dist/examples/managed-rtmp-streaming-with-restream-example.d.ts +0 -11
  155. package/dist/examples/managed-rtmp-streaming-with-restream-example.d.ts.map +0 -1
  156. package/dist/examples/rtmp-streaming-example.d.ts +0 -2
  157. package/dist/examples/rtmp-streaming-example.d.ts.map +0 -1
  158. package/node_modules/@mentra/types/src/applet.ts +0 -51
  159. package/node_modules/@mentra/types/src/capabilities/even-realities-g1.ts +0 -63
  160. package/node_modules/@mentra/types/src/capabilities/mentra-live.ts +0 -103
  161. package/node_modules/@mentra/types/src/capabilities/simulated-glasses.ts +0 -76
  162. package/node_modules/@mentra/types/src/capabilities/vuzix-z100.ts +0 -60
  163. package/node_modules/@mentra/types/src/cli.ts +0 -169
  164. package/node_modules/@mentra/types/src/device.ts +0 -43
  165. package/node_modules/@mentra/types/src/enums.ts +0 -36
  166. package/node_modules/@mentra/types/src/hardware.ts +0 -172
  167. package/node_modules/@mentra/types/src/index.ts +0 -64
  168. package/node_modules/@mentra/types/tsconfig.json +0 -22
  169. package/node_modules/@mentra/types/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,171 @@
1
+ /**
2
+ * 🖥️ DisplayManager — AR Display Control
3
+ *
4
+ * v3 manager that wraps the existing LayoutManager display functionality.
5
+ * Sends DisplayRequest messages to the cloud with identical wire format
6
+ * to ensure backward compatibility.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const display = new DisplayManager(deps);
11
+ *
12
+ * // Simple text
13
+ * display.showText("Hello AR World!");
14
+ *
15
+ * // Pre-wrapped lines
16
+ * display.showText(["Line 1", "Line 2"]);
17
+ *
18
+ * // Structured layouts
19
+ * display.showReferenceCard("Weather", "Sunny and 75°F");
20
+ * display.showDashboardCard("BPM", "72");
21
+ *
22
+ * // Clear the display
23
+ * display.clear();
24
+ * ```
25
+ */
26
+ /**
27
+ * Shared dependency bag injected by MentraSession.
28
+ * Keeps managers decoupled from the session implementation.
29
+ */
30
+ export interface ManagerDeps {
31
+ /** DataStreamRouter — register for DATA_STREAM messages by streamType key. */
32
+ router: {
33
+ on(key: string, handler: (streamType: string, data: any, message: any) => void): () => void;
34
+ };
35
+ /** MessageHandlerRegistry — register for top-level message types. */
36
+ messageHandlers: {
37
+ register(type: string, handler: (msg: any) => void): () => void;
38
+ };
39
+ addSubscription: (stream: string) => void;
40
+ removeSubscription: (stream: string) => void;
41
+ sendMessage: (message: any) => void;
42
+ sendBinary: (data: ArrayBuffer | Uint8Array) => void;
43
+ logger: {
44
+ debug(...args: any[]): void;
45
+ info(...args: any[]): void;
46
+ warn(...args: any[]): void;
47
+ error(...args: any[]): void;
48
+ };
49
+ getPackageName: () => string;
50
+ getSessionId: () => string;
51
+ }
52
+ /**
53
+ * Controls the AR display on the user's glasses.
54
+ *
55
+ * Provides high-level methods for showing text, cards, bitmaps, and
56
+ * clearing the display. All methods produce a `DisplayRequest` message
57
+ * with `type: "display_event"` — the exact same wire format the cloud
58
+ * and glasses firmware already understand from v2.
59
+ */
60
+ export declare class DisplayManager {
61
+ private readonly deps;
62
+ constructor(deps: ManagerDeps);
63
+ /**
64
+ * Show text on the AR display.
65
+ *
66
+ * Accepts a single string or an array of pre-wrapped lines.
67
+ * When an array is provided the lines are joined with newlines
68
+ * and sent as a single TextWall layout.
69
+ *
70
+ * @param text - A string or array of strings to display
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * display.showText("Connected to server");
75
+ * display.showText(["Line 1", "Line 2", "Line 3"]);
76
+ * ```
77
+ */
78
+ showText(text: string | string[]): void;
79
+ /**
80
+ * 📝 Show a single block of text on the main display.
81
+ *
82
+ * Best for simple messages, status updates, and notifications.
83
+ *
84
+ * @param text - Text content to display
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * display.showTextWall("Listening…");
89
+ * ```
90
+ */
91
+ showTextWall(text: string): void;
92
+ /**
93
+ * ↕️ Show two sections of text, one above the other.
94
+ *
95
+ * Best for before/after content, question/answer, translations,
96
+ * or any two-part message.
97
+ *
98
+ * @param leftText - Text for the top section
99
+ * @param rightText - Text for the bottom section
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * display.showDoubleTextWall("Original: Hello", "Translated: Bonjour");
104
+ * ```
105
+ */
106
+ showDoubleTextWall(leftText: string, rightText: string): void;
107
+ /**
108
+ * 📇 Show a card with a title and body text.
109
+ *
110
+ * Best for titled content, important information, and notifications
111
+ * with context.
112
+ *
113
+ * @param title - Card title
114
+ * @param body - Main content text
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * display.showReferenceCard("Meeting Reminder", "Team standup in 5 minutes");
119
+ * ```
120
+ */
121
+ showReferenceCard(title: string, body: string): void;
122
+ /**
123
+ * 📊 Show a dashboard card with left and right text.
124
+ *
125
+ * Best for key-value pairs, metrics, and dashboard-style displays.
126
+ * Automatically uses the DASHBOARD view type.
127
+ *
128
+ * @param leftText - Left side text (typically label/key)
129
+ * @param rightText - Right side text (typically value)
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * display.showDashboardCard("Weather", "72°F");
134
+ * ```
135
+ */
136
+ showDashboardCard(leftText: string, rightText: string): void;
137
+ /**
138
+ * 🖼️ Show a bitmap image on the display.
139
+ *
140
+ * @param data - Hex or base64 encoded bitmap data string
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * display.showBitmap(base64EncodedBitmapString);
145
+ * ```
146
+ */
147
+ showBitmap(data: any): void;
148
+ /**
149
+ * 🧹 Clear the AR display.
150
+ *
151
+ * Removes any currently shown content from the main view.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * display.clear();
156
+ * ```
157
+ */
158
+ clear(): void;
159
+ /**
160
+ * Build and send a DisplayRequest message.
161
+ *
162
+ * Wire format is identical to v2 LayoutManager — the cloud receives
163
+ * the same `{ type: "display_event", packageName, view, layout, … }`.
164
+ *
165
+ * @param layout - The layout configuration to display
166
+ * @param view - View type (main or dashboard), defaults to MAIN
167
+ * @param durationMs - Optional display duration in milliseconds
168
+ */
169
+ private sendDisplayEvent;
170
+ }
171
+ //# sourceMappingURL=DisplayManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DisplayManager.d.ts","sourceRoot":"","sources":["../../../src/session/managers/DisplayManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAiBH;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,8EAA8E;IAC9E,MAAM,EAAE;QACN,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;KAC7F,CAAC;IACF,qEAAqE;IACrE,eAAe,EAAE;QACf,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;KACjE,CAAC;IACF,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,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G,IAAI;IAkB3B;;;;;;;;;OASG;IACH,KAAK,IAAI,IAAI;IASb;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB;CAgCzB"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * LedManager — v3 SDK LED Control API
3
+ *
4
+ * Thin wrapper around the existing LedModule patterns. Provides a simplified
5
+ * API for controlling RGB LEDs on connected smart glasses.
6
+ *
7
+ * Wire format is identical to v2:
8
+ * ```json
9
+ * {
10
+ * "type": "rgb_led_control",
11
+ * "packageName": "<packageName>",
12
+ * "sessionId": "<sessionId>",
13
+ * "requestId": "<requestId>",
14
+ * "action": "on" | "off",
15
+ * "color": "<LedColor>",
16
+ * "ontime": <ms>
17
+ * }
18
+ * ```
19
+ *
20
+ * @module
21
+ */
22
+ /**
23
+ * Dependencies injected by MentraSession.
24
+ *
25
+ * Structural type — no concrete imports so the manager stays unit-testable
26
+ * with plain stubs.
27
+ */
28
+ export interface LedManagerDeps {
29
+ /** DataStreamRouter — register for DATA_STREAM messages by streamType key. */
30
+ router: {
31
+ on(key: string, handler: (streamType: string, data: any, message: any) => void): () => void;
32
+ };
33
+ /** MessageHandlerRegistry — register for top-level message types. */
34
+ messageHandlers: {
35
+ register(type: string, handler: (msg: any) => void): () => void;
36
+ };
37
+ /** Add a subscription string (triggers SUBSCRIPTION_UPDATE to cloud). */
38
+ addSubscription: (stream: string) => void;
39
+ /** Remove a subscription string. */
40
+ removeSubscription: (stream: string) => void;
41
+ /** Send an arbitrary JSON message over the WebSocket. */
42
+ sendMessage: (message: any) => void;
43
+ /** Structured logger. */
44
+ logger: {
45
+ debug(...args: any[]): void;
46
+ info(...args: any[]): void;
47
+ warn(...args: any[]): void;
48
+ error(...args: any[]): void;
49
+ };
50
+ /** Package name for outgoing messages. */
51
+ getPackageName: () => string;
52
+ /** Current session ID. */
53
+ getSessionId: () => string;
54
+ }
55
+ /**
56
+ * Controls RGB LEDs on connected smart glasses.
57
+ *
58
+ * LED commands are fire-and-forget — the methods return immediately after
59
+ * sending the control message to the cloud. No response is awaited.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const session = await mentra.connect();
64
+ *
65
+ * // Solid green LED for 2 seconds
66
+ * session.led.setColor("green", 2000);
67
+ *
68
+ * // Turn LED off
69
+ * session.led.off();
70
+ * ```
71
+ */
72
+ /** Options for LED blink patterns. */
73
+ export interface LedBlinkOptions {
74
+ /** How long the LED stays on per cycle (ms). */
75
+ onTime: number;
76
+ /** How long the LED stays off between cycles (ms). */
77
+ offTime: number;
78
+ /** Number of on/off cycles. */
79
+ count: number;
80
+ }
81
+ export declare class LedManager {
82
+ private readonly deps;
83
+ constructor(deps: LedManagerDeps);
84
+ /**
85
+ * Set the LED to a specific colour.
86
+ *
87
+ * Sends an `rgb_led_control` message with `action: "on"` to the cloud.
88
+ *
89
+ * Three calling styles:
90
+ * - `setColor(color)` - on for 1000ms (default)
91
+ * - `setColor(color, durationMs)` - on for the specified duration
92
+ * - `setColor(color, { onTime, offTime, count })` - blink pattern
93
+ *
94
+ * @param color - LED colour name. One of `"red"`, `"green"`, `"blue"`, `"orange"`, `"white"`.
95
+ * @param durationOrOptions - Duration in ms, or an options object for blink patterns.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * // Red LED for 500ms
100
+ * session.led.setColor("red", 500);
101
+ *
102
+ * // White LED for the default 1s
103
+ * session.led.setColor("white");
104
+ *
105
+ * // Blink green 3 times (500ms on, 500ms off)
106
+ * session.led.setColor("green", { onTime: 500, offTime: 500, count: 3 });
107
+ * ```
108
+ */
109
+ setColor(color: string, durationOrOptions?: number | LedBlinkOptions): void;
110
+ /**
111
+ * Turn the LED off.
112
+ *
113
+ * Sends an `rgb_led_control` message with `action: "off"` to the cloud.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * session.led.off();
118
+ * ```
119
+ */
120
+ off(): void;
121
+ /**
122
+ * Clean up resources.
123
+ *
124
+ * Called by MentraSession during disconnect/cleanup. LED commands are
125
+ * fire-and-forget so there is no pending state to drain.
126
+ *
127
+ * @internal
128
+ */
129
+ destroy(): void;
130
+ }
131
+ //# sourceMappingURL=LedManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LedManager.d.ts","sourceRoot":"","sources":["../../../src/session/managers/LedManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,8EAA8E;IAC9E,MAAM,EAAE;QACN,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;KAC7F,CAAC;IACF,qEAAqE;IACrE,eAAe,EAAE;QACf,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;KACjE,CAAC;IACF,yEAAyE;IACzE,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,oCAAoC;IACpC,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,yDAAyD;IACzD,WAAW,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACpC,yBAAyB;IACzB,MAAM,EAAE;QACN,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAC3B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;KAC7B,CAAC;IACF,0CAA0C;IAC1C,cAAc,EAAE,MAAM,MAAM,CAAC;IAC7B,0BAA0B;IAC1B,YAAY,EAAE,MAAM,MAAM,CAAC;CAC5B;AAiBD;;;;;;;;;;;;;;;;GAgBG;AACH,sCAAsC;AACtC,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiB;gBAE1B,IAAI,EAAE,cAAc;IAMhC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI;IAqC3E;;;;;;;;;OASG;IACH,GAAG,IAAI,IAAI;IAmBX;;;;;;;OAOG;IACH,OAAO,IAAI,IAAI;CAGhB"}
@@ -0,0 +1,255 @@
1
+ /**
2
+ * LocationManager — v3 SDK Location API
3
+ *
4
+ * Wraps the existing LocationManager patterns from v2 with a cleaner,
5
+ * composable API. Subscribes to location data streams, caches the latest
6
+ * known position, and supports one-shot location polls.
7
+ *
8
+ * Wire format is identical to v2:
9
+ * - Location stream subscription: `"location_stream"` added to subscriptions
10
+ * - Location poll: `{ type: "location_poll_request", packageName, sessionId, accuracy, correlationId }`
11
+ * - Location updates arrive as DATA_STREAM messages with streamType `"location_update"` or `"location_stream"`
12
+ *
13
+ * The LocationUpdate payload shape (from glasses-to-cloud):
14
+ * ```json
15
+ * {
16
+ * "type": "location_update",
17
+ * "lat": number,
18
+ * "lng": number,
19
+ * "accuracy": number,
20
+ * "correlationId": string | undefined
21
+ * }
22
+ * ```
23
+ *
24
+ * @module
25
+ */
26
+ /**
27
+ * Normalised location data delivered to subscriber callbacks.
28
+ */
29
+ export interface LocationData {
30
+ /** Latitude in decimal degrees. */
31
+ lat: number;
32
+ /** Longitude in decimal degrees. */
33
+ lng: number;
34
+ /** Horizontal accuracy in metres (`undefined` if not available). */
35
+ accuracy?: number;
36
+ /** Unix timestamp (ms) when the location was recorded. */
37
+ timestamp: number;
38
+ /** Correlation ID returned from a one-shot poll (if applicable). */
39
+ correlationId?: string;
40
+ }
41
+ /**
42
+ * Accuracy tier for location stream subscriptions.
43
+ * Maps directly to the v2 `LocationStreamRequest.rate` values.
44
+ */
45
+ export type LocationAccuracy = "standard" | "high" | "realtime" | "tenMeters" | "hundredMeters" | "kilometer" | "threeKilometers" | "reduced";
46
+ /** Callback signature for location subscribers. */
47
+ export type LocationHandler = (location: LocationData) => void;
48
+ /** Location configuration options. */
49
+ export interface LocationConfig {
50
+ /** Accuracy level for location updates. Default: "standard". */
51
+ accuracy?: LocationAccuracy;
52
+ }
53
+ /**
54
+ * Dependencies injected by MentraSession.
55
+ *
56
+ * Structural type — no concrete imports so the manager stays unit-testable
57
+ * with plain stubs.
58
+ */
59
+ export interface LocationManagerDeps {
60
+ /** DataStreamRouter — register for DATA_STREAM messages by streamType key. */
61
+ router: {
62
+ on(key: string, handler: (streamType: string, data: any, message: any) => void): () => void;
63
+ };
64
+ /** MessageHandlerRegistry — register for top-level message types. */
65
+ messageHandlers: {
66
+ register(type: string, handler: (msg: any) => void): () => void;
67
+ };
68
+ /** Add a subscription string (triggers SUBSCRIPTION_UPDATE to cloud). */
69
+ addSubscription: (stream: string) => void;
70
+ /** Remove a subscription string. */
71
+ removeSubscription: (stream: string) => void;
72
+ /** Send an arbitrary JSON message over the WebSocket. */
73
+ sendMessage: (message: any) => void;
74
+ /** Structured logger. */
75
+ logger: {
76
+ debug(...args: any[]): void;
77
+ info(...args: any[]): void;
78
+ warn(...args: any[]): void;
79
+ error(...args: any[]): void;
80
+ };
81
+ /** Package name for outgoing messages. */
82
+ getPackageName: () => string;
83
+ /** Current session ID. */
84
+ getSessionId: () => string;
85
+ }
86
+ /**
87
+ * Manages location subscriptions, caches the latest known position, and
88
+ * supports one-shot location polls.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * const session = await mentra.connect();
93
+ *
94
+ * // Subscribe to continuous location updates
95
+ * const stop = session.location.onUpdate((loc) => {
96
+ * console.log(`${loc.lat}, ${loc.lng} (±${loc.accuracy}m)`);
97
+ * });
98
+ *
99
+ * // Read cached values at any time
100
+ * console.log("Last known:", session.location.lat, session.location.lng);
101
+ *
102
+ * // Request a single location update
103
+ * session.location.requestUpdate();
104
+ *
105
+ * // Stop all subscriptions
106
+ * session.location.stop();
107
+ * ```
108
+ */
109
+ export declare class LocationManager {
110
+ private readonly deps;
111
+ /**
112
+ * All currently-active registrations. Tracked so that {@link stop}
113
+ * can clean everything up in one shot.
114
+ */
115
+ private registrations;
116
+ /**
117
+ * Reference count for the location_stream subscription.
118
+ * We only call `removeSubscription` when ref-count drops to zero.
119
+ */
120
+ private streamRefCount;
121
+ /** Latest latitude, or `null` if no update has been received. */
122
+ private _lat;
123
+ /** Latest longitude, or `null` if no update has been received. */
124
+ private _lng;
125
+ /** Latest horizontal accuracy in metres, or `null` if unknown. */
126
+ private _accuracy;
127
+ /** Timestamp of the latest location update, or `null` if none received. */
128
+ private _timestamp;
129
+ /**
130
+ * Whether the device has location permission.
131
+ * Optimistically `true`, updated to `false` on permission errors.
132
+ */
133
+ private _hasPermission;
134
+ /** User-provided configuration (accuracy, etc.). */
135
+ private _config;
136
+ /** Pending one-shot poll requests awaiting a correlated response. */
137
+ private pendingPolls;
138
+ /** Cleanup for the internal location_update message handler. */
139
+ private locationUpdateCleanup;
140
+ constructor(deps: LocationManagerDeps);
141
+ /**
142
+ * Configure location settings.
143
+ *
144
+ * Sets the accuracy level for subsequent `onUpdate()` subscriptions
145
+ * and `requestUpdate()` calls.
146
+ *
147
+ * @example
148
+ * ```ts
149
+ * session.location.configure({ accuracy: "high" });
150
+ * ```
151
+ */
152
+ configure(config: LocationConfig): void;
153
+ /**
154
+ * Subscribe to continuous location updates.
155
+ *
156
+ * Registers on the DataStreamRouter for `"location_stream"` events and
157
+ * adds the `"location_stream"` subscription to the cloud. Multiple
158
+ * independent subscriptions are supported — each returns its own
159
+ * cleanup function.
160
+ *
161
+ * Uses the accuracy level set via {@link configure}. Defaults to `"standard"`.
162
+ *
163
+ * @param handler - Called each time a location update arrives.
164
+ * @returns A cleanup function that removes this specific subscription.
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * session.location.configure({ accuracy: "high" });
169
+ * const stop = session.location.onUpdate((loc) => {
170
+ * console.log(`${loc.lat}, ${loc.lng}`);
171
+ * });
172
+ *
173
+ * // Later:
174
+ * stop();
175
+ * ```
176
+ */
177
+ onUpdate(handler: LocationHandler): () => void;
178
+ /**
179
+ * Request a single location update (one-shot poll).
180
+ *
181
+ * Sends a `location_poll_request` message to the cloud and returns a
182
+ * Promise that resolves with the {@link LocationData} when the correlated
183
+ * response arrives. The response will also be delivered to any active
184
+ * `onUpdate()` listeners and will update the cached position.
185
+ *
186
+ * Uses the accuracy level set via {@link configure}. Defaults to `"standard"`.
187
+ *
188
+ * @returns A promise that resolves with the location data from the poll.
189
+ * @throws If the poll times out (default: 15 seconds).
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * session.location.configure({ accuracy: "high" });
194
+ * const loc = await session.location.requestUpdate();
195
+ * console.log(`${loc.lat}, ${loc.lng}`);
196
+ * ```
197
+ */
198
+ requestUpdate(): Promise<LocationData>;
199
+ /**
200
+ * Stop all location subscriptions and remove every handler.
201
+ *
202
+ * After calling this, no location callbacks will fire until new
203
+ * subscriptions are created via {@link onUpdate}.
204
+ *
205
+ * @example
206
+ * ```ts
207
+ * session.location.stop();
208
+ * ```
209
+ */
210
+ stop(): void;
211
+ /**
212
+ * Latest known latitude, or `null` if no location update has been received.
213
+ */
214
+ get lat(): number | null;
215
+ /**
216
+ * Latest known longitude, or `null` if no location update has been received.
217
+ */
218
+ get lng(): number | null;
219
+ /**
220
+ * Latest horizontal accuracy in metres, or `null` if unknown.
221
+ */
222
+ get accuracy(): number | null;
223
+ /**
224
+ * Unix timestamp (ms) of the latest location update, or `null` if none received.
225
+ */
226
+ get timestamp(): number | null;
227
+ /**
228
+ * Whether the device has granted location permission.
229
+ *
230
+ * Optimistically `true` — updated to `false` if a permission error
231
+ * is received from the cloud.
232
+ */
233
+ get hasPermission(): boolean;
234
+ /**
235
+ * Check if incoming data matches a pending one-shot poll and resolve it.
236
+ */
237
+ private resolvePendingPoll;
238
+ /**
239
+ * Update cached location values from raw incoming data.
240
+ */
241
+ private cacheLocation;
242
+ /**
243
+ * Called by MentraSession if a permission error for location is received.
244
+ * @internal
245
+ */
246
+ setPermission(granted: boolean): void;
247
+ /**
248
+ * Clean up all resources.
249
+ *
250
+ * Called by MentraSession during disconnect/cleanup.
251
+ * @internal
252
+ */
253
+ destroy(): void;
254
+ }
255
+ //# sourceMappingURL=LocationManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocationManager.d.ts","sourceRoot":"","sources":["../../../src/session/managers/LocationManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAMH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACxB,UAAU,GACV,MAAM,GACN,UAAU,GACV,WAAW,GACX,eAAe,GACf,WAAW,GACX,iBAAiB,GACjB,SAAS,CAAC;AAEd,mDAAmD;AACnD,MAAM,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;AAE/D,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC7B;AAID;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