@raydiant/playlist-window-manager 0.0.0-test-32 → 0.0.0-test29
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.
- package/build/BrowserViewRenderer.js +1 -0
- package/build/BrowserWindowRenderer.d.ts +1 -0
- package/build/BrowserWindowRenderer.js +10 -2
- package/build/PlaylistWindowManager.d.ts +1 -0
- package/build/PlaylistWindowManager.js +6 -1
- package/build/PresentationWindow.d.ts +2 -1
- package/build/PresentationWindow.js +20 -8
- package/build/embeddedApps.js +3 -0
- package/build/embeddedApps.test.js +7 -0
- package/build/types.d.ts +1 -0
- package/package.json +2 -2
- package/src/BrowserViewRenderer.ts +1 -0
- package/src/BrowserWindowRenderer.ts +20 -5
- package/src/PlaylistWindowManager.ts +12 -0
- package/src/PresentationWindow.ts +27 -6
- package/src/embeddedApps.test.ts +11 -0
- package/src/embeddedApps.ts +2 -0
- package/src/types.ts +1 -0
|
@@ -87,6 +87,7 @@ var BrowserViewRenderer = /** @class */ (function () {
|
|
|
87
87
|
view: new electron_1.BrowserView({
|
|
88
88
|
webPreferences: {
|
|
89
89
|
preload: path.join(__dirname, 'preload.js'),
|
|
90
|
+
contextIsolation: false,
|
|
90
91
|
},
|
|
91
92
|
}),
|
|
92
93
|
bounds: bounds || __assign(__assign({}, this.mainWindow.getBounds()), { x: 0, y: 0 }),
|
|
@@ -90,10 +90,13 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
90
90
|
hasShadow: this.opts.hasShadow,
|
|
91
91
|
webPreferences: {
|
|
92
92
|
preload: path.join(__dirname, 'preload.js'),
|
|
93
|
+
contextIsolation: false,
|
|
93
94
|
},
|
|
94
95
|
});
|
|
95
96
|
this.proxySettings = null;
|
|
96
|
-
|
|
97
|
+
if (!opts.fullscreen) {
|
|
98
|
+
this.offscreenWindow.setBounds(opts.bounds);
|
|
99
|
+
}
|
|
97
100
|
if (opts.proxySettings) {
|
|
98
101
|
this.proxySettings = opts.proxySettings;
|
|
99
102
|
}
|
|
@@ -118,11 +121,13 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
118
121
|
? this.createOrGetPooledBrowserView(windowId, {
|
|
119
122
|
webPreferences: {
|
|
120
123
|
preload: path.join(__dirname, 'preload.js'),
|
|
124
|
+
contextIsolation: false,
|
|
121
125
|
},
|
|
122
126
|
})
|
|
123
127
|
: this.createOrGetPooledBrowserWindow(windowId, {
|
|
124
128
|
show: false,
|
|
125
129
|
frame: this.opts.frame,
|
|
130
|
+
fullscreen: this.opts.fullscreen,
|
|
126
131
|
// NOTE: useWindowPool: true does not work with renderChildWindowsAsBrowserViews: false
|
|
127
132
|
// because the parent can't be changed after creating the BrowserWindow.
|
|
128
133
|
parent: parentWindowId
|
|
@@ -132,6 +137,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
132
137
|
hasShadow: this.opts.hasShadow,
|
|
133
138
|
webPreferences: {
|
|
134
139
|
preload: path.join(__dirname, 'preload.js'),
|
|
140
|
+
contextIsolation: false,
|
|
135
141
|
},
|
|
136
142
|
}),
|
|
137
143
|
// If we are creating a child window and renderChildWindowsAsBrowserViews is false that means
|
|
@@ -172,7 +178,9 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
172
178
|
// Electron issue: https://github.com/electron/electron/issues/20357
|
|
173
179
|
window.view.setBackgroundColor(backgroundColor === 'transparent' ? '#00000000' : backgroundColor);
|
|
174
180
|
}
|
|
175
|
-
|
|
181
|
+
if (!this.opts.fullscreen) {
|
|
182
|
+
window.view.setBounds(window.bounds);
|
|
183
|
+
}
|
|
176
184
|
if (!this.proxySettings) return [3 /*break*/, 2];
|
|
177
185
|
return [4 /*yield*/, window.view.webContents.session.setProxy(this.proxySettings)];
|
|
178
186
|
case 1:
|
|
@@ -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,
|
|
@@ -940,6 +941,10 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
940
941
|
// Swap windows.
|
|
941
942
|
this.currentWindow = this.nextWindow;
|
|
942
943
|
if (this.currentWindow) {
|
|
944
|
+
// Restore this.currentPresentation value since if this.removeCurrentWindow()
|
|
945
|
+
// was called then this.currentPresentation was set to null.
|
|
946
|
+
// This fixes an issue where publishing a playlist with single presentation results
|
|
947
|
+
// in two iFrames created. See CX-2602 for more details.
|
|
943
948
|
this.currentPresentation = nextPresentation;
|
|
944
949
|
this.currentWindow.onComplete(this.handleCurrentPresentationComplete);
|
|
945
950
|
this.currentWindow.onError(this.handleCurrentPresentationError);
|
|
@@ -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
|
|
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.
|
|
84
|
+
var defaultAppRendererUrl = 'https://apps.raydiant.com/3.0.7/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.
|
|
694
|
-
var
|
|
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.
|
|
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
|
|
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.
|
|
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/build/embeddedApps.js
CHANGED
|
@@ -24,6 +24,9 @@ function createEmbeddedApp(presentation, applicationVersion, metadata) {
|
|
|
24
24
|
if (metadataKey === 'renderMode') {
|
|
25
25
|
value = metadata.renderMode;
|
|
26
26
|
}
|
|
27
|
+
else if (metadataKey === 'token') {
|
|
28
|
+
value = presentation.token;
|
|
29
|
+
}
|
|
27
30
|
}
|
|
28
31
|
else {
|
|
29
32
|
// Don't replace variables that are numbers to allow setting
|
|
@@ -121,3 +121,10 @@ test('File input uses url as value', function () {
|
|
|
121
121
|
presentationProperties: [{ type: 'file', name: 'file' }],
|
|
122
122
|
}), createMetadata())).toBe("https://example.come?image=".concat(encodeURIComponent('https://image.png')));
|
|
123
123
|
});
|
|
124
|
+
test('Replaces $token with presentation token', function () {
|
|
125
|
+
var presentation = createPresentation({ token: 'abc' });
|
|
126
|
+
var applicationVersion = createApplicationVersion({
|
|
127
|
+
embeddedUrlFormat: 'https://example.com?token=:$token',
|
|
128
|
+
});
|
|
129
|
+
expect((0, embeddedApps_1.default)(presentation, applicationVersion, createMetadata())).toBe('https://example.com?token=abc');
|
|
130
|
+
});
|
package/build/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raydiant/playlist-window-manager",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-test29",
|
|
4
4
|
"description": "Window manager for playlist playback.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@types/jschannel": "^1.0.1",
|
|
23
23
|
"@types/jest": "^24.0.15",
|
|
24
24
|
"@types/uuid": "8.3.0",
|
|
25
|
-
"electron": "
|
|
25
|
+
"electron": "28.1.2",
|
|
26
26
|
"jest": "^24.8.0",
|
|
27
27
|
"ts-jest": "^24.0.2",
|
|
28
28
|
"typescript": "^4.1.2"
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
ipcMain,
|
|
6
6
|
IpcMainEvent,
|
|
7
7
|
Event,
|
|
8
|
-
Details,
|
|
9
8
|
BrowserWindowConstructorOptions,
|
|
10
9
|
BrowserViewConstructorOptions,
|
|
10
|
+
RenderProcessGoneDetails,
|
|
11
11
|
} from 'electron';
|
|
12
12
|
import {
|
|
13
13
|
PresentationWindowRenderer,
|
|
@@ -32,7 +32,10 @@ interface BrowserWindowRendererWindow {
|
|
|
32
32
|
payload?: any
|
|
33
33
|
) => void;
|
|
34
34
|
unresponsiveCallback: () => void;
|
|
35
|
-
renderProcessGoneCallback: (
|
|
35
|
+
renderProcessGoneCallback: (
|
|
36
|
+
event: Event,
|
|
37
|
+
details: RenderProcessGoneDetails
|
|
38
|
+
) => void;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
interface BrowserWindowRendererOptions {
|
|
@@ -42,6 +45,7 @@ interface BrowserWindowRendererOptions {
|
|
|
42
45
|
renderChildWindowsAsBrowserViews: boolean;
|
|
43
46
|
useWindowPool: boolean;
|
|
44
47
|
logger: Logger;
|
|
48
|
+
fullscreen?: boolean;
|
|
45
49
|
proxySettings?: ProxySettings;
|
|
46
50
|
windowCrashHandler?: () => void;
|
|
47
51
|
}
|
|
@@ -64,6 +68,7 @@ export default class BrowserWindowRenderer
|
|
|
64
68
|
hasShadow: this.opts.hasShadow,
|
|
65
69
|
webPreferences: {
|
|
66
70
|
preload: path.join(__dirname, 'preload.js'),
|
|
71
|
+
contextIsolation: false,
|
|
67
72
|
},
|
|
68
73
|
});
|
|
69
74
|
|
|
@@ -72,7 +77,9 @@ export default class BrowserWindowRenderer
|
|
|
72
77
|
private logger: Logger;
|
|
73
78
|
|
|
74
79
|
constructor(private opts: BrowserWindowRendererOptions) {
|
|
75
|
-
|
|
80
|
+
if (!opts.fullscreen) {
|
|
81
|
+
this.offscreenWindow.setBounds(opts.bounds);
|
|
82
|
+
}
|
|
76
83
|
if (opts.proxySettings) {
|
|
77
84
|
this.proxySettings = opts.proxySettings;
|
|
78
85
|
}
|
|
@@ -101,11 +108,13 @@ export default class BrowserWindowRenderer
|
|
|
101
108
|
? this.createOrGetPooledBrowserView(windowId, {
|
|
102
109
|
webPreferences: {
|
|
103
110
|
preload: path.join(__dirname, 'preload.js'),
|
|
111
|
+
contextIsolation: false,
|
|
104
112
|
},
|
|
105
113
|
})
|
|
106
114
|
: this.createOrGetPooledBrowserWindow(windowId, {
|
|
107
115
|
show: false,
|
|
108
116
|
frame: this.opts.frame,
|
|
117
|
+
fullscreen: this.opts.fullscreen,
|
|
109
118
|
// NOTE: useWindowPool: true does not work with renderChildWindowsAsBrowserViews: false
|
|
110
119
|
// because the parent can't be changed after creating the BrowserWindow.
|
|
111
120
|
parent: parentWindowId
|
|
@@ -115,6 +124,7 @@ export default class BrowserWindowRenderer
|
|
|
115
124
|
hasShadow: this.opts.hasShadow,
|
|
116
125
|
webPreferences: {
|
|
117
126
|
preload: path.join(__dirname, 'preload.js'),
|
|
127
|
+
contextIsolation: false,
|
|
118
128
|
},
|
|
119
129
|
}),
|
|
120
130
|
// If we are creating a child window and renderChildWindowsAsBrowserViews is false that means
|
|
@@ -148,7 +158,10 @@ export default class BrowserWindowRenderer
|
|
|
148
158
|
);
|
|
149
159
|
},
|
|
150
160
|
|
|
151
|
-
renderProcessGoneCallback: (
|
|
161
|
+
renderProcessGoneCallback: (
|
|
162
|
+
_: Event,
|
|
163
|
+
details: RenderProcessGoneDetails
|
|
164
|
+
) => {
|
|
152
165
|
this.logger.error(
|
|
153
166
|
`Window received 'render-process-gone' event. Reason: ${details.reason}`,
|
|
154
167
|
{ windowId }
|
|
@@ -191,7 +204,9 @@ export default class BrowserWindowRenderer
|
|
|
191
204
|
);
|
|
192
205
|
}
|
|
193
206
|
|
|
194
|
-
|
|
207
|
+
if (!this.opts.fullscreen) {
|
|
208
|
+
window.view.setBounds(window.bounds);
|
|
209
|
+
}
|
|
195
210
|
|
|
196
211
|
if (this.proxySettings) {
|
|
197
212
|
await window.view.webContents.session.setProxy(this.proxySettings);
|
|
@@ -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,
|
|
@@ -698,6 +704,8 @@ export default class PlaylistWindowManager extends EventEmitter {
|
|
|
698
704
|
nextPreviewPresentationId = preview.presentationId;
|
|
699
705
|
}
|
|
700
706
|
|
|
707
|
+
// Save reference to next presentation since later call to
|
|
708
|
+
// this.removeCurrentWindow() will set this.currentPresentation to null.
|
|
701
709
|
const nextPresentation = this.nextPresentation;
|
|
702
710
|
// Set this.currentPresentationId before removing the current window to avoid timing issues with previewCheck
|
|
703
711
|
// triggering during removeCurrentWindow. Current presentation id needs to be set to the next
|
|
@@ -735,6 +743,10 @@ export default class PlaylistWindowManager extends EventEmitter {
|
|
|
735
743
|
// Swap windows.
|
|
736
744
|
this.currentWindow = this.nextWindow;
|
|
737
745
|
if (this.currentWindow) {
|
|
746
|
+
// Restore this.currentPresentation value since if this.removeCurrentWindow()
|
|
747
|
+
// was called then this.currentPresentation was set to null.
|
|
748
|
+
// This fixes an issue where publishing a playlist with single presentation results
|
|
749
|
+
// in two iFrames created. See CX-2602 for more details.
|
|
738
750
|
this.currentPresentation = nextPresentation;
|
|
739
751
|
this.currentWindow.onComplete(this.handleCurrentPresentationComplete);
|
|
740
752
|
this.currentWindow.onError(this.handleCurrentPresentationError);
|
|
@@ -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.
|
|
64
|
+
const defaultAppRendererUrl = 'https://apps.raydiant.com/3.0.7/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
|
|
492
|
-
|
|
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.
|
|
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.
|
|
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) => {
|
package/src/embeddedApps.test.ts
CHANGED
|
@@ -229,3 +229,14 @@ test('File input uses url as value', () => {
|
|
|
229
229
|
`https://example.come?image=${encodeURIComponent('https://image.png')}`
|
|
230
230
|
);
|
|
231
231
|
});
|
|
232
|
+
|
|
233
|
+
test('Replaces $token with presentation token', () => {
|
|
234
|
+
const presentation = createPresentation({ token: 'abc' });
|
|
235
|
+
const applicationVersion = createApplicationVersion({
|
|
236
|
+
embeddedUrlFormat: 'https://example.com?token=:$token',
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
expect(
|
|
240
|
+
createEmbeddedApp(presentation, applicationVersion, createMetadata())
|
|
241
|
+
).toBe('https://example.com?token=abc');
|
|
242
|
+
});
|
package/src/embeddedApps.ts
CHANGED
|
@@ -32,6 +32,8 @@ export default function createEmbeddedApp(
|
|
|
32
32
|
const metadataKey = variableName.slice(1);
|
|
33
33
|
if (metadataKey === 'renderMode') {
|
|
34
34
|
value = metadata.renderMode;
|
|
35
|
+
} else if (metadataKey === 'token') {
|
|
36
|
+
value = presentation.token;
|
|
35
37
|
}
|
|
36
38
|
} else {
|
|
37
39
|
// Don't replace variables that are numbers to allow setting
|