@mentra/sdk 1.1.19
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 +102 -0
- package/dist/constants/index.d.ts +14 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +16 -0
- package/dist/examples/rtmp-streaming-example.d.ts +2 -0
- package/dist/examples/rtmp-streaming-example.d.ts.map +1 -0
- package/dist/examples/rtmp-streaming-example.js +102 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/logging/logger.d.ts +3 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +79 -0
- package/dist/tpa/index.d.ts +6 -0
- package/dist/tpa/index.d.ts.map +1 -0
- package/dist/tpa/index.js +24 -0
- package/dist/tpa/server/index.d.ts +193 -0
- package/dist/tpa/server/index.d.ts.map +1 -0
- package/dist/tpa/server/index.js +436 -0
- package/dist/tpa/session/api-client.d.ts +49 -0
- package/dist/tpa/session/api-client.d.ts.map +1 -0
- package/dist/tpa/session/api-client.js +101 -0
- package/dist/tpa/session/dashboard.d.ts +52 -0
- package/dist/tpa/session/dashboard.d.ts.map +1 -0
- package/dist/tpa/session/dashboard.js +149 -0
- package/dist/tpa/session/events.d.ts +178 -0
- package/dist/tpa/session/events.d.ts.map +1 -0
- package/dist/tpa/session/events.js +294 -0
- package/dist/tpa/session/index.d.ts +391 -0
- package/dist/tpa/session/index.d.ts.map +1 -0
- package/dist/tpa/session/index.js +1452 -0
- package/dist/tpa/session/layouts.d.ts +150 -0
- package/dist/tpa/session/layouts.d.ts.map +1 -0
- package/dist/tpa/session/layouts.js +282 -0
- package/dist/tpa/session/modules/streaming.d.ts +100 -0
- package/dist/tpa/session/modules/streaming.d.ts.map +1 -0
- package/dist/tpa/session/modules/streaming.js +270 -0
- package/dist/tpa/session/settings.d.ts +202 -0
- package/dist/tpa/session/settings.d.ts.map +1 -0
- package/dist/tpa/session/settings.js +361 -0
- package/dist/tpa/token/index.d.ts +7 -0
- package/dist/tpa/token/index.d.ts.map +1 -0
- package/dist/tpa/token/index.js +22 -0
- package/dist/tpa/token/utils.d.ts +69 -0
- package/dist/tpa/token/utils.d.ts.map +1 -0
- package/dist/tpa/token/utils.js +144 -0
- package/dist/tpa/webview/index.d.ts +47 -0
- package/dist/tpa/webview/index.d.ts.map +1 -0
- package/dist/tpa/webview/index.js +344 -0
- package/dist/types/dashboard/index.d.ts +128 -0
- package/dist/types/dashboard/index.d.ts.map +1 -0
- package/dist/types/dashboard/index.js +12 -0
- package/dist/types/enums.d.ts +57 -0
- package/dist/types/enums.d.ts.map +1 -0
- package/dist/types/enums.js +72 -0
- package/dist/types/index.d.ts +38 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +87 -0
- package/dist/types/layouts.d.ts +51 -0
- package/dist/types/layouts.d.ts.map +1 -0
- package/dist/types/layouts.js +3 -0
- package/dist/types/message-types.d.ts +109 -0
- package/dist/types/message-types.d.ts.map +1 -0
- package/dist/types/message-types.js +189 -0
- package/dist/types/messages/base.d.ts +12 -0
- package/dist/types/messages/base.d.ts.map +1 -0
- package/dist/types/messages/base.js +3 -0
- package/dist/types/messages/cloud-to-glasses.d.ts +126 -0
- package/dist/types/messages/cloud-to-glasses.d.ts.map +1 -0
- package/dist/types/messages/cloud-to-glasses.js +60 -0
- package/dist/types/messages/cloud-to-tpa.d.ts +228 -0
- package/dist/types/messages/cloud-to-tpa.d.ts.map +1 -0
- package/dist/types/messages/cloud-to-tpa.js +61 -0
- package/dist/types/messages/glasses-to-cloud.d.ts +219 -0
- package/dist/types/messages/glasses-to-cloud.d.ts.map +1 -0
- package/dist/types/messages/glasses-to-cloud.js +88 -0
- package/dist/types/messages/tpa-to-cloud.d.ts +146 -0
- package/dist/types/messages/tpa-to-cloud.d.ts.map +1 -0
- package/dist/types/messages/tpa-to-cloud.js +67 -0
- package/dist/types/models.d.ts +165 -0
- package/dist/types/models.d.ts.map +1 -0
- package/dist/types/models.js +84 -0
- package/dist/types/rtmp-stream.d.ts +68 -0
- package/dist/types/rtmp-stream.d.ts.map +1 -0
- package/dist/types/rtmp-stream.js +3 -0
- package/dist/types/streams.d.ts +138 -0
- package/dist/types/streams.d.ts.map +1 -0
- package/dist/types/streams.js +251 -0
- package/dist/types/token.d.ts +41 -0
- package/dist/types/token.d.ts.map +1 -0
- package/dist/types/token.js +7 -0
- package/dist/types/user-session.d.ts +73 -0
- package/dist/types/user-session.d.ts.map +1 -0
- package/dist/types/user-session.js +17 -0
- package/dist/types/webhooks.d.ts +107 -0
- package/dist/types/webhooks.d.ts.map +1 -0
- package/dist/types/webhooks.js +55 -0
- package/dist/utils/resource-tracker.d.ts +94 -0
- package/dist/utils/resource-tracker.d.ts.map +1 -0
- package/dist/utils/resource-tracker.js +153 -0
- package/package.json +50 -0
@@ -0,0 +1,270 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.StreamingModule = void 0;
|
4
|
+
/**
|
5
|
+
* 📹 RTMP Streaming Module
|
6
|
+
*
|
7
|
+
* Provides functionality for TPAs to request and manage RTMP streams from smart glasses.
|
8
|
+
* Handles stream lifecycle, status monitoring, and cleanup.
|
9
|
+
*/
|
10
|
+
const types_1 = require("../../../types");
|
11
|
+
const streams_1 = require("../../../types/streams");
|
12
|
+
// Stream status information and handler types are imported from '../../../types/rtmp-stream'
|
13
|
+
/**
|
14
|
+
* StreamingModule provides functionality for TPAs to request and manage RTMP streams.
|
15
|
+
*
|
16
|
+
* Streams can be requested with configurable parameters for video quality,
|
17
|
+
* audio settings, and stream constraints. Status updates are received through
|
18
|
+
* the standard subscription mechanism.
|
19
|
+
*/
|
20
|
+
class StreamingModule {
|
21
|
+
/**
|
22
|
+
* Create a new StreamingModule
|
23
|
+
*
|
24
|
+
* @param packageName - The TPA package name
|
25
|
+
* @param sessionId - The current session ID
|
26
|
+
* @param send - Function to send messages to the cloud
|
27
|
+
* @param session - Reference to the parent TpaSession (optional)
|
28
|
+
*/
|
29
|
+
constructor(packageName, sessionId, send, session) {
|
30
|
+
this.isStreaming = false;
|
31
|
+
this.packageName = packageName;
|
32
|
+
this.sessionId = sessionId;
|
33
|
+
this.send = send;
|
34
|
+
this.session = session;
|
35
|
+
}
|
36
|
+
/**
|
37
|
+
* Begin an RTMP stream to the specified URL
|
38
|
+
*
|
39
|
+
* @param options - Configuration options for the stream
|
40
|
+
* @returns Promise that resolves when the stream request is sent (not when streaming begins)
|
41
|
+
*/
|
42
|
+
async requestStream(options) {
|
43
|
+
console.log(`[RTMP_STREAM_REQUEST] StreamingModule.requestStream called`, {
|
44
|
+
debugKey: 'RTMP_STREAM_REQUEST',
|
45
|
+
packageName: this.packageName,
|
46
|
+
sessionId: this.sessionId,
|
47
|
+
rtmpUrl: options.rtmpUrl,
|
48
|
+
isCurrentlyStreaming: this.isStreaming,
|
49
|
+
currentStreamUrl: this.currentStreamUrl,
|
50
|
+
currentStreamState: this.currentStreamState
|
51
|
+
});
|
52
|
+
if (!options.rtmpUrl) {
|
53
|
+
throw new Error('rtmpUrl is required');
|
54
|
+
}
|
55
|
+
if (this.isStreaming) {
|
56
|
+
console.error(`[RTMP_STREAM_ALREADY_ACTIVE] Already streaming error`, {
|
57
|
+
debugKey: 'RTMP_STREAM_ALREADY_ACTIVE',
|
58
|
+
packageName: this.packageName,
|
59
|
+
sessionId: this.sessionId,
|
60
|
+
currentStreamUrl: this.currentStreamUrl,
|
61
|
+
requestedUrl: options.rtmpUrl,
|
62
|
+
currentStreamState: this.currentStreamState,
|
63
|
+
isStreaming: this.isStreaming
|
64
|
+
});
|
65
|
+
throw new Error('Already streaming. Stop the current stream before starting a new one.');
|
66
|
+
}
|
67
|
+
// Create stream request message
|
68
|
+
const message = {
|
69
|
+
type: types_1.TpaToCloudMessageType.RTMP_STREAM_REQUEST,
|
70
|
+
packageName: this.packageName,
|
71
|
+
sessionId: this.sessionId,
|
72
|
+
rtmpUrl: options.rtmpUrl,
|
73
|
+
video: options.video,
|
74
|
+
audio: options.audio,
|
75
|
+
stream: options.stream,
|
76
|
+
timestamp: new Date()
|
77
|
+
};
|
78
|
+
// Save stream URL for reference
|
79
|
+
this.currentStreamUrl = options.rtmpUrl;
|
80
|
+
// Send the request
|
81
|
+
try {
|
82
|
+
console.log(`[RTMP_STREAM_SENDING] Sending RTMP stream request`, {
|
83
|
+
debugKey: 'RTMP_STREAM_SENDING',
|
84
|
+
packageName: this.packageName,
|
85
|
+
sessionId: this.sessionId,
|
86
|
+
rtmpUrl: options.rtmpUrl,
|
87
|
+
messageType: message.type
|
88
|
+
});
|
89
|
+
this.send(message);
|
90
|
+
this.isStreaming = true;
|
91
|
+
console.log(`[RTMP_STREAM_REQUEST_SENT] RTMP stream request sent successfully`, {
|
92
|
+
debugKey: 'RTMP_STREAM_REQUEST_SENT',
|
93
|
+
packageName: this.packageName,
|
94
|
+
sessionId: this.sessionId,
|
95
|
+
isStreaming: this.isStreaming,
|
96
|
+
currentStreamUrl: this.currentStreamUrl
|
97
|
+
});
|
98
|
+
return Promise.resolve();
|
99
|
+
}
|
100
|
+
catch (error) {
|
101
|
+
console.error(`[RTMP_STREAM_REQUEST_FAIL] Failed to send RTMP stream request`, {
|
102
|
+
debugKey: 'RTMP_STREAM_REQUEST_FAIL',
|
103
|
+
packageName: this.packageName,
|
104
|
+
sessionId: this.sessionId,
|
105
|
+
error,
|
106
|
+
rtmpUrl: options.rtmpUrl
|
107
|
+
});
|
108
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
109
|
+
return Promise.reject(new Error(`Failed to request RTMP stream: ${errorMessage}`));
|
110
|
+
}
|
111
|
+
}
|
112
|
+
/**
|
113
|
+
* Stop the current RTMP stream
|
114
|
+
*
|
115
|
+
* @returns Promise that resolves when the stop request is sent
|
116
|
+
*/
|
117
|
+
async stopStream() {
|
118
|
+
console.log(`[RTMP_STREAM_STOP_REQUEST] StreamingModule.stopStream called`, {
|
119
|
+
debugKey: 'RTMP_STREAM_STOP_REQUEST',
|
120
|
+
packageName: this.packageName,
|
121
|
+
sessionId: this.sessionId,
|
122
|
+
isCurrentlyStreaming: this.isStreaming,
|
123
|
+
currentStreamUrl: this.currentStreamUrl,
|
124
|
+
currentStreamState: this.currentStreamState
|
125
|
+
});
|
126
|
+
if (!this.isStreaming) {
|
127
|
+
console.log(`[RTMP_STREAM_STOP_NOOP] Not streaming - no-op`, {
|
128
|
+
debugKey: 'RTMP_STREAM_STOP_NOOP',
|
129
|
+
packageName: this.packageName,
|
130
|
+
sessionId: this.sessionId
|
131
|
+
});
|
132
|
+
// Not an error - just a no-op if not streaming
|
133
|
+
return Promise.resolve();
|
134
|
+
}
|
135
|
+
// Create stop request message
|
136
|
+
const message = {
|
137
|
+
type: types_1.TpaToCloudMessageType.RTMP_STREAM_STOP,
|
138
|
+
packageName: this.packageName,
|
139
|
+
sessionId: this.sessionId,
|
140
|
+
streamId: this.currentStreamState?.streamId, // Include streamId if available
|
141
|
+
timestamp: new Date()
|
142
|
+
};
|
143
|
+
// Send the request
|
144
|
+
try {
|
145
|
+
this.send(message);
|
146
|
+
return Promise.resolve();
|
147
|
+
}
|
148
|
+
catch (error) {
|
149
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
150
|
+
return Promise.reject(new Error(`Failed to stop RTMP stream: ${errorMessage}`));
|
151
|
+
}
|
152
|
+
}
|
153
|
+
/**
|
154
|
+
* Check if currently streaming
|
155
|
+
*
|
156
|
+
* @returns True if a stream is active or initializing
|
157
|
+
*/
|
158
|
+
isCurrentlyStreaming() {
|
159
|
+
return this.isStreaming;
|
160
|
+
}
|
161
|
+
/**
|
162
|
+
* Get the URL of the current stream (if any)
|
163
|
+
*
|
164
|
+
* @returns The RTMP URL of the current stream, or undefined if not streaming
|
165
|
+
*/
|
166
|
+
getCurrentStreamUrl() {
|
167
|
+
return this.currentStreamUrl;
|
168
|
+
}
|
169
|
+
/**
|
170
|
+
* Get the current stream status
|
171
|
+
*
|
172
|
+
* @returns The current stream status, or undefined if not available
|
173
|
+
*/
|
174
|
+
getStreamStatus() {
|
175
|
+
return this.currentStreamState;
|
176
|
+
}
|
177
|
+
/**
|
178
|
+
* Subscribe to RTMP stream status updates
|
179
|
+
* This uses the standard stream subscription mechanism
|
180
|
+
*/
|
181
|
+
subscribeToStatusUpdates() {
|
182
|
+
if (this.session) {
|
183
|
+
this.session.subscribe(streams_1.StreamType.RTMP_STREAM_STATUS);
|
184
|
+
}
|
185
|
+
else {
|
186
|
+
console.error('Cannot subscribe to status updates: session reference not available');
|
187
|
+
}
|
188
|
+
}
|
189
|
+
/**
|
190
|
+
* Unsubscribe from RTMP stream status updates
|
191
|
+
*/
|
192
|
+
unsubscribeFromStatusUpdates() {
|
193
|
+
if (this.session) {
|
194
|
+
this.session.unsubscribe(streams_1.StreamType.RTMP_STREAM_STATUS);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
/**
|
198
|
+
* Listen for status updates using the standard event system
|
199
|
+
* @param handler - Function to call when stream status changes
|
200
|
+
* @returns Cleanup function to remove the handler
|
201
|
+
*/
|
202
|
+
onStatus(handler) {
|
203
|
+
if (!this.session) {
|
204
|
+
console.error('Cannot listen for status updates: session reference not available');
|
205
|
+
return () => { };
|
206
|
+
}
|
207
|
+
this.subscribeToStatusUpdates();
|
208
|
+
return this.session.on(streams_1.StreamType.RTMP_STREAM_STATUS, handler);
|
209
|
+
}
|
210
|
+
/**
|
211
|
+
* Update internal stream state based on a status message
|
212
|
+
* For internal use by TpaSession
|
213
|
+
* @param message - The status message from the cloud
|
214
|
+
*/
|
215
|
+
updateStreamState(message) {
|
216
|
+
console.log(`[RTMP_STREAM_STATE_UPDATE] StreamingModule.updateStreamState called`, {
|
217
|
+
debugKey: 'RTMP_STREAM_STATE_UPDATE',
|
218
|
+
packageName: this.packageName,
|
219
|
+
sessionId: this.sessionId,
|
220
|
+
messageType: message?.type,
|
221
|
+
messageStatus: message?.status,
|
222
|
+
currentIsStreaming: this.isStreaming
|
223
|
+
});
|
224
|
+
// Verify this is a valid stream response
|
225
|
+
if (!(0, types_1.isRtmpStreamStatus)(message)) {
|
226
|
+
console.warn('[RTMP_STREAM_INVALID_STATUS] Received invalid stream status message', {
|
227
|
+
debugKey: 'RTMP_STREAM_INVALID_STATUS',
|
228
|
+
packageName: this.packageName,
|
229
|
+
sessionId: this.sessionId,
|
230
|
+
message
|
231
|
+
});
|
232
|
+
return;
|
233
|
+
}
|
234
|
+
// Convert to StreamStatus format
|
235
|
+
const status = {
|
236
|
+
type: message.type,
|
237
|
+
streamId: message.streamId,
|
238
|
+
status: message.status,
|
239
|
+
errorDetails: message.errorDetails,
|
240
|
+
appId: message.appId,
|
241
|
+
stats: message.stats,
|
242
|
+
timestamp: message.timestamp || new Date()
|
243
|
+
};
|
244
|
+
console.log(`[RTMP_STREAM_STATUS_PROCESSED] Stream status processed`, {
|
245
|
+
debugKey: 'RTMP_STREAM_STATUS_PROCESSED',
|
246
|
+
packageName: this.packageName,
|
247
|
+
sessionId: this.sessionId,
|
248
|
+
streamId: status.streamId,
|
249
|
+
oldStatus: this.currentStreamState?.status,
|
250
|
+
newStatus: status.status,
|
251
|
+
wasStreaming: this.isStreaming
|
252
|
+
});
|
253
|
+
// Updated logic to check for timeout to handle resetting state.
|
254
|
+
// Update local state based on status
|
255
|
+
if (status.status === 'stopped' || status.status === 'error' || status.status === 'timeout') {
|
256
|
+
console.log(`[RTMP_STREAM_STATE_STOPPED] Stream stopped - updating local state`, {
|
257
|
+
debugKey: 'RTMP_STREAM_STATE_STOPPED',
|
258
|
+
packageName: this.packageName,
|
259
|
+
sessionId: this.sessionId,
|
260
|
+
status: status.status,
|
261
|
+
wasStreaming: this.isStreaming
|
262
|
+
});
|
263
|
+
this.isStreaming = false;
|
264
|
+
this.currentStreamUrl = undefined;
|
265
|
+
}
|
266
|
+
// Save the latest status
|
267
|
+
this.currentStreamState = status;
|
268
|
+
}
|
269
|
+
}
|
270
|
+
exports.StreamingModule = StreamingModule;
|
@@ -0,0 +1,202 @@
|
|
1
|
+
import { AppSetting, AppSettings } from '../../types';
|
2
|
+
/**
|
3
|
+
* Change information for a single setting
|
4
|
+
*/
|
5
|
+
export interface SettingChange {
|
6
|
+
oldValue: any;
|
7
|
+
newValue: any;
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* Map of setting keys to their change information
|
11
|
+
*/
|
12
|
+
export type SettingsChangeMap = Record<string, SettingChange>;
|
13
|
+
/**
|
14
|
+
* Callback for when any setting changes
|
15
|
+
*/
|
16
|
+
export type SettingsChangeHandler = (changes: SettingsChangeMap) => void;
|
17
|
+
/**
|
18
|
+
* Callback for when a specific setting changes
|
19
|
+
*/
|
20
|
+
export type SettingValueChangeHandler<T = any> = (newValue: T, oldValue: T) => void;
|
21
|
+
/**
|
22
|
+
* 🔧 Settings Manager
|
23
|
+
*
|
24
|
+
* Provides a type-safe interface for accessing and reacting to TPA settings.
|
25
|
+
* Automatically synchronizes with AugmentOS Cloud.
|
26
|
+
*/
|
27
|
+
export declare class SettingsManager {
|
28
|
+
private settings;
|
29
|
+
private emitter;
|
30
|
+
private apiClient?;
|
31
|
+
private augmentosSettings;
|
32
|
+
private augmentosEmitter;
|
33
|
+
private subscribeFn?;
|
34
|
+
/**
|
35
|
+
* Create a new settings manager
|
36
|
+
*
|
37
|
+
* @param initialSettings Initial settings values (if available)
|
38
|
+
* @param packageName Package name for the TPA
|
39
|
+
* @param wsUrl WebSocket URL (for deriving HTTP API URL)
|
40
|
+
* @param userId User ID (for authenticated requests)
|
41
|
+
* @param subscribeFn Optional function to call to subscribe to streams
|
42
|
+
*/
|
43
|
+
constructor(initialSettings?: AppSettings, packageName?: string, wsUrl?: string, userId?: string, subscribeFn?: (streams: string[]) => Promise<void>);
|
44
|
+
/**
|
45
|
+
* Configure the API client
|
46
|
+
*
|
47
|
+
* @param packageName Package name for the TPA
|
48
|
+
* @param wsUrl WebSocket URL
|
49
|
+
* @param userId User ID
|
50
|
+
*/
|
51
|
+
configureApiClient(packageName: string, wsUrl: string, userId: string): void;
|
52
|
+
/**
|
53
|
+
* Update the current settings
|
54
|
+
* This is called internally when settings are loaded or changed
|
55
|
+
*
|
56
|
+
* @param newSettings New settings values
|
57
|
+
* @returns Map of changed settings
|
58
|
+
*/
|
59
|
+
updateSettings(newSettings: AppSettings): SettingsChangeMap;
|
60
|
+
/**
|
61
|
+
* Check if two setting values are equal
|
62
|
+
*
|
63
|
+
* @param a First value
|
64
|
+
* @param b Second value
|
65
|
+
* @returns True if the values are equal
|
66
|
+
*/
|
67
|
+
private areEqual;
|
68
|
+
/**
|
69
|
+
* Emit change events for updated settings
|
70
|
+
*
|
71
|
+
* @param changes Map of changed settings
|
72
|
+
*/
|
73
|
+
private emitChanges;
|
74
|
+
/**
|
75
|
+
* 🔄 Listen for changes to any setting
|
76
|
+
*
|
77
|
+
* @param handler Function to call when settings change
|
78
|
+
* @returns Function to remove the listener
|
79
|
+
*
|
80
|
+
* @example
|
81
|
+
* ```typescript
|
82
|
+
* settings.onChange((changes) => {
|
83
|
+
* console.log('Settings changed:', changes);
|
84
|
+
* });
|
85
|
+
* ```
|
86
|
+
*/
|
87
|
+
onChange(handler: SettingsChangeHandler): () => void;
|
88
|
+
/**
|
89
|
+
* 🔄 Listen for changes to a specific setting
|
90
|
+
*
|
91
|
+
* @param key Setting key to monitor
|
92
|
+
* @param handler Function to call when the setting changes
|
93
|
+
* @returns Function to remove the listener
|
94
|
+
*
|
95
|
+
* @example
|
96
|
+
* ```typescript
|
97
|
+
* settings.onValueChange('transcribe_language', (newValue, oldValue) => {
|
98
|
+
* console.log(`Language changed from ${oldValue} to ${newValue}`);
|
99
|
+
* });
|
100
|
+
* ```
|
101
|
+
*/
|
102
|
+
onValueChange<T = any>(key: string, handler: SettingValueChangeHandler<T>): () => void;
|
103
|
+
/**
|
104
|
+
* 🔍 Check if a setting exists
|
105
|
+
*
|
106
|
+
* @param key Setting key to check
|
107
|
+
* @returns True if the setting exists
|
108
|
+
*/
|
109
|
+
has(key: string): boolean;
|
110
|
+
/**
|
111
|
+
* 🔍 Get all settings
|
112
|
+
*
|
113
|
+
* @returns Copy of all settings
|
114
|
+
*/
|
115
|
+
getAll(): AppSettings;
|
116
|
+
/**
|
117
|
+
* 🔍 Get a setting value with type safety
|
118
|
+
*
|
119
|
+
* @param key Setting key to get
|
120
|
+
* @param defaultValue Default value if setting doesn't exist or is undefined
|
121
|
+
* @returns Setting value or default value
|
122
|
+
*
|
123
|
+
* @example
|
124
|
+
* ```typescript
|
125
|
+
* const lineWidth = settings.get<number>('line_width', 30);
|
126
|
+
* const language = settings.get<string>('transcribe_language', 'English');
|
127
|
+
* ```
|
128
|
+
*/
|
129
|
+
get<T = any>(key: string, defaultValue?: T): T;
|
130
|
+
/**
|
131
|
+
* 🎛️ Get an AugmentOS system setting value with optional default
|
132
|
+
*
|
133
|
+
* @param key AugmentOS setting key (e.g., 'metricSystemEnabled', 'brightness')
|
134
|
+
* @param defaultValue Default value to return if the setting is not found
|
135
|
+
* @returns The setting value or the default value
|
136
|
+
*
|
137
|
+
* @example
|
138
|
+
* ```typescript
|
139
|
+
* const isMetric = settings.getAugmentOS<boolean>('metricSystemEnabled', false);
|
140
|
+
* const brightness = settings.getAugmentOS<number>('brightness', 50);
|
141
|
+
* ```
|
142
|
+
*/
|
143
|
+
getAugmentOS<T = any>(key: string, defaultValue?: T): T;
|
144
|
+
/**
|
145
|
+
* 🔍 Find a setting by key
|
146
|
+
*
|
147
|
+
* @param key Setting key to find
|
148
|
+
* @returns Setting object or undefined
|
149
|
+
*/
|
150
|
+
getSetting(key: string): AppSetting | undefined;
|
151
|
+
/**
|
152
|
+
* 🔄 Fetch settings from the cloud
|
153
|
+
* This is generally not needed since settings are automatically kept in sync,
|
154
|
+
* but can be used to force a refresh if needed.
|
155
|
+
*
|
156
|
+
* @returns Promise that resolves to the updated settings
|
157
|
+
* @throws Error if the API client is not configured or the request fails
|
158
|
+
*/
|
159
|
+
fetch(): Promise<AppSettings>;
|
160
|
+
/**
|
161
|
+
* 🎛️ Listen for changes to a specific AugmentOS setting (e.g., metricSystemEnabled)
|
162
|
+
*
|
163
|
+
* @param key The augmentosSettings key to listen for (e.g., 'metricSystemEnabled')
|
164
|
+
* @param handler Function to call when the value changes
|
165
|
+
* @returns Function to remove the listener
|
166
|
+
*
|
167
|
+
* @example
|
168
|
+
* ```typescript
|
169
|
+
* settings.onAugmentOSChange('metricSystemEnabled', (isMetric, wasMetric) => {
|
170
|
+
* console.log(`Units changed: ${wasMetric ? 'metric' : 'imperial'} → ${isMetric ? 'metric' : 'imperial'}`);
|
171
|
+
* });
|
172
|
+
* ```
|
173
|
+
*/
|
174
|
+
onAugmentOSChange<T = any>(key: string, handler: SettingValueChangeHandler<T>): () => void;
|
175
|
+
/**
|
176
|
+
* Listen for changes to a specific AugmentOS setting (e.g., metricSystemEnabled)
|
177
|
+
* This is a convenience wrapper for onValueChange for well-known augmentosSettings keys.
|
178
|
+
* @param key The augmentosSettings key to listen for (e.g., 'metricSystemEnabled')
|
179
|
+
* @param handler Function to call when the value changes
|
180
|
+
* @returns Function to remove the listener
|
181
|
+
* @deprecated Use onAugmentOSChange instead
|
182
|
+
*/
|
183
|
+
onAugmentosSettingsChange<T = any>(key: string, handler: SettingValueChangeHandler<T>): () => void;
|
184
|
+
/**
|
185
|
+
* Update the current AugmentOS settings
|
186
|
+
* Compares new and old values, emits per-key events, and updates stored values.
|
187
|
+
* @param newSettings The new AugmentOS settings object
|
188
|
+
*/
|
189
|
+
updateAugmentosSettings(newSettings: Record<string, any>): void;
|
190
|
+
/**
|
191
|
+
* Subscribe to changes for a specific AugmentOS setting (e.g., 'metricSystemEnabled')
|
192
|
+
* @param key The AugmentOS setting key to listen for
|
193
|
+
* @param handler Function to call when the value changes (newValue, oldValue)
|
194
|
+
* @returns Function to remove the listener
|
195
|
+
*/
|
196
|
+
onAugmentosSettingChange<T = any>(key: string, handler: (newValue: T, oldValue: T) => void): () => void;
|
197
|
+
/**
|
198
|
+
* Get the current value of an AugmentOS setting
|
199
|
+
*/
|
200
|
+
getAugmentosSetting<T = any>(key: string, defaultValue?: T): T;
|
201
|
+
}
|
202
|
+
//# sourceMappingURL=settings.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../src/tpa/session/settings.ts"],"names":[],"mappings":"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"}
|