yoto-nodejs-client 0.0.1 → 0.0.2

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 (37) hide show
  1. package/bin/lib/cli-helpers.d.ts +32 -0
  2. package/bin/lib/cli-helpers.d.ts.map +1 -1
  3. package/bin/lib/token-helpers.d.ts +32 -0
  4. package/bin/lib/token-helpers.d.ts.map +1 -1
  5. package/index.d.ts +368 -0
  6. package/index.d.ts.map +1 -1
  7. package/lib/api-endpoints/auth.d.ts +85 -0
  8. package/lib/api-endpoints/auth.d.ts.map +1 -1
  9. package/lib/api-endpoints/constants.d.ts +22 -0
  10. package/lib/api-endpoints/constants.d.ts.map +1 -1
  11. package/lib/api-endpoints/content.d.ts +760 -0
  12. package/lib/api-endpoints/content.d.ts.map +1 -1
  13. package/lib/api-endpoints/devices.d.ts +581 -0
  14. package/lib/api-endpoints/devices.d.ts.map +1 -1
  15. package/lib/api-endpoints/family-library-groups.d.ts +187 -0
  16. package/lib/api-endpoints/family-library-groups.d.ts.map +1 -1
  17. package/lib/api-endpoints/family.d.ts +88 -0
  18. package/lib/api-endpoints/family.d.ts.map +1 -1
  19. package/lib/api-endpoints/helpers.d.ts +37 -3
  20. package/lib/api-endpoints/helpers.d.ts.map +1 -1
  21. package/lib/api-endpoints/icons.d.ts +196 -0
  22. package/lib/api-endpoints/icons.d.ts.map +1 -1
  23. package/lib/api-endpoints/media.d.ts +83 -0
  24. package/lib/api-endpoints/media.d.ts.map +1 -1
  25. package/lib/api-endpoints/test-helpers.d.ts +21 -0
  26. package/lib/api-endpoints/test-helpers.d.ts.map +1 -1
  27. package/lib/mqtt/client.d.ts +277 -0
  28. package/lib/mqtt/client.d.ts.map +1 -1
  29. package/lib/mqtt/commands.d.ts +195 -0
  30. package/lib/mqtt/commands.d.ts.map +1 -1
  31. package/lib/mqtt/factory.d.ts +43 -0
  32. package/lib/mqtt/factory.d.ts.map +1 -1
  33. package/lib/mqtt/topics.d.ts +157 -0
  34. package/lib/mqtt/topics.d.ts.map +1 -1
  35. package/lib/token.d.ts +88 -0
  36. package/lib/token.d.ts.map +1 -1
  37. package/package.json +1 -1
