@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.
Files changed (101) hide show
  1. package/README.md +102 -0
  2. package/dist/constants/index.d.ts +14 -0
  3. package/dist/constants/index.d.ts.map +1 -0
  4. package/dist/constants/index.js +16 -0
  5. package/dist/examples/rtmp-streaming-example.d.ts +2 -0
  6. package/dist/examples/rtmp-streaming-example.d.ts.map +1 -0
  7. package/dist/examples/rtmp-streaming-example.js +102 -0
  8. package/dist/index.d.ts +4 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +33 -0
  11. package/dist/logging/logger.d.ts +3 -0
  12. package/dist/logging/logger.d.ts.map +1 -0
  13. package/dist/logging/logger.js +79 -0
  14. package/dist/tpa/index.d.ts +6 -0
  15. package/dist/tpa/index.d.ts.map +1 -0
  16. package/dist/tpa/index.js +24 -0
  17. package/dist/tpa/server/index.d.ts +193 -0
  18. package/dist/tpa/server/index.d.ts.map +1 -0
  19. package/dist/tpa/server/index.js +436 -0
  20. package/dist/tpa/session/api-client.d.ts +49 -0
  21. package/dist/tpa/session/api-client.d.ts.map +1 -0
  22. package/dist/tpa/session/api-client.js +101 -0
  23. package/dist/tpa/session/dashboard.d.ts +52 -0
  24. package/dist/tpa/session/dashboard.d.ts.map +1 -0
  25. package/dist/tpa/session/dashboard.js +149 -0
  26. package/dist/tpa/session/events.d.ts +178 -0
  27. package/dist/tpa/session/events.d.ts.map +1 -0
  28. package/dist/tpa/session/events.js +294 -0
  29. package/dist/tpa/session/index.d.ts +391 -0
  30. package/dist/tpa/session/index.d.ts.map +1 -0
  31. package/dist/tpa/session/index.js +1452 -0
  32. package/dist/tpa/session/layouts.d.ts +150 -0
  33. package/dist/tpa/session/layouts.d.ts.map +1 -0
  34. package/dist/tpa/session/layouts.js +282 -0
  35. package/dist/tpa/session/modules/streaming.d.ts +100 -0
  36. package/dist/tpa/session/modules/streaming.d.ts.map +1 -0
  37. package/dist/tpa/session/modules/streaming.js +270 -0
  38. package/dist/tpa/session/settings.d.ts +202 -0
  39. package/dist/tpa/session/settings.d.ts.map +1 -0
  40. package/dist/tpa/session/settings.js +361 -0
  41. package/dist/tpa/token/index.d.ts +7 -0
  42. package/dist/tpa/token/index.d.ts.map +1 -0
  43. package/dist/tpa/token/index.js +22 -0
  44. package/dist/tpa/token/utils.d.ts +69 -0
  45. package/dist/tpa/token/utils.d.ts.map +1 -0
  46. package/dist/tpa/token/utils.js +144 -0
  47. package/dist/tpa/webview/index.d.ts +47 -0
  48. package/dist/tpa/webview/index.d.ts.map +1 -0
  49. package/dist/tpa/webview/index.js +344 -0
  50. package/dist/types/dashboard/index.d.ts +128 -0
  51. package/dist/types/dashboard/index.d.ts.map +1 -0
  52. package/dist/types/dashboard/index.js +12 -0
  53. package/dist/types/enums.d.ts +57 -0
  54. package/dist/types/enums.d.ts.map +1 -0
  55. package/dist/types/enums.js +72 -0
  56. package/dist/types/index.d.ts +38 -0
  57. package/dist/types/index.d.ts.map +1 -0
  58. package/dist/types/index.js +87 -0
  59. package/dist/types/layouts.d.ts +51 -0
  60. package/dist/types/layouts.d.ts.map +1 -0
  61. package/dist/types/layouts.js +3 -0
  62. package/dist/types/message-types.d.ts +109 -0
  63. package/dist/types/message-types.d.ts.map +1 -0
  64. package/dist/types/message-types.js +189 -0
  65. package/dist/types/messages/base.d.ts +12 -0
  66. package/dist/types/messages/base.d.ts.map +1 -0
  67. package/dist/types/messages/base.js +3 -0
  68. package/dist/types/messages/cloud-to-glasses.d.ts +126 -0
  69. package/dist/types/messages/cloud-to-glasses.d.ts.map +1 -0
  70. package/dist/types/messages/cloud-to-glasses.js +60 -0
  71. package/dist/types/messages/cloud-to-tpa.d.ts +228 -0
  72. package/dist/types/messages/cloud-to-tpa.d.ts.map +1 -0
  73. package/dist/types/messages/cloud-to-tpa.js +61 -0
  74. package/dist/types/messages/glasses-to-cloud.d.ts +219 -0
  75. package/dist/types/messages/glasses-to-cloud.d.ts.map +1 -0
  76. package/dist/types/messages/glasses-to-cloud.js +88 -0
  77. package/dist/types/messages/tpa-to-cloud.d.ts +146 -0
  78. package/dist/types/messages/tpa-to-cloud.d.ts.map +1 -0
  79. package/dist/types/messages/tpa-to-cloud.js +67 -0
  80. package/dist/types/models.d.ts +165 -0
  81. package/dist/types/models.d.ts.map +1 -0
  82. package/dist/types/models.js +84 -0
  83. package/dist/types/rtmp-stream.d.ts +68 -0
  84. package/dist/types/rtmp-stream.d.ts.map +1 -0
  85. package/dist/types/rtmp-stream.js +3 -0
  86. package/dist/types/streams.d.ts +138 -0
  87. package/dist/types/streams.d.ts.map +1 -0
  88. package/dist/types/streams.js +251 -0
  89. package/dist/types/token.d.ts +41 -0
  90. package/dist/types/token.d.ts.map +1 -0
  91. package/dist/types/token.js +7 -0
  92. package/dist/types/user-session.d.ts +73 -0
  93. package/dist/types/user-session.d.ts.map +1 -0
  94. package/dist/types/user-session.js +17 -0
  95. package/dist/types/webhooks.d.ts +107 -0
  96. package/dist/types/webhooks.d.ts.map +1 -0
  97. package/dist/types/webhooks.js +55 -0
  98. package/dist/utils/resource-tracker.d.ts +94 -0
  99. package/dist/utils/resource-tracker.d.ts.map +1 -0
  100. package/dist/utils/resource-tracker.js +153 -0
  101. package/package.json +50 -0
