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