@@ -1,4 +1,23 @@
1
+ /**
2
+ * Yoto MQTT Client class
3
+ * @extends EventEmitter
4
+ *
5
+ * @fires YotoMqttClient#events
6
+ * @fires YotoMqttClient#status
7
+ * @fires YotoMqttClient#response
8
+ * @fires YotoMqttClient#connected
9
+ * @fires YotoMqttClient#disconnected
10
+ * @fires YotoMqttClient#reconnecting
11
+ * @fires YotoMqttClient#error
12
+ */
1
13
  export class YotoMqttClient extends EventEmitter<any> {
14
+ /**
15
+ * Create a Yoto MQTT client
16
+ * @param {MqttClient} mqttClient - Underlying MQTT client
17
+ * @param {string} deviceId - Device ID
18
+ * @param {Object} [options] - Client options
19
+ * @param {boolean} [options.autoSubscribe=true] - Auto-subscribe to device topics on connect
20
+ */
2
21
  constructor(mqttClient: MqttClient, deviceId: string, options?: {
3
22
  autoSubscribe?: boolean | undefined;
4
23
  });
@@ -16,17 +35,78 @@ export class YotoMqttClient extends EventEmitter<any> {
16
35
  bluetoothAudioSource: typeof import("./commands.js").createBluetoothAudioSourceCommand;
17
36
  displayPreview: typeof import("./commands.js").createDisplayPreviewCommand;
18
37
  };
38
+ /**
39
+ * Get current connection state
40
+ * @returns {YotoMqttConnectionState}
41
+ */
19
42
  get state(): YotoMqttConnectionState;
43
+ /**
44
+ * Check if client is connected
45
+ * @returns {boolean}
46
+ */
20
47
  get connected(): boolean;
48
+ /**
49
+ * Connect to MQTT broker
50
+ * @returns {Promise<void>}
51
+ */
21
52
  connect(): Promise<void>;
53
+ /**
54
+ * Disconnect from MQTT broker
55
+ * @returns {Promise<void>}
56
+ */
22
57
  disconnect(): Promise<void>;
58
+ /**
59
+ * Request current events from device
60
+ * @returns {Promise<void>}
61
+ */
23
62
  requestEvents(): Promise<void>;
63
+ /**
64
+ * Request current status from device
65
+ * @returns {Promise<void>}
66
+ */
24
67
  requestStatus(): Promise<void>;
68
+ /**
69
+ * Set device volume
70
+ * @param {number} volume - Volume level [0-100]
71
+ * @returns {Promise<void>}
72
+ */
25
73
  setVolume(volume: number): Promise<void>;
74
+ /**
75
+ * Set ambient light color
76
+ * @param {number} r - Red intensity [0-255]
77
+ * @param {number} g - Green intensity [0-255]
78
+ * @param {number} b - Blue intensity [0-255]
79
+ * @returns {Promise<void>}
80
+ */
26
81
  setAmbient(r: number, g: number, b: number): Promise<void>;
82
+ /**
83
+ * Set ambient light color from hex
84
+ * @param {string} hexColor - Hex color string (e.g., "#FF0000")
85
+ * @returns {Promise<void>}
86
+ */
27
87
  setAmbientHex(hexColor: string): Promise<void>;
88
+ /**
89
+ * Set sleep timer
90
+ * @param {number} seconds - Timer duration in seconds (0 to disable)
91
+ * @returns {Promise<void>}
92
+ */
28
93
  setSleepTimer(seconds: number): Promise<void>;
94
+ /**
95
+ * Reboot device
96
+ * @returns {Promise<void>}
97
+ */
29
98
  reboot(): Promise<void>;
99
+ /**
100
+ * Start card playback
101
+ * @param {Object} options - Card start options
102
+ * @param {string} options.uri - Card URI (e.g., "https://yoto.io/<cardID>")
103
+ * @param {string} [options.chapterKey] - Chapter to start from
104
+ * @param {string} [options.trackKey] - Track to start from
105
+ * @param {number} [options.secondsIn] - Playback start offset in seconds
106
+ * @param {number} [options.cutOff] - Playback stop offset in seconds
107
+ * @param {boolean} [options.anyButtonStop] - Whether button press stops playback
108
+ * @returns {Promise<void>}
109
+ */
30
110
  startCard(options: {
31
111
  uri: string;
32
112
  chapterKey?: string | undefined;
@@ -35,9 +115,31 @@ export class YotoMqttClient extends EventEmitter<any> {
35
115
  cutOff?: number | undefined;
36
116
  anyButtonStop?: boolean | undefined;
37
117
  }): Promise<void>;
118
+ /**
119
+ * Stop card playback
120
+ * @returns {Promise<void>}
121
+ */
38
122
  stopCard(): Promise<void>;
123
+ /**
124
+ * Pause card playback
125
+ * @returns {Promise<void>}
126
+ */
39
127
  pauseCard(): Promise<void>;
128
+ /**
129
+ * Resume card playback
130
+ * @returns {Promise<void>}
131
+ */
40
132
  resumeCard(): Promise<void>;
133
+ /**
134
+ * Turn Bluetooth on
135
+ * @param {Object} [options] - Bluetooth options
136
+ * @param {string} [options.action] - Bluetooth action
137
+ * @param {boolean | string} [options.mode] - Bluetooth mode
138
+ * @param {number} [options.rssi] - RSSI threshold
139
+ * @param {string} [options.name] - Target device name
140
+ * @param {string} [options.mac] - Target device MAC
141
+ * @returns {Promise<void>}
142
+ */
41
143
  bluetoothOn(options?: {
42
144
  action?: string | undefined;
43
145
  mode?: string | boolean | undefined;
@@ -45,13 +147,49 @@ export class YotoMqttClient extends EventEmitter<any> {
45
147
  name?: string | undefined;
46
148
  mac?: string | undefined;
47
149
  }): Promise<void>;
150
+ /**
151
+ * Turn Bluetooth off
152
+ * @returns {Promise<void>}
153
+ */
48
154
  bluetoothOff(): Promise<void>;
155
+ /**
156
+ * Enable Bluetooth speaker mode
157
+ * @returns {Promise<void>}
158
+ */
49
159
  bluetoothSpeakerMode(): Promise<void>;
160
+ /**
161
+ * Enable Bluetooth audio source mode
162
+ * @returns {Promise<void>}
163
+ */
50
164
  bluetoothAudioSourceMode(): Promise<void>;
165
+ /**
166
+ * Delete all Bluetooth bonds
167
+ * @returns {Promise<void>}
168
+ */
51
169
  bluetoothDeleteBonds(): Promise<void>;
170
+ /**
171
+ * Connect to Bluetooth device
172
+ * @returns {Promise<void>}
173
+ */
52
174
  bluetoothConnect(): Promise<void>;
175
+ /**
176
+ * Disconnect Bluetooth device
177
+ * @returns {Promise<void>}
178
+ */
53
179
  bluetoothDisconnect(): Promise<void>;
180
+ /**
181
+ * Get Bluetooth state
182
+ * @returns {Promise<void>}
183
+ */
54
184
  bluetoothGetState(): Promise<void>;
185
+ /**
186
+ * Preview display icon
187
+ * @param {Object} options - Display preview options
188
+ * @param {string} options.uri - Icon URI
189
+ * @param {number} options.timeout - Display duration in seconds
190
+ * @param {boolean} options.animated - Whether icon is animated
191
+ * @returns {Promise<void>}
192
+ */
55
193
  displayPreview(options: {
56
194
  uri: string;
57
195
  timeout: number;
@@ -59,52 +197,188 @@ export class YotoMqttClient extends EventEmitter<any> {
59
197
  }): Promise<void>;
60
198
  #private;
61
199
  }
200
+ /**
201
+ * Events message from device
202
+ * Note: Messages are partial - only changed fields are included
203
+ */
62
204
  export type YotoEventsMessage = {
205
+ /**
206
+ * - Repeat all tracks
207
+ */
63
208
  repeatAll?: boolean;
209
+ /**
210
+ * - Whether streaming
211
+ */
64
212
  streaming?: boolean;
213
+ /**
214
+ * - Current volume level
215
+ */
65
216
  volume?: number;
217
+ /**
218
+ * - Maximum volume level
219
+ */
66
220
  volumeMax?: number;
221
+ /**
222
+ * - Playback waiting
223
+ */
67
224
  playbackWait?: boolean;
225
+ /**
226
+ * - Sleep timer active
227
+ */
68
228
  sleepTimerActive?: boolean;
229
+ /**
230
+ * - Unix timestamp
231
+ */
69
232
  eventUtc?: number;
233
+ /**
234
+ * - Track duration in seconds
235
+ */
70
236
  trackLength?: number;
237
+ /**
238
+ * - Current position in seconds
239
+ */
71
240
  position?: number;
241
+ /**
242
+ * - Currently playing card ID
243
+ */
72
244
  cardId?: string;
245
+ /**
246
+ * - Source of playback (e.g., "card", "remote", "MQTT")
247
+ */
73
248
  source?: string;
249
+ /**
250
+ * - ISO8601 format timestamp
251
+ */
74
252
  cardUpdatedAt?: string;
253
+ /**
254
+ * - Current chapter title
255
+ */
75
256
  chapterTitle?: string;
257
+ /**
258
+ * - Current chapter key
259
+ */
76
260
  chapterKey?: string;
261
+ /**
262
+ * - Current track title
263
+ */
77
264
  trackTitle?: string;
265
+ /**
266
+ * - Current track key
267
+ */
78
268
  trackKey?: string;
269
+ /**
270
+ * - Playback status (e.g., "playing", "paused", "stopped")
271
+ */
79
272
  playbackStatus?: string;
273
+ /**
274
+ * - Seconds remaining on sleep timer
275
+ */
80
276
  sleepTimerSeconds?: number;
81
277
  };
278
+ /**
279
+ * Status message from device
280
+ */
82
281
  export type YotoStatusMessage = {
282
+ /**
283
+ * - Status message version
284
+ */
83
285
  statusVersion: number;
286
+ /**
287
+ * - Firmware version
288
+ */
84
289
  fwVersion: string;
290
+ /**
291
+ * - Product type identifier
292
+ */
85
293
  productType: string;
294
+ /**
295
+ * - Battery level percentage
296
+ */
86
297
  batteryLevel: number;
298
+ /**
299
+ * - Ambient light sensor reading
300
+ */
87
301
  als: number;
302
+ /**
303
+ * - Free disk space
304
+ */
88
305
  freeDisk: number;
306
+ /**
307
+ * - Shutdown timeout in seconds
308
+ */
89
309
  shutdownTimeout: number;
310
+ /**
311
+ * - DBAT timeout
312
+ */
90
313
  dbatTimeout: number;
314
+ /**
315
+ * - Charging state (0 or 1)
316
+ */
91
317
  charging: number;
318
+ /**
319
+ * - Active card ID
320
+ */
92
321
  activeCard: string;
322
+ /**
323
+ * - Card insertion state
324
+ */
93
325
  cardInserted: number;
326
+ /**
327
+ * - Playing status code
328
+ */
94
329
  playingStatus: number;
330
+ /**
331
+ * - Headphones connected
332
+ */
95
333
  headphones: boolean;
334
+ /**
335
+ * - Current display brightness
336
+ */
96
337
  dnowBrightness: number;
338
+ /**
339
+ * - Day brightness setting
340
+ */
97
341
  dayBright: number;
342
+ /**
343
+ * - Night brightness setting
344
+ */
98
345
  nightBright: number;
346
+ /**
347
+ * - Bluetooth headphones enabled
348
+ */
99
349
  bluetoothHp: boolean;
350
+ /**
351
+ * - Current volume
352
+ */
100
353
  volume: number;
354
+ /**
355
+ * - User volume setting
356
+ */
101
357
  userVolume: number;
358
+ /**
359
+ * - Time format preference
360
+ */
102
361
  timeFormat: "12" | "24";
362
+ /**
363
+ * - Nightlight mode setting
364
+ */
103
365
  nightlightMode: string;
366
+ /**
367
+ * - Temperature reading
368
+ */
104
369
  temp: string;
370
+ /**
371
+ * - Day mode (0 or 1)
372
+ */
105
373
  day: number;
106
374
  };
375
+ /**
376
+ * Response message from device
377
+ */
107
378
  export type YotoResponseMessage = {
379
+ /**
380
+ * - Status object with dynamic resource keys
381
+ */
108
382
  status: {
109
383
  volume?: "OK" | "FAIL" | undefined;
110
384
  ambients?: "OK" | "FAIL" | undefined;
@@ -118,6 +392,9 @@ export type YotoResponseMessage = {
118
392
  sleepTimer: "OK" | "FAIL";
119
393
  };
120
394
  };
395
+ /**
396
+ * MQTT connection state
397
+ */
121
398
  export type YotoMqttConnectionState = "disconnected" | "connected" | "reconnecting";
122
399
  import { EventEmitter } from 'events';
123
400
  import type { MqttClient } from 'mqtt';
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["client.js"],"names":[],"mappings":"AAgIA;IAQE,wBALW,UAAU,YACV,MAAM,YAEd;QAA0B,aAAa;KACzC,EAaA;IATC,uBAA4B;IAC5B,iBAAwB;IACxB,uBAAoD;IAMpD;;;;;;;;;;MAAwB;IAO1B,aAFa,uBAAuB,CAMnC;IAMD,iBAFa,OAAO,CAInB;IA2GD,WAFa,OAAO,CAAC,IAAI,CAAC,CA8BzB;IAMD,cAFa,OAAO,CAAC,IAAI,CAAC,CAiBzB;IA4BD,iBAFa,OAAO,CAAC,IAAI,CAAC,CAKzB;IAMD,iBAFa,OAAO,CAAC,IAAI,CAAC,CAKzB;IAOD,kBAHW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAMzB;IASD,cALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAMzB;IAOD,wBAHW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAMzB;IAOD,uBAHW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAMzB;IAMD,UAFa,OAAO,CAAC,IAAI,CAAC,CAKzB;IAaD,mBARG;QAAwB,GAAG,EAAnB,MAAM;QACW,UAAU;QACV,QAAQ;QACR,SAAS;QACT,MAAM;QACL,aAAa;KACvC,GAAU,OAAO,CAAC,IAAI,CAAC,CAMzB;IAMD,YAFa,OAAO,CAAC,IAAI,CAAC,CAKzB;IAMD,aAFa,OAAO,CAAC,IAAI,CAAC,CA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AM;;;;kBACN,MAAM;;;;mBACN,MAAM;;;;gBACN,OAAO;;;;oBACP,MAAM;;;;eACN,MAAM;;;;iBACN,MAAM;;;;iBACN,OAAO;;;;YACP,MAAM;;;;gBACN,MAAM;;;;gBACN,IAAI,GAAG,IAAI;;;;oBACX,MAAM;;;;UACN,MAAM;;;;SACN,MAAM;;;;;;;;;YAQjB;QAAkC,MAAM;QACN,QAAQ;QACR,IAAI;QACJ,MAAM;QACN,MAAM;QACN,SAAS;QACT,OAAO;QACP,MAAM;QACd,QAAQ,EAAvB,MAAM;QACgB,UAAU,EAAhC,IAAI,GAAG,MAAM;KAE1B;;;;;sCAIY,cAAc,GAAG,WAAW,GAAG,cAAc;6BAG7B,QAAQ;gCAhFN,MAAM"}
@@ -1,7 +1,100 @@
1
+ /**
2
+ * MQTT Command Builders for Yoto Players
3
+ *
4
+ * Type-safe builders for constructing MQTT command payloads
5
+ * @see https://yoto.dev/players-mqtt/
6
+ */
7
+ /**
8
+ * Volume command payload
9
+ * @see https://yoto.dev/players-mqtt/mqtt-docs/#deviceidcommandvolumeset
10
+ * @typedef {Object} YotoVolumeCommand
11
+ * @property {number} volume - Volume level [0-100]
12
+ */
13
+ /**
14
+ * Ambient light command payload
15
+ * @see https://yoto.dev/players-mqtt/mqtt-docs/#deviceidcommandambientsset
16
+ * @typedef {Object} YotoAmbientCommand
17
+ * @property {number} r - Red intensity [0-255]
18
+ * @property {number} g - Green intensity [0-255]
19
+ * @property {number} b - Blue intensity [0-255]
20
+ */
21
+ /**
22
+ * Sleep timer command payload
23
+ * @see https://yoto.dev/players-mqtt/mqtt-docs/#deviceidcommandsleep-timerset
24
+ * @typedef {Object} YotoSleepTimerCommand
25
+ * @property {number} seconds - Timer duration in seconds (0 to disable)
26
+ */
27
+ /**
28
+ * Card start command payload
29
+ * @see https://yoto.dev/players-mqtt/mqtt-docs/#deviceidcommandcardstart
30
+ * @typedef {Object} YotoCardStartCommand
31
+ * @property {string} uri - Card URI (e.g., "https://yoto.io/<cardID>")
32
+ * @property {string} [chapterKey] - Chapter to start from
33
+ * @property {string} [trackKey] - Track to start from
34
+ * @property {number} [secondsIn] - Playback start offset in seconds
35
+ * @property {number} [cutOff] - Playback stop offset in seconds
36
+ * @property {boolean} [anyButtonStop] - Whether button press stops playback
37
+ */
38
+ /**
39
+ * Bluetooth command payload
40
+ * @see https://yoto.dev/players-mqtt/mqtt-docs/#deviceidcommandbluetooth
41
+ * @typedef {Object} YotoBluetoothCommand
42
+ * @property {string} [action] - Bluetooth action (e.g., "on")
43
+ * @property {boolean | string} [mode] - Bluetooth mode (true for audio source, "bt_speaker" for sink)
44
+ * @property {number} [rssi] - RSSI threshold for auto-connect
45
+ * @property {string} [name] - Target Bluetooth device name
46
+ * @property {string} [mac] - Target Bluetooth MAC address
47
+ */
48
+ /**
49
+ * Display preview command payload
50
+ * @see https://yoto.dev/players-mqtt/mqtt-docs/#deviceidcommanddisplaypreview
51
+ * @typedef {Object} YotoDisplayPreviewCommand
52
+ * @property {string} uri - Filepath to icon asset
53
+ * @property {number} timeout - Display duration in seconds
54
+ * @property {0 | 1} animated - Whether icon is animated (1) or static (0)
55
+ */
56
+ /**
57
+ * Create a volume set command
58
+ * @param {number} volume - Volume level [0-100]
59
+ * @returns {YotoVolumeCommand}
60
+ * @throws {Error} If volume is out of range
61
+ */
1
62
  export function createVolumeCommand(volume: number): YotoVolumeCommand;
63
+ /**
64
+ * Create an ambient light set command
65
+ * @param {number} r - Red intensity [0-255]
66
+ * @param {number} g - Green intensity [0-255]
67
+ * @param {number} b - Blue intensity [0-255]
68
+ * @returns {YotoAmbientCommand}
69
+ * @throws {Error} If any color value is out of range
70
+ */
2
71
  export function createAmbientCommand(r: number, g: number, b: number): YotoAmbientCommand;
72
+ /**
73
+ * Create an ambient light command from hex color
74
+ * @param {string} hexColor - Hex color string (e.g., "#FF0000" or "FF0000")
75
+ * @returns {YotoAmbientCommand}
76
+ * @throws {Error} If hex color is invalid
77
+ */
3
78
  export function createAmbientCommandFromHex(hexColor: string): YotoAmbientCommand;
79
+ /**
80
+ * Create a sleep timer set command
81
+ * @param {number} seconds - Timer duration in seconds (0 to disable)
82
+ * @returns {YotoSleepTimerCommand}
83
+ * @throws {Error} If seconds is negative
84
+ */
4
85
  export function createSleepTimerCommand(seconds: number): YotoSleepTimerCommand;
86
+ /**
87
+ * Create a card start command
88
+ * @param {Object} options - Card start options
89
+ * @param {string} options.uri - Card URI (e.g., "https://yoto.io/<cardID>")
90
+ * @param {string} [options.chapterKey] - Chapter to start from
91
+ * @param {string} [options.trackKey] - Track to start from
92
+ * @param {number} [options.secondsIn] - Playback start offset in seconds
93
+ * @param {number} [options.cutOff] - Playback stop offset in seconds
94
+ * @param {boolean} [options.anyButtonStop] - Whether button press stops playback
95
+ * @returns {YotoCardStartCommand}
96
+ * @throws {Error} If uri is missing
97
+ */
5
98
  export function createCardStartCommand(options: {
6
99
  uri: string;
7
100
  chapterKey?: string | undefined;
@@ -10,6 +103,16 @@ export function createCardStartCommand(options: {
10
103
  cutOff?: number | undefined;
11
104
  anyButtonStop?: boolean | undefined;
12
105
  }): YotoCardStartCommand;
106
+ /**
107
+ * Create a bluetooth on command
108
+ * @param {Object} [options] - Bluetooth options
109
+ * @param {string} [options.action] - Bluetooth action (e.g., "on")
110
+ * @param {boolean | string} [options.mode] - Bluetooth mode (true for audio source, "bt_speaker" for sink)
111
+ * @param {number} [options.rssi] - RSSI threshold for auto-connect
112
+ * @param {string} [options.name] - Target Bluetooth device name
113
+ * @param {string} [options.mac] - Target Bluetooth MAC address
114
+ * @returns {YotoBluetoothCommand}
115
+ */
13
116
  export function createBluetoothOnCommand(options?: {
14
117
  action?: string | undefined;
15
118
  mode?: string | boolean | undefined;
@@ -17,8 +120,25 @@ export function createBluetoothOnCommand(options?: {
17
120
  name?: string | undefined;
18
121
  mac?: string | undefined;
19
122
  }): YotoBluetoothCommand;
123
+ /**
124
+ * Create a bluetooth speaker mode command
125
+ * @returns {YotoBluetoothCommand}
126
+ */
20
127
  export function createBluetoothSpeakerCommand(): YotoBluetoothCommand;
128
+ /**
129
+ * Create a bluetooth audio source mode command
130
+ * @returns {YotoBluetoothCommand}
131
+ */
21
132
  export function createBluetoothAudioSourceCommand(): YotoBluetoothCommand;
133
+ /**
134
+ * Create a display preview command
135
+ * @param {Object} options - Display preview options
136
+ * @param {string} options.uri - Filepath to icon asset
137
+ * @param {number} options.timeout - Display duration in seconds
138
+ * @param {boolean} options.animated - Whether icon is animated
139
+ * @returns {YotoDisplayPreviewCommand}
140
+ * @throws {Error} If uri or timeout is missing
141
+ */
22
142
  export function createDisplayPreviewCommand(options: {
23
143
  uri: string;
24
144
  timeout: number;
@@ -35,35 +155,110 @@ export namespace commands {
35
155
  export { createBluetoothAudioSourceCommand as bluetoothAudioSource };
36
156
  export { createDisplayPreviewCommand as displayPreview };
37
157
  }
158
+ /**
159
+ * Volume command payload
160
+ */
38
161
  export type YotoVolumeCommand = {
162
+ /**
163
+ * - Volume level [0-100]
164
+ */
39
165
  volume: number;
40
166
  };
167
+ /**
168
+ * Ambient light command payload
169
+ */
41
170
  export type YotoAmbientCommand = {
171
+ /**
172
+ * - Red intensity [0-255]
173
+ */
42
174
  r: number;
175
+ /**
176
+ * - Green intensity [0-255]
177
+ */
43
178
  g: number;
179
+ /**
180
+ * - Blue intensity [0-255]
181
+ */
44
182
  b: number;
45
183
  };
184
+ /**
185
+ * Sleep timer command payload
186
+ */
46
187
  export type YotoSleepTimerCommand = {
188
+ /**
189
+ * - Timer duration in seconds (0 to disable)
190
+ */
47
191
  seconds: number;
48
192
  };
193
+ /**
194
+ * Card start command payload
195
+ */
49
196
  export type YotoCardStartCommand = {
197
+ /**
198
+ * - Card URI (e.g., "https://yoto.io/<cardID>")
199
+ */
50
200
  uri: string;
201
+ /**
202
+ * - Chapter to start from
203
+ */
51
204
  chapterKey?: string;
205
+ /**
206
+ * - Track to start from
207
+ */
52
208
  trackKey?: string;
209
+ /**
210
+ * - Playback start offset in seconds
211
+ */
53
212
  secondsIn?: number;
213
+ /**
214
+ * - Playback stop offset in seconds
215
+ */
54
216
  cutOff?: number;
217
+ /**
218
+ * - Whether button press stops playback
219
+ */
55
220
  anyButtonStop?: boolean;
56
221
  };
222
+ /**
223
+ * Bluetooth command payload
224
+ */
57
225
  export type YotoBluetoothCommand = {
226
+ /**
227
+ * - Bluetooth action (e.g., "on")
228
+ */
58
229
  action?: string;
230
+ /**
231
+ * - Bluetooth mode (true for audio source, "bt_speaker" for sink)
232
+ */
59
233
  mode?: boolean | string;
234
+ /**
235
+ * - RSSI threshold for auto-connect
236
+ */
60
237
  rssi?: number;
238
+ /**
239
+ * - Target Bluetooth device name
240
+ */
61
241
  name?: string;
242
+ /**
243
+ * - Target Bluetooth MAC address
244
+ */
62
245
  mac?: string;
63
246
  };
247
+ /**
248
+ * Display preview command payload
249
+ */
64
250
  export type YotoDisplayPreviewCommand = {
251
+ /**
252
+ * - Filepath to icon asset
253
+ */
65
254
  uri: string;
255
+ /**
256
+ * - Display duration in seconds
257
+ */
66
258
  timeout: number;
259
+ /**
260
+ * - Whether icon is animated (1) or static (0)
261
+ */
67
262
  animated: 0 | 1;
68
263
  };
69
264
  //# sourceMappingURL=commands.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["commands.js"],"names":[],"mappings":"AAwEA,4CAJW,MAAM,GACJ,iBAAiB,CAS7B;AAUD,wCANW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,kBAAkB,CAS9B;AAQD,sDAJW,MAAM,GACJ,kBAAkB,CAgB9B;AAQD,iDAJW,MAAM,GACJ,qBAAqB,CASjC;AAcD,gDATG;IAAwB,GAAG,EAAnB,MAAM;IACW,UAAU;IACV,QAAQ;IACR,SAAS;IACT,MAAM;IACL,aAAa;CACvC,GAAU,oBAAoB,CAkBhC;AAYD,mDAPG;IAAyB,MAAM;IACI,IAAI;IACd,IAAI;IACJ,IAAI;IACJ,GAAG;CAC5B,GAAU,oBAAoB,CAahC;AAMD,iDAFa,oBAAoB,CAIhC;AAMD,qDAFa,oBAAoB,CAIhC;AAWD,qDANG;IAAwB,GAAG,EAAnB,MAAM;IACU,OAAO,EAAvB,MAAM;IACW,QAAQ,EAAzB,OAAO;CACf,GAAU,yBAAyB,CAiBrC;;;;;;;;;;;;;YA/Ma,MAAM;;;OAON,MAAM;OACN,MAAM;OACN,MAAM;;;aAON,MAAM;;;SAON,MAAM;iBACN,MAAM;eACN,MAAM;gBACN,MAAM;aACN,MAAM;oBACN,OAAO;;;aAOP,MAAM;WACN,OAAO,GAAG,MAAM;WAChB,MAAM;WACN,MAAM;UACN,MAAM;;;SAON,MAAM;aACN,MAAM;cACN,CAAC,GAAG,CAAC"}
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["commands.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;GAKG;AAEH;;;;;;;GAOG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;GASG;AAEH;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,4CAJW,MAAM,GACJ,iBAAiB,CAS7B;AAED;;;;;;;GAOG;AACH,wCANW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,kBAAkB,CAS9B;AAED;;;;;GAKG;AACH,sDAJW,MAAM,GACJ,kBAAkB,CAgB9B;AAED;;;;;GAKG;AACH,iDAJW,MAAM,GACJ,qBAAqB,CASjC;AAED;;;;;;;;;;;GAWG;AACH,gDATG;IAAwB,GAAG,EAAnB,MAAM;IACW,UAAU;IACV,QAAQ;IACR,SAAS;IACT,MAAM;IACL,aAAa;CACvC,GAAU,oBAAoB,CAkBhC;AAED;;;;;;;;;GASG;AACH,mDAPG;IAAyB,MAAM;IACI,IAAI;IACd,IAAI;IACJ,IAAI;IACJ,GAAG;CAC5B,GAAU,oBAAoB,CAahC;AAED;;;GAGG;AACH,iDAFa,oBAAoB,CAIhC;AAED;;;GAGG;AACH,qDAFa,oBAAoB,CAIhC;AAED;;;;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