@raydiant/playlist-window-manager 0.25.0 → 0.25.1-canary.0
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.d.ts +2 -3
- package/build/BrowserViewRenderer.js +23 -48
- package/build/BrowserWindowRenderer.d.ts +2 -3
- package/build/BrowserWindowRenderer.js +42 -69
- package/build/IFrameRenderer.d.ts +2 -4
- package/build/IFrameRenderer.js +44 -63
- package/build/PlaylistWindowManager.d.ts +1 -10
- package/build/PlaylistWindowManager.js +18 -87
- package/build/PlaylistWindowManagerState.js +3 -3
- package/build/PresentationWindow.d.ts +5 -39
- package/build/PresentationWindow.js +98 -683
- package/build/WindowLoadError.js +1 -3
- package/build/WindowTimeoutError.js +1 -3
- package/build/WindowUnresponsiveError.js +1 -3
- package/build/embeddedApps.d.ts +2 -2
- package/build/embeddedApps.js +15 -36
- package/build/embeddedApps.test.js +36 -89
- package/build/index.js +6 -19
- package/build/preload.js +14 -14
- package/build/types.d.ts +2 -49
- package/package.json +1 -1
- package/src/BrowserViewRenderer.ts +6 -5
- package/src/BrowserWindowRenderer.ts +16 -14
- package/build/PresentationWindow.test.d.ts +0 -1
- package/build/PresentationWindow.test.js +0 -406
- package/build/testUtils.d.ts +0 -43
- package/build/testUtils.js +0 -209
|
@@ -10,35 +10,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
15
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
16
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) :
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
42
18
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
19
|
});
|
|
44
20
|
};
|
|
@@ -48,7 +24,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
24
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
25
|
function step(op) {
|
|
50
26
|
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (
|
|
27
|
+
while (_) try {
|
|
52
28
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
29
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
30
|
switch (op[0]) {
|
|
@@ -69,53 +45,28 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
46
|
}
|
|
71
47
|
};
|
|
48
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
52
|
+
result["default"] = mod;
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
72
55
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
73
56
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
74
57
|
};
|
|
75
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
59
|
var RE = __importStar(require("@raydiant/playlist-rule-engine"));
|
|
77
60
|
var fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
78
|
-
var uuid_1 = require("uuid");
|
|
79
61
|
var embeddedApps_1 = __importDefault(require("./embeddedApps"));
|
|
80
62
|
var PlaylistWindowManager_1 = __importDefault(require("./PlaylistWindowManager"));
|
|
81
63
|
var WindowTimeoutError_1 = __importDefault(require("./WindowTimeoutError"));
|
|
82
64
|
var WindowLoadError_1 = __importDefault(require("./WindowLoadError"));
|
|
83
65
|
// TODO: Automatically inject latest version when building in CI.
|
|
84
|
-
var defaultAppRendererUrl = 'https://apps.raydiant.com/
|
|
66
|
+
var defaultAppRendererUrl = 'https://apps.raydiant.com/1.4.7/index.html';
|
|
85
67
|
var isValidNumber = function (value) {
|
|
86
68
|
return typeof value === 'number' && !isNaN(value);
|
|
87
69
|
};
|
|
88
|
-
var isValidAnalyticsEvent = function (value) {
|
|
89
|
-
return value &&
|
|
90
|
-
typeof value === 'object' &&
|
|
91
|
-
typeof value.type === 'string' &&
|
|
92
|
-
typeof value.source === 'string' &&
|
|
93
|
-
(typeof value.productCategory === 'string' ||
|
|
94
|
-
value.productCategory === undefined ||
|
|
95
|
-
value.productCategory === null);
|
|
96
|
-
};
|
|
97
|
-
var isValidChargeRequest = function (value) {
|
|
98
|
-
return value &&
|
|
99
|
-
typeof value === 'object' &&
|
|
100
|
-
typeof value.requestId === 'string' &&
|
|
101
|
-
typeof value.amount === 'number';
|
|
102
|
-
};
|
|
103
|
-
var isValidAcquireLockRequest = function (value) {
|
|
104
|
-
return value && typeof value === 'object' && typeof value.requestId === 'string';
|
|
105
|
-
};
|
|
106
|
-
var isValidRenewLockRequest = function (value) {
|
|
107
|
-
return value &&
|
|
108
|
-
typeof value === 'object' &&
|
|
109
|
-
typeof value.requestId === 'string' &&
|
|
110
|
-
typeof value.lockId === 'string';
|
|
111
|
-
};
|
|
112
|
-
var isValidReleaseLockRequest = function (value) {
|
|
113
|
-
return value &&
|
|
114
|
-
typeof value === 'object' &&
|
|
115
|
-
typeof value.requestId === 'string' &&
|
|
116
|
-
typeof value.lockId === 'string';
|
|
117
|
-
};
|
|
118
|
-
var lockDuration = 1000 * 60; // 1 minute
|
|
119
70
|
var PresentationWindow = /** @class */ (function () {
|
|
120
71
|
function PresentationWindow(options) {
|
|
121
72
|
var _this = this;
|
|
@@ -126,6 +77,7 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
126
77
|
this.completeCallback = null;
|
|
127
78
|
this.errorCallback = null;
|
|
128
79
|
this.readyTimeout = null;
|
|
80
|
+
// private completeThrottleTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
129
81
|
this.windowManagers = {};
|
|
130
82
|
this.focusedWindowManager = null;
|
|
131
83
|
this.didEmbeddedAppLoad = false;
|
|
@@ -135,266 +87,44 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
135
87
|
this.isChildWindowLocked = {};
|
|
136
88
|
this.enableInterruptLockCallback = null;
|
|
137
89
|
this.disableInterruptLockCallback = null;
|
|
138
|
-
this.analyticsEventCallback = null;
|
|
139
|
-
this.chargeRequestCallback = null;
|
|
140
90
|
this.forceMute = false;
|
|
141
91
|
this.error = null;
|
|
142
|
-
this.
|
|
143
|
-
this.workerSubscriptions = new Set();
|
|
144
|
-
this.runtimeSubscriptions = new Set();
|
|
145
|
-
this.previewSubscriptions = new Set();
|
|
146
|
-
this.previewState = { inputs: {} };
|
|
147
|
-
this.paymentSubscriptions = new Set();
|
|
148
|
-
this.createObjectURLResolvers = {};
|
|
149
|
-
this.createObjectURLTimeouts = {};
|
|
150
|
-
this.interruptLocks = {};
|
|
151
|
-
this.previouslyLocked = false;
|
|
152
|
-
this.handleEmbeddedMessage = function (type, payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
153
|
-
var windowId, workerState, lock, lock, lock;
|
|
154
|
-
return __generator(this, function (_a) {
|
|
155
|
-
windowId = this.options.windowId;
|
|
156
|
-
switch (type) {
|
|
157
|
-
case 'ready': {
|
|
158
|
-
this.logInfo("Received 'ready' from window '".concat(windowId, "'"));
|
|
159
|
-
this.handleReady();
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
case 'complete': {
|
|
163
|
-
if (payload === undefined) {
|
|
164
|
-
this.logInfo("Received 'complete' from window '".concat(windowId, "'"));
|
|
165
|
-
this.handleComplete();
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
this.logInfo("Received 'complete' with error from window '".concat(windowId, ", error=").concat(payload, "'"));
|
|
169
|
-
this.handleError(payload);
|
|
170
|
-
}
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
case 'runtime-subscribe': {
|
|
174
|
-
if (typeof payload === 'string') {
|
|
175
|
-
this.logInfo("Received 'runtime-subscribe' from window '".concat(windowId, "'"));
|
|
176
|
-
// The payload is the event name (ex. 'play').
|
|
177
|
-
this.runtimeSubscriptions.add(payload);
|
|
178
|
-
// Immediately send play if the app if already playing.
|
|
179
|
-
if (this.isPlaying()) {
|
|
180
|
-
this.sendMessageString('play');
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
this.logWarning("Invalid payload for runtime-subscribe message: ".concat(payload));
|
|
185
|
-
}
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
case 'runtime-unsubscribe': {
|
|
189
|
-
if (typeof payload === 'string') {
|
|
190
|
-
this.logInfo("Received 'runtime-unsubscribe' from window '".concat(windowId, "'"));
|
|
191
|
-
// The payload is the event name (ex. 'play').
|
|
192
|
-
this.runtimeSubscriptions.delete(payload);
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
this.logWarning("Invalid payload for runtime-subscribe message: ".concat(payload));
|
|
196
|
-
}
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
case 'worker-subscribe': {
|
|
200
|
-
if (typeof payload === 'string') {
|
|
201
|
-
this.logInfo("Received 'worker-subscribe' from window '".concat(windowId, "'"));
|
|
202
|
-
// The payload is the worker name.
|
|
203
|
-
this.workerSubscriptions.add(payload);
|
|
204
|
-
workerState = this.workerState[payload];
|
|
205
|
-
if (workerState !== undefined) {
|
|
206
|
-
this.sendMessageString('worker-state', {
|
|
207
|
-
name: payload,
|
|
208
|
-
state: workerState,
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
this.logWarning("Invalid payload for worker-subscribe message: ".concat(payload));
|
|
214
|
-
}
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
|
-
case 'worker-unsubscribe': {
|
|
218
|
-
if (typeof payload === 'string') {
|
|
219
|
-
this.logInfo("Received 'worker-unsubscribe' from window '".concat(windowId, "'"));
|
|
220
|
-
// The payload is the worker name.
|
|
221
|
-
this.workerSubscriptions.delete(payload);
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
this.logWarning("Invalid payload for worker-unsubscribe message: ".concat(payload));
|
|
225
|
-
}
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
case 'analytics-event': {
|
|
229
|
-
if (isValidAnalyticsEvent(payload)) {
|
|
230
|
-
if (this.analyticsEventCallback) {
|
|
231
|
-
this.analyticsEventCallback(payload);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
this.logWarning("Invalid payload for analytics-event message: ".concat(payload));
|
|
236
|
-
}
|
|
237
|
-
break;
|
|
238
|
-
}
|
|
239
|
-
case 'create-object-url-result': {
|
|
240
|
-
if (isValidCreateObjectURLResultPayload(payload)) {
|
|
241
|
-
// Resolve promise with the local blob URL.
|
|
242
|
-
if (this.createObjectURLResolvers[payload.requestId]) {
|
|
243
|
-
this.createObjectURLResolvers[payload.requestId](payload.url);
|
|
244
|
-
delete this.createObjectURLResolvers[payload.requestId];
|
|
245
|
-
}
|
|
246
|
-
// Clear the timeout for the request.
|
|
247
|
-
if (this.createObjectURLTimeouts[payload.requestId]) {
|
|
248
|
-
clearTimeout(this.createObjectURLTimeouts[payload.requestId]);
|
|
249
|
-
delete this.createObjectURLTimeouts[payload.requestId];
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
else {
|
|
253
|
-
this.logWarning("Invalid payload for create-object-url-result message: ".concat(payload));
|
|
254
|
-
}
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
case 'preview-subscribe': {
|
|
258
|
-
if (typeof payload === 'string') {
|
|
259
|
-
this.logInfo("Received 'preview-subscribe' from window '".concat(windowId, "'"));
|
|
260
|
-
// The payload is the event name (ex. 'inputs').
|
|
261
|
-
this.previewSubscriptions.add(payload);
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
this.logWarning("Invalid payload for preview-subscribe message: ".concat(payload));
|
|
265
|
-
}
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
268
|
-
case 'preview-unsubscribe': {
|
|
269
|
-
if (typeof payload === 'string') {
|
|
270
|
-
this.logInfo("Received 'preview-unsubscribe' from window '".concat(windowId, "'"));
|
|
271
|
-
// The payload is the event name (ex. 'inputs').
|
|
272
|
-
this.previewSubscriptions.delete(payload);
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
this.logWarning("Invalid payload for preview-subscribe message: ".concat(payload));
|
|
276
|
-
}
|
|
277
|
-
break;
|
|
278
|
-
}
|
|
279
|
-
case 'payments-charge-request': {
|
|
280
|
-
if (isValidChargeRequest(payload)) {
|
|
281
|
-
if (this.chargeRequestCallback) {
|
|
282
|
-
this.chargeRequestCallback(payload);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
this.logWarning("Invalid payload for payments-charge-request message: ".concat(payload));
|
|
287
|
-
}
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
case 'payments-subscribe': {
|
|
291
|
-
if (typeof payload === 'string') {
|
|
292
|
-
this.logInfo("Received 'worker-subscribe' from window '".concat(windowId, "'"));
|
|
293
|
-
// The payload is the payment subscription type (ex. 'charge', 'terminal')
|
|
294
|
-
this.paymentSubscriptions.add(payload);
|
|
295
|
-
// Immediately send terminal when subscribing.
|
|
296
|
-
if (payload === 'terminal' && this.options.getTerminal) {
|
|
297
|
-
this.sendMessageObject('payments-terminal-event', {
|
|
298
|
-
terminal: this.options.getTerminal(),
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
this.logWarning("Invalid payload for payments-subscribe message: ".concat(payload));
|
|
304
|
-
}
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
case 'payments-unsubscribe': {
|
|
308
|
-
if (typeof payload === 'string') {
|
|
309
|
-
this.logInfo("Received 'payments-unsubscribe' from window '".concat(windowId, "'"));
|
|
310
|
-
this.paymentSubscriptions.delete(payload);
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
this.logWarning("Invalid payload for payments-unsubscribe message: ".concat(payload));
|
|
314
|
-
}
|
|
315
|
-
break;
|
|
316
|
-
}
|
|
317
|
-
case 'runtime-acquire-interrupt-lock-request': {
|
|
318
|
-
if (isValidAcquireLockRequest(payload)) {
|
|
319
|
-
this.logInfo("Received 'runtime-acquire-interrupt-lock-request'");
|
|
320
|
-
lock = this.createInterruptLock();
|
|
321
|
-
this.sendMessageObject('runtime-acquire-interrupt-lock-response', {
|
|
322
|
-
requestId: payload.requestId,
|
|
323
|
-
lock: { id: lock.id, expiresAt: lock.expiresAt },
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
this.logWarning("Invalid payload for runtime-acquire-interrupt-lock-request message: ".concat(payload));
|
|
328
|
-
}
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
case 'runtime-renew-interrupt-lock-request': {
|
|
332
|
-
if (isValidRenewLockRequest(payload)) {
|
|
333
|
-
this.logInfo("Received 'runtime-renew-interrupt-lock-request'");
|
|
334
|
-
lock = this.renewInterruptLock(payload.lockId);
|
|
335
|
-
this.sendMessageObject('runtime-renew-interrupt-lock-response', {
|
|
336
|
-
requestId: payload.requestId,
|
|
337
|
-
lock: { id: lock.id, expiresAt: lock.expiresAt },
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
else {
|
|
341
|
-
this.logWarning("Invalid payload for runtime-renew-interrupt-lock-request message: ".concat(payload));
|
|
342
|
-
}
|
|
343
|
-
break;
|
|
344
|
-
}
|
|
345
|
-
case 'runtime-release-interrupt-lock-request': {
|
|
346
|
-
if (isValidReleaseLockRequest(payload)) {
|
|
347
|
-
this.logInfo("Received 'runtime-release-interrupt-lock-request'");
|
|
348
|
-
lock = this.releaseInterruptLock(payload.lockId);
|
|
349
|
-
this.sendMessageObject('runtime-release-interrupt-lock-response', {
|
|
350
|
-
requestId: payload.requestId,
|
|
351
|
-
lock: { id: lock.id, expiresAt: lock.expiresAt },
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
else {
|
|
355
|
-
this.logWarning("Invalid payload for runtime-release-interrupt-lock-request message: ".concat(payload));
|
|
356
|
-
}
|
|
357
|
-
break;
|
|
358
|
-
}
|
|
359
|
-
default: {
|
|
360
|
-
this.logWarning("Received unknown embedded message type: ".concat(type));
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
return [2 /*return*/];
|
|
364
|
-
});
|
|
365
|
-
}); };
|
|
366
|
-
this.handleLegacyMessage = function (type, payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
92
|
+
this.handleMessage = function (type, payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
367
93
|
var _a, windowId, onPresentationProperties;
|
|
368
94
|
return __generator(this, function (_b) {
|
|
369
95
|
_a = this.options, windowId = _a.windowId, onPresentationProperties = _a.onPresentationProperties;
|
|
370
96
|
if (type === 'loaded') {
|
|
371
|
-
this.logInfo("Received 'loaded' from window '"
|
|
97
|
+
this.logInfo("Received 'loaded' from window '" + windowId + "'");
|
|
372
98
|
this.sendRenderMessage();
|
|
373
99
|
}
|
|
374
100
|
if (type === 'presentation_ready') {
|
|
375
|
-
this.logInfo("Received 'presentation_ready' from window '"
|
|
376
|
-
this.
|
|
101
|
+
this.logInfo("Received 'presentation_ready' from window '" + windowId + "'");
|
|
102
|
+
this.didReceiveReady = true;
|
|
103
|
+
this.checkIsReadyCallback();
|
|
377
104
|
}
|
|
378
105
|
if (type === 'presentation_complete') {
|
|
379
|
-
this.logInfo("Received 'presentation_complete' from window '"
|
|
380
|
-
this.
|
|
106
|
+
this.logInfo("Received 'presentation_complete' from window '" + windowId + "'");
|
|
107
|
+
this.didReceiveComplete = true;
|
|
108
|
+
if (this.completeCallback) {
|
|
109
|
+
this.completeCallback();
|
|
110
|
+
}
|
|
381
111
|
}
|
|
382
112
|
if (type === 'enable_interrupt_lock') {
|
|
383
|
-
this.logInfo("Received 'enable_interrupt_lock' from window '"
|
|
113
|
+
this.logInfo("Received 'enable_interrupt_lock' from window '" + windowId + "'");
|
|
384
114
|
this.enableInteruptLock();
|
|
385
115
|
}
|
|
386
116
|
if (type === 'disable_interrupt_lock') {
|
|
387
|
-
this.logInfo("Received 'disable_interrupt_lock' from window '"
|
|
117
|
+
this.logInfo("Received 'disable_interrupt_lock' from window '" + windowId + "'");
|
|
388
118
|
this.disableInteruptLock();
|
|
389
119
|
}
|
|
390
120
|
if (type === 'open_child_window') {
|
|
391
|
-
this.logInfo("Received 'open_child_window' from window '"
|
|
121
|
+
this.logInfo("Received 'open_child_window' from window '" + windowId + "', windowId=" + payload.windowId + " playlistId=" + payload.playlistId + " isMuted=" + payload.isMuted + " x=" + payload.x + " y=" + payload.y + " width=" + payload.width + " height=" + payload.height);
|
|
392
122
|
if (this.isValidOpenChildWindowPayload(payload)) {
|
|
393
123
|
this.openChildWindow(payload.windowId, payload.playlistId, {
|
|
394
124
|
x: Math.round(payload.x),
|
|
395
125
|
y: Math.round(payload.y),
|
|
396
126
|
width: Math.round(payload.width),
|
|
397
|
-
height: Math.round(payload.height)
|
|
127
|
+
height: Math.round(payload.height)
|
|
398
128
|
}, payload.isMuted, payload.isFocused, payload.theme);
|
|
399
129
|
}
|
|
400
130
|
else {
|
|
@@ -403,20 +133,20 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
403
133
|
}
|
|
404
134
|
if (type === 'close_child_window') {
|
|
405
135
|
// TODO: Validate close_child_window message payload.
|
|
406
|
-
this.logInfo("Received 'close_child_window', windowId="
|
|
136
|
+
this.logInfo("Received 'close_child_window', windowId=" + payload.windowId);
|
|
407
137
|
this.closeChildWindow(payload.windowId);
|
|
408
138
|
}
|
|
409
139
|
if (type === 'log_error') {
|
|
410
|
-
this.handleError("Received error from window '"
|
|
140
|
+
this.handleError("Received error from window '" + windowId + "', error=" + JSON.stringify(payload));
|
|
411
141
|
}
|
|
412
142
|
if (type === 'log_info') {
|
|
413
|
-
this.logInfo("Received info log from window '"
|
|
143
|
+
this.logInfo("Received info log from window '" + windowId + "', message=" + JSON.stringify(payload));
|
|
414
144
|
}
|
|
415
145
|
if (type === 'log_debug') {
|
|
416
|
-
this.logDebug("Received info debug from window '"
|
|
146
|
+
this.logDebug("Received info debug from window '" + windowId + "', message=" + JSON.stringify(payload));
|
|
417
147
|
}
|
|
418
148
|
if (type === 'presentation_properties') {
|
|
419
|
-
this.logInfo("Received 'presentation_properties' from window '"
|
|
149
|
+
this.logInfo("Received 'presentation_properties' from window '" + windowId + "'");
|
|
420
150
|
if (onPresentationProperties) {
|
|
421
151
|
onPresentationProperties(payload.properties, payload.strings);
|
|
422
152
|
}
|
|
@@ -438,13 +168,12 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
438
168
|
this.ruleEngineState = options.ruleEngineState;
|
|
439
169
|
this.theme = options.theme;
|
|
440
170
|
this.forceMute = options.forceMute || false;
|
|
441
|
-
this.workerState = options.workerState;
|
|
442
171
|
}
|
|
443
172
|
PresentationWindow.prototype.load = function () {
|
|
444
173
|
if (this.isEmbeddedApp()) {
|
|
445
174
|
return this.loadEmbeddedApp();
|
|
446
175
|
}
|
|
447
|
-
return this.
|
|
176
|
+
return this.loadRaydiantApp();
|
|
448
177
|
};
|
|
449
178
|
PresentationWindow.prototype.show = function (isFocused) {
|
|
450
179
|
var _this = this;
|
|
@@ -475,7 +204,7 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
475
204
|
wm.show(false);
|
|
476
205
|
}
|
|
477
206
|
});
|
|
478
|
-
this.logInfo("Show window '"
|
|
207
|
+
this.logInfo("Show window '" + windowId + "' isMuted=" + isMuted + " isFocused=" + isFocused + (isChildWindowFocused ? " isChildWindowFocused=true" : ''));
|
|
479
208
|
};
|
|
480
209
|
PresentationWindow.prototype.hide = function () {
|
|
481
210
|
var _a = this.options, windowId = _a.windowId, renderer = _a.renderer;
|
|
@@ -496,8 +225,6 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
496
225
|
this.errorCallback = null;
|
|
497
226
|
this.enableInterruptLockCallback = null;
|
|
498
227
|
this.disableInterruptLockCallback = null;
|
|
499
|
-
// Clean up subscriptions
|
|
500
|
-
this.workerSubscriptions.clear();
|
|
501
228
|
// Clear timers
|
|
502
229
|
if (this.readyTimeout) {
|
|
503
230
|
clearTimeout(this.readyTimeout);
|
|
@@ -517,11 +244,11 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
517
244
|
return [4 /*yield*/, renderer.removeWindow(windowId)];
|
|
518
245
|
case 2:
|
|
519
246
|
_b.sent();
|
|
520
|
-
this.logInfo("Removed window '"
|
|
247
|
+
this.logInfo("Removed window '" + windowId + "'");
|
|
521
248
|
return [3 /*break*/, 4];
|
|
522
249
|
case 3:
|
|
523
250
|
err_1 = _b.sent();
|
|
524
|
-
this.logError("Failed to remove window '"
|
|
251
|
+
this.logError("Failed to remove window '" + windowId + "' with '" + err_1.message + "'");
|
|
525
252
|
return [3 /*break*/, 4];
|
|
526
253
|
case 4: return [2 /*return*/];
|
|
527
254
|
}
|
|
@@ -549,20 +276,16 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
549
276
|
}, durationMs);
|
|
550
277
|
}
|
|
551
278
|
if (!this.isEmbeddedApp()) {
|
|
552
|
-
this.
|
|
279
|
+
this.sendMessage('play');
|
|
553
280
|
// Play any child window managers.
|
|
554
281
|
Object.values(this.windowManagers).forEach(function (wm) {
|
|
555
|
-
// We only want
|
|
282
|
+
// We only want trigger play on child windows the first play of the main window or if
|
|
556
283
|
// the child window is paused.
|
|
557
284
|
if (!wm.isPlaying() || wm.isPaused()) {
|
|
558
285
|
wm.play();
|
|
559
286
|
}
|
|
560
287
|
});
|
|
561
288
|
}
|
|
562
|
-
else if (this.runtimeSubscriptions.has('play')) {
|
|
563
|
-
// If the embedded app has subscribed to the play event, send it a play event.
|
|
564
|
-
this.sendMessageString('play');
|
|
565
|
-
}
|
|
566
289
|
this.lastPlayedAt = new Date();
|
|
567
290
|
};
|
|
568
291
|
PresentationWindow.prototype.pause = function () {
|
|
@@ -588,16 +311,7 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
588
311
|
PresentationWindow.prototype.onDisableInterruptLock = function (callback) {
|
|
589
312
|
this.disableInterruptLockCallback = callback;
|
|
590
313
|
};
|
|
591
|
-
PresentationWindow.prototype.onAnalyticsEvent = function (callback) {
|
|
592
|
-
this.analyticsEventCallback = callback;
|
|
593
|
-
};
|
|
594
|
-
PresentationWindow.prototype.onChargeRequest = function (callback) {
|
|
595
|
-
this.chargeRequestCallback = callback;
|
|
596
|
-
};
|
|
597
314
|
PresentationWindow.prototype.isReady = function () {
|
|
598
|
-
// TODO: To support the 'ready' event in embedded apps, they will need to tell the
|
|
599
|
-
// runtime that it should wait for ready instead of DOMLoaded. This could be a "wait
|
|
600
|
-
// for ready" option in the Developer Portal.
|
|
601
315
|
if (this.isEmbeddedApp()) {
|
|
602
316
|
return this.didEmbeddedAppLoad;
|
|
603
317
|
}
|
|
@@ -617,29 +331,8 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
617
331
|
return !!this.error;
|
|
618
332
|
};
|
|
619
333
|
PresentationWindow.prototype.isLocked = function () {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
if (this.isWindowLocked) {
|
|
623
|
-
this.logDebug("Window '".concat(this.options.windowId, "' is locked due to enableInterruptLock"));
|
|
624
|
-
return true;
|
|
625
|
-
}
|
|
626
|
-
if (Object.values(this.isChildWindowLocked).some(Boolean)) {
|
|
627
|
-
this.logDebug("Window '".concat(this.options.windowId, "' is locked due to enableInterruptLock on child windows"));
|
|
628
|
-
return true;
|
|
629
|
-
}
|
|
630
|
-
// Check interrupt locks on current window or child windows, used by embedded apps (apps created through
|
|
631
|
-
// the Developer Portal).
|
|
632
|
-
var now = +new Date();
|
|
633
|
-
var isExpired = function (lock) { return lock.expiresAt < now; };
|
|
634
|
-
if (!Object.values(this.interruptLocks).every(isExpired)) {
|
|
635
|
-
this.logDebug("Window '".concat(this.options.windowId, "' is locked due to interrupt lock"));
|
|
636
|
-
return true;
|
|
637
|
-
}
|
|
638
|
-
if (Object.values(this.windowManagers).some(function (wm) { return wm.isLocked(); })) {
|
|
639
|
-
this.logDebug("Window '".concat(this.options.windowId, "' is locked due to interrupt lock on child windows"));
|
|
640
|
-
return true;
|
|
641
|
-
}
|
|
642
|
-
return false;
|
|
334
|
+
return (this.isWindowLocked ||
|
|
335
|
+
Object.values(this.isChildWindowLocked).some(Boolean));
|
|
643
336
|
};
|
|
644
337
|
PresentationWindow.prototype.setPresentation = function (presentation, playlistWindowManagerState, ruleEngineState) {
|
|
645
338
|
this.presentation = presentation;
|
|
@@ -657,92 +350,36 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
657
350
|
};
|
|
658
351
|
PresentationWindow.prototype.reload = function () {
|
|
659
352
|
return __awaiter(this, void 0, void 0, function () {
|
|
660
|
-
var _a, applicationVersion, windowId,
|
|
353
|
+
var _a, applicationVersion, windowId, url;
|
|
661
354
|
return __generator(this, function (_b) {
|
|
662
355
|
switch (_b.label) {
|
|
663
356
|
case 0:
|
|
664
357
|
_a = this.options, applicationVersion = _a.applicationVersion, windowId = _a.windowId;
|
|
665
|
-
if (!this.isEmbeddedApp()) return [3 /*break*/,
|
|
666
|
-
if (!applicationVersion.embeddedUrlFormat) return [3 /*break*/,
|
|
667
|
-
|
|
668
|
-
this.logInfo("Reload window '"
|
|
669
|
-
updatedInputs = transformInputValues(this.presentation.applicationVariables);
|
|
670
|
-
if (!(0, fast_deep_equal_1.default)(updatedInputs, this.previewState.inputs)) {
|
|
671
|
-
this.sendMessageObject('preview-inputs', updatedInputs);
|
|
672
|
-
}
|
|
673
|
-
this.previewState.inputs = updatedInputs;
|
|
674
|
-
return [3 /*break*/, 3];
|
|
675
|
-
case 1:
|
|
676
|
-
url = this.getEmbeddedAppUrl();
|
|
677
|
-
this.logInfo("Reload window '".concat(windowId, "' for embedded app url '").concat(url, "'"));
|
|
358
|
+
if (!this.isEmbeddedApp()) return [3 /*break*/, 3];
|
|
359
|
+
if (!applicationVersion.embeddedUrlFormat) return [3 /*break*/, 2];
|
|
360
|
+
url = embeddedApps_1.default(this.presentation, applicationVersion);
|
|
361
|
+
this.logInfo("Reload window '" + windowId + "' for embedded app url '" + url + "'");
|
|
678
362
|
return [4 /*yield*/, this.loadWindow(url)];
|
|
679
|
-
case
|
|
363
|
+
case 1:
|
|
680
364
|
_b.sent();
|
|
681
|
-
_b.label =
|
|
682
|
-
case
|
|
683
|
-
case
|
|
684
|
-
this.logInfo("Reload window '"
|
|
365
|
+
_b.label = 2;
|
|
366
|
+
case 2: return [3 /*break*/, 4];
|
|
367
|
+
case 3:
|
|
368
|
+
this.logInfo("Reload window '" + windowId + "'");
|
|
685
369
|
this.sendRenderMessage();
|
|
686
|
-
_b.label =
|
|
687
|
-
case
|
|
370
|
+
_b.label = 4;
|
|
371
|
+
case 4: return [2 /*return*/];
|
|
688
372
|
}
|
|
689
373
|
});
|
|
690
374
|
});
|
|
691
375
|
};
|
|
692
376
|
PresentationWindow.prototype.runGetProperties = function (builderState) {
|
|
693
|
-
|
|
694
|
-
// change the way conditional properties work.
|
|
695
|
-
if (!this.isEmbeddedApp()) {
|
|
696
|
-
this.sendMessageString('run_get_properties', builderState);
|
|
697
|
-
}
|
|
698
|
-
};
|
|
699
|
-
PresentationWindow.prototype.createObjectURL = function (blob) {
|
|
700
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
701
|
-
return __generator(this, function (_a) {
|
|
702
|
-
if (this.isEmbeddedApp()) {
|
|
703
|
-
return [2 /*return*/, this.createObjectURLForEmbeddedApp(blob)];
|
|
704
|
-
}
|
|
705
|
-
return [2 /*return*/, URL.createObjectURL(blob)];
|
|
706
|
-
});
|
|
707
|
-
});
|
|
708
|
-
};
|
|
709
|
-
PresentationWindow.prototype.sendChargeResponse = function (response) {
|
|
710
|
-
// TODO: Instead of sending the charge to all windows, we should only send it to the app
|
|
711
|
-
// that requested the charge. We probably don't want to use the windowId to avoid missing
|
|
712
|
-
// the events in case the window was closed/restarted. Since we are only sending the charge
|
|
713
|
-
// id and status this seems ok for now but need to be mindful of sending any sensitive data.
|
|
714
|
-
this.sendMessageObject('payments-charge-response', {
|
|
715
|
-
requestId: response.requestId,
|
|
716
|
-
charge: response.charge,
|
|
717
|
-
error: response.error,
|
|
718
|
-
});
|
|
719
|
-
// Forward the event to the child window managers.
|
|
720
|
-
Object.values(this.windowManagers).forEach(function (wm) {
|
|
721
|
-
return wm.sendChargeResponse(response);
|
|
722
|
-
});
|
|
723
|
-
};
|
|
724
|
-
PresentationWindow.prototype.sendCharge = function (charge) {
|
|
725
|
-
// TODO: Instead of sending the charge to all windows, we should only send it to the app
|
|
726
|
-
// that requested the charge.
|
|
727
|
-
if (this.paymentSubscriptions.has('charge')) {
|
|
728
|
-
this.sendMessageObject('payments-charge-event', { charge: charge });
|
|
729
|
-
}
|
|
730
|
-
// Forward the event to the child window managers.
|
|
731
|
-
Object.values(this.windowManagers).forEach(function (wm) { return wm.sendCharge(charge); });
|
|
732
|
-
};
|
|
733
|
-
PresentationWindow.prototype.sendTerminal = function (terminal) {
|
|
734
|
-
if (this.paymentSubscriptions.has('terminal')) {
|
|
735
|
-
this.sendMessageObject('payments-terminal-event', { terminal: terminal });
|
|
736
|
-
}
|
|
737
|
-
// Forward the event to the child window managers.
|
|
738
|
-
Object.values(this.windowManagers).forEach(function (wm) {
|
|
739
|
-
return wm.sendTerminal(terminal);
|
|
740
|
-
});
|
|
377
|
+
this.sendMessage('run_get_properties', builderState);
|
|
741
378
|
};
|
|
742
379
|
PresentationWindow.prototype.isEmbeddedApp = function () {
|
|
743
380
|
var _a = this.options, applicationVersion = _a.applicationVersion, isPreview = _a.isPreview;
|
|
744
381
|
// If the application has a source url, always use it for rendering the preview.
|
|
745
|
-
// This fixes an issue with Hoopla which is an embedded app but uses a
|
|
382
|
+
// This fixes an issue with Hoopla which is an embedded app but uses a Raydiant app
|
|
746
383
|
// for it's preview.
|
|
747
384
|
if (isPreview && applicationVersion.sourceUrl) {
|
|
748
385
|
return false;
|
|
@@ -771,17 +408,6 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
771
408
|
}
|
|
772
409
|
}
|
|
773
410
|
};
|
|
774
|
-
PresentationWindow.prototype.getFullAppRendererUrl = function (_a) {
|
|
775
|
-
var appRendererUrl = _a.appRendererUrl, windowId = _a.windowId, appRendererOfflineSupport = _a.appRendererOfflineSupport;
|
|
776
|
-
var url = new URL(appRendererUrl);
|
|
777
|
-
var hashParams = new URLSearchParams(url.hash.slice(1));
|
|
778
|
-
hashParams.set('__raydiantWindowId', windowId);
|
|
779
|
-
if (appRendererOfflineSupport === true) {
|
|
780
|
-
hashParams.set('__raydiantOfflineSupport', 'true');
|
|
781
|
-
}
|
|
782
|
-
url.hash = hashParams.toString();
|
|
783
|
-
return url.toString();
|
|
784
|
-
};
|
|
785
411
|
PresentationWindow.prototype.loadEmbeddedApp = function () {
|
|
786
412
|
return __awaiter(this, void 0, void 0, function () {
|
|
787
413
|
var _a, windowId, applicationVersion, url;
|
|
@@ -790,15 +416,20 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
790
416
|
case 0:
|
|
791
417
|
_a = this.options, windowId = _a.windowId, applicationVersion = _a.applicationVersion;
|
|
792
418
|
if (!applicationVersion.embeddedUrlFormat) {
|
|
793
|
-
throw new Error("Error loading embedded app, missing embeddedUrlFormat for '"
|
|
794
|
-
}
|
|
795
|
-
url = this.
|
|
796
|
-
this.logInfo("Create window '"
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
419
|
+
throw new Error("Error loading embedded app, missing embeddedUrlFormat for '" + applicationVersion.id + "'");
|
|
420
|
+
}
|
|
421
|
+
url = embeddedApps_1.default(this.presentation, applicationVersion);
|
|
422
|
+
this.logInfo("Create window '" + windowId + "' for embedded app url '" + url + "'");
|
|
423
|
+
// Embedded apps should not have a backgroundColor bexcause some sites expect
|
|
424
|
+
// the browser default of white will be applied. We also don't attach the message
|
|
425
|
+
// listeners for embedded apps. We could eventually allow embedded apps to send
|
|
426
|
+
// lifecycle events but we should consider namespacing our message events.
|
|
427
|
+
return [4 /*yield*/, this.createAndLoadWindow(url, '#ffffff')];
|
|
801
428
|
case 1:
|
|
429
|
+
// Embedded apps should not have a backgroundColor bexcause some sites expect
|
|
430
|
+
// the browser default of white will be applied. We also don't attach the message
|
|
431
|
+
// listeners for embedded apps. We could eventually allow embedded apps to send
|
|
432
|
+
// lifecycle events but we should consider namespacing our message events.
|
|
802
433
|
_b.sent();
|
|
803
434
|
this.didEmbeddedAppLoad = true;
|
|
804
435
|
this.checkIsReadyCallback();
|
|
@@ -807,20 +438,17 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
807
438
|
});
|
|
808
439
|
});
|
|
809
440
|
};
|
|
810
|
-
PresentationWindow.prototype.
|
|
441
|
+
PresentationWindow.prototype.loadRaydiantApp = function () {
|
|
811
442
|
return __awaiter(this, void 0, void 0, function () {
|
|
812
|
-
var _a, windowId, _b, appRendererUrl,
|
|
443
|
+
var _a, windowId, _b, appRendererUrl, backgroundColor, url;
|
|
813
444
|
return __generator(this, function (_c) {
|
|
814
445
|
switch (_c.label) {
|
|
815
446
|
case 0:
|
|
816
|
-
_a = this.options, windowId = _a.windowId, _b = _a.appRendererUrl, appRendererUrl = _b === void 0 ? defaultAppRendererUrl : _b,
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
appRendererOfflineSupport: appRendererOfflineSupport,
|
|
822
|
-
}), backgroundColor || '#000000', // Default to black bg for Raydiant apps
|
|
823
|
-
this.handleLegacyMessage)];
|
|
447
|
+
_a = this.options, windowId = _a.windowId, _b = _a.appRendererUrl, appRendererUrl = _b === void 0 ? defaultAppRendererUrl : _b, backgroundColor = _a.backgroundColor;
|
|
448
|
+
url = appRendererUrl + "#windowId=" + windowId;
|
|
449
|
+
this.logInfo("Create window '" + windowId + "'");
|
|
450
|
+
return [4 /*yield*/, this.createAndLoadWindow(url, backgroundColor || '#000000', // Default to black bg for Raydiant apps
|
|
451
|
+
this.handleMessage)];
|
|
824
452
|
case 1:
|
|
825
453
|
_c.sent();
|
|
826
454
|
return [4 /*yield*/, this.waitForPesentationReady()];
|
|
@@ -844,14 +472,14 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
844
472
|
bounds: bounds,
|
|
845
473
|
backgroundColor: backgroundColor,
|
|
846
474
|
receiveMessageCallback: receiveMessageCallback,
|
|
847
|
-
errorCallback: this.handleError
|
|
475
|
+
errorCallback: this.handleError
|
|
848
476
|
});
|
|
849
477
|
// Mute new window. This ensures preloaded windows are muted by default and
|
|
850
478
|
// prevents opening an audio channel on the device for SYB playback. When using
|
|
851
479
|
// the BrowserWindowRenderer this will call setAudioMuted(true) but the IFrameRenderer
|
|
852
480
|
// has no API for muting so we rely on apps that use mute presentation props to be
|
|
853
481
|
// initially muted before playing.
|
|
854
|
-
this.logInfo("Mute window "
|
|
482
|
+
this.logInfo("Mute window " + windowId);
|
|
855
483
|
renderer.muteWindow(windowId);
|
|
856
484
|
return [4 /*yield*/, this.loadWindow(url)];
|
|
857
485
|
case 1:
|
|
@@ -874,31 +502,22 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
874
502
|
return [4 /*yield*/, renderer.loadWindow(windowId, url)];
|
|
875
503
|
case 2:
|
|
876
504
|
_b.sent();
|
|
877
|
-
this.logInfo("Loaded window '"
|
|
505
|
+
this.logInfo("Loaded window '" + windowId + "'");
|
|
878
506
|
return [3 /*break*/, 4];
|
|
879
507
|
case 3:
|
|
880
508
|
err_2 = _b.sent();
|
|
881
|
-
this.handleError(new WindowLoadError_1.default("Failed to load window with '"
|
|
509
|
+
this.handleError(new WindowLoadError_1.default("Failed to load window with '" + err_2.message + "'"));
|
|
882
510
|
return [3 /*break*/, 4];
|
|
883
511
|
case 4: return [2 /*return*/];
|
|
884
512
|
}
|
|
885
513
|
});
|
|
886
514
|
});
|
|
887
515
|
};
|
|
888
|
-
|
|
889
|
-
// messages and should be deprecated in favor of sendMessageObject.
|
|
890
|
-
PresentationWindow.prototype.sendMessageString = function (type, payload) {
|
|
516
|
+
PresentationWindow.prototype.sendMessage = function (type, payload) {
|
|
891
517
|
var _a = this.options, windowId = _a.windowId, renderer = _a.renderer;
|
|
892
518
|
var message = JSON.stringify({ type: type, payload: payload, windowId: windowId });
|
|
893
|
-
this.logInfo("Sending '"
|
|
894
|
-
renderer.
|
|
895
|
-
};
|
|
896
|
-
// Send a message object to the renderer. This is the preferred way of sending messages
|
|
897
|
-
// going forward since it allows for more complex payloads like ArrayBuffers (for File Inputs).
|
|
898
|
-
PresentationWindow.prototype.sendMessageObject = function (type, payload) {
|
|
899
|
-
var _a = this.options, windowId = _a.windowId, renderer = _a.renderer;
|
|
900
|
-
this.logInfo("Sending '".concat(type, "' to window '").concat(windowId, "'"));
|
|
901
|
-
renderer.sendMessageObject(windowId, type, payload);
|
|
519
|
+
this.logInfo("Sending '" + type + "' to window '" + windowId + "'");
|
|
520
|
+
renderer.sendMessage(windowId, message);
|
|
902
521
|
};
|
|
903
522
|
PresentationWindow.prototype.waitForPesentationReady = function () {
|
|
904
523
|
var _this = this;
|
|
@@ -915,7 +534,7 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
915
534
|
clearTimeout(_this.readyTimeout);
|
|
916
535
|
}
|
|
917
536
|
_this.readyTimeout = setTimeout(function () {
|
|
918
|
-
_this.handleError(new WindowTimeoutError_1.default("Window "
|
|
537
|
+
_this.handleError(new WindowTimeoutError_1.default("Window " + windowId + " timed out after " + readyTimeoutDurationSeconds + " seconds"));
|
|
919
538
|
// Resolve the promise is the window times out. This ensures windowManager.load() resolves
|
|
920
539
|
// even if the current window times out. Fixes an issue where the boot screen isn't removed
|
|
921
540
|
// if the first presentation times out.
|
|
@@ -951,26 +570,26 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
951
570
|
// IFrames do not have a mute/unmute API so we are overriding any mute properties
|
|
952
571
|
// to support muting MZ zones when using the IFrameRenderer (SecondScreen).
|
|
953
572
|
if (this.forceMute) {
|
|
954
|
-
this.
|
|
573
|
+
this.sendMessage('render', {
|
|
955
574
|
builderState: this.builderState,
|
|
956
|
-
presentation: __assign(
|
|
575
|
+
presentation: __assign({}, this.presentation, { applicationVariables: __assign({}, this.presentation.applicationVariables, {
|
|
957
576
|
// TODO: We need a better way to identify mute properties (ie. PropType.mute())
|
|
958
577
|
// Force mute the presentation, existing apps use either mute or muted.
|
|
959
578
|
mute: true, muted: true }) }),
|
|
960
579
|
theme: this.buildTheme(),
|
|
961
580
|
applicationVersion: applicationVersion,
|
|
962
581
|
device: device,
|
|
963
|
-
isPreview: isPreview
|
|
582
|
+
isPreview: isPreview
|
|
964
583
|
});
|
|
965
584
|
}
|
|
966
585
|
else {
|
|
967
|
-
this.
|
|
586
|
+
this.sendMessage('render', {
|
|
968
587
|
builderState: this.builderState,
|
|
969
588
|
presentation: this.presentation,
|
|
970
589
|
theme: this.buildTheme(),
|
|
971
590
|
applicationVersion: applicationVersion,
|
|
972
591
|
device: device,
|
|
973
|
-
isPreview: isPreview
|
|
592
|
+
isPreview: isPreview
|
|
974
593
|
});
|
|
975
594
|
}
|
|
976
595
|
};
|
|
@@ -992,14 +611,14 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
992
611
|
prevRuleEngine = windowManager.getRuleEngine();
|
|
993
612
|
prevForceMute = windowManager.getForceMute();
|
|
994
613
|
didBoundsChange = prevBounds
|
|
995
|
-
? !
|
|
614
|
+
? !fast_deep_equal_1.default(bounds, prevBounds)
|
|
996
615
|
: true;
|
|
997
616
|
if (didBoundsChange) {
|
|
998
617
|
windowManager.updateBounds(bounds);
|
|
999
618
|
}
|
|
1000
619
|
didForceMuteChange = forceMute !== prevForceMute;
|
|
1001
620
|
didThemeOverrideChange = prevThemeOverride
|
|
1002
|
-
? !
|
|
621
|
+
? !fast_deep_equal_1.default(themeOverride, prevThemeOverride)
|
|
1003
622
|
: true;
|
|
1004
623
|
if (didForceMuteChange || didThemeOverrideChange) {
|
|
1005
624
|
windowManager.setThemeOverride(themeOverride);
|
|
@@ -1027,31 +646,14 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
1027
646
|
x: bounds.x,
|
|
1028
647
|
y: bounds.y,
|
|
1029
648
|
width: bounds.width,
|
|
1030
|
-
height: bounds.height
|
|
649
|
+
height: bounds.height
|
|
1031
650
|
},
|
|
1032
651
|
backgroundColor: 'transparent',
|
|
1033
652
|
themeOverride: themeOverride,
|
|
1034
653
|
forceMute: forceMute,
|
|
1035
654
|
isPreview: isPreview,
|
|
1036
|
-
onEnableInterruptLock: function () {
|
|
1037
|
-
|
|
1038
|
-
// runInterruptCallback is used by Developer Portal apps.
|
|
1039
|
-
if (_this.isEmbeddedApp()) {
|
|
1040
|
-
_this.runInterruptCallback();
|
|
1041
|
-
}
|
|
1042
|
-
else {
|
|
1043
|
-
_this.enableInteruptLock(windowName);
|
|
1044
|
-
}
|
|
1045
|
-
},
|
|
1046
|
-
onDisableInterruptLock: function () {
|
|
1047
|
-
if (_this.isEmbeddedApp()) {
|
|
1048
|
-
_this.runInterruptCallback();
|
|
1049
|
-
}
|
|
1050
|
-
else {
|
|
1051
|
-
_this.disableInteruptLock(windowName);
|
|
1052
|
-
}
|
|
1053
|
-
},
|
|
1054
|
-
getTerminal: this.options.getTerminal,
|
|
655
|
+
onEnableInterruptLock: function () { return _this.enableInteruptLock(windowName); },
|
|
656
|
+
onDisableInterruptLock: function () { return _this.disableInteruptLock(windowName); }
|
|
1055
657
|
});
|
|
1056
658
|
// Hook up child window manager events to bubble up to the parent.
|
|
1057
659
|
if (parentWindowManager) {
|
|
@@ -1067,12 +669,6 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
1067
669
|
windowManager.on('window_end_error', function (metadata) {
|
|
1068
670
|
parentWindowManager.emit('window_end_error', metadata);
|
|
1069
671
|
});
|
|
1070
|
-
windowManager.on('window_analytics_event', function (metadata) {
|
|
1071
|
-
parentWindowManager.emit('window_analytics_event', metadata);
|
|
1072
|
-
});
|
|
1073
|
-
windowManager.on('window_charge_request', function (metadata) {
|
|
1074
|
-
parentWindowManager.emit('window_charge_request', metadata);
|
|
1075
|
-
});
|
|
1076
672
|
}
|
|
1077
673
|
this.windowManagers[windowName] = windowManager;
|
|
1078
674
|
windowManager.setRenderer(renderer);
|
|
@@ -1109,11 +705,9 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
1109
705
|
delete this.windowManagers[windowName];
|
|
1110
706
|
}
|
|
1111
707
|
else {
|
|
1112
|
-
this.logWarning("Failed to close child window manager for '"
|
|
708
|
+
this.logWarning("Failed to close child window manager for '" + windowName + "'.");
|
|
1113
709
|
}
|
|
1114
710
|
};
|
|
1115
|
-
// Legacy enable interrupt lock for RaydiantKit apps (ie. Virtual Rooms). This has been
|
|
1116
|
-
// replaced by createInterruptLock for embedded apps.
|
|
1117
711
|
PresentationWindow.prototype.enableInteruptLock = function (windowName) {
|
|
1118
712
|
if (windowName) {
|
|
1119
713
|
this.isChildWindowLocked[windowName] = true;
|
|
@@ -1121,12 +715,11 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
1121
715
|
else {
|
|
1122
716
|
this.isWindowLocked = true;
|
|
1123
717
|
}
|
|
718
|
+
// If the presentation is ready and locked, trigger the enable interrupt callback.
|
|
1124
719
|
if (this.isReady() && this.isLocked() && this.enableInterruptLockCallback) {
|
|
1125
720
|
this.enableInterruptLockCallback();
|
|
1126
721
|
}
|
|
1127
722
|
};
|
|
1128
|
-
// Legacy disable interrupt lock for RaydiantKit apps (ie. Virtual Rooms). This has been
|
|
1129
|
-
// replaced by releaseInterruptLock for embedded apps.
|
|
1130
723
|
PresentationWindow.prototype.disableInteruptLock = function (windowName) {
|
|
1131
724
|
if (windowName) {
|
|
1132
725
|
this.isChildWindowLocked[windowName] = false;
|
|
@@ -1134,34 +727,13 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
1134
727
|
else {
|
|
1135
728
|
this.isWindowLocked = false;
|
|
1136
729
|
}
|
|
730
|
+
// If the presentation is ready and unlocked, trigger the disable interrupt callback.
|
|
1137
731
|
if (this.isReady() &&
|
|
1138
732
|
!this.isLocked() &&
|
|
1139
733
|
this.disableInterruptLockCallback) {
|
|
1140
734
|
this.disableInterruptLockCallback();
|
|
1141
735
|
}
|
|
1142
736
|
};
|
|
1143
|
-
PresentationWindow.prototype.getEmbeddedAppUrl = function () {
|
|
1144
|
-
var _a = this.options, windowId = _a.windowId, appRendererOfflineSupport = _a.appRendererOfflineSupport;
|
|
1145
|
-
var metadata = {
|
|
1146
|
-
renderMode: this.options.isPreview ? 'preview' : 'live',
|
|
1147
|
-
};
|
|
1148
|
-
var url = (0, embeddedApps_1.default)(this.presentation, this.options.applicationVersion, metadata);
|
|
1149
|
-
return this.getFullAppRendererUrl({
|
|
1150
|
-
appRendererUrl: url,
|
|
1151
|
-
windowId: windowId,
|
|
1152
|
-
appRendererOfflineSupport: appRendererOfflineSupport,
|
|
1153
|
-
});
|
|
1154
|
-
};
|
|
1155
|
-
PresentationWindow.prototype.handleReady = function () {
|
|
1156
|
-
this.didReceiveReady = true;
|
|
1157
|
-
this.checkIsReadyCallback();
|
|
1158
|
-
};
|
|
1159
|
-
PresentationWindow.prototype.handleComplete = function () {
|
|
1160
|
-
this.didReceiveComplete = true;
|
|
1161
|
-
if (this.completeCallback) {
|
|
1162
|
-
this.completeCallback();
|
|
1163
|
-
}
|
|
1164
|
-
};
|
|
1165
737
|
PresentationWindow.prototype.logDebug = function (message) {
|
|
1166
738
|
this.options.logger.debug(message, this.getLogContext());
|
|
1167
739
|
};
|
|
@@ -1188,30 +760,12 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
1188
760
|
publishedAt: publishedAt,
|
|
1189
761
|
playlistId: playlistId,
|
|
1190
762
|
playlistName: playlistName,
|
|
1191
|
-
rule: rule
|
|
763
|
+
rule: rule
|
|
1192
764
|
};
|
|
1193
765
|
};
|
|
1194
766
|
PresentationWindow.prototype.metadata = function () {
|
|
1195
767
|
return this.getLogContext();
|
|
1196
768
|
};
|
|
1197
|
-
PresentationWindow.prototype.runWorkerSubscriptions = function (state) {
|
|
1198
|
-
// For each worker subscription, compare the previous state to the new state.
|
|
1199
|
-
// If the state has changed, send the new state to the subscription.
|
|
1200
|
-
for (var _i = 0, _a = Array.from(this.workerSubscriptions); _i < _a.length; _i++) {
|
|
1201
|
-
var workerName = _a[_i];
|
|
1202
|
-
var workerState = state[workerName];
|
|
1203
|
-
var previousWorkerState = this.workerState[workerName];
|
|
1204
|
-
if (workerState !== undefined &&
|
|
1205
|
-
!(0, fast_deep_equal_1.default)(workerState, previousWorkerState)) {
|
|
1206
|
-
this.sendMessageString('worker-state', {
|
|
1207
|
-
name: workerName,
|
|
1208
|
-
state: workerState,
|
|
1209
|
-
});
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
// Persist the new state so we can compare if the previous values have changed..
|
|
1213
|
-
this.workerState = state;
|
|
1214
|
-
};
|
|
1215
769
|
PresentationWindow.prototype.createRuleEngine = function (playlistId) {
|
|
1216
770
|
var globalRule = this.options.globalRule;
|
|
1217
771
|
return new RE.RuleEngine(playlistId, this.ruleEngineState, globalRule
|
|
@@ -1224,15 +778,15 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
1224
778
|
{
|
|
1225
779
|
type: 'equals',
|
|
1226
780
|
left: { var: ['target', 'hasPlaylists'] },
|
|
1227
|
-
right: { const: false }
|
|
1228
|
-
}
|
|
1229
|
-
]
|
|
781
|
+
right: { const: false }
|
|
782
|
+
}
|
|
783
|
+
]
|
|
1230
784
|
}
|
|
1231
785
|
: {
|
|
1232
786
|
// A global rule was not provided so we don't need to combine the rule with an AND.
|
|
1233
787
|
type: 'equals',
|
|
1234
788
|
left: { var: ['target', 'hasPlaylists'] },
|
|
1235
|
-
right: { const: false }
|
|
789
|
+
right: { const: false }
|
|
1236
790
|
});
|
|
1237
791
|
};
|
|
1238
792
|
PresentationWindow.prototype.isValidOpenChildWindowPayload = function (payload) {
|
|
@@ -1269,145 +823,6 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
1269
823
|
var isMutedMultizone = appVars.muteZone1 === true && appVars.muteZone2 === true;
|
|
1270
824
|
return isMutedMultizone;
|
|
1271
825
|
};
|
|
1272
|
-
PresentationWindow.prototype.createObjectURLForEmbeddedApp = function (blob) {
|
|
1273
|
-
var _this = this;
|
|
1274
|
-
return new Promise(function (resolve, reject) {
|
|
1275
|
-
// Handle multiple concurrent createObjectURL calls by creating a request id for each
|
|
1276
|
-
// call. We send the request id along with the message to the running app and the app
|
|
1277
|
-
// sends the request id back with the result so we can resolve the correct promise.
|
|
1278
|
-
var requestId = (0, uuid_1.v4)();
|
|
1279
|
-
_this.createObjectURLResolvers[requestId] = resolve;
|
|
1280
|
-
// Start a timer to reject the promise if the app doesn't respond with the create object
|
|
1281
|
-
// url result within 1 second. This should be more or less instant.
|
|
1282
|
-
_this.createObjectURLTimeouts[requestId] = setTimeout(function () {
|
|
1283
|
-
var error = new Error("Timed out waiting for the create-object-url-result message for request id ".concat(requestId));
|
|
1284
|
-
reject(error);
|
|
1285
|
-
delete _this.createObjectURLResolvers[requestId];
|
|
1286
|
-
delete _this.createObjectURLTimeouts[requestId];
|
|
1287
|
-
}, 1000);
|
|
1288
|
-
// Create a FileReader object to read the file data as an ArrayBuffer.
|
|
1289
|
-
var reader = new FileReader();
|
|
1290
|
-
reader.addEventListener('load', function () {
|
|
1291
|
-
var buffer = reader.result;
|
|
1292
|
-
// Check if buffer is an ArrayBuffer
|
|
1293
|
-
if (buffer instanceof ArrayBuffer) {
|
|
1294
|
-
// Send the ArrayBuffer to the running app to create the local file blob URL.
|
|
1295
|
-
_this.sendMessageObject('create-object-url', { requestId: requestId, buffer: buffer });
|
|
1296
|
-
}
|
|
1297
|
-
}, false);
|
|
1298
|
-
reader.readAsArrayBuffer(blob);
|
|
1299
|
-
return '';
|
|
1300
|
-
});
|
|
1301
|
-
};
|
|
1302
|
-
PresentationWindow.prototype.createInterruptLock = function () {
|
|
1303
|
-
var lockId = (0, uuid_1.v4)();
|
|
1304
|
-
var lock = {
|
|
1305
|
-
id: lockId,
|
|
1306
|
-
expiresAt: +new Date() + lockDuration,
|
|
1307
|
-
timeout: this.createLockTimeout(lockId),
|
|
1308
|
-
};
|
|
1309
|
-
this.interruptLocks[lock.id] = lock;
|
|
1310
|
-
this.runInterruptCallback();
|
|
1311
|
-
return lock;
|
|
1312
|
-
};
|
|
1313
|
-
PresentationWindow.prototype.renewInterruptLock = function (id) {
|
|
1314
|
-
var lock = this.interruptLocks[id];
|
|
1315
|
-
if (lock) {
|
|
1316
|
-
// Reset expiration time.
|
|
1317
|
-
lock.expiresAt = +new Date() + lockDuration;
|
|
1318
|
-
// Reset timeout.
|
|
1319
|
-
if (lock.timeout) {
|
|
1320
|
-
clearTimeout(lock.timeout);
|
|
1321
|
-
}
|
|
1322
|
-
lock.timeout = this.createLockTimeout(id);
|
|
1323
|
-
}
|
|
1324
|
-
else {
|
|
1325
|
-
// If the lock doesn't exist it was already released, create a new lock with the same id.
|
|
1326
|
-
lock = {
|
|
1327
|
-
id: id,
|
|
1328
|
-
expiresAt: +new Date() + lockDuration,
|
|
1329
|
-
timeout: this.createLockTimeout(id),
|
|
1330
|
-
};
|
|
1331
|
-
this.interruptLocks[lock.id] = lock;
|
|
1332
|
-
}
|
|
1333
|
-
this.runInterruptCallback();
|
|
1334
|
-
return lock;
|
|
1335
|
-
};
|
|
1336
|
-
PresentationWindow.prototype.releaseInterruptLock = function (id) {
|
|
1337
|
-
var lock = this.interruptLocks[id];
|
|
1338
|
-
if (lock) {
|
|
1339
|
-
if (lock.timeout) {
|
|
1340
|
-
clearTimeout(lock.timeout);
|
|
1341
|
-
}
|
|
1342
|
-
delete this.interruptLocks[id];
|
|
1343
|
-
}
|
|
1344
|
-
else {
|
|
1345
|
-
// If the lock doesn't exist it was already released, return a fake lock object to
|
|
1346
|
-
// send a response back to the running app.
|
|
1347
|
-
lock = { id: id, expiresAt: 0, timeout: null };
|
|
1348
|
-
}
|
|
1349
|
-
this.runInterruptCallback();
|
|
1350
|
-
return lock;
|
|
1351
|
-
};
|
|
1352
|
-
PresentationWindow.prototype.createLockTimeout = function (id) {
|
|
1353
|
-
var _this = this;
|
|
1354
|
-
return setTimeout(function () {
|
|
1355
|
-
_this.logInfo("Interrupt lock expired, releasing: ".concat(id));
|
|
1356
|
-
_this.releaseInterruptLock(id);
|
|
1357
|
-
}, lockDuration);
|
|
1358
|
-
};
|
|
1359
|
-
PresentationWindow.prototype.runInterruptCallback = function () {
|
|
1360
|
-
var currentlyLocked = this.isLocked();
|
|
1361
|
-
// If locked and the lock state has changed, run the interrupt lock callback.
|
|
1362
|
-
// Or if not locked and the lock state has changed, run the disable interrupt lock callback.
|
|
1363
|
-
if (currentlyLocked &&
|
|
1364
|
-
this.previouslyLocked !== currentlyLocked &&
|
|
1365
|
-
this.enableInterruptLockCallback) {
|
|
1366
|
-
this.enableInterruptLockCallback();
|
|
1367
|
-
}
|
|
1368
|
-
else if (!currentlyLocked &&
|
|
1369
|
-
this.previouslyLocked !== currentlyLocked &&
|
|
1370
|
-
this.disableInterruptLockCallback) {
|
|
1371
|
-
this.disableInterruptLockCallback();
|
|
1372
|
-
}
|
|
1373
|
-
this.previouslyLocked = currentlyLocked;
|
|
1374
|
-
};
|
|
1375
826
|
return PresentationWindow;
|
|
1376
827
|
}());
|
|
1377
828
|
exports.default = PresentationWindow;
|
|
1378
|
-
var isValidCreateObjectURLResultPayload = function (payload) {
|
|
1379
|
-
return (
|
|
1380
|
-
// Ensure payload is an object.
|
|
1381
|
-
typeof payload === 'object' &&
|
|
1382
|
-
payload !== null &&
|
|
1383
|
-
// Ensure requestId is a string.
|
|
1384
|
-
'requestId' in payload &&
|
|
1385
|
-
typeof payload['requestId'] === 'string' &&
|
|
1386
|
-
// Ensure payload.file is an object.
|
|
1387
|
-
'url' in payload &&
|
|
1388
|
-
typeof payload['url'] === 'string');
|
|
1389
|
-
};
|
|
1390
|
-
var transformInputValues = function (inputs) {
|
|
1391
|
-
var transformed = {};
|
|
1392
|
-
// Recursively traverse inputs, transforming any file input values to remove internal
|
|
1393
|
-
// properties like file_upload_id.
|
|
1394
|
-
for (var _i = 0, _a = Object.entries(inputs); _i < _a.length; _i++) {
|
|
1395
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
1396
|
-
if (typeof value === 'object' && value !== null && 'url' in value) {
|
|
1397
|
-
// Value is a file input, strip out the file_upload_id property.
|
|
1398
|
-
transformed[key] = { url: value.url };
|
|
1399
|
-
}
|
|
1400
|
-
else if (Array.isArray(value)) {
|
|
1401
|
-
// Value is an array input, traverse each item in the array for file input values.
|
|
1402
|
-
transformed[key] = [];
|
|
1403
|
-
for (var _c = 0, value_1 = value; _c < value_1.length; _c++) {
|
|
1404
|
-
var item = value_1[_c];
|
|
1405
|
-
transformed[key].push(transformInputValues(item));
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
else {
|
|
1409
|
-
transformed[key] = value;
|
|
1410
|
-
}
|
|
1411
|
-
}
|
|
1412
|
-
return transformed;
|
|
1413
|
-
};
|