@reveldigital/player-client 1.0.13 → 1.0.15

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 (33) hide show
  1. package/README.md +236 -3
  2. package/esm2020/lib/interfaces/client.interface.mjs +1 -1
  3. package/esm2020/lib/interfaces/command.interface.mjs +1 -1
  4. package/esm2020/lib/interfaces/config.interface.mjs +45 -1
  5. package/esm2020/lib/interfaces/device.interface.mjs +1 -1
  6. package/esm2020/lib/interfaces/event-properties.interface.mjs +1 -1
  7. package/esm2020/lib/interfaces/location.interface.mjs +1 -1
  8. package/esm2020/lib/player-client.service.mjs +506 -76
  9. package/esm2020/lib/safe-style.pipe.mjs +3 -2
  10. package/esm2020/lib/version.mjs +2 -2
  11. package/fesm2015/reveldigital-player-client.mjs +509 -80
  12. package/fesm2015/reveldigital-player-client.mjs.map +1 -1
  13. package/fesm2020/reveldigital-player-client.mjs +509 -79
  14. package/fesm2020/reveldigital-player-client.mjs.map +1 -1
  15. package/lib/interfaces/client.interface.d.ts +318 -76
  16. package/lib/interfaces/client.interface.d.ts.map +1 -1
  17. package/lib/interfaces/command.interface.d.ts +66 -6
  18. package/lib/interfaces/command.interface.d.ts.map +1 -1
  19. package/lib/interfaces/config.interface.d.ts +127 -9
  20. package/lib/interfaces/config.interface.d.ts.map +1 -1
  21. package/lib/interfaces/device.interface.d.ts +104 -16
  22. package/lib/interfaces/device.interface.d.ts.map +1 -1
  23. package/lib/interfaces/event-properties.interface.d.ts +127 -3
  24. package/lib/interfaces/event-properties.interface.d.ts.map +1 -1
  25. package/lib/interfaces/location.interface.d.ts +150 -21
  26. package/lib/interfaces/location.interface.d.ts.map +1 -1
  27. package/lib/player-client.service.d.ts +491 -71
  28. package/lib/player-client.service.d.ts.map +1 -1
  29. package/lib/safe-style.pipe.d.ts +2 -1
  30. package/lib/safe-style.pipe.d.ts.map +1 -1
  31. package/lib/version.d.ts +1 -1
  32. package/package.json +3 -2
  33. package/schematics/ng-add/utils/yml2xml.js +2 -1
@@ -12,28 +12,120 @@ import { APP_BASE_HREF } from '@angular/common';
12
12
  import * as i1$1 from '@angular/platform-browser';
13
13
 
14
14
  // Generated by genversion.
15
- const version = '1.0.13';
15
+ const version = '1.0.15';
16
16
 
