@player-ui/reference-assets-plugin 0.4.0 → 0.4.1-next.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/dist/index.cjs.js CHANGED
@@ -4,28 +4,28 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var assetTransformPlugin = require('@player-ui/asset-transform-plugin');
6
6
 
7
- var __defProp$1 = Object.defineProperty;
8
- var __defProps$1 = Object.defineProperties;
9
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
10
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
11
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
12
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
13
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
- var __spreadValues$1 = (a, b) => {
7
+ var __defProp$3 = Object.defineProperty;
8
+ var __defProps$3 = Object.defineProperties;
9
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
10
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
11
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
12
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
13
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
+ var __spreadValues$3 = (a, b) => {
15
15
  for (var prop in b || (b = {}))
16
- if (__hasOwnProp$1.call(b, prop))
17
- __defNormalProp$1(a, prop, b[prop]);
18
- if (__getOwnPropSymbols$1)
19
- for (var prop of __getOwnPropSymbols$1(b)) {
20
- if (__propIsEnum$1.call(b, prop))
21
- __defNormalProp$1(a, prop, b[prop]);
16
+ if (__hasOwnProp$3.call(b, prop))
17
+ __defNormalProp$3(a, prop, b[prop]);
18
+ if (__getOwnPropSymbols$3)
19
+ for (var prop of __getOwnPropSymbols$3(b)) {
20
+ if (__propIsEnum$3.call(b, prop))
21
+ __defNormalProp$3(a, prop, b[prop]);
22
22
  }
23
23
  return a;
24
24
  };
25
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
25
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
26
26
  const inputTransform = (asset, options) => {
27
27
  var _a, _b;
28
- return __spreadProps$1(__spreadValues$1({}, asset), {
28
+ return __spreadProps$3(__spreadValues$3({}, asset), {
29
29
  format(val) {
30
30
  if (asset.binding === void 0) {
31
31
  return val;
@@ -49,30 +49,30 @@ const inputTransform = (asset, options) => {
49
49
  });
50
50
  };
51
51
 
52
- var __defProp = Object.defineProperty;
53
- var __defProps = Object.defineProperties;
54
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
55
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
56
- var __hasOwnProp = Object.prototype.hasOwnProperty;
57
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
58
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
59
- var __spreadValues = (a, b) => {
52
+ var __defProp$2 = Object.defineProperty;
53
+ var __defProps$2 = Object.defineProperties;
54
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
55
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
56
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
57
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
58
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
59
+ var __spreadValues$2 = (a, b) => {
60
60
  for (var prop in b || (b = {}))
61
- if (__hasOwnProp.call(b, prop))
62
- __defNormalProp(a, prop, b[prop]);
63
- if (__getOwnPropSymbols)
64
- for (var prop of __getOwnPropSymbols(b)) {
65
- if (__propIsEnum.call(b, prop))
66
- __defNormalProp(a, prop, b[prop]);
61
+ if (__hasOwnProp$2.call(b, prop))
62
+ __defNormalProp$2(a, prop, b[prop]);
63
+ if (__getOwnPropSymbols$2)
64
+ for (var prop of __getOwnPropSymbols$2(b)) {
65
+ if (__propIsEnum$2.call(b, prop))
66
+ __defNormalProp$2(a, prop, b[prop]);
67
67
  }
68
68
  return a;
69
69
  };
70
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
70
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
71
71
  function isBackAction(action) {
72
72
  return action.value === "Prev";
73
73
  }
74
74
  const transform = (action, options) => {
75
- return __spreadProps(__spreadValues({}, action), {
75
+ return __spreadProps$2(__spreadValues$2({}, action), {
76
76
  run() {
77
77
  var _a, _b;
78
78
  if (action.exp) {
@@ -85,15 +85,26 @@ const transform = (action, options) => {
85
85
  }
86
86
  });
87
87
  };
88
+ const backIconTransform = (action) => {
89
+ var _a;
90
+ if (isBackAction(action) && ((_a = action == null ? void 0 : action.metaData) == null ? void 0 : _a.role) === void 0) {
91
+ return __spreadProps$2(__spreadValues$2({}, action), {
92
+ metaData: __spreadProps$2(__spreadValues$2({}, action == null ? void 0 : action.metaData), {
93
+ role: "back"
94
+ })
95
+ });
96
+ }
97
+ return action;
98
+ };
88
99
  const expPropTransform = (asset) => {
89
100
  var _a, _b, _c, _d, _e, _f;
90
101
  const skipArray = (_b = (_a = asset.plugins) == null ? void 0 : _a.stringResolver) == null ? void 0 : _b.propertiesToSkip;
91
102
  if (skipArray && skipArray.indexOf("exp") > 1) {
92
103
  return asset;
93
104
  }
94
- return __spreadProps(__spreadValues({}, asset), {
95
- plugins: __spreadProps(__spreadValues({}, asset.plugins), {
96
- stringResolver: __spreadProps(__spreadValues({}, (_c = asset == null ? void 0 : asset.plugins) == null ? void 0 : _c.stringResolver), {
105
+ return __spreadProps$2(__spreadValues$2({}, asset), {
106
+ plugins: __spreadProps$2(__spreadValues$2({}, asset.plugins), {
107
+ stringResolver: __spreadProps$2(__spreadValues$2({}, (_c = asset == null ? void 0 : asset.plugins) == null ? void 0 : _c.stringResolver), {
97
108
  propertiesToSkip: [
98
109
  ...(_f = (_e = (_d = asset.plugins) == null ? void 0 : _d.stringResolver) == null ? void 0 : _e.propertiesToSkip) != null ? _f : [],
99
110
  "exp"
@@ -102,7 +113,72 @@ const expPropTransform = (asset) => {
102
113
  })
103
114
  });
104
115
  };
105
- const actionTransform = assetTransformPlugin.compose(transform, assetTransformPlugin.composeBefore(expPropTransform));
116
+ const actionTransform = assetTransformPlugin.compose(transform, backIconTransform, assetTransformPlugin.composeBefore(expPropTransform));
117
+
118
+ var __defProp$1 = Object.defineProperty;
119
+ var __defProps$1 = Object.defineProperties;
120
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
121
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
122
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
123
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
124
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
125
+ var __spreadValues$1 = (a, b) => {
126
+ for (var prop in b || (b = {}))
127
+ if (__hasOwnProp$1.call(b, prop))
128
+ __defNormalProp$1(a, prop, b[prop]);
129
+ if (__getOwnPropSymbols$1)
130
+ for (var prop of __getOwnPropSymbols$1(b)) {
131
+ if (__propIsEnum$1.call(b, prop))
132
+ __defNormalProp$1(a, prop, b[prop]);
133
+ }
134
+ return a;
135
+ };
136
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
137
+ const infoTransform = (infoAsset) => {
138
+ const actions = infoAsset == null ? void 0 : infoAsset.actions;
139
+ const segmentedActions = actions == null ? void 0 : actions.reduce((segmentedActionsArray, action) => {
140
+ segmentedActionsArray[isBackAction(action.asset) ? "prev" : "next"].push(action);
141
+ return segmentedActionsArray;
142
+ }, { next: [], prev: [] });
143
+ return __spreadProps$1(__spreadValues$1({}, infoAsset), {
144
+ segmentedActions
145
+ });
146
+ };
147
+
148
+ var __defProp = Object.defineProperty;
149
+ var __defProps = Object.defineProperties;
150
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
151
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
152
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
153
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
154
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
155
+ var __spreadValues = (a, b) => {
156
+ for (var prop in b || (b = {}))
157
+ if (__hasOwnProp.call(b, prop))
158
+ __defNormalProp(a, prop, b[prop]);
159
+ if (__getOwnPropSymbols)
160
+ for (var prop of __getOwnPropSymbols(b)) {
161
+ if (__propIsEnum.call(b, prop))
162
+ __defNormalProp(a, prop, b[prop]);
163
+ }
164
+ return a;
165
+ };
166
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
167
+ const getImageAlt = (props) => {
168
+ const { metaData, placeholder } = props;
169
+ if (metaData.accessibility)
170
+ return metaData.accessibility;
171
+ if (placeholder)
172
+ return placeholder;
173
+ return "Image";
174
+ };
175
+ const imageTransform = (props) => {
176
+ const altText = getImageAlt(props);
177
+ const newImage = __spreadProps(__spreadValues({}, props), {
178
+ altText
179
+ });
180
+ return newImage;
181
+ };
106
182
 
107
183
  class ReferenceAssetsPlugin {
108
184
  constructor() {
@@ -111,7 +187,9 @@ class ReferenceAssetsPlugin {
111
187
  apply(player) {
112
188
  player.registerPlugin(new assetTransformPlugin.AssetTransformPlugin([
113
189
  [{ type: "action" }, actionTransform],
114
- [{ type: "input" }, inputTransform]
190
+ [{ type: "input" }, inputTransform],
191
+ [{ type: "image" }, imageTransform],
192
+ [{ type: "info" }, infoTransform]
115
193
  ]));
116
194
  }
117
195
  }
@@ -119,6 +197,8 @@ class ReferenceAssetsPlugin {
119
197
  exports.ReferenceAssetsPlugin = ReferenceAssetsPlugin;
120
198
  exports.actionTransform = actionTransform;
121
199
  exports.expPropTransform = expPropTransform;
200
+ exports.imageTransform = imageTransform;
201
+ exports.infoTransform = infoTransform;
122
202
  exports.inputTransform = inputTransform;
123
203
  exports.isBackAction = isBackAction;
124
204
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.d.ts CHANGED
@@ -58,6 +58,8 @@ interface ActionAsset<AnyTextAsset extends Asset = Asset> extends Asset<'action'
58
58
  beacon?: BeaconDataType;
59
59
  /** Force transition to the next view without checking for validation */
60
60
  skipValidation?: boolean;
61
+ /** string value to decide for the left anchor sign */
62
+ role?: string;
61
63
  };
62
64
  }
63
65
  /** A stateful instance of an action */
@@ -66,6 +68,9 @@ interface TransformedAction extends ActionAsset {
66
68
  run: () => void;
67
69
  }
68
70
 
71
+ /**
72
+ * Function to find prev button
73
+ */
69
74
  declare function isBackAction(action: ActionAsset): boolean;
70
75
  /**
71
76
  * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist
@@ -92,6 +97,27 @@ interface InfoAsset extends Asset<'info'> {
92
97
  /** List of actions to show at the bottom of the page */
93
98
  actions?: Array<AssetWrapper>;
94
99
  }
100
+ interface InfoAssetTransform extends InfoAsset {
101
+ /**
102
+ * This is an array of next and prev actions
103
+ */
104
+ segmentedActions?: {
105
+ /**
106
+ * Array of next actions
107
+ */
108
+ next: Array<AssetWrapper<ActionAsset>>;
109
+ /**
110
+ * Array of prev actions
111
+ */
112
+ prev: Array<AssetWrapper<ActionAsset>>;
113
+ };
114
+ }
115
+
116
+ /**
117
+ * This transform should add segmentedActions to the info asset.
118
+ * Segmented actions display side by side in larger viewports. Segmented Actions is an object of next and prev actions
119
+ */
120
+ declare const infoTransform: TransformFunction<InfoAsset, InfoAssetTransform>;
95
121
 
96
122
  interface TextAsset extends Asset<'text'> {
97
123
  /** The text to display */
@@ -123,6 +149,31 @@ interface LinkModifier {
123
149
  };
124
150
  }
125
151
 
152
+ interface ImageAsset extends Asset<'image'> {
153
+ /** Reference to the image */
154
+ metaData: ImageMetaData;
155
+ /** Optional placeholder text */
156
+ placeholder?: string;
157
+ /** Optional caption */
158
+ caption?: Asset;
159
+ }
160
+ /** A modifier to turn the text into a link */
161
+ interface ImageMetaData {
162
+ /** The location of the image to load */
163
+ ref: string;
164
+ /** Used for accessibility support */
165
+ accessibility?: string;
166
+ }
167
+ interface TransformedImage extends ImageAsset {
168
+ /** Alt text */
169
+ altText: string;
170
+ }
171
+
172
+ /**
173
+ * Sets the Image's placeholder and accessibilty
174
+ */
175
+ declare const imageTransform: TransformFunction<ImageAsset, TransformedImage>;
176
+
126
177
  /**
127
178
  * A plugin to add transforms for the reference assets
128
179
  */
@@ -131,4 +182,4 @@ declare class ReferenceAssetsPlugin implements PlayerPlugin {
131
182
  apply(player: Player): void;
132
183
  }
133
184
 
134
- export { ActionAsset, BasicTextModifier, CollectionAsset, InfoAsset, InputAsset, LinkModifier, ReferenceAssetsPlugin, TextAsset, TextModifier, TransformedAction, TransformedInput, actionTransform, expPropTransform, inputTransform, isBackAction };
185
+ export { ActionAsset, BasicTextModifier, CollectionAsset, ImageAsset, ImageMetaData, InfoAsset, InfoAssetTransform, InputAsset, LinkModifier, ReferenceAssetsPlugin, TextAsset, TextModifier, TransformedAction, TransformedImage, TransformedInput, actionTransform, expPropTransform, imageTransform, infoTransform, inputTransform, isBackAction };
package/dist/index.esm.js CHANGED
@@ -1,27 +1,27 @@
1
1
  import { compose, composeBefore, AssetTransformPlugin } from '@player-ui/asset-transform-plugin';
2
2
 
3
- var __defProp$1 = Object.defineProperty;
4
- var __defProps$1 = Object.defineProperties;
5
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
7
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
8
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues$1 = (a, b) => {
3
+ var __defProp$3 = Object.defineProperty;
4
+ var __defProps$3 = Object.defineProperties;
5
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues$3 = (a, b) => {
11
11
  for (var prop in b || (b = {}))
12
- if (__hasOwnProp$1.call(b, prop))
13
- __defNormalProp$1(a, prop, b[prop]);
14
- if (__getOwnPropSymbols$1)
15
- for (var prop of __getOwnPropSymbols$1(b)) {
16
- if (__propIsEnum$1.call(b, prop))
17
- __defNormalProp$1(a, prop, b[prop]);
12
+ if (__hasOwnProp$3.call(b, prop))
13
+ __defNormalProp$3(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols$3)
15
+ for (var prop of __getOwnPropSymbols$3(b)) {
16
+ if (__propIsEnum$3.call(b, prop))
17
+ __defNormalProp$3(a, prop, b[prop]);
18
18
  }
19
19
  return a;
20
20
  };
21
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
21
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
22
22
  const inputTransform = (asset, options) => {
23
23
  var _a, _b;
24
- return __spreadProps$1(__spreadValues$1({}, asset), {
24
+ return __spreadProps$3(__spreadValues$3({}, asset), {
25
25
  format(val) {
26
26
  if (asset.binding === void 0) {
27
27
  return val;
@@ -45,30 +45,30 @@ const inputTransform = (asset, options) => {
45
45
  });
46
46
  };
47
47
 
48
- var __defProp = Object.defineProperty;
49
- var __defProps = Object.defineProperties;
50
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
51
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
52
- var __hasOwnProp = Object.prototype.hasOwnProperty;
53
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
54
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
55
- var __spreadValues = (a, b) => {
48
+ var __defProp$2 = Object.defineProperty;
49
+ var __defProps$2 = Object.defineProperties;
50
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
51
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
52
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
53
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
54
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
55
+ var __spreadValues$2 = (a, b) => {
56
56
  for (var prop in b || (b = {}))
57
- if (__hasOwnProp.call(b, prop))
58
- __defNormalProp(a, prop, b[prop]);
59
- if (__getOwnPropSymbols)
60
- for (var prop of __getOwnPropSymbols(b)) {
61
- if (__propIsEnum.call(b, prop))
62
- __defNormalProp(a, prop, b[prop]);
57
+ if (__hasOwnProp$2.call(b, prop))
58
+ __defNormalProp$2(a, prop, b[prop]);
59
+ if (__getOwnPropSymbols$2)
60
+ for (var prop of __getOwnPropSymbols$2(b)) {
61
+ if (__propIsEnum$2.call(b, prop))
62
+ __defNormalProp$2(a, prop, b[prop]);
63
63
  }
64
64
  return a;
65
65
  };
66
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
66
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
67
67
  function isBackAction(action) {
68
68
  return action.value === "Prev";
69
69
  }
70
70
  const transform = (action, options) => {
71
- return __spreadProps(__spreadValues({}, action), {
71
+ return __spreadProps$2(__spreadValues$2({}, action), {
72
72
  run() {
73
73
  var _a, _b;
74
74
  if (action.exp) {
@@ -81,15 +81,26 @@ const transform = (action, options) => {
81
81
  }
82
82
  });
83
83
  };
84
+ const backIconTransform = (action) => {
85
+ var _a;
86
+ if (isBackAction(action) && ((_a = action == null ? void 0 : action.metaData) == null ? void 0 : _a.role) === void 0) {
87
+ return __spreadProps$2(__spreadValues$2({}, action), {
88
+ metaData: __spreadProps$2(__spreadValues$2({}, action == null ? void 0 : action.metaData), {
89
+ role: "back"
90
+ })
91
+ });
92
+ }
93
+ return action;
94
+ };
84
95
  const expPropTransform = (asset) => {
85
96
  var _a, _b, _c, _d, _e, _f;
86
97
  const skipArray = (_b = (_a = asset.plugins) == null ? void 0 : _a.stringResolver) == null ? void 0 : _b.propertiesToSkip;
87
98
  if (skipArray && skipArray.indexOf("exp") > 1) {
88
99
  return asset;
89
100
  }
90
- return __spreadProps(__spreadValues({}, asset), {
91
- plugins: __spreadProps(__spreadValues({}, asset.plugins), {
92
- stringResolver: __spreadProps(__spreadValues({}, (_c = asset == null ? void 0 : asset.plugins) == null ? void 0 : _c.stringResolver), {
101
+ return __spreadProps$2(__spreadValues$2({}, asset), {
102
+ plugins: __spreadProps$2(__spreadValues$2({}, asset.plugins), {
103
+ stringResolver: __spreadProps$2(__spreadValues$2({}, (_c = asset == null ? void 0 : asset.plugins) == null ? void 0 : _c.stringResolver), {
93
104
  propertiesToSkip: [
94
105
  ...(_f = (_e = (_d = asset.plugins) == null ? void 0 : _d.stringResolver) == null ? void 0 : _e.propertiesToSkip) != null ? _f : [],
95
106
  "exp"
@@ -98,7 +109,72 @@ const expPropTransform = (asset) => {
98
109
  })
99
110
  });
100
111
  };
101
- const actionTransform = compose(transform, composeBefore(expPropTransform));
112
+ const actionTransform = compose(transform, backIconTransform, composeBefore(expPropTransform));
113
+
114
+ var __defProp$1 = Object.defineProperty;
115
+ var __defProps$1 = Object.defineProperties;
116
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
117
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
118
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
119
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
120
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
121
+ var __spreadValues$1 = (a, b) => {
122
+ for (var prop in b || (b = {}))
123
+ if (__hasOwnProp$1.call(b, prop))
124
+ __defNormalProp$1(a, prop, b[prop]);
125
+ if (__getOwnPropSymbols$1)
126
+ for (var prop of __getOwnPropSymbols$1(b)) {
127
+ if (__propIsEnum$1.call(b, prop))
128
+ __defNormalProp$1(a, prop, b[prop]);
129
+ }
130
+ return a;
131
+ };
132
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
133
+ const infoTransform = (infoAsset) => {
134
+ const actions = infoAsset == null ? void 0 : infoAsset.actions;
135
+ const segmentedActions = actions == null ? void 0 : actions.reduce((segmentedActionsArray, action) => {
136
+ segmentedActionsArray[isBackAction(action.asset) ? "prev" : "next"].push(action);
137
+ return segmentedActionsArray;
138
+ }, { next: [], prev: [] });
139
+ return __spreadProps$1(__spreadValues$1({}, infoAsset), {
140
+ segmentedActions
141
+ });
142
+ };
143
+
144
+ var __defProp = Object.defineProperty;
145
+ var __defProps = Object.defineProperties;
146
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
147
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
148
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
149
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
150
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
151
+ var __spreadValues = (a, b) => {
152
+ for (var prop in b || (b = {}))
153
+ if (__hasOwnProp.call(b, prop))
154
+ __defNormalProp(a, prop, b[prop]);
155
+ if (__getOwnPropSymbols)
156
+ for (var prop of __getOwnPropSymbols(b)) {
157
+ if (__propIsEnum.call(b, prop))
158
+ __defNormalProp(a, prop, b[prop]);
159
+ }
160
+ return a;
161
+ };
162
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
163
+ const getImageAlt = (props) => {
164
+ const { metaData, placeholder } = props;
165
+ if (metaData.accessibility)
166
+ return metaData.accessibility;
167
+ if (placeholder)
168
+ return placeholder;
169
+ return "Image";
170
+ };
171
+ const imageTransform = (props) => {
172
+ const altText = getImageAlt(props);
173
+ const newImage = __spreadProps(__spreadValues({}, props), {
174
+ altText
175
+ });
176
+ return newImage;
177
+ };
102
178
 
103
179
  class ReferenceAssetsPlugin {
104
180
  constructor() {
@@ -107,10 +183,12 @@ class ReferenceAssetsPlugin {
107
183
  apply(player) {
108
184
  player.registerPlugin(new AssetTransformPlugin([
109
185
  [{ type: "action" }, actionTransform],
110
- [{ type: "input" }, inputTransform]
186
+ [{ type: "input" }, inputTransform],
187
+ [{ type: "image" }, imageTransform],
188
+ [{ type: "info" }, infoTransform]
111
189
  ]));
112
190
  }
113
191
  }
114
192
 
115
- export { ReferenceAssetsPlugin, actionTransform, expPropTransform, inputTransform, isBackAction };
193
+ export { ReferenceAssetsPlugin, actionTransform, expPropTransform, imageTransform, infoTransform, inputTransform, isBackAction };
116
194
  //# sourceMappingURL=index.esm.js.map
@@ -323,7 +323,7 @@ class AssetTransformPlugin {
323
323
  /*!************************************************************************************!*\
324
324
  !*** ./bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/dist/index.esm.js ***!
325
325
  \************************************************************************************/
326
- /*! exports provided: ReferenceAssetsPlugin, actionTransform, expPropTransform, inputTransform, isBackAction */
326
+ /*! exports provided: ReferenceAssetsPlugin, actionTransform, expPropTransform, imageTransform, infoTransform, inputTransform, isBackAction */
327
327
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
328
328
 
329
329
  "use strict";
@@ -331,33 +331,35 @@ __webpack_require__.r(__webpack_exports__);
331
331
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReferenceAssetsPlugin", function() { return ReferenceAssetsPlugin; });
332
332
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "actionTransform", function() { return actionTransform; });
333
333
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expPropTransform", function() { return expPropTransform; });
334
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageTransform", function() { return imageTransform; });
335
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "infoTransform", function() { return infoTransform; });
334
336
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inputTransform", function() { return inputTransform; });
335
337
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isBackAction", function() { return isBackAction; });
336
338
  /* harmony import */ var _player_ui_asset_transform_plugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @player-ui/asset-transform-plugin */ "./bazel-out/k8-fastbuild/bin/plugins/asset-transform/core/dist/index.esm.js");
337
339
 
338
340
 
339
- var __defProp$1 = Object.defineProperty;
340
- var __defProps$1 = Object.defineProperties;
341
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
342
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
343
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
344
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
345
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
346
- var __spreadValues$1 = (a, b) => {
341
+ var __defProp$3 = Object.defineProperty;
342
+ var __defProps$3 = Object.defineProperties;
343
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
344
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
345
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
346
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
347
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
348
+ var __spreadValues$3 = (a, b) => {
347
349
  for (var prop in b || (b = {}))
348
- if (__hasOwnProp$1.call(b, prop))
349
- __defNormalProp$1(a, prop, b[prop]);
350
- if (__getOwnPropSymbols$1)
351
- for (var prop of __getOwnPropSymbols$1(b)) {
352
- if (__propIsEnum$1.call(b, prop))
353
- __defNormalProp$1(a, prop, b[prop]);
350
+ if (__hasOwnProp$3.call(b, prop))
351
+ __defNormalProp$3(a, prop, b[prop]);
352
+ if (__getOwnPropSymbols$3)
353
+ for (var prop of __getOwnPropSymbols$3(b)) {
354
+ if (__propIsEnum$3.call(b, prop))
355
+ __defNormalProp$3(a, prop, b[prop]);
354
356
  }
355
357
  return a;
356
358
  };
357
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
359
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
358
360
  const inputTransform = (asset, options) => {
359
361
  var _a, _b;
360
- return __spreadProps$1(__spreadValues$1({}, asset), {
362
+ return __spreadProps$3(__spreadValues$3({}, asset), {
361
363
  format(val) {
362
364
  if (asset.binding === void 0) {
363
365
  return val;
@@ -381,30 +383,30 @@ const inputTransform = (asset, options) => {
381
383
  });
382
384
  };
383
385
 
384
- var __defProp = Object.defineProperty;
385
- var __defProps = Object.defineProperties;
386
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
387
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
388
- var __hasOwnProp = Object.prototype.hasOwnProperty;
389
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
390
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
391
- var __spreadValues = (a, b) => {
386
+ var __defProp$2 = Object.defineProperty;
387
+ var __defProps$2 = Object.defineProperties;
388
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
389
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
390
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
391
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
392
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
393
+ var __spreadValues$2 = (a, b) => {
392
394
  for (var prop in b || (b = {}))
393
- if (__hasOwnProp.call(b, prop))
394
- __defNormalProp(a, prop, b[prop]);
395
- if (__getOwnPropSymbols)
396
- for (var prop of __getOwnPropSymbols(b)) {
397
- if (__propIsEnum.call(b, prop))
398
- __defNormalProp(a, prop, b[prop]);
395
+ if (__hasOwnProp$2.call(b, prop))
396
+ __defNormalProp$2(a, prop, b[prop]);
397
+ if (__getOwnPropSymbols$2)
398
+ for (var prop of __getOwnPropSymbols$2(b)) {
399
+ if (__propIsEnum$2.call(b, prop))
400
+ __defNormalProp$2(a, prop, b[prop]);
399
401
  }
400
402
  return a;
401
403
  };
402
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
404
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
403
405
  function isBackAction(action) {
404
406
  return action.value === "Prev";
405
407
  }
406
408
  const transform = (action, options) => {
407
- return __spreadProps(__spreadValues({}, action), {
409
+ return __spreadProps$2(__spreadValues$2({}, action), {
408
410
  run() {
409
411
  var _a, _b;
410
412
  if (action.exp) {
@@ -417,15 +419,26 @@ const transform = (action, options) => {
417
419
  }
418
420
  });
419
421
  };
422
+ const backIconTransform = (action) => {
423
+ var _a;
424
+ if (isBackAction(action) && ((_a = action == null ? void 0 : action.metaData) == null ? void 0 : _a.role) === void 0) {
425
+ return __spreadProps$2(__spreadValues$2({}, action), {
426
+ metaData: __spreadProps$2(__spreadValues$2({}, action == null ? void 0 : action.metaData), {
427
+ role: "back"
428
+ })
429
+ });
430
+ }
431
+ return action;
432
+ };
420
433
  const expPropTransform = (asset) => {
421
434
  var _a, _b, _c, _d, _e, _f;
422
435
  const skipArray = (_b = (_a = asset.plugins) == null ? void 0 : _a.stringResolver) == null ? void 0 : _b.propertiesToSkip;
423
436
  if (skipArray && skipArray.indexOf("exp") > 1) {
424
437
  return asset;
425
438
  }
426
- return __spreadProps(__spreadValues({}, asset), {
427
- plugins: __spreadProps(__spreadValues({}, asset.plugins), {
428
- stringResolver: __spreadProps(__spreadValues({}, (_c = asset == null ? void 0 : asset.plugins) == null ? void 0 : _c.stringResolver), {
439
+ return __spreadProps$2(__spreadValues$2({}, asset), {
440
+ plugins: __spreadProps$2(__spreadValues$2({}, asset.plugins), {
441
+ stringResolver: __spreadProps$2(__spreadValues$2({}, (_c = asset == null ? void 0 : asset.plugins) == null ? void 0 : _c.stringResolver), {
429
442
  propertiesToSkip: [
430
443
  ...(_f = (_e = (_d = asset.plugins) == null ? void 0 : _d.stringResolver) == null ? void 0 : _e.propertiesToSkip) != null ? _f : [],
431
444
  "exp"
@@ -434,7 +447,72 @@ const expPropTransform = (asset) => {
434
447
  })
435
448
  });
436
449
  };
437
- const actionTransform = Object(_player_ui_asset_transform_plugin__WEBPACK_IMPORTED_MODULE_0__["compose"])(transform, Object(_player_ui_asset_transform_plugin__WEBPACK_IMPORTED_MODULE_0__["composeBefore"])(expPropTransform));
450
+ const actionTransform = Object(_player_ui_asset_transform_plugin__WEBPACK_IMPORTED_MODULE_0__["compose"])(transform, backIconTransform, Object(_player_ui_asset_transform_plugin__WEBPACK_IMPORTED_MODULE_0__["composeBefore"])(expPropTransform));
451
+
452
+ var __defProp$1 = Object.defineProperty;
453
+ var __defProps$1 = Object.defineProperties;
454
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
455
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
456
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
457
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
458
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
459
+ var __spreadValues$1 = (a, b) => {
460
+ for (var prop in b || (b = {}))
461
+ if (__hasOwnProp$1.call(b, prop))
462
+ __defNormalProp$1(a, prop, b[prop]);
463
+ if (__getOwnPropSymbols$1)
464
+ for (var prop of __getOwnPropSymbols$1(b)) {
465
+ if (__propIsEnum$1.call(b, prop))
466
+ __defNormalProp$1(a, prop, b[prop]);
467
+ }
468
+ return a;
469
+ };
470
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
471
+ const infoTransform = (infoAsset) => {
472
+ const actions = infoAsset == null ? void 0 : infoAsset.actions;
473
+ const segmentedActions = actions == null ? void 0 : actions.reduce((segmentedActionsArray, action) => {
474
+ segmentedActionsArray[isBackAction(action.asset) ? "prev" : "next"].push(action);
475
+ return segmentedActionsArray;
476
+ }, { next: [], prev: [] });
477
+ return __spreadProps$1(__spreadValues$1({}, infoAsset), {
478
+ segmentedActions
479
+ });
480
+ };
481
+
482
+ var __defProp = Object.defineProperty;
483
+ var __defProps = Object.defineProperties;
484
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
485
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
486
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
487
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
488
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
489
+ var __spreadValues = (a, b) => {
490
+ for (var prop in b || (b = {}))
491
+ if (__hasOwnProp.call(b, prop))
492
+ __defNormalProp(a, prop, b[prop]);
493
+ if (__getOwnPropSymbols)
494
+ for (var prop of __getOwnPropSymbols(b)) {
495
+ if (__propIsEnum.call(b, prop))
496
+ __defNormalProp(a, prop, b[prop]);
497
+ }
498
+ return a;
499
+ };
500
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
501
+ const getImageAlt = (props) => {
502
+ const { metaData, placeholder } = props;
503
+ if (metaData.accessibility)
504
+ return metaData.accessibility;
505
+ if (placeholder)
506
+ return placeholder;
507
+ return "Image";
508
+ };
509
+ const imageTransform = (props) => {
510
+ const altText = getImageAlt(props);
511
+ const newImage = __spreadProps(__spreadValues({}, props), {
512
+ altText
513
+ });
514
+ return newImage;
515
+ };
438
516
 
439
517
  class ReferenceAssetsPlugin {
440
518
  constructor() {
@@ -443,7 +521,9 @@ class ReferenceAssetsPlugin {
443
521
  apply(player) {
444
522
  player.registerPlugin(new _player_ui_asset_transform_plugin__WEBPACK_IMPORTED_MODULE_0__["AssetTransformPlugin"]([
445
523
  [{ type: "action" }, actionTransform],
446
- [{ type: "input" }, inputTransform]
524
+ [{ type: "input" }, inputTransform],
525
+ [{ type: "image" }, imageTransform],
526
+ [{ type: "info" }, infoTransform]
447
527
  ]));
448
528
  }
449
529
  }
@@ -1 +1 @@
1
- !function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports.ReferenceAssetsPlugin=t():e.ReferenceAssetsPlugin=t()}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t,r){var n,o=function(){var e=function(e){var t=e.constructor;return t.prototype=e,t}({constructor:function(e,r){this.array=[],this.compare=r||t;for(var n=e.length,o=0;o<n;)this.insert(e[o++])},insert:function(e){for(var t,r,n=this.array,o=this.compare,i=n.length-1,s=0,u=-1;i>=s;)if((r=o(n[t=(i+s)/2>>>0],e))<0)s=t+1;else{if(!(r>0)){u=t;break}i=t-1}for(-1===u&&(u=i),u++,i=n.length-1;u<i&&0===o(e,n[u]);)u++;for(t=n.length,n.push(e);t>u;)n[t]=n[--t];return n[u]=e,this},search:function(e){for(var t,r,n=this.array,o=this.compare,i=n.length-1,s=0;i>=s;)if((r=o(n[t=(i+s)/2>>>0],e))<0)s=t+1;else{if(!(r>0))return t;i=t-1}return-1},remove:function(e){var t=this.search(e);return t>=0&&this.array.splice(t,1),this}});return e.comparing=function(r,n){return new e(n,(function(e,n){return t(e[r],n[r])}))},e;function t(e,t){return e<t?-1:e>t?1:0}}();e.exports=o,void 0===(n=function(){return o}.call(t,r,t,e))||(e.exports=n)},function(e,t,r){e.exports=function(e,t,r,n,o){for(t=t.split?t.split("."):t,n=0;n<t.length;n++)e=e?e[t[n]]:o;return e===o?r:e}},function(e,t,r){"use strict";r.r(t),r.d(t,"ReferenceAssetsPlugin",(function(){return z})),r.d(t,"actionTransform",(function(){return I})),r.d(t,"expPropTransform",(function(){return D})),r.d(t,"inputTransform",(function(){return P})),r.d(t,"isBackAction",(function(){return M}));var n=r(0),o=r.n(n),i=r(1),s=r.n(i);function u(e,t=[],r=new Map){for(const n of Object.keys(e)){const o=e[n],i=[...t,n];"object"===typeof o?u(o,i,r):r.set(i,o)}return r}function c(e){const t=u(e),r=e=>{for(const r of t){const[t,n]=r;if(s()(e,t)!==n)return!1}return!0};return r.count=t.size,r}const a=()=>new o.a([],(e=>e.matcher.count));class l{constructor(e){this.store=a(),null==e||e.forEach((([e,t])=>{this.set(e,t)}))}set(e,t){const r="object"===typeof e?c(e):function(e){const t=t=>e===t;return t.count=1,t}(e);this.store.insert({key:e,value:t,matcher:r})}get(e){for(const t of this.store.array)if(t.matcher(e))return t.value}forEach(e){for(const t of this.store.array)e(t)}clear(){this.store=a()}}function f(...e){const[t,...r]=e.reverse();return(e,n,o)=>{const i=t(e,n,o);return r.length?r.reduce(((e,t)=>t(e,n,o)),i):i}}function p(...e){const t=[],r=[];for(const n of e)"function"===typeof n?r.push(n):((null==n?void 0:n.resolve)&&r.push(n.resolve),(null==n?void 0:n.beforeResolve)&&t.push(n.beforeResolve));return{beforeResolve:t.length?f(...t):void 0,resolve:r.length?f(...r):void 0}}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;function d(e){return"object"===typeof e?e:p(e)}class v{constructor(e){this.name="asset-transform",this.registry=function(e){if(Array.isArray(e)){const t=e.map((([e,t])=>[e,d(t)]));return new l(t)}const t=new l;return e.forEach((({key:e,value:r})=>{t.set(e,d(r))})),t}(e)}apply(e){e.hooks.viewController.tap(this.name,(e=>{this.registry.forEach((({key:t,value:r})=>e.transformRegistry.set(t,d(r))))}))}}var y=Object.defineProperty,b=Object.defineProperties,g=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,j=(e,t,r)=>t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const P=(e,t)=>{var r,n,o,i;return o=((e,t)=>{for(var r in t||(t={}))m.call(t,r)&&j(e,r,t[r]);if(h)for(var r of h(t))O.call(t,r)&&j(e,r,t[r]);return e})({},e),i={format:r=>void 0===e.binding?r:t.data.format(e.binding,r),set(r){if(void 0!==e.binding)return t.data.model.set([[e.binding,r]],{formatted:!0})},value:void 0===e.binding?"":t.data.model.get(e.binding,{includeInvalid:!0,formatted:!0}),validation:void 0===e.binding||null==(r=t.validation)?void 0:r.get(e.binding,{track:!0}),dataType:void 0===e.binding||null==(n=t.validation)?void 0:n.type(e.binding)},b(o,g(i))};var w=Object.defineProperty,x=Object.defineProperties,k=Object.getOwnPropertyDescriptors,R=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,E=(e,t,r)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,A=(e,t)=>{for(var r in t||(t={}))S.call(t,r)&&E(e,r,t[r]);if(R)for(var r of R(t))T.call(t,r)&&E(e,r,t[r]);return e},_=(e,t)=>x(e,k(t));function M(e){return"Prev"===e.value}const D=e=>{var t,r,n,o,i,s;const u=null==(r=null==(t=e.plugins)?void 0:t.stringResolver)?void 0:r.propertiesToSkip;return u&&u.indexOf("exp")>1?e:_(A({},e),{plugins:_(A({},e.plugins),{stringResolver:_(A({},null==(n=null==e?void 0:e.plugins)?void 0:n.stringResolver),{propertiesToSkip:[...null!=(s=null==(i=null==(o=e.plugins)?void 0:o.stringResolver)?void 0:i.propertiesToSkip)?s:[],"exp"]})})})},I=p(((e,t)=>_(A({},e),{run(){var r,n;if(e.exp&&t.evaluate(e.exp),e.value){const o=null==(r=e.metaData)?void 0:r.skipValidation;null==(n=t.transition)||n.call(t,e.value,{force:o})}}})),function(...e){return{beforeResolve:f(...e)}}(D));class z{constructor(){this.name="reference-assets-transforms"}apply(e){e.registerPlugin(new v([[{type:"action"},I],[{type:"input"},P]]))}}}])}));
1
+ !function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports.ReferenceAssetsPlugin=t():e.ReferenceAssetsPlugin=t()}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t,r){var n,o=function(){var e=function(e){var t=e.constructor;return t.prototype=e,t}({constructor:function(e,r){this.array=[],this.compare=r||t;for(var n=e.length,o=0;o<n;)this.insert(e[o++])},insert:function(e){for(var t,r,n=this.array,o=this.compare,i=n.length-1,s=0,a=-1;i>=s;)if((r=o(n[t=(i+s)/2>>>0],e))<0)s=t+1;else{if(!(r>0)){a=t;break}i=t-1}for(-1===a&&(a=i),a++,i=n.length-1;a<i&&0===o(e,n[a]);)a++;for(t=n.length,n.push(e);t>a;)n[t]=n[--t];return n[a]=e,this},search:function(e){for(var t,r,n=this.array,o=this.compare,i=n.length-1,s=0;i>=s;)if((r=o(n[t=(i+s)/2>>>0],e))<0)s=t+1;else{if(!(r>0))return t;i=t-1}return-1},remove:function(e){var t=this.search(e);return t>=0&&this.array.splice(t,1),this}});return e.comparing=function(r,n){return new e(n,(function(e,n){return t(e[r],n[r])}))},e;function t(e,t){return e<t?-1:e>t?1:0}}();e.exports=o,void 0===(n=function(){return o}.call(t,r,t,e))||(e.exports=n)},function(e,t,r){e.exports=function(e,t,r,n,o){for(t=t.split?t.split("."):t,n=0;n<t.length;n++)e=e?e[t[n]]:o;return e===o?r:e}},function(e,t,r){"use strict";r.r(t),r.d(t,"ReferenceAssetsPlugin",(function(){return Y})),r.d(t,"actionTransform",(function(){return M})),r.d(t,"expPropTransform",(function(){return _})),r.d(t,"imageTransform",(function(){return X})),r.d(t,"infoTransform",(function(){return H})),r.d(t,"inputTransform",(function(){return P})),r.d(t,"isBackAction",(function(){return I}));var n=r(0),o=r.n(n),i=r(1),s=r.n(i);function a(e,t=[],r=new Map){for(const n of Object.keys(e)){const o=e[n],i=[...t,n];"object"===typeof o?a(o,i,r):r.set(i,o)}return r}function c(e){const t=a(e),r=e=>{for(const r of t){const[t,n]=r;if(s()(e,t)!==n)return!1}return!0};return r.count=t.size,r}const u=()=>new o.a([],(e=>e.matcher.count));class l{constructor(e){this.store=u(),null==e||e.forEach((([e,t])=>{this.set(e,t)}))}set(e,t){const r="object"===typeof e?c(e):function(e){const t=t=>e===t;return t.count=1,t}(e);this.store.insert({key:e,value:t,matcher:r})}get(e){for(const t of this.store.array)if(t.matcher(e))return t.value}forEach(e){for(const t of this.store.array)e(t)}clear(){this.store=u()}}function f(...e){const[t,...r]=e.reverse();return(e,n,o)=>{const i=t(e,n,o);return r.length?r.reduce(((e,t)=>t(e,n,o)),i):i}}function p(...e){const t=[],r=[];for(const n of e)"function"===typeof n?r.push(n):((null==n?void 0:n.resolve)&&r.push(n.resolve),(null==n?void 0:n.beforeResolve)&&t.push(n.beforeResolve));return{beforeResolve:t.length?f(...t):void 0,resolve:r.length?f(...r):void 0}}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;function d(e){return"object"===typeof e?e:p(e)}class v{constructor(e){this.name="asset-transform",this.registry=function(e){if(Array.isArray(e)){const t=e.map((([e,t])=>[e,d(t)]));return new l(t)}const t=new l;return e.forEach((({key:e,value:r})=>{t.set(e,d(r))})),t}(e)}apply(e){e.hooks.viewController.tap(this.name,(e=>{this.registry.forEach((({key:t,value:r})=>e.transformRegistry.set(t,d(r))))}))}}var b=Object.defineProperty,y=Object.defineProperties,g=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,j=(e,t,r)=>t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const P=(e,t)=>{var r,n,o,i;return o=((e,t)=>{for(var r in t||(t={}))h.call(t,r)&&j(e,r,t[r]);if(m)for(var r of m(t))O.call(t,r)&&j(e,r,t[r]);return e})({},e),i={format:r=>void 0===e.binding?r:t.data.format(e.binding,r),set(r){if(void 0!==e.binding)return t.data.model.set([[e.binding,r]],{formatted:!0})},value:void 0===e.binding?"":t.data.model.get(e.binding,{includeInvalid:!0,formatted:!0}),validation:void 0===e.binding||null==(r=t.validation)?void 0:r.get(e.binding,{track:!0}),dataType:void 0===e.binding||null==(n=t.validation)?void 0:n.type(e.binding)},y(o,g(i))};var w=Object.defineProperty,x=Object.defineProperties,k=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,D=(e,t,r)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,E=(e,t)=>{for(var r in t||(t={}))R.call(t,r)&&D(e,r,t[r]);if(S)for(var r of S(t))T.call(t,r)&&D(e,r,t[r]);return e},A=(e,t)=>x(e,k(t));function I(e){return"Prev"===e.value}const _=e=>{var t,r,n,o,i,s;const a=null==(r=null==(t=e.plugins)?void 0:t.stringResolver)?void 0:r.propertiesToSkip;return a&&a.indexOf("exp")>1?e:A(E({},e),{plugins:A(E({},e.plugins),{stringResolver:A(E({},null==(n=null==e?void 0:e.plugins)?void 0:n.stringResolver),{propertiesToSkip:[...null!=(s=null==(i=null==(o=e.plugins)?void 0:o.stringResolver)?void 0:i.propertiesToSkip)?s:[],"exp"]})})})},M=p(((e,t)=>A(E({},e),{run(){var r,n;if(e.exp&&t.evaluate(e.exp),e.value){const o=null==(r=e.metaData)?void 0:r.skipValidation;null==(n=t.transition)||n.call(t,e.value,{force:o})}}})),(e=>{var t;return I(e)&&void 0===(null==(t=null==e?void 0:e.metaData)?void 0:t.role)?A(E({},e),{metaData:A(E({},null==e?void 0:e.metaData),{role:"back"})}):e}),function(...e){return{beforeResolve:f(...e)}}(_));var z=Object.defineProperty,B=Object.defineProperties,C=Object.getOwnPropertyDescriptors,V=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable,G=(e,t,r)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const H=e=>{const t=null==e?void 0:e.actions,r=null==t?void 0:t.reduce(((e,t)=>(e[I(t.asset)?"prev":"next"].push(t),e)),{next:[],prev:[]});return n=((e,t)=>{for(var r in t||(t={}))q.call(t,r)&&G(e,r,t[r]);if(V)for(var r of V(t))F.call(t,r)&&G(e,r,t[r]);return e})({},e),B(n,C({segmentedActions:r}));var n};var J=Object.defineProperty,K=Object.defineProperties,L=Object.getOwnPropertyDescriptors,N=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,W=(e,t,r)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const X=e=>{const t=(e=>{const{metaData:t,placeholder:r}=e;return t.accessibility?t.accessibility:r||"Image"})(e),r=(n=((e,t)=>{for(var r in t||(t={}))Q.call(t,r)&&W(e,r,t[r]);if(N)for(var r of N(t))U.call(t,r)&&W(e,r,t[r]);return e})({},e),K(n,L({altText:t})));var n;return r};class Y{constructor(){this.name="reference-assets-transforms"}apply(e){e.registerPlugin(new v([[{type:"action"},M],[{type:"input"},P],[{type:"image"},X],[{type:"info"},H]]))}}}])}));
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@player-ui/reference-assets-plugin",
3
- "version": "0.4.0",
3
+ "version": "0.4.1-next.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"
7
7
  },
8
8
  "peerDependencies": {
9
- "@player-ui/player": "0.4.0"
9
+ "@player-ui/player": "0.4.1-next.0"
10
10
  },
11
11
  "dependencies": {
12
- "@player-ui/beacon-plugin": "0.4.0",
13
- "@player-ui/asset-transform-plugin": "0.4.0",
12
+ "@player-ui/beacon-plugin": "0.4.1-next.0",
13
+ "@player-ui/asset-transform-plugin": "0.4.1-next.0",
14
14
  "@babel/runtime": "7.15.4"
15
15
  },
16
16
  "main": "dist/index.cjs.js",
@@ -54,6 +54,14 @@
54
54
  {
55
55
  "name": "Kelly Harrop",
56
56
  "url": "https://github.com/kharrop"
57
+ },
58
+ {
59
+ "name": "Alejandro Fimbres",
60
+ "url": "https://github.com/lexfm"
61
+ },
62
+ {
63
+ "name": "Rafael Campos",
64
+ "url": "https://github.com/rafbcampos"
57
65
  }
58
66
  ],
59
67
  "bundle": "./dist/reference-assets-plugin.prod.js"
@@ -6,6 +6,9 @@ import type {
6
6
  import { compose, composeBefore } from '@player-ui/asset-transform-plugin';
7
7
  import type { ActionAsset, TransformedAction } from './types';
8
8
 
9
+ /**
10
+ * Function to find prev button
11
+ */
9
12
  export function isBackAction(action: ActionAsset): boolean {
10
13
  return action.value === 'Prev';
11
14
  }
@@ -32,6 +35,28 @@ const transform: TransformFunction<ActionAsset, TransformedAction> = (
32
35
  };
33
36
  };
34
37
 
38
+ /**
39
+ * De couples back button from the back icon
40
+ */
41
+ const backIconTransform: TransformFunction<ActionAsset, ActionAsset> = (
42
+ action
43
+ ) => {
44
+ /** For previous versions of player, the back button would already have the back icon.
45
+ * This ensures that the old functionality does not break and back button is still visible when they update the player.
46
+ */
47
+ if (isBackAction(action) && action?.metaData?.role === undefined) {
48
+ return {
49
+ ...action,
50
+ metaData: {
51
+ ...action?.metaData,
52
+ role: 'back',
53
+ },
54
+ };
55
+ }
56
+
57
+ return action;
58
+ };
59
+
35
60
  /**
36
61
  * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist
37
62
  *
@@ -61,5 +86,6 @@ export const expPropTransform: BeforeTransformFunction<Asset> = (asset) => {
61
86
 
62
87
  export const actionTransform = compose(
63
88
  transform,
89
+ backIconTransform,
64
90
  composeBefore(expPropTransform)
65
91
  );
@@ -27,6 +27,9 @@ export interface ActionAsset<AnyTextAsset extends Asset = Asset>
27
27
 
28
28
  /** Force transition to the next view without checking for validation */
29
29
  skipValidation?: boolean;
30
+
31
+ /** string value to decide for the left anchor sign */
32
+ role?: string;
30
33
  };
31
34
  }
32
35
 
@@ -0,0 +1,2 @@
1
+ export * from './transform';
2
+ export * from './types';
@@ -0,0 +1,32 @@
1
+ import type { TransformFunction } from '@player-ui/player';
2
+ import type { ImageAsset, TransformedImage } from './types';
3
+
4
+ /**
5
+ * Function to retrieve the desired alt text based on passed in props.
6
+ * @param props Image props
7
+ * @returns The alt text for the image asset
8
+ */
9
+ const getImageAlt = (props: ImageAsset): string => {
10
+ const { metaData, placeholder } = props;
11
+ if (metaData.accessibility) return metaData.accessibility;
12
+
13
+ if (placeholder) return placeholder;
14
+
15
+ return 'Image';
16
+ };
17
+
18
+ /**
19
+ * Sets the Image's placeholder and accessibilty
20
+ */
21
+ export const imageTransform: TransformFunction<ImageAsset, TransformedImage> = (
22
+ props
23
+ ) => {
24
+ const altText = getImageAlt(props);
25
+
26
+ const newImage = {
27
+ ...props,
28
+ altText,
29
+ };
30
+
31
+ return newImage;
32
+ };
@@ -0,0 +1,26 @@
1
+ import type { Asset } from '@player-ui/player';
2
+
3
+ export interface ImageAsset extends Asset<'image'> {
4
+ /** Reference to the image */
5
+ metaData: ImageMetaData;
6
+
7
+ /** Optional placeholder text */
8
+ placeholder?: string;
9
+
10
+ /** Optional caption */
11
+ caption?: Asset;
12
+ }
13
+
14
+ /** A modifier to turn the text into a link */
15
+ export interface ImageMetaData {
16
+ /** The location of the image to load */
17
+ ref: string;
18
+
19
+ /** Used for accessibility support */
20
+ accessibility?: string;
21
+ }
22
+
23
+ export interface TransformedImage extends ImageAsset {
24
+ /** Alt text */
25
+ altText: string;
26
+ }
@@ -3,3 +3,4 @@ export * from './action';
3
3
  export * from './collection';
4
4
  export * from './info';
5
5
  export * from './text';
6
+ export * from './image';
@@ -1 +1,2 @@
1
+ export * from './transform';
1
2
  export * from './types';
@@ -0,0 +1,38 @@
1
+ import type { TransformFunction } from '@player-ui/player';
2
+ import type { AssetWrapper } from '@player-ui/player';
3
+ import type { InfoAsset, InfoAssetTransform } from './types';
4
+ import type { ActionAsset } from '../action/types';
5
+ import { isBackAction } from '../action/transform';
6
+
7
+ /**
8
+ * This transform should add segmentedActions to the info asset.
9
+ * Segmented actions display side by side in larger viewports. Segmented Actions is an object of next and prev actions
10
+ */
11
+ export const infoTransform: TransformFunction<InfoAsset, InfoAssetTransform> = (
12
+ infoAsset
13
+ ) => {
14
+ const actions = infoAsset?.actions;
15
+ const segmentedActions = actions?.reduce(
16
+ (segmentedActionsArray, action) => {
17
+ segmentedActionsArray[
18
+ isBackAction(action.asset as ActionAsset) ? 'prev' : 'next'
19
+ ].push(action as AssetWrapper<ActionAsset>);
20
+ return segmentedActionsArray;
21
+ },
22
+ { next: [], prev: [] } as {
23
+ /**
24
+ * next is an array of next actions
25
+ */
26
+ next: Array<AssetWrapper<ActionAsset>>;
27
+ /**
28
+ * prev is an array of prev actions
29
+ */
30
+ prev: Array<AssetWrapper<ActionAsset>>;
31
+ }
32
+ );
33
+
34
+ return {
35
+ ...infoAsset,
36
+ segmentedActions,
37
+ };
38
+ };
@@ -1,4 +1,5 @@
1
1
  import type { AssetWrapper, Asset } from '@player-ui/player';
2
+ import type { ActionAsset } from '../action/types';
2
3
 
3
4
  export interface InfoAsset extends Asset<'info'> {
4
5
  /** The string value to show */
@@ -13,3 +14,19 @@ export interface InfoAsset extends Asset<'info'> {
13
14
  /** List of actions to show at the bottom of the page */
14
15
  actions?: Array<AssetWrapper>;
15
16
  }
17
+
18
+ export interface InfoAssetTransform extends InfoAsset {
19
+ /**
20
+ * This is an array of next and prev actions
21
+ */
22
+ segmentedActions?: {
23
+ /**
24
+ * Array of next actions
25
+ */
26
+ next: Array<AssetWrapper<ActionAsset>>;
27
+ /**
28
+ * Array of prev actions
29
+ */
30
+ prev: Array<AssetWrapper<ActionAsset>>;
31
+ };
32
+ }
package/src/plugin.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import type { Player, PlayerPlugin } from '@player-ui/player';
2
2
  import { AssetTransformPlugin } from '@player-ui/asset-transform-plugin';
3
- import { inputTransform, actionTransform } from './assets';
3
+ import {
4
+ inputTransform,
5
+ actionTransform,
6
+ imageTransform,
7
+ infoTransform,
8
+ } from './assets';
4
9
 
5
10
  /**
6
11
  * A plugin to add transforms for the reference assets
@@ -13,6 +18,8 @@ export class ReferenceAssetsPlugin implements PlayerPlugin {
13
18
  new AssetTransformPlugin([
14
19
  [{ type: 'action' }, actionTransform],
15
20
  [{ type: 'input' }, inputTransform],
21
+ [{ type: 'image' }, imageTransform],
22
+ [{ type: 'info' }, infoTransform],
16
23
  ])
17
24
  );
18
25
  }