@raydiant/playlist-window-manager 0.26.1 → 0.27.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/PresentationWindow.js +4 -1
- package/build/embeddedApps.js +15 -0
- package/build/embeddedApps.test.js +21 -0
- package/build/types.d.ts +2 -0
- package/package.json +1 -1
- package/src/PresentationWindow.ts +5 -1
- package/src/embeddedApps.test.ts +37 -0
- package/src/embeddedApps.ts +14 -0
- package/src/types.ts +2 -0
- package/tasks/npm-publish.sh +1 -1
|
@@ -1144,10 +1144,13 @@ var PresentationWindow = /** @class */ (function () {
|
|
|
1144
1144
|
}
|
|
1145
1145
|
};
|
|
1146
1146
|
PresentationWindow.prototype.getEmbeddedAppUrl = function () {
|
|
1147
|
-
var _a = this.options, windowId = _a.windowId, appRendererOfflineSupport = _a.appRendererOfflineSupport;
|
|
1147
|
+
var _a = this.options, windowId = _a.windowId, appRendererOfflineSupport = _a.appRendererOfflineSupport, device = _a.device;
|
|
1148
1148
|
var metadata = {
|
|
1149
1149
|
renderMode: this.options.isPreview ? 'preview' : 'live',
|
|
1150
1150
|
};
|
|
1151
|
+
if (device) {
|
|
1152
|
+
metadata.deviceId = device.id;
|
|
1153
|
+
}
|
|
1151
1154
|
var url = (0, embeddedApps_1.default)(this.presentation, this.options.applicationVersion, metadata);
|
|
1152
1155
|
return this.getFullAppRendererUrl({
|
|
1153
1156
|
appRendererUrl: url,
|
package/build/embeddedApps.js
CHANGED
|
@@ -13,6 +13,7 @@ function createEmbeddedApp(presentation, applicationVersion, metadata) {
|
|
|
13
13
|
} while (match !== null);
|
|
14
14
|
// replace
|
|
15
15
|
var url = applicationVersion.embeddedUrlFormat || '';
|
|
16
|
+
var queryIndex = url.indexOf('?');
|
|
16
17
|
matches.forEach(function (m) {
|
|
17
18
|
var queryParamVariableName = m[1]; // Where the value of your input will be injected. E.g. ":location"
|
|
18
19
|
var queryParamName = m[2]; // The query param name. E.g. "location"
|
|
@@ -20,6 +21,8 @@ function createEmbeddedApp(presentation, applicationVersion, metadata) {
|
|
|
20
21
|
var shouldEncodeValue = true;
|
|
21
22
|
var value = '';
|
|
22
23
|
if (variableName.charAt(0) === '$') {
|
|
24
|
+
var variableIndex = url.indexOf(queryParamVariableName);
|
|
25
|
+
var isPartOfQuery = queryIndex != -1 && variableIndex > queryIndex;
|
|
23
26
|
var metadataKey = variableName.slice(1);
|
|
24
27
|
if (metadataKey === 'renderMode') {
|
|
25
28
|
value = metadata.renderMode;
|
|
@@ -27,6 +30,18 @@ function createEmbeddedApp(presentation, applicationVersion, metadata) {
|
|
|
27
30
|
else if (metadataKey === 'token') {
|
|
28
31
|
value = presentation.token;
|
|
29
32
|
}
|
|
33
|
+
else if (metadataKey === 'deviceId') {
|
|
34
|
+
if (metadata.deviceId) {
|
|
35
|
+
value = metadata.deviceId;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// If :$deviceId is part of the URL path, avoid creating a broken URL if metadata.deviceId is not defined.
|
|
39
|
+
// This will use the variable name as the value instead of an empty string.
|
|
40
|
+
if (!isPartOfQuery) {
|
|
41
|
+
value = queryParamVariableName;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
30
45
|
}
|
|
31
46
|
else {
|
|
32
47
|
// Don't replace variables that are numbers to allow setting
|
|
@@ -128,3 +128,24 @@ test('Replaces $token with presentation token', function () {
|
|
|
128
128
|
});
|
|
129
129
|
expect((0, embeddedApps_1.default)(presentation, applicationVersion, createMetadata())).toBe('https://example.com?token=abc');
|
|
130
130
|
});
|
|
131
|
+
test('Replaces $deviceId with metadata deviceId when provided', function () {
|
|
132
|
+
var presentation = createPresentation();
|
|
133
|
+
var applicationVersion = createApplicationVersion({
|
|
134
|
+
embeddedUrlFormat: 'https://example.com/:$deviceId/content',
|
|
135
|
+
});
|
|
136
|
+
expect((0, embeddedApps_1.default)(presentation, applicationVersion, createMetadata({ deviceId: 'device-id' }))).toBe('https://example.com/device-id/content');
|
|
137
|
+
});
|
|
138
|
+
test('Do not replace $deviceId when in the URI with metadata not defined', function () {
|
|
139
|
+
var presentation = createPresentation();
|
|
140
|
+
var applicationVersion = createApplicationVersion({
|
|
141
|
+
embeddedUrlFormat: 'https://example.com/:$deviceId/content',
|
|
142
|
+
});
|
|
143
|
+
expect((0, embeddedApps_1.default)(presentation, applicationVersion, createMetadata())).toBe("https://example.com/".concat(encodeURIComponent(':$deviceId'), "/content"));
|
|
144
|
+
});
|
|
145
|
+
test('Replaces $deviceId with empty string when in the query string and metadata not defined', function () {
|
|
146
|
+
var presentation = createPresentation();
|
|
147
|
+
var applicationVersion = createApplicationVersion({
|
|
148
|
+
embeddedUrlFormat: 'https://example.com/content?device=:$deviceId',
|
|
149
|
+
});
|
|
150
|
+
expect((0, embeddedApps_1.default)(presentation, applicationVersion, createMetadata())).toBe("https://example.com/content?device=");
|
|
151
|
+
});
|
package/build/types.d.ts
CHANGED
|
@@ -135,6 +135,7 @@ export interface InputState {
|
|
|
135
135
|
}
|
|
136
136
|
export interface EmbeddedAppMetadata {
|
|
137
137
|
renderMode: 'preview' | 'live';
|
|
138
|
+
deviceId?: string;
|
|
138
139
|
}
|
|
139
140
|
export interface AnalyticsEvent {
|
|
140
141
|
type: string;
|
|
@@ -142,6 +143,7 @@ export interface AnalyticsEvent {
|
|
|
142
143
|
productCategory?: string | null;
|
|
143
144
|
}
|
|
144
145
|
export interface ChargeRequest {
|
|
146
|
+
orderId?: string;
|
|
145
147
|
requestId: string;
|
|
146
148
|
subTotal: number;
|
|
147
149
|
tip: number;
|
package/package.json
CHANGED
|
@@ -953,12 +953,16 @@ export default class PresentationWindow {
|
|
|
953
953
|
}
|
|
954
954
|
|
|
955
955
|
private getEmbeddedAppUrl() {
|
|
956
|
-
const { windowId, appRendererOfflineSupport } = this.options;
|
|
956
|
+
const { windowId, appRendererOfflineSupport, device } = this.options;
|
|
957
957
|
|
|
958
958
|
const metadata: EmbeddedAppMetadata = {
|
|
959
959
|
renderMode: this.options.isPreview ? 'preview' : 'live',
|
|
960
960
|
};
|
|
961
961
|
|
|
962
|
+
if (device) {
|
|
963
|
+
metadata.deviceId = device.id;
|
|
964
|
+
}
|
|
965
|
+
|
|
962
966
|
const url = createEmbeddedApp(
|
|
963
967
|
this.presentation,
|
|
964
968
|
this.options.applicationVersion,
|
package/src/embeddedApps.test.ts
CHANGED
|
@@ -240,3 +240,40 @@ test('Replaces $token with presentation token', () => {
|
|
|
240
240
|
createEmbeddedApp(presentation, applicationVersion, createMetadata())
|
|
241
241
|
).toBe('https://example.com?token=abc');
|
|
242
242
|
});
|
|
243
|
+
|
|
244
|
+
test('Replaces $deviceId with metadata deviceId when provided', () => {
|
|
245
|
+
const presentation = createPresentation();
|
|
246
|
+
const applicationVersion = createApplicationVersion({
|
|
247
|
+
embeddedUrlFormat: 'https://example.com/:$deviceId/content',
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
expect(
|
|
251
|
+
createEmbeddedApp(
|
|
252
|
+
presentation,
|
|
253
|
+
applicationVersion,
|
|
254
|
+
createMetadata({ deviceId: 'device-id' })
|
|
255
|
+
)
|
|
256
|
+
).toBe('https://example.com/device-id/content');
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
test('Do not replace $deviceId when in the URI with metadata not defined', () => {
|
|
260
|
+
const presentation = createPresentation();
|
|
261
|
+
const applicationVersion = createApplicationVersion({
|
|
262
|
+
embeddedUrlFormat: 'https://example.com/:$deviceId/content',
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
expect(
|
|
266
|
+
createEmbeddedApp(presentation, applicationVersion, createMetadata())
|
|
267
|
+
).toBe(`https://example.com/${encodeURIComponent(':$deviceId')}/content`);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test('Replaces $deviceId with empty string when in the query string and metadata not defined', () => {
|
|
271
|
+
const presentation = createPresentation();
|
|
272
|
+
const applicationVersion = createApplicationVersion({
|
|
273
|
+
embeddedUrlFormat: 'https://example.com/content?device=:$deviceId',
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
expect(
|
|
277
|
+
createEmbeddedApp(presentation, applicationVersion, createMetadata())
|
|
278
|
+
).toBe(`https://example.com/content?device=`);
|
|
279
|
+
});
|
package/src/embeddedApps.ts
CHANGED
|
@@ -19,6 +19,7 @@ export default function createEmbeddedApp(
|
|
|
19
19
|
|
|
20
20
|
// replace
|
|
21
21
|
let url = applicationVersion.embeddedUrlFormat || '';
|
|
22
|
+
const queryIndex = url.indexOf('?');
|
|
22
23
|
matches.forEach((m) => {
|
|
23
24
|
const queryParamVariableName = m[1]; // Where the value of your input will be injected. E.g. ":location"
|
|
24
25
|
const queryParamName = m[2]; // The query param name. E.g. "location"
|
|
@@ -29,11 +30,24 @@ export default function createEmbeddedApp(
|
|
|
29
30
|
let value: any = '';
|
|
30
31
|
|
|
31
32
|
if (variableName.charAt(0) === '$') {
|
|
33
|
+
const variableIndex = url.indexOf(queryParamVariableName);
|
|
34
|
+
const isPartOfQuery = queryIndex != -1 && variableIndex > queryIndex;
|
|
35
|
+
|
|
32
36
|
const metadataKey = variableName.slice(1);
|
|
33
37
|
if (metadataKey === 'renderMode') {
|
|
34
38
|
value = metadata.renderMode;
|
|
35
39
|
} else if (metadataKey === 'token') {
|
|
36
40
|
value = presentation.token;
|
|
41
|
+
} else if (metadataKey === 'deviceId') {
|
|
42
|
+
if (metadata.deviceId) {
|
|
43
|
+
value = metadata.deviceId;
|
|
44
|
+
} else {
|
|
45
|
+
// If :$deviceId is part of the URL path, avoid creating a broken URL if metadata.deviceId is not defined.
|
|
46
|
+
// This will use the variable name as the value instead of an empty string.
|
|
47
|
+
if (!isPartOfQuery) {
|
|
48
|
+
value = queryParamVariableName;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
37
51
|
}
|
|
38
52
|
} else {
|
|
39
53
|
// Don't replace variables that are numbers to allow setting
|
package/src/types.ts
CHANGED
|
@@ -167,6 +167,7 @@ export interface InputState {
|
|
|
167
167
|
|
|
168
168
|
export interface EmbeddedAppMetadata {
|
|
169
169
|
renderMode: 'preview' | 'live';
|
|
170
|
+
deviceId?: string;
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
export interface AnalyticsEvent {
|
|
@@ -176,6 +177,7 @@ export interface AnalyticsEvent {
|
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
export interface ChargeRequest {
|
|
180
|
+
orderId?: string;
|
|
179
181
|
requestId: string;
|
|
180
182
|
subTotal: number;
|
|
181
183
|
tip: number;
|
package/tasks/npm-publish.sh
CHANGED