17
+ /**
18
+ * Service for interacting with the Revel Digital player client.
19
+ *
20
+ * This service provides a comprehensive interface for gadgets and web applications
21
+ * to communicate with the Revel Digital player environment. It handles device
22
+ * information, commands, events, analytics tracking, and configuration management.
23
+ *
24
+ * The service supports both direct API calls and event-based communication patterns,
25
+ * allowing gadgets to respond to player lifecycle events (start, stop, commands) and
26
+ * send data back to the player or remote devices.
27
+ *
28
+ * ```typescript
29
+ * constructor(private client: PlayerClientService) {
30
+ * // Subscribe to player events
31
+ * this.client.onStart$.subscribe(() => {
32
+ * console.log('Gadget started');
33
+ * });
34
+ *
35
+ * this.client.onCommand$.subscribe(command => {
36
+ * console.log('Received command:', command);
37
+ * });
38
+ * }
39
+ *
40
+ * async ngOnInit() {
41
+ * // Get device information
42
+ * const device = await this.client.getDevice();
43
+ * const deviceTime = await this.client.getDeviceTime();
44
+ *
45
+ * // Track analytics
46
+ * this.client.track('gadget_loaded', { version: '1.0' });
47
+ * }
48
+ * ```
49
+ *
50
+ * @since 1.0.0
51
+ */
17
52
  class PlayerClientService {
18
53
  /** @ignore */
19
54
  constructor(zone) {
20
55
  /**
21
- * Commands sent to this player.
56
+ * Observable stream of commands sent to this player from the Revel Digital platform.
57
+ * Subscribe to this to handle custom commands sent from templates, playlists, or remote devices.
58
+ *
59
+ * ```typescript
60
+ * this.client.onCommand$.subscribe(command => {
61
+ * if (command.name === 'customAction') {
62
+ * this.handleCustomAction(command.arg);
63
+ * }
64
+ * });
65
+ * ```
22
66
  */
23
67
  this.onCommand$ = new Subject();
24
68
  /**
25
- * Signals the gadget has been loaded and is ready to start.
69
+ * Observable that signals when the gadget has been loaded and is ready to start.
70
+ * Emits `true` when ready, `false` when destroyed.
71
+ *
72
+ * ```typescript
73
+ * this.client.onReady$.subscribe(isReady => {
74
+ * if (isReady) {
75
+ * console.log('Client is ready');
76
+ * this.initializeGadget();
77
+ * }
78
+ * });
79
+ * ```
26
80
  */
27
81
  this.onReady$ = new BehaviorSubject(false);
28
82
  /**
29
- * Signals the gadget has been started by the player.
83
+ * Observable that signals when the gadget has been started by the player.
84
+ * This event occurs when the player begins execution of the gadget content.
85
+ *
86
+ * ```typescript
87
+ * this.client.onStart$.subscribe(() => {
88
+ * console.log('Gadget started');
89
+ * this.startAnimation();
90
+ * });
91
+ * ```
30
92
  */
31
93
  this.onStart$ = new Subject();
32
94
  /**
33
- * Signals the gadgets has been stopped by the player.
95
+ * Observable that signals when the gadget has been stopped by the player.
96
+ * This event occurs when the player stops execution, typically when moving
97
+ * to the next item in a playlist or when the content duration expires.
98
+ *
99
+ * ```typescript
100
+ * this.client.onStop$.subscribe(() => {
101
+ * console.log('Gadget stopped');
102
+ * this.cleanup();
103
+ * });
104
+ * ```
34
105
  */
35
106
  this.onStop$ = new Subject();
107
+ /**
108
+ * Observable that signals when the gadget should open the configuration window.
109
+ * This allows gadgets to respond to configuration requests from the player.
110
+ *
111
+ * ```typescript
112
+ * this.client.onConfig$.subscribe(() => {
113
+ * this.openConfigurationDialog();
114
+ * });
115
+ * ```
116
+ */
36
117
  this.onConfig$ = new Subject();
118
+ /**
119
+ * Observable that signals when the gadget has received a postMessage event from the player.
120
+ * This handles communication between the gadget and player via the postMessage API.
121
+ *
122
+ * ```typescript
123
+ * this.client.onPostMessage$.subscribe(message => {
124
+ * console.log('Received message:', message);
125
+ * this.handlePlayerMessage(message);
126
+ * });
127
+ * ```
128
+ */
37
129
  this.onPostMessage$ = new Subject();
38
130
  /** @ignore */
39
131
  this.onStartEvt$ = fromEvent(window, 'RevelDigital.Start').pipe(share(), tap(this.onStart$));
@@ -95,14 +187,21 @@ class PlayerClientService {
95
187
  console.log('%c⚙️ Initializing Revel Digital client library', 'background-color:blue; color:yellow;');
96
188
  }
97
189
  /**
190
+ * Sends a callback to player scripting with variable arguments.
191
+ *
98
192
  * This method allows the gadget to communicate with player scripting.
99
- * If the appropriate scripting is in place in the currently running template, calling this method
100
- * will initiate a callback which can be acted upon in player script.
193
+ * If the appropriate scripting is in place in the currently running template,
194
+ * calling this method will initiate a callback which can be acted upon in player script.
101
195
  *
102
- * @example
103
- * client.callback('test', 'this');
196
+ * @param args - Variable number of arguments to pass to the callback (max 5 arguments)
104
197
  *
105
- * @param args variable number of arguments
198
+ * ```typescript
199
+ * // Send a simple callback
200
+ * this.client.callback('test', 'data');
201
+ *
202
+ * // Send multiple parameters
203
+ * this.client.callback('action', 'value1', 'value2', { data: 'object' });
204
+ * ```
106
205
  */
107
206
  callback(...args) {
108
207
  this.getClient().then((client) => {
@@ -129,26 +228,47 @@ class PlayerClientService {
129
228
  });
130
229
  }
131
230
  /**
132
- * Accessor method for the user preferences interface exposed by the Gadgets API.
231
+ * Gets the user preferences interface exposed by the Google Gadgets API.
232
+ *
233
+ * This method provides access to gadget preferences which can be configured
234
+ * in the Revel Digital CMS. Use this to retrieve user-configurable settings
235
+ * for your gadget.
133
236
  *
134
- * See {@link https://developers.google.com/gadgets/docs/basic} for more details on the Gadgets API.
237
+ * @returns The Gadgets API Prefs object for accessing preference values
135
238
  *
136
- * @example
239
+ * ```typescript
137
240
  * constructor(public client: PlayerClientService) {
138
- * let prefs = client.getPrefs();
139
- * let myString = prefs.getString('myStringPref');
241
+ * const prefs = client.getPrefs();
242
+ * const myString = prefs.getString('myStringPref');
243
+ * const myNumber = prefs.getInt('myNumberPref');
244
+ * const myBool = prefs.getBool('myBoolPref');
140
245
  * }
141
- * @returns {gadgets.Prefs} Gadget API Prefs object
246
+ * ```
247
+ *
248
+ * @see {@link https://developers.google.com/gadgets/docs/basic} Google Gadgets API documentation
142
249
  */
143
250
  getPrefs() {
144
251
  return new window['gadgets']['Prefs']();
145
252
  }
146
253
  /**
147
- * Returns the current device time in ISO8601 format.
254
+ * Gets the current device time in ISO8601 format.
255
+ *
148
256
  * Current device time is determined by the device timezone assigned to the device in the CMS.
257
+ * This is useful for displaying time-sensitive content or scheduling operations based on
258
+ * the device's local time rather than browser time.
149
259
  *
150
- * @param date Optional. If supplied will translate the supplied date/time to device time based on respective timezones.
151
- * @returns Date/time in ISO8601 format
260
+ * @param date - Optional. If supplied, will translate the supplied date/time to device time based on respective timezones
261
+ * @returns Promise resolving to date/time in ISO8601 format
262
+ *
263
+ * ```typescript
264
+ * // Get current device time
265
+ * const currentTime = await this.client.getDeviceTime();
266
+ * console.log('Device time:', currentTime);
267
+ *
268
+ * // Convert a specific date to device time
269
+ * const specificDate = new Date('2023-01-01T12:00:00Z');
270
+ * const deviceTime = await this.client.getDeviceTime(specificDate);
271
+ * ```
152
272
  */
153
273
  async getDeviceTime(date) {
154
274
  const client = await this.getClient();
@@ -158,55 +278,99 @@ class PlayerClientService {
158
278
  return client.getDeviceTime();
159
279
  }
160
280
  /**
161
- * Returns the timezone name currently assigned to the device.
281
+ * Gets the timezone name currently assigned to the device.
282
+ *
283
+ * @returns Promise resolving to the timezone name (e.g., "America/New_York")
162
284
  *
163
- * @returns Timezone Name
285
+ * ```typescript
286
+ * const timezoneName = await this.client.getDeviceTimeZoneName();
287
+ * console.log('Device timezone:', timezoneName);
288
+ * ```
164
289
  */
165
290
  async getDeviceTimeZoneName() {
166
291
  const client = await this.getClient();
167
292
  return client.getDeviceTimeZoneName();
168
293
  }
169
294
  /**
170
- * Returns the timezone ID currently assigned to the device.
295
+ * Gets the timezone ID currently assigned to the device.
171
296
  *
172
- * @returns Timezone ID
297
+ * @returns Promise resolving to the timezone ID
298
+ *
299
+ * ```typescript
300
+ * const timezoneId = await this.client.getDeviceTimeZoneID();
301
+ * console.log('Device timezone ID:', timezoneId);
302
+ * ```
173
303
  */
174
304
  async getDeviceTimeZoneID() {
175
305
  const client = await this.getClient();
176
306
  return client.getDeviceTimeZoneID();
177
307
  }
178
308
  /**
179
- * Returns the numerical offset from GMT of the timezone currently assigned to the device.
309
+ * Gets the numerical offset from GMT of the timezone currently assigned to the device.
310
+ *
311
+ * @returns Promise resolving to the timezone offset in hours (e.g., -5 for EST)
180
312
  *
181
- * @returns Timezone offset
313
+ * ```typescript
314
+ * const offset = await this.client.getDeviceTimeZoneOffset();
315
+ * console.log('Device timezone offset:', offset, 'hours from GMT');
316
+ * ```
182
317
  */
183
318
  async getDeviceTimeZoneOffset() {
184
319
  const client = await this.getClient();
185
320
  return client.getDeviceTimeZoneOffset();
186
321
  }
187
322
  /**
188
- * Returns the language code of the language currently assigned to the device.
323
+ * Gets the language code of the language currently assigned to the device.
324
+ *
325
+ * @returns Promise resolving to the language code (e.g., "en-US", "fr-FR")
189
326
  *
190
- * @returns Language code
327
+ * ```typescript
328
+ * const languageCode = await this.client.getLanguageCode();
329
+ * console.log('Device language:', languageCode);
330
+ * // Use for localization
331
+ * this.loadLanguageResources(languageCode);
332
+ * ```
191
333
  */
192
334
  async getLanguageCode() {
193
335
  const client = await this.getClient();
194
336
  return client.getLanguageCode();
195
337
  }
196
338
  /**
197
- * Returns the unique Revel Digital device key associated with the device.
339
+ * Gets the unique Revel Digital device key associated with the device.
198
340
  *
199
- * @returns Device key
341
+ * The device key is a unique identifier for this specific player device
342
+ * and can be used for device-specific operations or remote commands.
343
+ *
344
+ * @returns Promise resolving to the device key string
345
+ *
346
+ * ```typescript
347
+ * const deviceKey = await this.client.getDeviceKey();
348
+ * console.log('Device key:', deviceKey);
349
+ * ```
200
350
  */
201
351
  async getDeviceKey() {
202
352
  const client = await this.getClient();
203
353
  return client.getDeviceKey();
204
354
  }
205
355
  /**
206
- * Send a command to the player device.
356
+ * Sends a command to the local player device.
357
+ *
358
+ * Commands can be used to control various aspects of the player or trigger
359
+ * specific behaviors. The command is processed by the local player only.
207
360
  *
208
- * @param name Command name
209
- * @param arg Command argument
361
+ * @param name - The command name/identifier
362
+ * @param arg - The command argument/payload
363
+ *
364
+ * ```typescript
365
+ * // Send a simple command
366
+ * this.client.sendCommand('refresh', '');
367
+ *
368
+ * // Send a command with data
369
+ * this.client.sendCommand('setVolume', '50');
370
+ *
371
+ * // Send a command with JSON data
372
+ * this.client.sendCommand('configure', JSON.stringify({ setting: 'value' }));
373
+ * ```
210
374
  */
211
375
  sendCommand(name, arg) {
212
376
  this.getClient().then((client) => {
@@ -214,12 +378,29 @@ class PlayerClientService {
214
378
  });
215
379
  }
216
380
  /**
217
- * Send a command to any remote player with the supplied device key(s).
381
+ * Sends a command to remote player devices with the specified device keys.
382
+ *
383
+ * Remote commands allow cross-device communication within the same Revel Digital account.
384
+ * This is useful for synchronized displays, device coordination, or remote control scenarios.
385
+ *
218
386
  * Note: Remote commands can only be delivered to devices within the same account as the sender device.
219
387
  *
220
- * @param deviceKeys Array of remote device keys
221
- * @param name Command name
222
- * @param arg Command arg
388
+ * @param deviceKeys - Array of target device keys to send the command to
389
+ * @param name - The command name/identifier
390
+ * @param arg - The command argument/payload
391
+ *
392
+ * ```typescript
393
+ * // Send command to specific devices
394
+ * const targetDevices = ['device-key-1', 'device-key-2'];
395
+ * this.client.sendRemoteCommand(targetDevices, 'syncAction', 'start');
396
+ *
397
+ * // Broadcast to multiple devices
398
+ * this.client.sendRemoteCommand(
399
+ * ['lobby-display', 'kiosk-1', 'kiosk-2'],
400
+ * 'updateContent',
401
+ * JSON.stringify({ contentId: '12345' })
402
+ * );
403
+ * ```
223
404
  */
224
405
  sendRemoteCommand(deviceKeys, name, arg) {
225
406
  this.getClient().then((client) => {
@@ -227,11 +408,33 @@ class PlayerClientService {
227
408
  });
228
409
  }
229
410
  /**
230
- * Log an event for use with AdHawk analytics.
231
- * Events are used for tracking various metrics including usage statistics, player condition, state changes, etc.
411
+ * Logs an analytics event for use with AdHawk analytics and reporting.
232
412
  *
233
- * @param eventName Unique name for this event
234
- * @param properties A map of user defined properties to associate with this event
413
+ * Events are used for tracking various metrics including usage statistics,
414
+ * player condition, state changes, user interactions, and custom business metrics.
415
+ * These events can be viewed in the Revel Digital analytics dashboard.
416
+ *
417
+ * @param eventName - Unique name for this event (should be descriptive and consistent)
418
+ * @param properties - Optional map of user-defined properties to associate with this event
419
+ *
420
+ * ```typescript
421
+ * // Simple event tracking
422
+ * this.client.track('gadget_loaded');
423
+ *
424
+ * // Event with properties
425
+ * this.client.track('user_interaction', {
426
+ * action: 'button_click',
427
+ * button_id: 'start_button',
428
+ * timestamp: new Date().toISOString()
429
+ * });
430
+ *
431
+ * // Performance tracking
432
+ * this.client.track('content_displayed', {
433
+ * content_type: 'video',
434
+ * duration: 30,
435
+ * quality: 'HD'
436
+ * });
437
+ * ```
235
438
  */
236
439
  track(eventName, properties) {
237
440
  this.getClient().then((client) => {
@@ -239,13 +442,32 @@ class PlayerClientService {
239
442
  });
240
443
  }
241
444
  /**
242
- * Method for initiating a timed event.
243
- * Timed events are useful for tracking the duration of an event and must be proceeded with a call to track().
445
+ * Initiates a timed event for duration tracking.
446
+ *
447
+ * Timed events are useful for tracking the duration of operations or user interactions.
448
+ * This method must be followed by a call to track() with the same event name to complete
449
+ * the timing measurement. The duration will be automatically calculated and included
450
+ * in the event properties.
451
+ *
452
+ * @param eventName - Unique name for this timed event (must match the subsequent track() call)
244
453
  *
245
- * @example
246
- * client.timeEvent('testEvent');
247
- * client.track("test", { "a": "b" });
248
- * @param eventName Unique name for this event
454
+ * ```typescript
455
+ * // Start timing an event
456
+ * this.client.timeEvent('video_playback');
457
+ *
458
+ * // ... video plays for some duration ...
459
+ *
460
+ * // End timing and log the event with duration
461
+ * this.client.track('video_playback', {
462
+ * video_id: 'abc123',
463
+ * quality: 'HD'
464
+ * }); // Duration will be automatically added
465
+ *
466
+ * // Example for user interaction timing
467
+ * this.client.timeEvent('form_completion');
468
+ * // ... user fills out form ...
469
+ * this.client.track('form_completion', { form_type: 'contact' });
470
+ * ```
249
471
  */
250
472
  timeEvent(eventName) {
251
473
  this.getClient().then((client) => {
@@ -253,11 +475,33 @@ class PlayerClientService {
253
475
  });
254
476
  }
255
477
  /**
256
- * A session is a way of grouping events together. Each event has an associated session ID.
257
- * Session ID's are randomly generated and reset by subsequent calls to newEventSession().
478
+ * Creates a new analytics event session for grouping related events.
479
+ *
480
+ * A session is a way of grouping events together for analysis. Each event tracked
481
+ * after calling this method will have the same session ID until a new session is created.
482
+ * Session IDs are randomly generated unless explicitly provided.
483
+ *
484
+ * This is useful for tracking user journeys, workflow completion, or grouping
485
+ * related interactions within a specific time period.
486
+ *
487
+ * @param id - Optional user-supplied session ID. If not provided, a random session ID will be generated
488
+ *
489
+ * ```typescript
490
+ * // Start a new session with auto-generated ID
491
+ * this.client.newEventSession();
492
+ * this.client.track('session_start');
493
+ * this.client.track('user_action_1');
494
+ * this.client.track('user_action_2');
258
495
  *
259
- * Each call to track() will utilize the same session ID, until another call to newEventSession().
260
- * @param id Optional. User supplied session ID. If not supplied a random session ID will be generated.
496
+ * // Start a session with custom ID
497
+ * this.client.newEventSession('user-workflow-12345');
498
+ * this.client.track('workflow_start');
499
+ * this.client.track('step_completed', { step: 1 });
500
+ *
501
+ * // Start a new session for different workflow
502
+ * this.client.newEventSession();
503
+ * this.client.track('different_workflow_start');
504
+ * ```
261
505
  */
262
506
  newEventSession(id) {
263
507
  this.getClient().then((client) => {
@@ -270,26 +514,74 @@ class PlayerClientService {
270
514
  });
271
515
  }
272
516
  /**
273
- * Returns the root folder utilized by this player device.
517
+ * Gets the root folder path utilized by this player device.
518
+ *
519
+ * This returns the base directory path where the Revel Digital player
520
+ * stores its files and resources on the local device.
521
+ *
522
+ * @returns Promise resolving to the path of the root folder
274
523
  *
275
- * @returns Path to the root folder
524
+ * ```typescript
525
+ * const rootPath = await this.client.getRevelRoot();
526
+ * console.log('Player root directory:', rootPath);
527
+ * // Use for constructing file paths or understanding storage structure
528
+ * ```
276
529
  */
277
530
  async getRevelRoot() {
278
531
  const client = await this.getClient();
279
532
  return client.getRevelRoot();
280
533
  }
281
534
  /**
282
- * Returns a map of commands currently active for this device.
535
+ * Gets a map of commands currently active for this device.
536
+ *
537
+ * This returns the current command configuration that defines how the device
538
+ * responds to various command triggers and remote commands.
539
+ *
540
+ * @returns Promise resolving to a map of currently active commands
541
+ *
542
+ * ```typescript
543
+ * const commandMap = await this.client.getCommandMap();
544
+ * console.log('Active commands:', commandMap);
283
545
  *
284
- * @returns Map of commands currently active for this device.
546
+ * // Check if specific command is available
547
+ * if (commandMap['customCommand']) {
548
+ * console.log('Custom command is available');
549
+ * }
550
+ * ```
285
551
  */
286
552
  async getCommandMap() {
287
553
  const client = await this.getClient();
288
554
  return JSON.parse(await client.getCommandMap());
289
555
  }
290
556
  /**
291
- * Indicate to the player that this gadget has finished it's visualization.
292
- * This allows the player to proceed with the next item in a playlist if applicable.
557
+ * Signals to the player that this gadget has completed its visualization.
558
+ *
559
+ * This method notifies the player that the current gadget has finished its
560
+ * content display or interaction cycle. The player can then proceed with
561
+ * the next item in a playlist if applicable, or handle the completion
562
+ * according to its configuration.
563
+ *
564
+ * Call this method when your gadget has completed its intended function,
565
+ * such as finishing an animation, completing a form, or reaching a natural
566
+ * stopping point.
567
+ *
568
+ * ```typescript
569
+ * // After completing an animation
570
+ * private onAnimationComplete(): void {
571
+ * this.client.finish();
572
+ * }
573
+ *
574
+ * // After user interaction is complete
575
+ * private onFormSubmitted(): void {
576
+ * this.saveFormData();
577
+ * this.client.finish();
578
+ * }
579
+ *
580
+ * // After a timed display period
581
+ * setTimeout(() => {
582
+ * this.client.finish();
583
+ * }, 30000); // 30 seconds
584
+ * ```
293
585
  */
294
586
  finish() {
295
587
  this.getClient().then((client) => {
@@ -297,20 +589,64 @@ class PlayerClientService {
297
589
  });
298
590
  }
299
591
  /**
300
- * Check is the gadget is running in preview mode. Preview mode is enabled when the gadget is
301
- * being edited in the CMS, or otherwise not running in a normal player environment.
592
+ * Checks if the gadget is running in preview mode.
593
+ *
594
+ * Preview mode is enabled when the gadget is being edited in the Revel Digital CMS,
595
+ * tested in the gadget editor, or otherwise not running in a normal player environment.
596
+ * This is useful for providing different behavior during development/testing versus
597
+ * production deployment.
598
+ *
599
+ * @returns Promise resolving to true if running in preview mode, false if running on actual player
600
+ *
601
+ * ```typescript
602
+ * const isPreview = await this.client.isPreviewMode();
603
+ *
604
+ * if (isPreview) {
605
+ * console.log('Running in preview mode - using mock data');
606
+ * this.loadMockData();
607
+ * } else {
608
+ * console.log('Running on player device - using live data');
609
+ * this.loadLiveData();
610
+ * }
302
611
  *
303
- * @returns True if the gadget is running in preview mode, false otherwise.
612
+ * // Show different UI in preview
613
+ * this.showPreviewIndicator = isPreview;
614
+ * ```
304
615
  */
305
616
  async isPreviewMode() {
306
617
  const client = await this.getClient();
307
618
  return client instanceof NoopClient;
308
619
  }
309
620
  /**
310
- * Returns the device details associated with the player running the gadget or web app.
311
- *
312
- * @returns Device details.
313
- */
621
+ * Gets detailed information about the device running the player.
622
+ *
623
+ * Returns comprehensive device details including name, registration key, type,
624
+ * service date, language, timezone, tags, and location information. This data
625
+ * is configured in the Revel Digital CMS for each device.
626
+ *
627
+ * @returns Promise resolving to device details object, or null if not available
628
+ *
629
+ * ```typescript
630
+ * const device = await this.client.getDevice();
631
+ *
632
+ * if (device) {
633
+ * console.log('Device name:', device.name);
634
+ * console.log('Device type:', device.deviceType);
635
+ * console.log('Location:', device.location.city, device.location.state);
636
+ * console.log('Tags:', device.tags);
637
+ *
638
+ * // Use device info for customization
639
+ * if (device.location.country === 'US') {
640
+ * this.loadUSContent();
641
+ * }
642
+ *
643
+ * // Check device capabilities based on type
644
+ * if (device.deviceType === 'android') {
645
+ * this.enableTouchFeatures();
646
+ * }
647
+ * }
648
+ * ```
649
+ */
314
650
  async getDevice() {
315
651
  const client = await this.getClient();
316
652
  let obj = JSON.parse(await client.getDevice());
@@ -337,41 +673,125 @@ class PlayerClientService {
337
673
  return device[0];
338
674
  }
339
675
  /**
340
- * Returns the width of the visualization area.
676
+ * Gets the width of the visualization area in pixels.
677
+ *
678
+ * This returns the available width for content display, which may be
679
+ * different from the full screen width depending on player configuration
680
+ * and template layout.
681
+ *
682
+ * @returns Promise resolving to width in pixels, or null if not available
341
683
  *
342
- * @returns Width of the visualization area
684
+ * ```typescript
685
+ * const width = await this.client.getWidth();
686
+ *
687
+ * if (width) {
688
+ * console.log('Available width:', width, 'pixels');
689
+ *
690
+ * // Adapt content layout based on width
691
+ * if (width < 800) {
692
+ * this.enableMobileLayout();
693
+ * } else {
694
+ * this.enableDesktopLayout();
695
+ * }
696
+ * }
697
+ * ```
343
698
  */
344
699
  async getWidth() {
345
700
  const client = await this.getClient();
346
701
  return client.getWidth();
347
702
  }
348
703
  /**
349
- * Returns the height of the visualization area.
704
+ * Gets the height of the visualization area in pixels.
350
705
  *
351
- * @returns Height of the visualization area
706
+ * This returns the available height for content display, which may be
707
+ * different from the full screen height depending on player configuration
708
+ * and template layout.
709
+ *
710
+ * @returns Promise resolving to height in pixels, or null if not available
711
+ *
712
+ * ```typescript
713
+ * const height = await this.client.getHeight();
714
+ *
715
+ * if (height) {
716
+ * console.log('Available height:', height, 'pixels');
717
+ *
718
+ * // Calculate aspect ratio for responsive design
719
+ * const width = await this.client.getWidth();
720
+ * const aspectRatio = width / height;
721
+ * this.adjustContentForAspectRatio(aspectRatio);
722
+ * }
723
+ * ```
352
724
  */
353
725
  async getHeight() {
354
726
  const client = await this.getClient();
355
727
  return client.getHeight();
356
728
  }
357
729
  /**
358
- * Returns the duration of the currently playing source.
359
- * (only applicable when associated with a playlist)
730
+ * Gets the duration of the currently playing content item.
731
+ *
732
+ * This method is only applicable when the gadget is associated with a playlist
733
+ * and returns the duration assigned to the current playlist item. The duration
734
+ * determines how long the content should be displayed before moving to the next item.
735
+ *
736
+ * @returns Promise resolving to duration in milliseconds, or null if not applicable/available
360
737
  *
361
- * @returns Duration of the current item in milliseconds
738
+ * ```typescript
739
+ * const duration = await this.client.getDuration();
740
+ *
741
+ * if (duration) {
742
+ * console.log('Content duration:', duration, 'milliseconds');
743
+ *
744
+ * // Set up auto-finish timer
745
+ * setTimeout(() => {
746
+ * this.client.finish();
747
+ * }, duration);
748
+ *
749
+ * // Show progress indicator
750
+ * this.startProgressIndicator(duration);
751
+ * }
752
+ * ```
362
753
  */
363
754
  async getDuration() {
364
755
  const client = await this.getClient();
365
756
  return client.getDuration();
366
757
  }
367
758
  /**
368
- * Returns the current SDK version.
759
+ * Gets the current version of the Revel Digital SDK.
760
+ *
761
+ * @returns Promise resolving to the SDK version string
762
+ *
763
+ * ```typescript
764
+ * const version = await this.client.getSdkVersion();
765
+ * console.log('SDK Version:', version);
369
766
  *
370
- * @returns SDK version
767
+ * // Use for compatibility checks or logging
768
+ * this.client.track('gadget_loaded', { sdkVersion: version });
769
+ * ```
371
770
  */
372
771
  async getSdkVersion() {
373
772
  return Promise.resolve(version);
374
773
  }
774
+ /**
775
+ * Applies configuration preferences to the gadget (preview mode only).
776
+ *
777
+ * This method is only available when running in preview mode (typically during
778
+ * gadget development or testing in the CMS). It allows applying configuration
779
+ * changes that would normally come from the gadget's preference settings.
780
+ *
781
+ * @param prefs - Dictionary of preference key-value pairs to apply
782
+ *
783
+ * ```typescript
784
+ * if (await this.client.isPreviewMode()) {
785
+ * // Apply test configuration in preview
786
+ * await this.client.applyConfig({
787
+ * 'title': 'Test Title',
788
+ * 'backgroundColor': '#ff0000',
789
+ * 'showBorder': true,
790
+ * 'refreshInterval': 30
791
+ * });
792
+ * }
793
+ * ```
794
+ */
375
795
  async applyConfig(prefs) {
376
796
  if (await this.isPreviewMode()) {
377
797
  const client = await this.getClient();
@@ -428,10 +848,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
428
848
  }], ctorParameters: function () { return [{ type: i0.NgZone }]; } });
429
849
  // ----------------------------------------------------------------------------------- //
430
850
  // ----------------------------------------------------------------------------------- //
431
- // I provide a mock API for the 3rd-party script. This just allows the consuming code to
432
- // act as though the library is available even if it failed to load (example, it was
433
- // blocked by an ad-blocker).
434
- /** @ignore */
851
+ /**
852
+ * Mock implementation of the IClient interface.
853
+ *
854
+ * This class provides a no-operation (NOOP) implementation of the client API
855
+ * that allows consuming code to function normally even when the actual player
856
+ * API is not available. This typically occurs during development, testing,
857
+ * or when the player script is blocked by ad-blockers.
858
+ *
859
+ * All methods in this class either return null/empty values or perform no
860
+ * operations, allowing gadgets to function without errors while providing
861
+ * appropriate fallback behavior.
862
+ *
863
+ * @private
864
+ */
435
865
  class NoopClient {
436
866
  constructor() {
437
867
  console.log('%cClient API not available, falling back to mock API', 'background-color:blue; color:yellow;');
@@ -616,8 +1046,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
616
1046
  * The safe style pipe is used when custom styles are defined for a gadget and must be applied to an Angular
617
1047
  * component. This pipe will ensure the style can be appied safely by utilizing the DomSanitizer.
618
1048
  *
619
- * @example
1049
+ * ```html
620
1050
  * <h2 [style]="style | safeStyle">Sample Pref: {{ prefs.getString('myStringPref') }}</h2>
1051
+ * ```
621
1052
  */
622
1053
  class SafeStylePipe {
623
1054
  constructor(sanitized) {
@@ -646,8 +1077,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
646
1077
  declarations: [SafeStylePipe],
647
1078
  exports: [SafeStylePipe],
648
1079
  }]
649
- }] });
650
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2FmZS1zdHlsZS5waXBlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvcmV2ZWxkaWdpdGFsL3BsYXllci1jbGllbnQvc3JjL2xpYi9zYWZlLXN0eWxlLnBpcGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLElBQUksRUFBaUIsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDOzs7QUFHOUQ7Ozs7OztHQU1HO0FBSUgsTUFBTSxPQUFPLGFBQWE7SUFDdEIsWUFBb0IsU0FBdUI7UUFBdkIsY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