@@ -0,0 +1,150 @@
1
+ /**
2
+ * 🎨 Layout Manager Module
3
+ *
4
+ * Manages AR display layouts for TPAs. This class provides an easy-to-use interface
5
+ * for showing different types of content in the user's AR view.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const layouts = new LayoutManager('org.example.myapp', sendMessage);
10
+ *
11
+ * // Show a simple message
12
+ * layouts.showTextWall('Hello AR World!');
13
+ *
14
+ * // Show a card with title
15
+ * layouts.showReferenceCard('Weather', 'Sunny and 75°F');
16
+ * ```
17
+ */
18
+ import { DisplayRequest, ViewType } from '../../types';
19
+ export declare class LayoutManager {
20
+ private packageName;
21
+ private sendMessage;
22
+ /**
23
+ * 🎯 Creates a new LayoutManager instance
24
+ *
25
+ * @param packageName - TPA package identifier
26
+ * @param sendMessage - Function to send display requests to AugmentOS
27
+ */
28
+ constructor(packageName: string, sendMessage: (message: DisplayRequest) => void);
29
+ /**
30
+ * 📦 Creates a display event request with validation
31
+ *
32
+ * @param layout - Layout configuration to display
33
+ * @param view - View type (main or dashboard)
34
+ * @param durationMs - How long to show the layout (optional)
35
+ * @returns Formatted display request
36
+ * @throws Error if layout is invalid
37
+ */
38
+ private createDisplayEvent;
39
+ /**
40
+ * 📝 Shows a single block of text
41
+ *
42
+ * Best for:
43
+ * - Simple messages
44
+ * - Status updates
45
+ * - Notifications
46
+ *
47
+ * @param text - Text content to display
48
+ * @param options - Optional parameters (view, duration, priority)
49
+ * - priority: If true, this display will not be overridden by other requests (default: false)
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * layouts.showTextWall('Connected to server');
54
+ * layouts.showTextWall('Onboarding!', { priority: true });
55
+ * ```
56
+ */
57
+ showTextWall(text: string, options?: {
58
+ view?: ViewType;
59
+ durationMs?: number;
60
+ }): void;
61
+ /**
62
+ * ↕️ Shows two sections of text, one above the other
63
+ *
64
+ * Best for:
65
+ * - Before/After content
66
+ * - Question/Answer displays
67
+ * - Two-part messages
68
+ * - Comparisons
69
+ *
70
+ * @param topText - Text to show in top section
71
+ * @param bottomText - Text to show in bottom section
72
+ * @param options - Optional parameters (view, duration)
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * layouts.showDoubleTextWall(
77
+ * 'Original: Hello',
78
+ * 'Translated: Bonjour'
79
+ * );
80
+ * ```
81
+ */
82
+ showDoubleTextWall(topText: string, bottomText: string, options?: {
83
+ view?: ViewType;
84
+ durationMs?: number;
85
+ }): void;
86
+ /**
87
+ * 📇 Shows a card with a title and content
88
+ *
89
+ * Best for:
90
+ * - Titled content
91
+ * - Important information
92
+ * - Structured data
93
+ * - Notifications with context
94
+ *
95
+ * @param title - Card title
96
+ * @param text - Main content text
97
+ * @param options - Optional parameters (view, duration)
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * layouts.showReferenceCard(
102
+ * 'Meeting Reminder',
103
+ * 'Team standup in 5 minutes'
104
+ * );
105
+ * ```
106
+ */
107
+ showReferenceCard(title: string, text: string, options?: {
108
+ view?: ViewType;
109
+ durationMs?: number;
110
+ }): void;
111
+ /**
112
+ * 📇 Shows a bitmap
113
+ *
114
+ * @param data - base64 encoded bitmap data
115
+ * @param options - Optional parameters (view, duration)
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * layouts.showBitmapView(
120
+ * yourBase64EncodedBitmapDataString
121
+ * );
122
+ * ```
123
+ */
124
+ showBitmapView(data: string, options?: {
125
+ view?: ViewType;
126
+ durationMs?: number;
127
+ }): void;
128
+ /**
129
+ * 📊 Shows a dashboard card with left and right text
130
+ *
131
+ * Best for:
132
+ * - Key-value pairs
133
+ * - Dashboard displays
134
+ * - Metrics
135
+ *
136
+ * @param leftText - Left side text (typically label/key)
137
+ * @param rightText - Right side text (typically value)
138
+ * @param options - Optional parameters (view, duration)
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * layouts.showDashboardCard('Weather', '72°F');
143
+ * ```
144
+ */
145
+ showDashboardCard(leftText: string, rightText: string, options?: {
146
+ view?: ViewType;
147
+ durationMs?: number;
148
+ }): void;
149
+ }
150
+ //# sourceMappingURL=layouts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layouts.d.ts","sourceRoot":"","sources":["../../../src/tpa/session/layouts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EACL,cAAc,EAOd,QAAQ,EAGT,MAAM,aAAa,CAAC;AAErB,qBAAa,aAAa;IAQtB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,WAAW;IARrB;;;;;OAKG;gBAEO,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI;IAGxD;;;;;;;;OAQG;IACH,OAAO,CAAC,kBAAkB;IAmG1B;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CACV,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAC;IAuCnD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,kBAAkB,CAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAcpD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,iBAAiB,CACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAclD;;;;;;;;;;;;KAYC;IACH,cAAc,CACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAapD;;;;;;;;;;;;;;;;OAgBG;IACH,iBAAiB,CACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;CAarD"}
@@ -0,0 +1,282 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LayoutManager = void 0;
4
+ /**
5
+ * 🎨 Layout Manager Module
6
+ *
7
+ * Manages AR display layouts for TPAs. This class provides an easy-to-use interface
8
+ * for showing different types of content in the user's AR view.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const layouts = new LayoutManager('org.example.myapp', sendMessage);
13
+ *
14
+ * // Show a simple message
15
+ * layouts.showTextWall('Hello AR World!');
16
+ *
17
+ * // Show a card with title
18
+ * layouts.showReferenceCard('Weather', 'Sunny and 75°F');
19
+ * ```
20
+ */
21
+ const types_1 = require("../../types");
22
+ class LayoutManager {
23
+ /**
24
+ * 🎯 Creates a new LayoutManager instance
25
+ *
26
+ * @param packageName - TPA package identifier
27
+ * @param sendMessage - Function to send display requests to AugmentOS
28
+ */
29
+ constructor(packageName, sendMessage) {
30
+ this.packageName = packageName;
31
+ this.sendMessage = sendMessage;
32
+ }
33
+ /**
34
+ * 📦 Creates a display event request with validation
35
+ *
36
+ * @param layout - Layout configuration to display
37
+ * @param view - View type (main or dashboard)
38
+ * @param durationMs - How long to show the layout (optional)
39
+ * @returns Formatted display request
40
+ * @throws Error if layout is invalid
41
+ */
42
+ createDisplayEvent(layout, view = types_1.ViewType.MAIN, durationMs) {
43
+ try {
44
+ // Validate layout data before sending
45
+ if (!layout) {
46
+ throw new Error("Layout cannot be null or undefined");
47
+ }
48
+ if (!layout.layoutType) {
49
+ throw new Error("Layout must have a layoutType property");
50
+ }
51
+ // Layout-specific validations
52
+ switch (layout.layoutType) {
53
+ case types_1.LayoutType.TEXT_WALL:
54
+ if (typeof layout.text !== 'string') {
55
+ throw new Error("TextWall layout must have a text property");
56
+ }
57
+ // Ensure text is not too long (prevent performance issues)
58
+ if (layout.text.length > 1000) {
59
+ console.warn("TextWall text is very long, this may cause performance issues");
60
+ }
61
+ break;
62
+ case types_1.LayoutType.DOUBLE_TEXT_WALL:
63
+ const doubleText = layout;
64
+ if (typeof doubleText.topText !== 'string') {
65
+ throw new Error("DoubleTextWall layout must have a topText property");
66
+ }
67
+ if (typeof doubleText.bottomText !== 'string') {
68
+ throw new Error("DoubleTextWall layout must have a bottomText property");
69
+ }
70
+ break;
71
+ case types_1.LayoutType.REFERENCE_CARD:
72
+ const refCard = layout;
73
+ if (typeof refCard.title !== 'string') {
74
+ throw new Error("ReferenceCard layout must have a title property");
75
+ }
76
+ if (typeof refCard.text !== 'string') {
77
+ throw new Error("ReferenceCard layout must have a text property");
78
+ }
79
+ break;
80
+ case types_1.LayoutType.DASHBOARD_CARD:
81
+ const dashCard = layout;
82
+ if (typeof dashCard.leftText !== 'string') {
83
+ throw new Error("DashboardCard layout must have a leftText property");
84
+ }
85
+ if (typeof dashCard.rightText !== 'string') {
86
+ throw new Error("DashboardCard layout must have a rightText property");
87
+ }
88
+ break;
89
+ case types_1.LayoutType.BITMAP_VIEW:
90
+ const bitmapView = layout;
91
+ if (typeof bitmapView.data !== 'string') {
92
+ throw new Error("BitmapView layout must have a data property");
93
+ }
94
+ // Check if data is too large (prevent OOM errors)
95
+ if (bitmapView.data.length > 1000000) { // 1MB limit
96
+ throw new Error("Bitmap data is too large (>1MB), please reduce size");
97
+ }
98
+ break;
99
+ }
100
+ // Validate view type
101
+ if (view !== types_1.ViewType.MAIN && view !== types_1.ViewType.DASHBOARD) {
102
+ console.warn(`Invalid view type: ${view}, defaulting to MAIN`);
103
+ view = types_1.ViewType.MAIN;
104
+ }
105
+ // Validate duration if provided
106
+ if (durationMs !== undefined) {
107
+ if (typeof durationMs !== 'number' || durationMs < 0) {
108
+ console.warn(`Invalid duration: ${durationMs}, ignoring`);
109
+ durationMs = undefined;
110
+ }
111
+ }
112
+ // Create the display request with validated data
113
+ return {
114
+ timestamp: new Date(),
115
+ sessionId: '', // Will be filled by session
116
+ type: types_1.TpaToCloudMessageType.DISPLAY_REQUEST,
117
+ packageName: this.packageName,
118
+ view,
119
+ layout,
120
+ durationMs
121
+ };
122
+ }
123
+ catch (error) {
124
+ console.error("Error creating display event:", error);
125
+ throw error; // Re-throw to notify caller
126
+ }
127
+ }
128
+ /**
129
+ * 📝 Shows a single block of text
130
+ *
131
+ * Best for:
132
+ * - Simple messages
133
+ * - Status updates
134
+ * - Notifications
135
+ *
136
+ * @param text - Text content to display
137
+ * @param options - Optional parameters (view, duration, priority)
138
+ * - priority: If true, this display will not be overridden by other requests (default: false)
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * layouts.showTextWall('Connected to server');
143
+ * layouts.showTextWall('Onboarding!', { priority: true });
144
+ * ```
145
+ */
146
+ showTextWall(text, options) {
147
+ try {
148
+ // Validate input before processing
149
+ if (text === undefined || text === null) {
150
+ text = ""; // Default to empty string instead of crashing
151
+ console.warn("showTextWall called with null/undefined text");
152
+ }
153
+ // Ensure text is a string
154
+ if (typeof text !== 'string') {
155
+ text = String(text); // Convert to string
156
+ console.warn("showTextWall: Non-string input converted to string");
157
+ }
158
+ // Create layout with validated text
159
+ const layout = {
160
+ layoutType: types_1.LayoutType.TEXT_WALL,
161
+ text
162
+ };
163
+ // Create and send display event with error handling
164
+ try {
165
+ const displayEvent = this.createDisplayEvent(layout, options?.view, options?.durationMs);
166
+ this.sendMessage(displayEvent);
167
+ }
168
+ catch (error) {
169
+ console.error("Failed to display text wall:", error);
170
+ // Don't re-throw - prevent app crashes
171
+ }
172
+ }
173
+ catch (error) {
174
+ console.error("Error in showTextWall:", error);
175
+ // Don't crash the TPA - fail gracefully
176
+ }
177
+ }
178
+ /**
179
+ * ↕️ Shows two sections of text, one above the other
180
+ *
181
+ * Best for:
182
+ * - Before/After content
183
+ * - Question/Answer displays
184
+ * - Two-part messages
185
+ * - Comparisons
186
+ *
187
+ * @param topText - Text to show in top section
188
+ * @param bottomText - Text to show in bottom section
189
+ * @param options - Optional parameters (view, duration)
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * layouts.showDoubleTextWall(
194
+ * 'Original: Hello',
195
+ * 'Translated: Bonjour'
196
+ * );
197
+ * ```
198
+ */
199
+ showDoubleTextWall(topText, bottomText, options) {
200
+ const layout = {
201
+ layoutType: types_1.LayoutType.DOUBLE_TEXT_WALL,
202
+ topText,
203
+ bottomText
204
+ };
205
+ this.sendMessage(this.createDisplayEvent(layout, options?.view, options?.durationMs));
206
+ }
207
+ /**
208
+ * 📇 Shows a card with a title and content
209
+ *
210
+ * Best for:
211
+ * - Titled content
212
+ * - Important information
213
+ * - Structured data
214
+ * - Notifications with context
215
+ *
216
+ * @param title - Card title
217
+ * @param text - Main content text
218
+ * @param options - Optional parameters (view, duration)
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * layouts.showReferenceCard(
223
+ * 'Meeting Reminder',
224
+ * 'Team standup in 5 minutes'
225
+ * );
226
+ * ```
227
+ */
228
+ showReferenceCard(title, text, options) {
229
+ const layout = {
230
+ layoutType: types_1.LayoutType.REFERENCE_CARD,
231
+ title,
232
+ text
233
+ };
234
+ this.sendMessage(this.createDisplayEvent(layout, options?.view, options?.durationMs));
235
+ }
236
+ /**
237
+ * 📇 Shows a bitmap
238
+ *
239
+ * @param data - base64 encoded bitmap data
240
+ * @param options - Optional parameters (view, duration)
241
+ *
242
+ * @example
243
+ * ```typescript
244
+ * layouts.showBitmapView(
245
+ * yourBase64EncodedBitmapDataString
246
+ * );
247
+ * ```
248
+ */
249
+ showBitmapView(data, options) {
250
+ const layout = {
251
+ layoutType: types_1.LayoutType.BITMAP_VIEW,
252
+ data
253
+ };
254
+ this.sendMessage(this.createDisplayEvent(layout, options?.view, options?.durationMs));
255
+ }
256
+ /**
257
+ * 📊 Shows a dashboard card with left and right text
258
+ *
259
+ * Best for:
260
+ * - Key-value pairs
261
+ * - Dashboard displays
262
+ * - Metrics
263
+ *
264
+ * @param leftText - Left side text (typically label/key)
265
+ * @param rightText - Right side text (typically value)
266
+ * @param options - Optional parameters (view, duration)
267
+ *
268
+ * @example
269
+ * ```typescript
270
+ * layouts.showDashboardCard('Weather', '72°F');
271
+ * ```
272
+ */
273
+ showDashboardCard(leftText, rightText, options) {
274
+ const layout = {
275
+ layoutType: types_1.LayoutType.DASHBOARD_CARD,
276
+ leftText,
277
+ rightText
278
+ };
279
+ this.sendMessage(this.createDisplayEvent(layout, options?.view || types_1.ViewType.DASHBOARD, options?.durationMs));
280
+ }
281
+ }
282
+ exports.LayoutManager = LayoutManager;
@@ -0,0 +1,100 @@
1
+ /**
2
+ * 📹 RTMP Streaming Module
3
+ *
4
+ * Provides functionality for TPAs to request and manage RTMP streams from smart glasses.
5
+ * Handles stream lifecycle, status monitoring, and cleanup.
6
+ */
7
+ import { RtmpStreamStatus } from '../../../types';
8
+ import { VideoConfig, AudioConfig, StreamConfig, StreamStatusHandler } from '../../../types/rtmp-stream';
9
+ export { VideoConfig, AudioConfig, StreamConfig, StreamStatusHandler };
10
+ /**
11
+ * Configuration options for an RTMP stream
12
+ */
13
+ export interface RtmpStreamOptions {
14
+ /** The RTMP URL to stream to (e.g., rtmp://server.example.com/live/stream-key) */
15
+ rtmpUrl: string;
16
+ /** Optional video configuration settings */
17
+ video?: VideoConfig;
18
+ /** Optional audio configuration settings */
19
+ audio?: AudioConfig;
20
+ /** Optional stream configuration settings */
21
+ stream?: StreamConfig;
22
+ }
23
+ /**
24
+ * StreamingModule provides functionality for TPAs to request and manage RTMP streams.
25
+ *
26
+ * Streams can be requested with configurable parameters for video quality,
27
+ * audio settings, and stream constraints. Status updates are received through
28
+ * the standard subscription mechanism.
29
+ */
30
+ export declare class StreamingModule {
31
+ private send;
32
+ private packageName;
33
+ private sessionId;
34
+ private session?;
35
+ private isStreaming;
36
+ private currentStreamUrl?;
37
+ private currentStreamState?;
38
+ /**
39
+ * Create a new StreamingModule
40
+ *
41
+ * @param packageName - The TPA package name
42
+ * @param sessionId - The current session ID
43
+ * @param send - Function to send messages to the cloud
44
+ * @param session - Reference to the parent TpaSession (optional)
45
+ */
46
+ constructor(packageName: string, sessionId: string, send: (message: any) => void, session?: any);
47
+ /**
48
+ * Begin an RTMP stream to the specified URL
49
+ *
50
+ * @param options - Configuration options for the stream
51
+ * @returns Promise that resolves when the stream request is sent (not when streaming begins)
52
+ */
53
+ requestStream(options: RtmpStreamOptions): Promise<void>;
54
+ /**
55
+ * Stop the current RTMP stream
56
+ *
57
+ * @returns Promise that resolves when the stop request is sent
58
+ */
59
+ stopStream(): Promise<void>;
60
+ /**
61
+ * Check if currently streaming
62
+ *
63
+ * @returns True if a stream is active or initializing
64
+ */
65
+ isCurrentlyStreaming(): boolean;
66
+ /**
67
+ * Get the URL of the current stream (if any)
68
+ *
69
+ * @returns The RTMP URL of the current stream, or undefined if not streaming
70
+ */
71
+ getCurrentStreamUrl(): string | undefined;
72
+ /**
73
+ * Get the current stream status
74
+ *
75
+ * @returns The current stream status, or undefined if not available
76
+ */
77
+ getStreamStatus(): RtmpStreamStatus | undefined;
78
+ /**
79
+ * Subscribe to RTMP stream status updates
80
+ * This uses the standard stream subscription mechanism
81
+ */
82
+ subscribeToStatusUpdates(): void;
83
+ /**
84
+ * Unsubscribe from RTMP stream status updates
85
+ */
86
+ unsubscribeFromStatusUpdates(): void;
87
+ /**
88
+ * Listen for status updates using the standard event system
89
+ * @param handler - Function to call when stream status changes
90
+ * @returns Cleanup function to remove the handler
91
+ */
92
+ onStatus(handler: StreamStatusHandler): () => void;
93
+ /**
94
+ * Update internal stream state based on a status message
95
+ * For internal use by TpaSession
96
+ * @param message - The status message from the cloud
97
+ */
98
+ updateStreamState(message: any): void;
99
+ }
100
+ //# sourceMappingURL=streaming.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../../../src/tpa/session/modules/streaming.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAKL,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EAEZ,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EAEZ,mBAAmB,EACpB,CAAC;AAKF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,kFAAkF;IAClF,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAID;;;;;;GAMG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAC,CAAM;IACtB,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,kBAAkB,CAAC,CAAmB;IAE9C;;;;;;;OAOG;gBACS,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG;IAO/F;;;;;OAKG;IACG,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IA8E9D;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAuCjC;;;;OAIG;IACH,oBAAoB,IAAI,OAAO;IAI/B;;;;OAIG;IACH,mBAAmB,IAAI,MAAM,GAAG,SAAS;IAIzC;;;;OAIG;IACH,eAAe,IAAI,gBAAgB,GAAG,SAAS;IAI/C;;;OAGG;IACH,wBAAwB,IAAI,IAAI;IAQhC;;OAEG;IACH,4BAA4B,IAAI,IAAI;IAMpC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,IAAI;IAUlD;;;;OAIG;IACH,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;CA2DtC"}