@raydiant/playlist-window-manager 0.14.22 → 0.14.25
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/README.md +7 -1
- package/build/IFrameRenderer.js +6 -1
- package/build/PresentationWindow.js +1 -1
- package/build/embeddedApps.js +10 -5
- package/build/embeddedApps.test.js +7 -0
- package/package.json +2 -2
- package/src/IFrameRenderer.ts +7 -1
- package/src/PresentationWindow.ts +1 -1
- package/src/embeddedApps.test.ts +15 -0
- package/src/embeddedApps.ts +12 -5
package/README.md
CHANGED
package/build/IFrameRenderer.js
CHANGED
|
@@ -52,9 +52,14 @@ var IFrameRenderer = /** @class */ (function () {
|
|
|
52
52
|
console.warn("Invalid message received from iframe '" + JSON.stringify(event.data) + "', ignoring message");
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
+
if (!windowId) {
|
|
56
|
+
// ignore messages that don't have windowId
|
|
57
|
+
// such message are comming from 3rd party IFrames like google
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
55
60
|
var window = _this.getWindow(windowId);
|
|
56
61
|
if (!window) {
|
|
57
|
-
throw new Error("Failed add receive message callback to window,
|
|
62
|
+
throw new Error("Failed add receive message callback to window, window with window id: '" + windowId + "' was not found");
|
|
58
63
|
}
|
|
59
64
|
if (window.receiveMessageCallback) {
|
|
60
65
|
window.receiveMessageCallback(type, payload);
|
|
@@ -63,7 +63,7 @@ var PlaylistWindowManager_1 = __importDefault(require("./PlaylistWindowManager")
|
|
|
63
63
|
var WindowTimeoutError_1 = __importDefault(require("./WindowTimeoutError"));
|
|
64
64
|
var WindowLoadError_1 = __importDefault(require("./WindowLoadError"));
|
|
65
65
|
// TODO: Automatically inject latest version when building in CI.
|
|
66
|
-
var defaultAppRendererUrl = 'https://apps.raydiant.com/1.4.
|
|
66
|
+
var defaultAppRendererUrl = 'https://apps.raydiant.com/1.4.6/index.html';
|
|
67
67
|
var isValidNumber = function (value) {
|
|
68
68
|
return typeof value === 'number' && !isNaN(value);
|
|
69
69
|
};
|
package/build/embeddedApps.js
CHANGED
|
@@ -14,8 +14,9 @@ function createEmbeddedApp(presentation, applicationVersion) {
|
|
|
14
14
|
// replace
|
|
15
15
|
var url = applicationVersion.embeddedUrlFormat || '';
|
|
16
16
|
matches.forEach(function (m) {
|
|
17
|
-
var
|
|
18
|
-
var
|
|
17
|
+
var queryParamVariableName = m[1]; // Where the value of your input will be injected. E.g. ":location"
|
|
18
|
+
var queryParamName = m[2]; // The query param name. E.g. "location"
|
|
19
|
+
var _a = queryParamVariableName.split(':'), variableName = _a[1];
|
|
19
20
|
// Don't replace variables that are numbers to allow setting
|
|
20
21
|
// port numbers in the embedded app url.
|
|
21
22
|
if (!isNaN(Number(variableName)))
|
|
@@ -24,12 +25,16 @@ function createEmbeddedApp(presentation, applicationVersion) {
|
|
|
24
25
|
// If the presentation property is not found (this shouldn't happen), default to encoding the value.
|
|
25
26
|
// Otherwise, only skip encoding if the presentation property's encode property is false.
|
|
26
27
|
var shouldEncodeValue = !presentationProperty || presentationProperty.encode !== false;
|
|
27
|
-
var value = presentation.applicationVariables[
|
|
28
|
+
var value = presentation.applicationVariables[queryParamName];
|
|
28
29
|
if (value === undefined)
|
|
29
30
|
value = '';
|
|
30
|
-
if (
|
|
31
|
+
if (Array.isArray(value)) {
|
|
32
|
+
value = JSON.stringify(value);
|
|
33
|
+
}
|
|
34
|
+
if (shouldEncodeValue) {
|
|
31
35
|
value = encodeURIComponent(value);
|
|
32
|
-
|
|
36
|
+
}
|
|
37
|
+
url = url.replace(queryParamVariableName, value);
|
|
33
38
|
});
|
|
34
39
|
return url;
|
|
35
40
|
}
|
|
@@ -63,3 +63,10 @@ test('Does not encode value if presentation property disables encoding', functio
|
|
|
63
63
|
presentationProperties: [{ name: 'url', encode: false }]
|
|
64
64
|
}))).toBe("https://raydiant.com");
|
|
65
65
|
});
|
|
66
|
+
test('Encodes a variables containing an array', function () {
|
|
67
|
+
var fooValue = ['option-a', 'option-b', 'option-c'];
|
|
68
|
+
var fooValueEncoded = '%5B%22option-a%22%2C%22option-b%22%2C%22option-c%22%5D';
|
|
69
|
+
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { foo: fooValue } }), createApplicationVersion({
|
|
70
|
+
embeddedUrlFormat: "http://localhost:8080?foo=:foo"
|
|
71
|
+
}))).toBe("http://localhost:8080?foo=" + fooValueEncoded);
|
|
72
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raydiant/playlist-window-manager",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.25",
|
|
4
4
|
"description": "Window manager for playlist playback.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"fast-deep-equal": "^3.1.3",
|
|
15
15
|
"@raydiant/playlist-rule-engine": "3.1.15",
|
|
16
|
-
"raydiant-kit": "
|
|
16
|
+
"raydiant-kit": "4.7.1",
|
|
17
17
|
"uuid": "^8.3.0",
|
|
18
18
|
"eventemitter3": "^4.0.7"
|
|
19
19
|
},
|
package/src/IFrameRenderer.ts
CHANGED
|
@@ -202,10 +202,16 @@ export default class IFrameRenderer implements PresentationWindowRenderer {
|
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
if (!windowId) {
|
|
206
|
+
// ignore messages that don't have windowId
|
|
207
|
+
// such message are comming from 3rd party IFrames like google
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
205
211
|
const window = this.getWindow(windowId);
|
|
206
212
|
if (!window) {
|
|
207
213
|
throw new Error(
|
|
208
|
-
`Failed add receive message callback to window,
|
|
214
|
+
`Failed add receive message callback to window, window with window id: '${windowId}' was not found`
|
|
209
215
|
);
|
|
210
216
|
}
|
|
211
217
|
|
|
@@ -49,7 +49,7 @@ export interface PresentationWindowOptions {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// TODO: Automatically inject latest version when building in CI.
|
|
52
|
-
const defaultAppRendererUrl = 'https://apps.raydiant.com/1.4.
|
|
52
|
+
const defaultAppRendererUrl = 'https://apps.raydiant.com/1.4.6/index.html';
|
|
53
53
|
|
|
54
54
|
const isValidNumber = (value: any) =>
|
|
55
55
|
typeof value === 'number' && !isNaN(value);
|
package/src/embeddedApps.test.ts
CHANGED
|
@@ -116,3 +116,18 @@ test('Does not encode value if presentation property disables encoding', () => {
|
|
|
116
116
|
)
|
|
117
117
|
).toBe(`https://raydiant.com`);
|
|
118
118
|
});
|
|
119
|
+
|
|
120
|
+
test('Encodes a variables containing an array', () => {
|
|
121
|
+
const fooValue = ['option-a', 'option-b', 'option-c'];
|
|
122
|
+
const fooValueEncoded =
|
|
123
|
+
'%5B%22option-a%22%2C%22option-b%22%2C%22option-c%22%5D';
|
|
124
|
+
|
|
125
|
+
expect(
|
|
126
|
+
createEmbeddedApp(
|
|
127
|
+
createPresentation({ applicationVariables: { foo: fooValue } }),
|
|
128
|
+
createApplicationVersion({
|
|
129
|
+
embeddedUrlFormat: `http://localhost:8080?foo=:foo`
|
|
130
|
+
})
|
|
131
|
+
)
|
|
132
|
+
).toBe(`http://localhost:8080?foo=${fooValueEncoded}`);
|
|
133
|
+
});
|
package/src/embeddedApps.ts
CHANGED
|
@@ -19,8 +19,10 @@ export default function createEmbeddedApp(
|
|
|
19
19
|
// replace
|
|
20
20
|
let url = applicationVersion.embeddedUrlFormat || '';
|
|
21
21
|
matches.forEach(m => {
|
|
22
|
-
const
|
|
23
|
-
const [
|
|
22
|
+
const queryParamVariableName = m[1]; // Where the value of your input will be injected. E.g. ":location"
|
|
23
|
+
const queryParamName = m[2]; // The query param name. E.g. "location"
|
|
24
|
+
|
|
25
|
+
const [, variableName] = queryParamVariableName.split(':');
|
|
24
26
|
// Don't replace variables that are numbers to allow setting
|
|
25
27
|
// port numbers in the embedded app url.
|
|
26
28
|
if (!isNaN(Number(variableName))) return;
|
|
@@ -34,11 +36,16 @@ export default function createEmbeddedApp(
|
|
|
34
36
|
const shouldEncodeValue =
|
|
35
37
|
!presentationProperty || presentationProperty.encode !== false;
|
|
36
38
|
|
|
37
|
-
let value = presentation.applicationVariables[
|
|
39
|
+
let value = presentation.applicationVariables[queryParamName];
|
|
38
40
|
if (value === undefined) value = '';
|
|
39
|
-
if (
|
|
41
|
+
if (Array.isArray(value)) {
|
|
42
|
+
value = JSON.stringify(value);
|
|
43
|
+
}
|
|
44
|
+
if (shouldEncodeValue) {
|
|
45
|
+
value = encodeURIComponent(value);
|
|
46
|
+
}
|
|
40
47
|
|
|
41
|
-
url = url.replace(
|
|
48
|
+
url = url.replace(queryParamVariableName, value);
|
|
42
49
|
});
|
|
43
50
|
|
|
44
51
|
return url;
|