@raydiant/playlist-window-manager 0.20.0 → 0.21.1
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 +3 -2
- package/build/BrowserViewRenderer.js +47 -23
- package/build/BrowserWindowRenderer.d.ts +3 -2
- package/build/BrowserWindowRenderer.js +66 -42
- package/build/IFrameRenderer.d.ts +3 -2
- package/build/IFrameRenderer.js +38 -28
- package/build/PlaylistWindowManager.js +14 -11
- package/build/PlaylistWindowManagerState.js +3 -3
- package/build/PresentationWindow.d.ts +9 -2
- package/build/PresentationWindow.js +241 -86
- package/build/PresentationWindow.test.d.ts +1 -0
- package/build/PresentationWindow.test.js +241 -0
- package/build/WindowLoadError.js +3 -1
- package/build/WindowTimeoutError.js +3 -1
- package/build/WindowUnresponsiveError.js +3 -1
- package/build/embeddedApps.js +7 -0
- package/build/embeddedApps.test.js +42 -32
- package/build/index.js +19 -6
- package/build/testUtils.d.ts +43 -0
- package/build/testUtils.js +208 -0
- package/build/types.d.ts +7 -2
- package/package.json +2 -2
- package/src/BrowserViewRenderer.ts +18 -7
- package/src/BrowserWindowRenderer.ts +29 -17
- package/src/IFrameRenderer.ts +27 -10
- package/src/PresentationWindow.test.ts +221 -0
- package/src/PresentationWindow.ts +232 -59
- package/src/embeddedApps.test.ts +39 -20
- package/src/embeddedApps.ts +13 -4
- package/src/testUtils.ts +159 -0
- package/src/types.ts +14 -3
- package/tasks/npm-publish.sh +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var testUtils_1 = require("./testUtils");
|
|
40
|
+
var delay = function (ms) { return new Promise(function (resolve) { return setTimeout(resolve, ms); }); };
|
|
41
|
+
describe('embedded apps', function () {
|
|
42
|
+
test('loads embedded url format', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
+
var testRenderer, window;
|
|
44
|
+
return __generator(this, function (_a) {
|
|
45
|
+
switch (_a.label) {
|
|
46
|
+
case 0:
|
|
47
|
+
testRenderer = (0, testUtils_1.createRenderer)();
|
|
48
|
+
window = (0, testUtils_1.createPresentationWindow)({
|
|
49
|
+
windowId: 'test-embedded-url-format',
|
|
50
|
+
presentation: (0, testUtils_1.createPresentation)({
|
|
51
|
+
applicationVariables: { input: 'test' },
|
|
52
|
+
}),
|
|
53
|
+
applicationVersion: (0, testUtils_1.createApplicationVersion)({
|
|
54
|
+
embeddedUrlFormat: 'http://test.local/:input',
|
|
55
|
+
presentationProperties: [{ name: 'input', type: 'string' }],
|
|
56
|
+
}),
|
|
57
|
+
renderer: testRenderer,
|
|
58
|
+
});
|
|
59
|
+
return [4 /*yield*/, window.load()];
|
|
60
|
+
case 1:
|
|
61
|
+
_a.sent();
|
|
62
|
+
expect(testRenderer.createWindow).toHaveBeenCalledWith({
|
|
63
|
+
windowId: 'test-embedded-url-format',
|
|
64
|
+
backgroundColor: '#ffffff',
|
|
65
|
+
bounds: undefined,
|
|
66
|
+
parentWindowId: undefined,
|
|
67
|
+
errorCallback: expect.any(Function),
|
|
68
|
+
receiveMessageCallback: expect.any(Function),
|
|
69
|
+
});
|
|
70
|
+
expect(testRenderer.loadWindow).toHaveBeenCalledWith('test-embedded-url-format', 'http://test.local/test#__raydiantWindowId=test-embedded-url-format');
|
|
71
|
+
return [2 /*return*/];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}); });
|
|
75
|
+
test('reloads by rendering embedded url format', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
76
|
+
var testRenderer, window;
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
switch (_a.label) {
|
|
79
|
+
case 0:
|
|
80
|
+
testRenderer = (0, testUtils_1.createRenderer)();
|
|
81
|
+
window = (0, testUtils_1.createPresentationWindow)({
|
|
82
|
+
windowId: 'test-reload-url',
|
|
83
|
+
presentation: (0, testUtils_1.createPresentation)({
|
|
84
|
+
applicationVariables: { input: 'test' },
|
|
85
|
+
}),
|
|
86
|
+
applicationVersion: (0, testUtils_1.createApplicationVersion)({
|
|
87
|
+
embeddedUrlFormat: 'http://test.local/:input',
|
|
88
|
+
presentationProperties: [{ name: 'input', type: 'string' }],
|
|
89
|
+
}),
|
|
90
|
+
renderer: testRenderer,
|
|
91
|
+
});
|
|
92
|
+
return [4 /*yield*/, window.load()];
|
|
93
|
+
case 1:
|
|
94
|
+
_a.sent();
|
|
95
|
+
window.setPresentation((0, testUtils_1.createPresentation)({ applicationVariables: { input: 'updated' } }), (0, testUtils_1.createPlaylistWindowManagerState)(), (0, testUtils_1.createRuleEngineState)());
|
|
96
|
+
return [4 /*yield*/, window.reload()];
|
|
97
|
+
case 2:
|
|
98
|
+
_a.sent();
|
|
99
|
+
expect(testRenderer.loadWindow).toHaveBeenCalledTimes(2);
|
|
100
|
+
expect(testRenderer.loadWindow).toHaveBeenCalledWith('test-reload-url', 'http://test.local/updated#__raydiantWindowId=test-reload-url');
|
|
101
|
+
return [2 /*return*/];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}); });
|
|
105
|
+
test('reloads by sending message if has preview subscription', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
+
var testRenderer, window;
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
switch (_a.label) {
|
|
109
|
+
case 0:
|
|
110
|
+
testRenderer = (0, testUtils_1.createRenderer)();
|
|
111
|
+
window = (0, testUtils_1.createPresentationWindow)({
|
|
112
|
+
windowId: 'test-reload-message',
|
|
113
|
+
presentation: (0, testUtils_1.createPresentation)({
|
|
114
|
+
applicationVariables: { input: 'test' },
|
|
115
|
+
}),
|
|
116
|
+
applicationVersion: (0, testUtils_1.createApplicationVersion)({
|
|
117
|
+
embeddedUrlFormat: 'http://test.local/:input',
|
|
118
|
+
presentationProperties: [{ name: 'input', type: 'string' }],
|
|
119
|
+
}),
|
|
120
|
+
renderer: testRenderer,
|
|
121
|
+
});
|
|
122
|
+
return [4 /*yield*/, window.load()];
|
|
123
|
+
case 1:
|
|
124
|
+
_a.sent();
|
|
125
|
+
// Subscribe to receive input updates via message.
|
|
126
|
+
testRenderer.runReceiveMessageCallback('preview-subscribe', 'inputs');
|
|
127
|
+
window.setPresentation((0, testUtils_1.createPresentation)({ applicationVariables: { input: 'updated' } }), (0, testUtils_1.createPlaylistWindowManagerState)(), (0, testUtils_1.createRuleEngineState)());
|
|
128
|
+
return [4 /*yield*/, window.reload()];
|
|
129
|
+
case 2:
|
|
130
|
+
_a.sent();
|
|
131
|
+
// loadWindow should only be called once for the initial load.
|
|
132
|
+
expect(testRenderer.loadWindow).toHaveBeenCalledTimes(1);
|
|
133
|
+
expect(testRenderer.sendMessageObject).toHaveBeenCalledWith('test-reload-message', 'preview-inputs', { input: 'updated' });
|
|
134
|
+
// sendMessageObject should not be called again for the same inputs.
|
|
135
|
+
return [4 /*yield*/, window.reload()];
|
|
136
|
+
case 3:
|
|
137
|
+
// sendMessageObject should not be called again for the same inputs.
|
|
138
|
+
_a.sent();
|
|
139
|
+
expect(testRenderer.sendMessageObject).toHaveBeenCalledTimes(1);
|
|
140
|
+
// Unsubscribe to receive input updates via message.
|
|
141
|
+
testRenderer.runReceiveMessageCallback('preview-unsubscribe', 'inputs');
|
|
142
|
+
return [4 /*yield*/, window.reload()];
|
|
143
|
+
case 4:
|
|
144
|
+
_a.sent();
|
|
145
|
+
// loadWindow should be called again since the preview subscription was removed.
|
|
146
|
+
expect(testRenderer.loadWindow).toHaveBeenCalledTimes(2);
|
|
147
|
+
return [2 /*return*/];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}); });
|
|
151
|
+
test('preview subscription strips internal file properties from inputs', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
152
|
+
var testRenderer, window;
|
|
153
|
+
return __generator(this, function (_a) {
|
|
154
|
+
switch (_a.label) {
|
|
155
|
+
case 0:
|
|
156
|
+
testRenderer = (0, testUtils_1.createRenderer)();
|
|
157
|
+
window = (0, testUtils_1.createPresentationWindow)({
|
|
158
|
+
windowId: 'test-reload-message',
|
|
159
|
+
presentation: (0, testUtils_1.createPresentation)({
|
|
160
|
+
applicationVariables: {
|
|
161
|
+
input: {
|
|
162
|
+
url: 'http://test.local/image.png',
|
|
163
|
+
'content-length': 123,
|
|
164
|
+
'content-type': 'image/png',
|
|
165
|
+
file_upload_id: 'test',
|
|
166
|
+
filename: 'image.png',
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
}),
|
|
170
|
+
applicationVersion: (0, testUtils_1.createApplicationVersion)({
|
|
171
|
+
embeddedUrlFormat: 'http://test.local/:input',
|
|
172
|
+
presentationProperties: [{ name: 'input', type: 'file' }],
|
|
173
|
+
}),
|
|
174
|
+
renderer: testRenderer,
|
|
175
|
+
});
|
|
176
|
+
return [4 /*yield*/, window.load()];
|
|
177
|
+
case 1:
|
|
178
|
+
_a.sent();
|
|
179
|
+
// Subscribe to receive input updates via message.
|
|
180
|
+
testRenderer.runReceiveMessageCallback('preview-subscribe', 'inputs');
|
|
181
|
+
return [4 /*yield*/, window.reload()];
|
|
182
|
+
case 2:
|
|
183
|
+
_a.sent();
|
|
184
|
+
expect(testRenderer.sendMessageObject).toHaveBeenCalledWith('test-reload-message', 'preview-inputs', { input: { url: 'http://test.local/image.png' } });
|
|
185
|
+
// Updating internal file input values should not cause a reload.
|
|
186
|
+
window.setPresentation((0, testUtils_1.createPresentation)({
|
|
187
|
+
applicationVariables: {
|
|
188
|
+
input: {
|
|
189
|
+
url: 'http://test.local/image.png',
|
|
190
|
+
file_upload_id: 'test2',
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
}), (0, testUtils_1.createPlaylistWindowManagerState)(), (0, testUtils_1.createRuleEngineState)());
|
|
194
|
+
return [4 /*yield*/, window.reload()];
|
|
195
|
+
case 3:
|
|
196
|
+
_a.sent();
|
|
197
|
+
// sendMessageObject should not be called again for the same inputs.
|
|
198
|
+
expect(testRenderer.sendMessageObject).toHaveBeenCalledTimes(1);
|
|
199
|
+
return [2 /*return*/];
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}); });
|
|
203
|
+
test('sends create object url message', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
204
|
+
var testRenderer, window, createObjectUrlPromise, requestId, result;
|
|
205
|
+
return __generator(this, function (_a) {
|
|
206
|
+
switch (_a.label) {
|
|
207
|
+
case 0:
|
|
208
|
+
testRenderer = (0, testUtils_1.createRenderer)();
|
|
209
|
+
window = (0, testUtils_1.createPresentationWindow)({
|
|
210
|
+
windowId: 'test-object-url',
|
|
211
|
+
presentation: (0, testUtils_1.createPresentation)(),
|
|
212
|
+
applicationVersion: (0, testUtils_1.createApplicationVersion)({
|
|
213
|
+
embeddedUrlFormat: 'http://test.local/:input',
|
|
214
|
+
}),
|
|
215
|
+
renderer: testRenderer,
|
|
216
|
+
});
|
|
217
|
+
return [4 /*yield*/, window.load()];
|
|
218
|
+
case 1:
|
|
219
|
+
_a.sent();
|
|
220
|
+
createObjectUrlPromise = window.createObjectURL(new Blob(['test']));
|
|
221
|
+
// Wait for the createObjectURL call to be sent to the renderer.
|
|
222
|
+
return [4 /*yield*/, delay(100)];
|
|
223
|
+
case 2:
|
|
224
|
+
// Wait for the createObjectURL call to be sent to the renderer.
|
|
225
|
+
_a.sent();
|
|
226
|
+
expect(testRenderer.sendMessageObject).toHaveBeenCalledWith('test-object-url', 'create-object-url', { requestId: expect.any(String), buffer: expect.any(ArrayBuffer) });
|
|
227
|
+
requestId = testRenderer.sendMessageObject.mock.calls[0][2].requestId;
|
|
228
|
+
testRenderer.runReceiveMessageCallback('create-object-url-result', {
|
|
229
|
+
requestId: requestId,
|
|
230
|
+
url: 'http://test.local/blob',
|
|
231
|
+
});
|
|
232
|
+
return [4 /*yield*/, createObjectUrlPromise];
|
|
233
|
+
case 3:
|
|
234
|
+
result = _a.sent();
|
|
235
|
+
expect(result).toBe('http://test.local/blob');
|
|
236
|
+
return [2 /*return*/];
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}); });
|
|
240
|
+
});
|
|
241
|
+
// TODO: Backfill tests for all legacy and embedded apps.
|
package/build/WindowLoadError.js
CHANGED
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
package/build/embeddedApps.js
CHANGED
|
@@ -41,6 +41,13 @@ function createEmbeddedApp(presentation, applicationVersion, metadata) {
|
|
|
41
41
|
if (Array.isArray(value)) {
|
|
42
42
|
value = JSON.stringify(value);
|
|
43
43
|
}
|
|
44
|
+
// Presentation property specific handling.
|
|
45
|
+
if (presentationProperty) {
|
|
46
|
+
// If the presentation property is a file, use the url property as the value.
|
|
47
|
+
if (presentationProperty.type === 'file' && value && value.url) {
|
|
48
|
+
value = value.url;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
44
51
|
}
|
|
45
52
|
if (shouldEncodeValue) {
|
|
46
53
|
value = encodeURIComponent(value);
|
|
@@ -20,9 +20,9 @@ var createPresentation = function (overrides) {
|
|
|
20
20
|
return (__assign({ id: 'id', name: 'name', applicationDeploymentId: 'applicationDeploymentId', themeId: null, applicationVariables: {}, duration: 0, r: {
|
|
21
21
|
resource: {
|
|
22
22
|
updatedAt: '',
|
|
23
|
-
createdAt: ''
|
|
23
|
+
createdAt: '',
|
|
24
24
|
},
|
|
25
|
-
presentationsPlaylists: []
|
|
25
|
+
presentationsPlaylists: [],
|
|
26
26
|
} }, overrides));
|
|
27
27
|
};
|
|
28
28
|
var createApplicationVersion = function (overrides) {
|
|
@@ -34,80 +34,90 @@ var createMetadata = function (overrides) {
|
|
|
34
34
|
return (__assign({ renderMode: 'live' }, overrides));
|
|
35
35
|
};
|
|
36
36
|
test('Replaces variable in query parameteers', function () {
|
|
37
|
-
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { foo: 'bar' } }), createApplicationVersion({
|
|
38
|
-
embeddedUrlFormat: 'https://example.com?foo=:foo'
|
|
37
|
+
expect((0, embeddedApps_1.default)(createPresentation({ applicationVariables: { foo: 'bar' } }), createApplicationVersion({
|
|
38
|
+
embeddedUrlFormat: 'https://example.com?foo=:foo',
|
|
39
39
|
}), createMetadata())).toBe('https://example.com?foo=bar');
|
|
40
40
|
});
|
|
41
41
|
test('Replaces variable in path', function () {
|
|
42
|
-
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { foo: 'bar' } }), createApplicationVersion({
|
|
43
|
-
embeddedUrlFormat: 'https://example.com/:foo'
|
|
42
|
+
expect((0, embeddedApps_1.default)(createPresentation({ applicationVariables: { foo: 'bar' } }), createApplicationVersion({
|
|
43
|
+
embeddedUrlFormat: 'https://example.com/:foo',
|
|
44
44
|
}), createMetadata())).toBe('https://example.com/bar');
|
|
45
45
|
});
|
|
46
46
|
test('Replaces undefined variable with empty string', function () {
|
|
47
|
-
expect(embeddedApps_1.default(createPresentation({ applicationVariables: {} }), createApplicationVersion({
|
|
48
|
-
embeddedUrlFormat: 'https://example.com/:foo'
|
|
47
|
+
expect((0, embeddedApps_1.default)(createPresentation({ applicationVariables: {} }), createApplicationVersion({
|
|
48
|
+
embeddedUrlFormat: 'https://example.com/:foo',
|
|
49
49
|
}), createMetadata())).toBe('https://example.com/');
|
|
50
50
|
});
|
|
51
51
|
test('Replaces variable with underscore', function () {
|
|
52
|
-
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { foo_1: 'bar' } }), createApplicationVersion({
|
|
53
|
-
embeddedUrlFormat: 'https://example.com/:foo_1'
|
|
52
|
+
expect((0, embeddedApps_1.default)(createPresentation({ applicationVariables: { foo_1: 'bar' } }), createApplicationVersion({
|
|
53
|
+
embeddedUrlFormat: 'https://example.com/:foo_1',
|
|
54
54
|
}), createMetadata())).toBe('https://example.com/bar');
|
|
55
55
|
});
|
|
56
56
|
test('Replaces variable with hyphen', function () {
|
|
57
|
-
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { 'foo-1': 'bar' } }), createApplicationVersion({
|
|
58
|
-
embeddedUrlFormat: 'https://example.com/:foo-1'
|
|
57
|
+
expect((0, embeddedApps_1.default)(createPresentation({ applicationVariables: { 'foo-1': 'bar' } }), createApplicationVersion({
|
|
58
|
+
embeddedUrlFormat: 'https://example.com/:foo-1',
|
|
59
59
|
}), createMetadata())).toBe('https://example.com/bar');
|
|
60
60
|
});
|
|
61
61
|
test('Does not replace variable that is a number', function () {
|
|
62
|
-
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { foo: 'bar' } }), createApplicationVersion({
|
|
63
|
-
embeddedUrlFormat: 'http://localhost:8080?foo=:foo'
|
|
62
|
+
expect((0, embeddedApps_1.default)(createPresentation({ applicationVariables: { foo: 'bar' } }), createApplicationVersion({
|
|
63
|
+
embeddedUrlFormat: 'http://localhost:8080?foo=:foo',
|
|
64
64
|
}), createMetadata())).toBe('http://localhost:8080?foo=bar');
|
|
65
65
|
});
|
|
66
66
|
test('Encodes a variables containing special characters', function () {
|
|
67
67
|
var fooValue = 'Lorem Ipsum. !@#$%^&*()-. More Text';
|
|
68
68
|
var fooValueEncoded = 'Lorem%20Ipsum.%20!%40%23%24%25%5E%26*()-.%20More%20Text';
|
|
69
|
-
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { foo: fooValue } }), createApplicationVersion({
|
|
70
|
-
embeddedUrlFormat: "http://localhost:8080?foo=:foo"
|
|
71
|
-
}), createMetadata())).toBe("http://localhost:8080?foo="
|
|
69
|
+
expect((0, embeddedApps_1.default)(createPresentation({ applicationVariables: { foo: fooValue } }), createApplicationVersion({
|
|
70
|
+
embeddedUrlFormat: "http://localhost:8080?foo=:foo",
|
|
71
|
+
}), createMetadata())).toBe("http://localhost:8080?foo=".concat(fooValueEncoded));
|
|
72
72
|
});
|
|
73
73
|
test('Does not encode value if presentation property disables encoding', function () {
|
|
74
|
-
expect(embeddedApps_1.default(createPresentation({
|
|
75
|
-
applicationVariables: { url: 'https://raydiant.com' }
|
|
74
|
+
expect((0, embeddedApps_1.default)(createPresentation({
|
|
75
|
+
applicationVariables: { url: 'https://raydiant.com' },
|
|
76
76
|
}), createApplicationVersion({
|
|
77
77
|
embeddedUrlFormat: ":url",
|
|
78
|
-
presentationProperties: [
|
|
78
|
+
presentationProperties: [
|
|
79
|
+
{ type: 'string', name: 'url', encode: false },
|
|
80
|
+
],
|
|
79
81
|
}), createMetadata())).toBe("https://raydiant.com");
|
|
80
82
|
});
|
|
81
83
|
test('Encodes a variables containing an array', function () {
|
|
82
84
|
var fooValue = ['option-a', 'option-b', 'option-c'];
|
|
83
85
|
var fooValueEncoded = '%5B%22option-a%22%2C%22option-b%22%2C%22option-c%22%5D';
|
|
84
|
-
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { foo: fooValue } }), createApplicationVersion({
|
|
85
|
-
embeddedUrlFormat: "http://localhost:8080?foo=:foo"
|
|
86
|
-
}), createMetadata())).toBe("http://localhost:8080?foo="
|
|
86
|
+
expect((0, embeddedApps_1.default)(createPresentation({ applicationVariables: { foo: fooValue } }), createApplicationVersion({
|
|
87
|
+
embeddedUrlFormat: "http://localhost:8080?foo=:foo",
|
|
88
|
+
}), createMetadata())).toBe("http://localhost:8080?foo=".concat(fooValueEncoded));
|
|
87
89
|
});
|
|
88
90
|
test('Replaces $renderMode with metadata', function () {
|
|
89
91
|
var presentation = createPresentation();
|
|
90
92
|
var applicationVersion = createApplicationVersion({
|
|
91
|
-
embeddedUrlFormat: 'https://example.com?renderMode=:$renderMode'
|
|
93
|
+
embeddedUrlFormat: 'https://example.com?renderMode=:$renderMode',
|
|
92
94
|
});
|
|
93
|
-
expect(embeddedApps_1.default(presentation, applicationVersion, createMetadata({ renderMode: 'preview' }))).toBe('https://example.com?renderMode=preview');
|
|
94
|
-
expect(embeddedApps_1.default(presentation, applicationVersion, createMetadata({ renderMode: 'live' }))).toBe('https://example.com?renderMode=live');
|
|
95
|
+
expect((0, embeddedApps_1.default)(presentation, applicationVersion, createMetadata({ renderMode: 'preview' }))).toBe('https://example.com?renderMode=preview');
|
|
96
|
+
expect((0, embeddedApps_1.default)(presentation, applicationVersion, createMetadata({ renderMode: 'live' }))).toBe('https://example.com?renderMode=live');
|
|
95
97
|
});
|
|
96
98
|
test('Replaces undefined metadata with empty string', function () {
|
|
97
99
|
var presentation = createPresentation();
|
|
98
100
|
var applicationVersion = createApplicationVersion({
|
|
99
|
-
embeddedUrlFormat: 'https://example.com?invalid=:$invalid'
|
|
101
|
+
embeddedUrlFormat: 'https://example.com?invalid=:$invalid',
|
|
100
102
|
});
|
|
101
|
-
expect(embeddedApps_1.default(presentation, applicationVersion, createMetadata())).toBe('https://example.com?invalid=');
|
|
103
|
+
expect((0, embeddedApps_1.default)(presentation, applicationVersion, createMetadata())).toBe('https://example.com?invalid=');
|
|
102
104
|
});
|
|
103
105
|
test('Replace protocol, ip and port', function () {
|
|
104
|
-
expect(embeddedApps_1.default(createPresentation({
|
|
106
|
+
expect((0, embeddedApps_1.default)(createPresentation({
|
|
105
107
|
applicationVariables: {
|
|
106
108
|
protocol: 'http',
|
|
107
109
|
ip: '192.168.1.0',
|
|
108
|
-
port: 3000
|
|
109
|
-
}
|
|
110
|
+
port: 3000,
|
|
111
|
+
},
|
|
110
112
|
}), createApplicationVersion({
|
|
111
|
-
embeddedUrlFormat: ":protocol://:ip::port"
|
|
113
|
+
embeddedUrlFormat: ":protocol://:ip::port",
|
|
112
114
|
}), createMetadata())).toBe("http://192.168.1.0:3000");
|
|
113
115
|
});
|
|
116
|
+
test('File input uses url as value', function () {
|
|
117
|
+
expect((0, embeddedApps_1.default)(createPresentation({
|
|
118
|
+
applicationVariables: { file: { url: 'https://image.png' } },
|
|
119
|
+
}), createApplicationVersion({
|
|
120
|
+
embeddedUrlFormat: "https://example.come?image=:file",
|
|
121
|
+
presentationProperties: [{ type: 'file', name: 'file' }],
|
|
122
|
+
}), createMetadata())).toBe("https://example.come?image=".concat(encodeURIComponent('https://image.png')));
|
|
123
|
+
});
|
package/build/index.js
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
5
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
18
|
};
|
|
8
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.PresentationWindow = exports.PlaylistWindowManagerState = exports.PlaylistWindowManager = void 0;
|
|
9
21
|
var PlaylistWindowManager_1 = __importDefault(require("./PlaylistWindowManager"));
|
|
10
22
|
exports.PlaylistWindowManager = PlaylistWindowManager_1.default;
|
|
11
|
-
|
|
23
|
+
__exportStar(require("./PlaylistWindowManager"), exports);
|
|
12
24
|
var PlaylistWindowManagerState_1 = __importDefault(require("./PlaylistWindowManagerState"));
|
|
13
25
|
exports.PlaylistWindowManagerState = PlaylistWindowManagerState_1.default;
|
|
14
|
-
|
|
26
|
+
__exportStar(require("./PlaylistWindowManagerState"), exports);
|
|
15
27
|
var PresentationWindow_1 = __importDefault(require("./PresentationWindow"));
|
|
16
28
|
exports.PresentationWindow = PresentationWindow_1.default;
|
|
17
|
-
|
|
29
|
+
__exportStar(require("./PresentationWindow"), exports);
|
|
30
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import * as re from '@raydiant/playlist-rule-engine';
|
|
3
|
+
import PresentationWindow, { PresentationWindowOptions } from './PresentationWindow';
|
|
4
|
+
import PlaylistWindowManagerState, { PlaylistWindowManagerStateOptions } from './PlaylistWindowManagerState';
|
|
5
|
+
import { Presentation, ApplicationVersion, Logger, CreateWindowOptions } from './types';
|
|
6
|
+
export declare function createPresentationWindow(overrides?: Partial<PresentationWindowOptions>): PresentationWindow;
|
|
7
|
+
export declare function createPresentation(overrides?: Partial<Presentation>): Presentation;
|
|
8
|
+
export declare function createPresentationRelationships(overrides?: Partial<Presentation['r']>): Presentation['r'];
|
|
9
|
+
export declare function createApplicationVersion(overrides?: Partial<ApplicationVersion>): ApplicationVersion;
|
|
10
|
+
export declare function createPlaylistWindowManagerState(overrides?: Partial<PlaylistWindowManagerStateOptions>): PlaylistWindowManagerState;
|
|
11
|
+
export declare function createRuleEngineState(playlists?: {
|
|
12
|
+
[index: string]: re.Playlist;
|
|
13
|
+
}, presentations?: {
|
|
14
|
+
[index: string]: re.Presentation;
|
|
15
|
+
}, rulesDataStore?: re.RulesDataStore, isMultitimezoneEnabled?: boolean): re.State;
|
|
16
|
+
export declare function createLogger(overrides?: Partial<Logger>): {
|
|
17
|
+
debug: (message: any, context?: {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
} | undefined) => void;
|
|
20
|
+
info: (message: any, context?: {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
} | undefined) => void;
|
|
23
|
+
warn: (message: any, context?: {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
} | undefined) => void;
|
|
26
|
+
error: (message: any, context?: {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
} | undefined) => void;
|
|
29
|
+
};
|
|
30
|
+
export declare function createRenderer(): {
|
|
31
|
+
createWindow: jest.Mock<void, [opts: CreateWindowOptions]>;
|
|
32
|
+
loadWindow: jest.Mock<any, any>;
|
|
33
|
+
updateWindowBounds: jest.Mock<any, any>;
|
|
34
|
+
showWindow: jest.Mock<any, any>;
|
|
35
|
+
hideWindow: jest.Mock<any, any>;
|
|
36
|
+
removeWindow: jest.Mock<any, any>;
|
|
37
|
+
sendMessageString: jest.Mock<any, any>;
|
|
38
|
+
sendMessageObject: jest.Mock<any, any>;
|
|
39
|
+
muteWindow: jest.Mock<any, any>;
|
|
40
|
+
unMuteWindow: jest.Mock<any, any>;
|
|
41
|
+
runReceiveMessageCallback(type: string, payload: any): void;
|
|
42
|
+
runErrorCallback(error: Error): void;
|
|
43
|
+
};
|