@raydiant/playlist-window-manager 0.14.23 → 0.14.26

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.
@@ -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.5/index.html';
66
+ var defaultAppRendererUrl = 'https://apps.raydiant.com/1.4.7/index.html';
67
67
  var isValidNumber = function (value) {
68
68
  return typeof value === 'number' && !isNaN(value);
69
69
  };
@@ -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 variable = m[1];
18
- var _a = variable.split(':'), variableName = _a[1];
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[m[2]];
28
+ var value = presentation.applicationVariables[queryParamName];
28
29
  if (value === undefined)
29
30
  value = '';
30
- if (shouldEncodeValue)
31
+ if (Array.isArray(value)) {
32
+ value = JSON.stringify(value);
33
+ }
34
+ if (shouldEncodeValue) {
31
35
  value = encodeURIComponent(value);
32
- url = url.replace(variable, value);
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.23",
3
+ "version": "0.14.26",
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": "^4.6.1",
16
+ "raydiant-kit": "4.7.3",
17
17
  "uuid": "^8.3.0",
18
18
  "eventemitter3": "^4.0.7"
19
19
  },
@@ -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.5/index.html';
52
+ const defaultAppRendererUrl = 'https://apps.raydiant.com/1.4.7/index.html';
53
53
 
54
54
  const isValidNumber = (value: any) =>
55
55
  typeof value === 'number' && !isNaN(value);
@@ -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
+ });
@@ -19,8 +19,10 @@ export default function createEmbeddedApp(
19
19
  // replace
20
20
  let url = applicationVersion.embeddedUrlFormat || '';
21
21
  matches.forEach(m => {
22
- const variable = m[1];
23
- const [, variableName] = variable.split(':');
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[m[2]];
39
+ let value = presentation.applicationVariables[queryParamName];
38
40
  if (value === undefined) value = '';
39
- if (shouldEncodeValue) value = encodeURIComponent(value);
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(variable, value);
48
+ url = url.replace(queryParamVariableName, value);
42
49
  });
43
50
 
44
51
  return url;