@raydiant/playlist-window-manager 0.23.1 → 0.23.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.
@@ -9,6 +9,7 @@ export interface PlaylistWindowManagerOptions {
9
9
  device?: Device;
10
10
  readyTimeoutDurationSeconds?: number;
11
11
  appRendererUrl?: string;
12
+ appRendererOfflineSupport?: boolean;
12
13
  bounds?: WindowBounds;
13
14
  backgroundColor?: string;
14
15
  themeOverride?: Theme;
@@ -677,7 +677,7 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
677
677
  }
678
678
  };
679
679
  PlaylistWindowManager.prototype.createWindow = function (pr) {
680
- var _a = this.options, readyTimeoutDurationSeconds = _a.readyTimeoutDurationSeconds, appRendererUrl = _a.appRendererUrl, backgroundColor = _a.backgroundColor, device = _a.device, logger = _a.logger, windowName = _a.windowName, parentWindowId = _a.parentWindowId, isPreview = _a.isPreview;
680
+ var _a = this.options, readyTimeoutDurationSeconds = _a.readyTimeoutDurationSeconds, appRendererUrl = _a.appRendererUrl, appRendererOfflineSupport = _a.appRendererOfflineSupport, backgroundColor = _a.backgroundColor, device = _a.device, logger = _a.logger, windowName = _a.windowName, parentWindowId = _a.parentWindowId, isPreview = _a.isPreview;
681
681
  if (!this.ruleEngine) {
682
682
  throw new Error('Attempted to create window but ruleEngine was not provided');
683
683
  }
@@ -712,6 +712,7 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
712
712
  forceMute: this.forceMute,
713
713
  readyTimeoutDurationSeconds: readyTimeoutDurationSeconds,
714
714
  appRendererUrl: appRendererUrl,
715
+ appRendererOfflineSupport: appRendererOfflineSupport,
715
716
  bounds: this.bounds,
716
717
  backgroundColor: backgroundColor,
717
718
  playlistWindowManagerState: this.state,
@@ -23,6 +23,7 @@ export interface PresentationWindowOptions {
23
23
  renderer: PresentationWindowRenderer;
24
24
  readyTimeoutDurationSeconds?: number;
25
25
  appRendererUrl?: string;
26
+ appRendererOfflineSupport?: boolean;
26
27
  bounds?: WindowBounds;
27
28
  backgroundColor?: string;
28
29
  isPreview?: boolean;
@@ -102,7 +103,7 @@ export default class PresentationWindow {
102
103
  private isEmbeddedApp;
103
104
  private allChildWindowManagersReady;
104
105
  private checkIsReadyCallback;
105
- private appendWindowIdToHash;
106
+ private getFullAppRendererUrl;
106
107
  private loadEmbeddedApp;
107
108
  private loadLegacyApp;
108
109
  private createAndLoadWindow;
@@ -81,7 +81,7 @@ var PlaylistWindowManager_1 = __importDefault(require("./PlaylistWindowManager")
81
81
  var WindowTimeoutError_1 = __importDefault(require("./WindowTimeoutError"));
82
82
  var WindowLoadError_1 = __importDefault(require("./WindowLoadError"));
83
83
  // TODO: Automatically inject latest version when building in CI.
84
- var defaultAppRendererUrl = 'https://apps.raydiant.com/3.0.4/index.html';
84
+ var defaultAppRendererUrl = 'https://apps.raydiant.com/3.0.5/index.html';
85
85
  var isValidNumber = function (value) {
86
86
  return typeof value === 'number' && !isNaN(value);
87
87
  };
@@ -690,10 +690,14 @@ var PresentationWindow = /** @class */ (function () {
690
690
  }
691
691
  }
692
692
  };
693
- PresentationWindow.prototype.appendWindowIdToHash = function (urlStr, windowId) {
694
- var url = new URL(urlStr);
693
+ PresentationWindow.prototype.getFullAppRendererUrl = function (_a) {
694
+ var appRendererUrl = _a.appRendererUrl, windowId = _a.windowId, appRendererOfflineSupport = _a.appRendererOfflineSupport;
695
+ var url = new URL(appRendererUrl);
695
696
  var hashParams = new URLSearchParams(url.hash.slice(1));
696
697
  hashParams.set('__raydiantWindowId', windowId);
698
+ if (appRendererOfflineSupport === true) {
699
+ hashParams.set('__raydiantOfflineSupport', 'true');
700
+ }
697
701
  url.hash = hashParams.toString();
698
702
  return url.toString();
699
703
  };
@@ -724,13 +728,17 @@ var PresentationWindow = /** @class */ (function () {
724
728
  };
725
729
  PresentationWindow.prototype.loadLegacyApp = function () {
726
730
  return __awaiter(this, void 0, void 0, function () {
727
- var _a, windowId, _b, appRendererUrl, backgroundColor;
731
+ var _a, windowId, _b, appRendererUrl, appRendererOfflineSupport, backgroundColor;
728
732
  return __generator(this, function (_c) {
729
733
  switch (_c.label) {
730
734
  case 0:
731
- _a = this.options, windowId = _a.windowId, _b = _a.appRendererUrl, appRendererUrl = _b === void 0 ? defaultAppRendererUrl : _b, backgroundColor = _a.backgroundColor;
735
+ _a = this.options, windowId = _a.windowId, _b = _a.appRendererUrl, appRendererUrl = _b === void 0 ? defaultAppRendererUrl : _b, appRendererOfflineSupport = _a.appRendererOfflineSupport, backgroundColor = _a.backgroundColor;
732
736
  this.logInfo("Create window '".concat(windowId, "'"));
733
- return [4 /*yield*/, this.createAndLoadWindow(this.appendWindowIdToHash(appRendererUrl, windowId), backgroundColor || '#000000', // Default to black bg for Raydiant apps
737
+ return [4 /*yield*/, this.createAndLoadWindow(this.getFullAppRendererUrl({
738
+ appRendererUrl: appRendererUrl,
739
+ windowId: windowId,
740
+ appRendererOfflineSupport: appRendererOfflineSupport,
741
+ }), backgroundColor || '#000000', // Default to black bg for Raydiant apps
734
742
  this.handleLegacyMessage)];
735
743
  case 1:
736
744
  _c.sent();
@@ -1034,12 +1042,16 @@ var PresentationWindow = /** @class */ (function () {
1034
1042
  }
1035
1043
  };
1036
1044
  PresentationWindow.prototype.getEmbeddedAppUrl = function () {
1037
- var windowId = this.options.windowId;
1045
+ var _a = this.options, windowId = _a.windowId, appRendererOfflineSupport = _a.appRendererOfflineSupport;
1038
1046
  var metadata = {
1039
1047
  renderMode: this.options.isPreview ? 'preview' : 'live',
1040
1048
  };
1041
1049
  var url = (0, embeddedApps_1.default)(this.presentation, this.options.applicationVersion, metadata);
1042
- return this.appendWindowIdToHash(url, windowId);
1050
+ return this.getFullAppRendererUrl({
1051
+ appRendererUrl: url,
1052
+ windowId: windowId,
1053
+ appRendererOfflineSupport: appRendererOfflineSupport,
1054
+ });
1043
1055
  };
1044
1056
  PresentationWindow.prototype.handleReady = function () {
1045
1057
  this.didReceiveReady = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raydiant/playlist-window-manager",
3
- "version": "0.23.1",
3
+ "version": "0.23.2",
4
4
  "description": "Window manager for playlist playback.",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -40,6 +40,10 @@ export interface PlaylistWindowManagerOptions {
40
40
  // Override the default app renderer url
41
41
  appRendererUrl?: string;
42
42
 
43
+ // App renderer offline support.
44
+ // If true, the app renderer will be using service worker to cache resources for offline support.
45
+ appRendererOfflineSupport?: boolean;
46
+
43
47
  // The bounds of the window manager, used for child windows
44
48
  bounds?: WindowBounds;
45
49
 
@@ -488,6 +492,7 @@ export default class PlaylistWindowManager extends EventEmitter {
488
492
  const {
489
493
  readyTimeoutDurationSeconds,
490
494
  appRendererUrl,
495
+ appRendererOfflineSupport,
491
496
  backgroundColor,
492
497
  device,
493
498
  logger,
@@ -541,6 +546,7 @@ export default class PlaylistWindowManager extends EventEmitter {
541
546
  forceMute: this.forceMute,
542
547
  readyTimeoutDurationSeconds,
543
548
  appRendererUrl,
549
+ appRendererOfflineSupport,
544
550
  bounds: this.bounds,
545
551
  backgroundColor,
546
552
  playlistWindowManagerState: this.state,
@@ -47,6 +47,7 @@ export interface PresentationWindowOptions {
47
47
  renderer: PresentationWindowRenderer;
48
48
  readyTimeoutDurationSeconds?: number;
49
49
  appRendererUrl?: string;
50
+ appRendererOfflineSupport?: boolean;
50
51
  bounds?: WindowBounds;
51
52
  backgroundColor?: string;
52
53
  isPreview?: boolean;
@@ -60,7 +61,7 @@ export interface PresentationWindowOptions {
60
61
  }
61
62
 
62
63
  // TODO: Automatically inject latest version when building in CI.
63
- const defaultAppRendererUrl = 'https://apps.raydiant.com/3.0.4/index.html';
64
+ const defaultAppRendererUrl = 'https://apps.raydiant.com/3.0.5/index.html';
64
65
 
65
66
  const isValidNumber = (value: any) =>
66
67
  typeof value === 'number' && !isNaN(value);
@@ -488,10 +489,21 @@ export default class PresentationWindow {
488
489
  }
489
490
  }
490
491
 
491
- private appendWindowIdToHash(urlStr: string, windowId: string) {
492
- const url = new URL(urlStr);
492
+ private getFullAppRendererUrl({
493
+ appRendererUrl,
494
+ windowId,
495
+ appRendererOfflineSupport,
496
+ }: {
497
+ appRendererUrl: string;
498
+ windowId: string;
499
+ appRendererOfflineSupport: boolean | undefined;
500
+ }) {
501
+ const url = new URL(appRendererUrl);
493
502
  const hashParams = new URLSearchParams(url.hash.slice(1));
494
503
  hashParams.set('__raydiantWindowId', windowId);
504
+ if (appRendererOfflineSupport === true) {
505
+ hashParams.set('__raydiantOfflineSupport', 'true');
506
+ }
495
507
  url.hash = hashParams.toString();
496
508
 
497
509
  return url.toString();
@@ -525,13 +537,18 @@ export default class PresentationWindow {
525
537
  const {
526
538
  windowId,
527
539
  appRendererUrl = defaultAppRendererUrl,
540
+ appRendererOfflineSupport,
528
541
  backgroundColor,
529
542
  } = this.options;
530
543
 
531
544
  this.logInfo(`Create window '${windowId}'`);
532
545
 
533
546
  await this.createAndLoadWindow(
534
- this.appendWindowIdToHash(appRendererUrl, windowId),
547
+ this.getFullAppRendererUrl({
548
+ appRendererUrl,
549
+ windowId,
550
+ appRendererOfflineSupport,
551
+ }),
535
552
  backgroundColor || '#000000', // Default to black bg for Raydiant apps
536
553
  this.handleLegacyMessage
537
554
  );
@@ -861,7 +878,7 @@ export default class PresentationWindow {
861
878
  }
862
879
 
863
880
  private getEmbeddedAppUrl() {
864
- const { windowId } = this.options;
881
+ const { windowId, appRendererOfflineSupport } = this.options;
865
882
 
866
883
  const metadata: EmbeddedAppMetadata = {
867
884
  renderMode: this.options.isPreview ? 'preview' : 'live',
@@ -873,7 +890,11 @@ export default class PresentationWindow {
873
890
  metadata
874
891
  );
875
892
 
876
- return this.appendWindowIdToHash(url, windowId);
893
+ return this.getFullAppRendererUrl({
894
+ appRendererUrl: url,
895
+ windowId,
896
+ appRendererOfflineSupport,
897
+ });
877
898
  }
878
899
 
879
900
  private handleEmbeddedMessage = async (type: string, payload?: any) => {