@player-ui/reference-assets-plugin 0.10.4-next.2 → 0.10.4

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.
@@ -22,12 +22,14 @@ var src_exports = {};
22
22
  __export(src_exports, {
23
23
  ReferenceAssetsPlugin: () => ReferenceAssetsPlugin,
24
24
  actionTransform: () => actionTransform,
25
+ chatMessageTransform: () => chatMessageTransform,
25
26
  choiceTransform: () => choiceTransform,
26
27
  expPropTransform: () => expPropTransform,
27
28
  imageTransform: () => imageTransform,
28
29
  infoTransform: () => infoTransform,
29
30
  inputTransform: () => inputTransform,
30
- isBackAction: () => isBackAction
31
+ isBackAction: () => isBackAction,
32
+ transform: () => transform2
31
33
  });
32
34
  module.exports = __toCommonJS(src_exports);
33
35
 
@@ -183,20 +185,35 @@ var choiceTransform = (asset, options) => {
183
185
  };
184
186
  };
185
187
 
186
- // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/plugin.ts
188
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/chat-message/transform.ts
187
189
  var import_asset_transform_plugin2 = require("@player-ui/asset-transform-plugin");
190
+ var import_async_node_plugin = require("@player-ui/async-node-plugin");
191
+ var transform2 = (asset) => {
192
+ const newAsset = asset.children?.[0]?.value;
193
+ if (!newAsset) {
194
+ return (0, import_async_node_plugin.asyncTransform)(asset.value.id, "collection");
195
+ }
196
+ return (0, import_async_node_plugin.asyncTransform)(asset.value.id, "collection", newAsset);
197
+ };
198
+ var chatMessageTransform = (0, import_asset_transform_plugin2.compose)(
199
+ (0, import_asset_transform_plugin2.composeBefore)(transform2)
200
+ );
201
+
202
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/plugin.ts
203
+ var import_asset_transform_plugin3 = require("@player-ui/asset-transform-plugin");
188
204
  var ReferenceAssetsPlugin = class {
189
205
  constructor() {
190
206
  this.name = "reference-assets-transforms";
191
207
  }
192
208
  apply(player) {
193
209
  player.registerPlugin(
194
- new import_asset_transform_plugin2.AssetTransformPlugin([
210
+ new import_asset_transform_plugin3.AssetTransformPlugin([
195
211
  [{ type: "action" }, actionTransform],
196
212
  [{ type: "input" }, inputTransform],
197
213
  [{ type: "image" }, imageTransform],
198
214
  [{ type: "info" }, infoTransform],
199
- [{ type: "choice" }, choiceTransform]
215
+ [{ type: "choice" }, choiceTransform],
216
+ [{ type: "chat-message" }, chatMessageTransform]
200
217
  ])
201
218
  );
202
219
  }
@@ -205,11 +222,13 @@ var ReferenceAssetsPlugin = class {
205
222
  0 && (module.exports = {
206
223
  ReferenceAssetsPlugin,
207
224
  actionTransform,
225
+ chatMessageTransform,
208
226
  choiceTransform,
209
227
  expPropTransform,
210
228
  imageTransform,
211
229
  infoTransform,
212
230
  inputTransform,
213
- isBackAction
231
+ isBackAction,
232
+ transform
214
233
  });
215
234
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/input/transform.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/action/transform.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/info/transform.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/image/transform.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/choice/transform.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/plugin.ts"],"sourcesContent":["export * from \"./assets\";\nexport * from \"./plugin\";\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type { InputAsset, TransformedInput } from \"./types\";\n\n/**\n * Docs about the asset transform\n */\nexport const inputTransform: TransformFunction<InputAsset, TransformedInput> = (\n asset,\n options,\n) => {\n return {\n ...asset,\n format(val) {\n if (asset.binding === undefined) {\n return val;\n }\n\n return options.data.format(asset.binding, val);\n },\n set(val) {\n if (asset.binding === undefined) {\n return;\n }\n\n return options.data.model.set([[asset.binding, val]], {\n formatted: true,\n });\n },\n value:\n asset.binding === undefined\n ? \"\"\n : options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: true,\n }),\n validation:\n asset.binding === undefined\n ? undefined\n : options.validation?.get(asset.binding, { track: true }),\n dataType:\n asset.binding === undefined\n ? undefined\n : options.validation?.type(asset.binding),\n };\n};\n","import type {\n Asset,\n TransformFunction,\n BeforeTransformFunction,\n} from \"@player-ui/player\";\nimport { compose, composeBefore } from \"@player-ui/asset-transform-plugin\";\nimport type { ActionAsset, TransformedAction } from \"./types\";\n\n/**\n * Function to find prev button\n */\nexport function isBackAction(action: ActionAsset): boolean {\n return action.value === \"Prev\";\n}\n\n/**\n * Attaches the methods to execute an action to an action\n */\nconst transform: TransformFunction<ActionAsset, TransformedAction> = (\n action,\n options,\n) => {\n return {\n ...action,\n run() {\n if (action.exp) {\n options.evaluate(action.exp);\n }\n\n if (action.value) {\n const skipValidation = action.metaData?.skipValidation;\n options.transition?.(action.value, { force: skipValidation });\n }\n },\n };\n};\n\n/**\n * De couples back button from the back icon\n */\nconst backIconTransform: TransformFunction<ActionAsset, ActionAsset> = (\n action,\n) => {\n /** For previous versions of player, the back button would already have the back icon.\n * This ensures that the old functionality does not break and back button is still visible when they update the player.\n */\n if (isBackAction(action) && action?.metaData?.role === undefined) {\n return {\n ...action,\n metaData: {\n ...action?.metaData,\n role: \"back\",\n },\n };\n }\n\n return action;\n};\n\n/**\n * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist\n *\n * @param asset - Asset to apply the transform to\n */\nexport const expPropTransform: BeforeTransformFunction<Asset> = (asset) => {\n const skipArray = asset.plugins?.stringResolver?.propertiesToSkip;\n\n if (skipArray && skipArray.indexOf(\"exp\") > 1) {\n return asset;\n }\n\n return {\n ...asset,\n plugins: {\n ...asset.plugins,\n stringResolver: {\n ...asset?.plugins?.stringResolver,\n propertiesToSkip: [\n ...(asset.plugins?.stringResolver?.propertiesToSkip ?? []),\n \"exp\",\n ],\n },\n },\n };\n};\n\nexport const actionTransform = compose(\n transform,\n backIconTransform,\n composeBefore(expPropTransform),\n);\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type { AssetWrapper } from \"@player-ui/player\";\nimport type { InfoAsset, InfoAssetTransform } from \"./types\";\nimport type { ActionAsset } from \"../action/types\";\nimport { isBackAction } from \"../action/transform\";\n\n/**\n * This transform should add segmentedActions to the info asset.\n * Segmented actions display side by side in larger viewports. Segmented Actions is an object of next and prev actions\n */\nexport const infoTransform: TransformFunction<InfoAsset, InfoAssetTransform> = (\n infoAsset,\n) => {\n const actions = infoAsset?.actions;\n const segmentedActions = actions?.reduce(\n (segmentedActionsArray, action) => {\n segmentedActionsArray[\n isBackAction(action.asset as ActionAsset) ? \"prev\" : \"next\"\n ].push(action as AssetWrapper<ActionAsset>);\n return segmentedActionsArray;\n },\n { next: [], prev: [] } as {\n /**\n * next is an array of next actions\n */\n next: Array<AssetWrapper<ActionAsset>>;\n /**\n * prev is an array of prev actions\n */\n prev: Array<AssetWrapper<ActionAsset>>;\n },\n );\n\n return {\n ...infoAsset,\n segmentedActions,\n };\n};\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type { ImageAsset, TransformedImage } from \"./types\";\n\n/**\n * Function to retrieve the desired alt text based on passed in props.\n * @param props Image props\n * @returns The alt text for the image asset\n */\nconst getImageAlt = (props: ImageAsset): string => {\n const { metaData, placeholder } = props;\n if (metaData.accessibility) return metaData.accessibility;\n\n if (placeholder) return placeholder;\n\n return \"Image\";\n};\n\n/**\n * Sets the Image's placeholder and accessibilty\n */\nexport const imageTransform: TransformFunction<ImageAsset, TransformedImage> = (\n props,\n) => {\n const altText = getImageAlt(props);\n\n const newImage = {\n ...props,\n altText,\n };\n\n return newImage;\n};\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type {\n ChoiceAsset,\n TransformedChoice,\n TransformedChoiceItem,\n} from \"./types\";\n\n/**\n * Docs about the asset transform\n */\nexport const choiceTransform: TransformFunction<\n ChoiceAsset,\n TransformedChoice\n> = (asset, options) => {\n const { items, binding, ...rest } = asset;\n\n const assetHasBinding = binding !== undefined;\n\n const currentValue = assetHasBinding\n ? options.data.model.get(binding, {\n includeInvalid: true,\n })\n : undefined;\n\n const resetValue = () => {\n if (assetHasBinding) {\n return options.data.model.set([[binding, null]]);\n }\n };\n\n const transformedChoiceItems: TransformedChoiceItem[] = (items || []).map(\n (item, index) => ({\n ...item,\n id: item.id ?? `${asset.id}-choice-${index}`,\n select() {\n if (assetHasBinding) {\n return options.data.model.set([[binding, item.value]]);\n }\n },\n unselect: resetValue,\n }),\n );\n\n return {\n ...rest,\n binding,\n clearSelection: resetValue,\n items: transformedChoiceItems,\n value: currentValue,\n validation: assetHasBinding\n ? options.validation?.get(binding, { track: true })\n : undefined,\n dataType: assetHasBinding ? options.validation?.type(binding) : undefined,\n };\n};\n","import type { Player, ExtendedPlayerPlugin } from \"@player-ui/player\";\nimport { AssetTransformPlugin } from \"@player-ui/asset-transform-plugin\";\nimport type {\n ActionAsset,\n InputAsset,\n ImageAsset,\n InfoAsset,\n TextAsset,\n CollectionAsset,\n ChoiceAsset,\n} from \"./assets\";\nimport {\n inputTransform,\n actionTransform,\n imageTransform,\n infoTransform,\n choiceTransform,\n} from \"./assets\";\n\n/**\n * A plugin to add transforms for the reference assets\n */\nexport class ReferenceAssetsPlugin\n implements\n ExtendedPlayerPlugin<\n [\n ActionAsset,\n InputAsset,\n ImageAsset,\n TextAsset,\n CollectionAsset,\n ChoiceAsset,\n ],\n [InfoAsset]\n >\n{\n name = \"reference-assets-transforms\";\n\n apply(player: Player) {\n player.registerPlugin(\n new AssetTransformPlugin([\n [{ type: \"action\" }, actionTransform],\n [{ type: \"input\" }, inputTransform],\n [{ type: \"image\" }, imageTransform],\n [{ type: \"info\" }, infoTransform],\n [{ type: \"choice\" }, choiceTransform],\n ]),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,IAAM,iBAAkE,CAC7E,OACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,KAAK;AACV,UAAI,MAAM,YAAY,QAAW;AAC/B,eAAO;AAAA,MACT;AAEA,aAAO,QAAQ,KAAK,OAAO,MAAM,SAAS,GAAG;AAAA,IAC/C;AAAA,IACA,IAAI,KAAK;AACP,UAAI,MAAM,YAAY,QAAW;AAC/B;AAAA,MACF;AAEA,aAAO,QAAQ,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,SAAS,GAAG,CAAC,GAAG;AAAA,QACpD,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,IACA,OACE,MAAM,YAAY,SACd,KACA,QAAQ,KAAK,MAAM,IAAI,MAAM,SAAS;AAAA,MACpC,gBAAgB;AAAA,MAChB,WAAW;AAAA,IACb,CAAC;AAAA,IACP,YACE,MAAM,YAAY,SACd,SACA,QAAQ,YAAY,IAAI,MAAM,SAAS,EAAE,OAAO,KAAK,CAAC;AAAA,IAC5D,UACE,MAAM,YAAY,SACd,SACA,QAAQ,YAAY,KAAK,MAAM,OAAO;AAAA,EAC9C;AACF;;;ACvCA,oCAAuC;AAMhC,SAAS,aAAa,QAA8B;AACzD,SAAO,OAAO,UAAU;AAC1B;AAKA,IAAM,YAA+D,CACnE,QACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM;AACJ,UAAI,OAAO,KAAK;AACd,gBAAQ,SAAS,OAAO,GAAG;AAAA,MAC7B;AAE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cL,gBAAO;AAAA;AAAA,EAEP,MAAM,QAAgB;AACpB,WAAO;AAAA,MACL,IAAI,oDAAqB;AAAA,QACvB,CAAC,EAAE,MAAM,SAAS,GAAG,eAAe;AAAA,QACpC,CAAC,EAAE,MAAM,QAAQ,GAAG,cAAc;AAAA,QAClC,CAAC,EAAE,MAAM,QAAQ,GAAG,cAAc;AAAA,QAClC,CAAC,EAAE,MAAM,OAAO,GAAG,aAAa;AAAA,QAChC,CAAC,EAAE,MAAM,SAAS,GAAG,eAAe;AAAA,MACtC,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["import_asset_transform_plugin"]}
1
+ {"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/input/transform.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/action/transform.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/info/transform.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/image/transform.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/choice/transform.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/chat-message/transform.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/plugin.ts"],"sourcesContent":["export * from \"./assets\";\nexport * from \"./plugin\";\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type { InputAsset, TransformedInput } from \"./types\";\n\n/**\n * Docs about the asset transform\n */\nexport const inputTransform: TransformFunction<InputAsset, TransformedInput> = (\n asset,\n options,\n) => {\n return {\n ...asset,\n format(val) {\n if (asset.binding === undefined) {\n return val;\n }\n\n return options.data.format(asset.binding, val);\n },\n set(val) {\n if (asset.binding === undefined) {\n return;\n }\n\n return options.data.model.set([[asset.binding, val]], {\n formatted: true,\n });\n },\n value:\n asset.binding === undefined\n ? \"\"\n : options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: true,\n }),\n validation:\n asset.binding === undefined\n ? undefined\n : options.validation?.get(asset.binding, { track: true }),\n dataType:\n asset.binding === undefined\n ? undefined\n : options.validation?.type(asset.binding),\n };\n};\n","import type {\n Asset,\n TransformFunction,\n BeforeTransformFunction,\n} from \"@player-ui/player\";\nimport { compose, composeBefore } from \"@player-ui/asset-transform-plugin\";\nimport type { ActionAsset, TransformedAction } from \"./types\";\n\n/**\n * Function to find prev button\n */\nexport function isBackAction(action: ActionAsset): boolean {\n return action.value === \"Prev\";\n}\n\n/**\n * Attaches the methods to execute an action to an action\n */\nconst transform: TransformFunction<ActionAsset, TransformedAction> = (\n action,\n options,\n) => {\n return {\n ...action,\n run() {\n if (action.exp) {\n options.evaluate(action.exp);\n }\n\n if (action.value) {\n const skipValidation = action.metaData?.skipValidation;\n options.transition?.(action.value, { force: skipValidation });\n }\n },\n };\n};\n\n/**\n * De couples back button from the back icon\n */\nconst backIconTransform: TransformFunction<ActionAsset, ActionAsset> = (\n action,\n) => {\n /** For previous versions of player, the back button would already have the back icon.\n * This ensures that the old functionality does not break and back button is still visible when they update the player.\n */\n if (isBackAction(action) && action?.metaData?.role === undefined) {\n return {\n ...action,\n metaData: {\n ...action?.metaData,\n role: \"back\",\n },\n };\n }\n\n return action;\n};\n\n/**\n * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist\n *\n * @param asset - Asset to apply the transform to\n */\nexport const expPropTransform: BeforeTransformFunction<Asset> = (asset) => {\n const skipArray = asset.plugins?.stringResolver?.propertiesToSkip;\n\n if (skipArray && skipArray.indexOf(\"exp\") > 1) {\n return asset;\n }\n\n return {\n ...asset,\n plugins: {\n ...asset.plugins,\n stringResolver: {\n ...asset?.plugins?.stringResolver,\n propertiesToSkip: [\n ...(asset.plugins?.stringResolver?.propertiesToSkip ?? []),\n \"exp\",\n ],\n },\n },\n };\n};\n\nexport const actionTransform = compose(\n transform,\n backIconTransform,\n composeBefore(expPropTransform),\n);\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type { AssetWrapper } from \"@player-ui/player\";\nimport type { InfoAsset, InfoAssetTransform } from \"./types\";\nimport type { ActionAsset } from \"../action/types\";\nimport { isBackAction } from \"../action/transform\";\n\n/**\n * This transform should add segmentedActions to the info asset.\n * Segmented actions display side by side in larger viewports. Segmented Actions is an object of next and prev actions\n */\nexport const infoTransform: TransformFunction<InfoAsset, InfoAssetTransform> = (\n infoAsset,\n) => {\n const actions = infoAsset?.actions;\n const segmentedActions = actions?.reduce(\n (segmentedActionsArray, action) => {\n segmentedActionsArray[\n isBackAction(action.asset as ActionAsset) ? \"prev\" : \"next\"\n ].push(action as AssetWrapper<ActionAsset>);\n return segmentedActionsArray;\n },\n { next: [], prev: [] } as {\n /**\n * next is an array of next actions\n */\n next: Array<AssetWrapper<ActionAsset>>;\n /**\n * prev is an array of prev actions\n */\n prev: Array<AssetWrapper<ActionAsset>>;\n },\n );\n\n return {\n ...infoAsset,\n segmentedActions,\n };\n};\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type { ImageAsset, TransformedImage } from \"./types\";\n\n/**\n * Function to retrieve the desired alt text based on passed in props.\n * @param props Image props\n * @returns The alt text for the image asset\n */\nconst getImageAlt = (props: ImageAsset): string => {\n const { metaData, placeholder } = props;\n if (metaData.accessibility) return metaData.accessibility;\n\n if (placeholder) return placeholder;\n\n return \"Image\";\n};\n\n/**\n * Sets the Image's placeholder and accessibilty\n */\nexport const imageTransform: TransformFunction<ImageAsset, TransformedImage> = (\n props,\n) => {\n const altText = getImageAlt(props);\n\n const newImage = {\n ...props,\n altText,\n };\n\n return newImage;\n};\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type {\n ChoiceAsset,\n TransformedChoice,\n TransformedChoiceItem,\n} from \"./types\";\n\n/**\n * Docs about the asset transform\n */\nexport const choiceTransform: TransformFunction<\n ChoiceAsset,\n TransformedChoice\n> = (asset, options) => {\n const { items, binding, ...rest } = asset;\n\n const assetHasBinding = binding !== undefined;\n\n const currentValue = assetHasBinding\n ? options.data.model.get(binding, {\n includeInvalid: true,\n })\n : undefined;\n\n const resetValue = () => {\n if (assetHasBinding) {\n return options.data.model.set([[binding, null]]);\n }\n };\n\n const transformedChoiceItems: TransformedChoiceItem[] = (items || []).map(\n (item, index) => ({\n ...item,\n id: item.id ?? `${asset.id}-choice-${index}`,\n select() {\n if (assetHasBinding) {\n return options.data.model.set([[binding, item.value]]);\n }\n },\n unselect: resetValue,\n }),\n );\n\n return {\n ...rest,\n binding,\n clearSelection: resetValue,\n items: transformedChoiceItems,\n value: currentValue,\n validation: assetHasBinding\n ? options.validation?.get(binding, { track: true })\n : undefined,\n dataType: assetHasBinding ? options.validation?.type(binding) : undefined,\n };\n};\n","/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport type {\n BeforeTransformFunction,\n TransformFunctions,\n} from \"@player-ui/player\";\nimport { composeBefore, compose } from \"@player-ui/asset-transform-plugin\";\nimport { asyncTransform } from \"@player-ui/async-node-plugin\";\nimport { ChatMessageAsset } from \"./types\";\n/**\n * In beforeTransform function, pass in flatten marker and call beforeResolve function.\n * Flatten default value is true.\n * input: ChatMessageAsset\n * @param asset - Asset to apply the transform to\n * @returns - transformed asset with async node and asset node\n */\nexport const transform: BeforeTransformFunction<ChatMessageAsset> = (asset) => {\n const newAsset = asset.children?.[0]?.value;\n\n if (!newAsset) {\n return asyncTransform(asset.value.id, \"collection\");\n }\n return asyncTransform(asset.value.id, \"collection\", newAsset);\n};\n\nexport const chatMessageTransform: TransformFunctions = compose(\n composeBefore(transform),\n);\n","import type { Player, ExtendedPlayerPlugin } from \"@player-ui/player\";\nimport { AssetTransformPlugin } from \"@player-ui/asset-transform-plugin\";\nimport type {\n ActionAsset,\n InputAsset,\n ImageAsset,\n InfoAsset,\n TextAsset,\n CollectionAsset,\n ChoiceAsset,\n ChatMessageAsset,\n} from \"./assets\";\nimport {\n inputTransform,\n actionTransform,\n imageTransform,\n infoTransform,\n choiceTransform,\n chatMessageTransform,\n} from \"./assets\";\n\n/**\n * A plugin to add transforms for the reference assets\n */\nexport class ReferenceAssetsPlugin\n implements\n ExtendedPlayerPlugin<\n [\n ActionAsset,\n InputAsset,\n ImageAsset,\n TextAsset,\n CollectionAsset,\n ChoiceAsset,\n ChatMessageAsset,\n ],\n [InfoAsset]\n >\n{\n name = \"reference-assets-transforms\";\n\n apply(player: Player) {\n player.registerPlugin(\n new AssetTransformPlugin([\n [{ type: \"action\" }, actionTransform],\n [{ type: \"input\" }, inputTransform],\n [{ type: \"image\" }, imageTransform],\n [{ type: \"info\" }, infoTransform],\n [{ type: \"choice\" }, choiceTransform],\n [{ type: \"chat-message\" }, chatMessageTransform],\n ]),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAAA;AAAA;AAAA;;;ACMO,IAAM,iBAAkE,CAC7E,OACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,KAAK;AACV,UAAI,MAAM,YAAY,QAAW;AAC/B,eAAO;AAAA,MACT;AAEA,aAAO,QAAQ,KAAK,OAAO,MAAM,SAAS,GAAG;AAAA,IAC/C;AAAA,IACA,IAAI,KAAK;AACP,UAAI,MAAM,YAAY,QAAW;AAC/B;AAAA,MACF;AAEA,aAAO,QAAQ,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,SAAS,GAAG,CAAC,GAAG;AAAA,QACpD,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,IACA,OACE,MAAM,YAAY,SACd,KACA,QAAQ,KAAK,MAAM,IAAI,MAAM,SAAS;AAAA,MACpC,gBAAgB;AAA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ransform = (asset, options) => {
150
150
  };
151
151
  };
152
152
 
153
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/chat-message/transform.ts
154
+ import { composeBefore as composeBefore2, compose as compose2 } from "@player-ui/asset-transform-plugin";
155
+ import { asyncTransform } from "@player-ui/async-node-plugin";
156
+ var transform2 = (asset) => {
157
+ const newAsset = asset.children?.[0]?.value;
158
+ if (!newAsset) {
159
+ return asyncTransform(asset.value.id, "collection");
160
+ }
161
+ return asyncTransform(asset.value.id, "collection", newAsset);
162
+ };
163
+ var chatMessageTransform = compose2(
164
+ composeBefore2(transform2)
165
+ );
166
+
153
167
  // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/plugin.ts
154
168
  import { AssetTransformPlugin } from "@player-ui/asset-transform-plugin";
155
169
  var ReferenceAssetsPlugin = class {
@@ -163,7 +177,8 @@ var ReferenceAssetsPlugin = class {
163
177
  [{ type: "input" }, inputTransform],
164
178
  [{ type: "image" }, imageTransform],
165
179
  [{ type: "info" }, infoTransform],
166
- [{ type: "choice" }, choiceTransform]
180
+ [{ type: "choice" }, choiceTransform],
181
+ [{ type: "chat-message" }, chatMessageTransform]
167
182
  ])
168
183
  );
169
184
  }
@@ -171,11 +186,13 @@ var ReferenceAssetsPlugin = class {
171
186
  export {
172
187
  ReferenceAssetsPlugin,
173
188
  actionTransform,
189
+ chatMessageTransform,
174
190
  choiceTransform,
175
191
  expPropTransform,
176
192
  imageTransform,
177
193
  infoTransform,
178
194
  inputTransform,
179
- isBackAction
195
+ isBackAction,
196
+ transform2 as transform
180
197
  };
181
198
  //# sourceMappingURL=index.mjs.map
package/dist/index.mjs CHANGED
@@ -150,6 +150,20 @@ var choiceTransform = (asset, options) => {
150
150
  };
151
151
  };
152
152
 
153
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/chat-message/transform.ts
154
+ import { composeBefore as composeBefore2, compose as compose2 } from "@player-ui/asset-transform-plugin";
155
+ import { asyncTransform } from "@player-ui/async-node-plugin";
156
+ var transform2 = (asset) => {
157
+ const newAsset = asset.children?.[0]?.value;
158
+ if (!newAsset) {
159
+ return asyncTransform(asset.value.id, "collection");
160
+ }
161
+ return asyncTransform(asset.value.id, "collection", newAsset);
162
+ };
163
+ var chatMessageTransform = compose2(
164
+ composeBefore2(transform2)
165
+ );
166
+
153
167
  // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/plugin.ts
154
168
  import { AssetTransformPlugin } from "@player-ui/asset-transform-plugin";
155
169
  var ReferenceAssetsPlugin = class {
@@ -163,7 +177,8 @@ var ReferenceAssetsPlugin = class {
163
177
  [{ type: "input" }, inputTransform],
164
178
  [{ type: "image" }, imageTransform],
165
179
  [{ type: "info" }, infoTransform],
166
- [{ type: "choice" }, choiceTransform]
180
+ [{ type: "choice" }, choiceTransform],
181
+ [{ type: "chat-message" }, chatMessageTransform]
167
182
  ])
168
183
  );
169
184
  }
@@ -171,11 +186,13 @@ var ReferenceAssetsPlugin = class {
171
186
  export {
172
187
  ReferenceAssetsPlugin,
173
188
  actionTransform,
189
+ chatMessageTransform,
174
190
  choiceTransform,
175
191
  expPropTransform,
176
192
  imageTransform,
177
193
  infoTransform,
178
194
  inputTransform,
179
- isBackAction
195
+ isBackAction,
196
+ transform2 as transform
180
197
  };
181
198
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/input/transform.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/action/transform.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/info/transform.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/image/transform.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/choice/transform.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/plugin.ts"],"sourcesContent":["import type { TransformFunction } from \"@player-ui/player\";\nimport type { InputAsset, TransformedInput } from \"./types\";\n\n/**\n * Docs about the asset transform\n */\nexport const inputTransform: TransformFunction<InputAsset, TransformedInput> = (\n asset,\n options,\n) => {\n return {\n ...asset,\n format(val) {\n if (asset.binding === undefined) {\n return val;\n }\n\n return options.data.format(asset.binding, val);\n },\n set(val) {\n if (asset.binding === undefined) {\n return;\n }\n\n return options.data.model.set([[asset.binding, val]], {\n formatted: true,\n });\n },\n value:\n asset.binding === undefined\n ? \"\"\n : options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: true,\n }),\n validation:\n asset.binding === undefined\n ? undefined\n : options.validation?.get(asset.binding, { track: true }),\n dataType:\n asset.binding === undefined\n ? undefined\n : options.validation?.type(asset.binding),\n };\n};\n","import type {\n Asset,\n TransformFunction,\n BeforeTransformFunction,\n} from \"@player-ui/player\";\nimport { compose, composeBefore } from \"@player-ui/asset-transform-plugin\";\nimport type { ActionAsset, TransformedAction } from \"./types\";\n\n/**\n * Function to find prev button\n */\nexport function isBackAction(action: ActionAsset): boolean {\n return action.value === \"Prev\";\n}\n\n/**\n * Attaches the methods to execute an action to an action\n */\nconst transform: TransformFunction<ActionAsset, TransformedAction> = (\n action,\n options,\n) => {\n return {\n ...action,\n run() {\n if (action.exp) {\n options.evaluate(action.exp);\n }\n\n if (action.value) {\n const skipValidation = action.metaData?.skipValidation;\n options.transition?.(action.value, { force: skipValidation });\n }\n },\n };\n};\n\n/**\n * De couples back button from the back icon\n */\nconst backIconTransform: TransformFunction<ActionAsset, ActionAsset> = (\n action,\n) => {\n /** For previous versions of player, the back button would already have the back icon.\n * This ensures that the old functionality does not break and back button is still visible when they update the player.\n */\n if (isBackAction(action) && action?.metaData?.role === undefined) {\n return {\n ...action,\n metaData: {\n ...action?.metaData,\n role: \"back\",\n },\n };\n }\n\n return action;\n};\n\n/**\n * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist\n *\n * @param asset - Asset to apply the transform to\n */\nexport const expPropTransform: BeforeTransformFunction<Asset> = (asset) => {\n const skipArray = asset.plugins?.stringResolver?.propertiesToSkip;\n\n if (skipArray && skipArray.indexOf(\"exp\") > 1) {\n return asset;\n }\n\n return {\n ...asset,\n plugins: {\n ...asset.plugins,\n stringResolver: {\n ...asset?.plugins?.stringResolver,\n propertiesToSkip: [\n ...(asset.plugins?.stringResolver?.propertiesToSkip ?? []),\n \"exp\",\n ],\n },\n },\n };\n};\n\nexport const actionTransform = compose(\n transform,\n backIconTransform,\n composeBefore(expPropTransform),\n);\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type { AssetWrapper } from \"@player-ui/player\";\nimport type { InfoAsset, InfoAssetTransform } from \"./types\";\nimport type { ActionAsset } from \"../action/types\";\nimport { isBackAction } from \"../action/transform\";\n\n/**\n * This transform should add segmentedActions to the info asset.\n * Segmented actions display side by side in larger viewports. Segmented Actions is an object of next and prev actions\n */\nexport const infoTransform: TransformFunction<InfoAsset, InfoAssetTransform> = (\n infoAsset,\n) => {\n const actions = infoAsset?.actions;\n const segmentedActions = actions?.reduce(\n (segmentedActionsArray, action) => {\n segmentedActionsArray[\n isBackAction(action.asset as ActionAsset) ? \"prev\" : \"next\"\n ].push(action as AssetWrapper<ActionAsset>);\n return segmentedActionsArray;\n },\n { next: [], prev: [] } as {\n /**\n * next is an array of next actions\n */\n next: Array<AssetWrapper<ActionAsset>>;\n /**\n * prev is an array of prev actions\n */\n prev: Array<AssetWrapper<ActionAsset>>;\n },\n );\n\n return {\n ...infoAsset,\n segmentedActions,\n };\n};\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type { ImageAsset, TransformedImage } from \"./types\";\n\n/**\n * Function to retrieve the desired alt text based on passed in props.\n * @param props Image props\n * @returns The alt text for the image asset\n */\nconst getImageAlt = (props: ImageAsset): string => {\n const { metaData, placeholder } = props;\n if (metaData.accessibility) return metaData.accessibility;\n\n if (placeholder) return placeholder;\n\n return \"Image\";\n};\n\n/**\n * Sets the Image's placeholder and accessibilty\n */\nexport const imageTransform: TransformFunction<ImageAsset, TransformedImage> = (\n props,\n) => {\n const altText = getImageAlt(props);\n\n const newImage = {\n ...props,\n altText,\n };\n\n return newImage;\n};\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type {\n ChoiceAsset,\n TransformedChoice,\n TransformedChoiceItem,\n} from \"./types\";\n\n/**\n * Docs about the asset transform\n */\nexport const choiceTransform: TransformFunction<\n ChoiceAsset,\n TransformedChoice\n> = (asset, options) => {\n const { items, binding, ...rest } = asset;\n\n const assetHasBinding = binding !== undefined;\n\n const currentValue = assetHasBinding\n ? options.data.model.get(binding, {\n includeInvalid: true,\n })\n : undefined;\n\n const resetValue = () => {\n if (assetHasBinding) {\n return options.data.model.set([[binding, null]]);\n }\n };\n\n const transformedChoiceItems: TransformedChoiceItem[] = (items || []).map(\n (item, index) => ({\n ...item,\n id: item.id ?? `${asset.id}-choice-${index}`,\n select() {\n if (assetHasBinding) {\n return options.data.model.set([[binding, item.value]]);\n }\n },\n unselect: resetValue,\n }),\n );\n\n return {\n ...rest,\n binding,\n clearSelection: resetValue,\n items: transformedChoiceItems,\n value: currentValue,\n validation: assetHasBinding\n ? options.validation?.get(binding, { track: true })\n : undefined,\n dataType: assetHasBinding ? options.validation?.type(binding) : undefined,\n };\n};\n","import type { Player, ExtendedPlayerPlugin } from \"@player-ui/player\";\nimport { AssetTransformPlugin } from \"@player-ui/asset-transform-plugin\";\nimport type {\n ActionAsset,\n InputAsset,\n ImageAsset,\n InfoAsset,\n TextAsset,\n CollectionAsset,\n ChoiceAsset,\n} from \"./assets\";\nimport {\n inputTransform,\n actionTransform,\n imageTransform,\n infoTransform,\n choiceTransform,\n} from \"./assets\";\n\n/**\n * A plugin to add transforms for the reference assets\n */\nexport class ReferenceAssetsPlugin\n implements\n ExtendedPlayerPlugin<\n [\n ActionAsset,\n InputAsset,\n ImageAsset,\n TextAsset,\n CollectionAsset,\n ChoiceAsset,\n ],\n [InfoAsset]\n >\n{\n name = \"reference-assets-transforms\";\n\n apply(player: Player) {\n player.registerPlugin(\n new AssetTransformPlugin([\n [{ type: \"action\" }, actionTransform],\n [{ type: \"input\" }, inputTransform],\n [{ type: \"image\" }, imageTransform],\n [{ type: \"info\" }, infoTransform],\n [{ type: \"choice\" }, choiceTransform],\n ]),\n );\n }\n}\n"],"mappings":";AAMO,IAAM,iBAAkE,CAC7E,OACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,KAAK;AACV,UAAI,MAAM,YAAY,QAAW;AAC/B,eAAO;AAAA,MACT;AAEA,aAAO,QAAQ,KAAK,OAAO,MAAM,SAAS,GAAG;AAAA,IAC/C;AAAA,IACA,IAAI,KAAK;AACP,UAAI,MAAM,YAAY,QAAW;AAC/B;AAAA,MACF;AAEA,aAAO,QAAQ,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,SAAS,GAAG,CAAC,GAAG;AAAA,QACpD,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,IACA,OACE,MAAM,YAAY,SACd,KACA,QAAQ,KAAK,MAAM,IAAI,MAAM,SAAS;AAAA,MACpC,gBAAgB;AAAA,MAChB,WAAW;AAAA,IACb,CAAC;AAAA,IACP,YACE,MAAM,YAAY,SACd,SACA,QAAQ,YAAY,IAAI,MAAM,SAAS,EAAE,OAAO,KAAK,CAAC;AAAA,IAC5D,UACE,MAAM,YAAY,SACd,SACA,QAAQ,YAAY,KAAK,MAAM,OAAO;AAAA,EAC9C;AACF;;;ACvCA,SAAS,SAAS,qBAAqB;AAMhC,SAAS,aAAa,QAA8B;AACzD,SAAO,OAAO,UAAU;AAC1B;AAKA,IAAM,YAA+D,CACnE,QACA,YACG;AACH,SAAO;AAAA,I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,OAAO,IAAI;AAAA,EAClE;AACF;;;ACrDA,SAAS,4BAA4B;AAqB9B,IAAM,wBAAN,MAaP;AAAA,EAbO;AAcL,gBAAO;AAAA;AAAA,EAEP,MAAM,QAAgB;AACpB,WAAO;AAAA,MACL,IAAI,qBAAqB;AAAA,QACvB,CAAC,EAAE,MAAM,SAAS,GAAG,eAAe;AAAA,QACpC,CAAC,EAAE,MAAM,QAAQ,GAAG,cAAc;AAAA,QAClC,CAAC,EAAE,MAAM,QAAQ,GAAG,cAAc;AAAA,QAClC,CAAC,EAAE,MAAM,OAAO,GAAG,aAAa;AAAA,QAChC,CAAC,EAAE,MAAM,SAAS,GAAG,eAAe;AAAA,MACtC,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/input/transform.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/action/transform.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/info/transform.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/image/transform.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/choice/transform.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/chat-message/transform.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/plugin.ts"],"sourcesContent":["import type { TransformFunction } from \"@player-ui/player\";\nimport type { InputAsset, TransformedInput } from \"./types\";\n\n/**\n * Docs about the asset transform\n */\nexport const inputTransform: TransformFunction<InputAsset, TransformedInput> = (\n asset,\n options,\n) => {\n return {\n ...asset,\n format(val) {\n if (asset.binding === undefined) {\n return val;\n }\n\n return options.data.format(asset.binding, val);\n },\n set(val) {\n if (asset.binding === undefined) {\n return;\n }\n\n return options.data.model.set([[asset.binding, val]], {\n formatted: true,\n });\n },\n value:\n asset.binding === undefined\n ? \"\"\n : options.data.model.get(asset.binding, {\n includeInvalid: true,\n formatted: true,\n }),\n validation:\n asset.binding === undefined\n ? undefined\n : options.validation?.get(asset.binding, { track: true }),\n dataType:\n asset.binding === undefined\n ? undefined\n : options.validation?.type(asset.binding),\n };\n};\n","import type {\n Asset,\n TransformFunction,\n BeforeTransformFunction,\n} from \"@player-ui/player\";\nimport { compose, composeBefore } from \"@player-ui/asset-transform-plugin\";\nimport type { ActionAsset, TransformedAction } from \"./types\";\n\n/**\n * Function to find prev button\n */\nexport function isBackAction(action: ActionAsset): boolean {\n return action.value === \"Prev\";\n}\n\n/**\n * Attaches the methods to execute an action to an action\n */\nconst transform: TransformFunction<ActionAsset, TransformedAction> = (\n action,\n options,\n) => {\n return {\n ...action,\n run() {\n if (action.exp) {\n options.evaluate(action.exp);\n }\n\n if (action.value) {\n const skipValidation = action.metaData?.skipValidation;\n options.transition?.(action.value, { force: skipValidation });\n }\n },\n };\n};\n\n/**\n * De couples back button from the back icon\n */\nconst backIconTransform: TransformFunction<ActionAsset, ActionAsset> = (\n action,\n) => {\n /** For previous versions of player, the back button would already have the back icon.\n * This ensures that the old functionality does not break and back button is still visible when they update the player.\n */\n if (isBackAction(action) && action?.metaData?.role === undefined) {\n return {\n ...action,\n metaData: {\n ...action?.metaData,\n role: \"back\",\n },\n };\n }\n\n return action;\n};\n\n/**\n * Appends `exp` to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist\n *\n * @param asset - Asset to apply the transform to\n */\nexport const expPropTransform: BeforeTransformFunction<Asset> = (asset) => {\n const skipArray = asset.plugins?.stringResolver?.propertiesToSkip;\n\n if (skipArray && skipArray.indexOf(\"exp\") > 1) {\n return asset;\n }\n\n return {\n ...asset,\n plugins: {\n ...asset.plugins,\n stringResolver: {\n ...asset?.plugins?.stringResolver,\n propertiesToSkip: [\n ...(asset.plugins?.stringResolver?.propertiesToSkip ?? []),\n \"exp\",\n ],\n },\n },\n };\n};\n\nexport const actionTransform = compose(\n transform,\n backIconTransform,\n composeBefore(expPropTransform),\n);\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type { AssetWrapper } from \"@player-ui/player\";\nimport type { InfoAsset, InfoAssetTransform } from \"./types\";\nimport type { ActionAsset } from \"../action/types\";\nimport { isBackAction } from \"../action/transform\";\n\n/**\n * This transform should add segmentedActions to the info asset.\n * Segmented actions display side by side in larger viewports. Segmented Actions is an object of next and prev actions\n */\nexport const infoTransform: TransformFunction<InfoAsset, InfoAssetTransform> = (\n infoAsset,\n) => {\n const actions = infoAsset?.actions;\n const segmentedActions = actions?.reduce(\n (segmentedActionsArray, action) => {\n segmentedActionsArray[\n isBackAction(action.asset as ActionAsset) ? \"prev\" : \"next\"\n ].push(action as AssetWrapper<ActionAsset>);\n return segmentedActionsArray;\n },\n { next: [], prev: [] } as {\n /**\n * next is an array of next actions\n */\n next: Array<AssetWrapper<ActionAsset>>;\n /**\n * prev is an array of prev actions\n */\n prev: Array<AssetWrapper<ActionAsset>>;\n },\n );\n\n return {\n ...infoAsset,\n segmentedActions,\n };\n};\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type { ImageAsset, TransformedImage } from \"./types\";\n\n/**\n * Function to retrieve the desired alt text based on passed in props.\n * @param props Image props\n * @returns The alt text for the image asset\n */\nconst getImageAlt = (props: ImageAsset): string => {\n const { metaData, placeholder } = props;\n if (metaData.accessibility) return metaData.accessibility;\n\n if (placeholder) return placeholder;\n\n return \"Image\";\n};\n\n/**\n * Sets the Image's placeholder and accessibilty\n */\nexport const imageTransform: TransformFunction<ImageAsset, TransformedImage> = (\n props,\n) => {\n const altText = getImageAlt(props);\n\n const newImage = {\n ...props,\n altText,\n };\n\n return newImage;\n};\n","import type { TransformFunction } from \"@player-ui/player\";\nimport type {\n ChoiceAsset,\n TransformedChoice,\n TransformedChoiceItem,\n} from \"./types\";\n\n/**\n * Docs about the asset transform\n */\nexport const choiceTransform: TransformFunction<\n ChoiceAsset,\n TransformedChoice\n> = (asset, options) => {\n const { items, binding, ...rest } = asset;\n\n const assetHasBinding = binding !== undefined;\n\n const currentValue = assetHasBinding\n ? options.data.model.get(binding, {\n includeInvalid: true,\n })\n : undefined;\n\n const resetValue = () => {\n if (assetHasBinding) {\n return options.data.model.set([[binding, null]]);\n }\n };\n\n const transformedChoiceItems: TransformedChoiceItem[] = (items || []).map(\n (item, index) => ({\n ...item,\n id: item.id ?? `${asset.id}-choice-${index}`,\n select() {\n if (assetHasBinding) {\n return options.data.model.set([[binding, item.value]]);\n }\n },\n unselect: resetValue,\n }),\n );\n\n return {\n ...rest,\n binding,\n clearSelection: resetValue,\n items: transformedChoiceItems,\n value: currentValue,\n validation: assetHasBinding\n ? options.validation?.get(binding, { track: true })\n : undefined,\n dataType: assetHasBinding ? options.validation?.type(binding) : undefined,\n };\n};\n","/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport type {\n BeforeTransformFunction,\n TransformFunctions,\n} from \"@player-ui/player\";\nimport { composeBefore, compose } from \"@player-ui/asset-transform-plugin\";\nimport { asyncTransform } from \"@player-ui/async-node-plugin\";\nimport { ChatMessageAsset } from \"./types\";\n/**\n * In beforeTransform function, pass in flatten marker and call beforeResolve function.\n * Flatten default value is true.\n * input: ChatMessageAsset\n * @param asset - Asset to apply the transform to\n * @returns - transformed asset with async node and asset node\n */\nexport const transform: BeforeTransformFunction<ChatMessageAsset> = (asset) => {\n const newAsset = asset.children?.[0]?.value;\n\n if (!newAsset) {\n return asyncTransform(asset.value.id, \"collection\");\n }\n return asyncTransform(asset.value.id, \"collection\", newAsset);\n};\n\nexport const chatMessageTransform: TransformFunctions = compose(\n composeBefore(transform),\n);\n","import type { Player, ExtendedPlayerPlugin } from \"@player-ui/player\";\nimport { AssetTransformPlugin } from \"@player-ui/asset-transform-plugin\";\nimport type {\n ActionAsset,\n InputAsset,\n ImageAsset,\n InfoAsset,\n TextAsset,\n CollectionAsset,\n ChoiceAsset,\n ChatMessageAsset,\n} from \"./assets\";\nimport {\n inputTransform,\n actionTransform,\n imageTransform,\n infoTransform,\n choiceTransform,\n chatMessageTransform,\n} from \"./assets\";\n\n/**\n * A plugin to add transforms for the reference assets\n */\nexport class ReferenceAssetsPlugin\n implements\n ExtendedPlayerPlugin<\n [\n ActionAsset,\n InputAsset,\n ImageAsset,\n TextAsset,\n CollectionAsset,\n ChoiceAsset,\n ChatMessageAsset,\n ],\n [InfoAsset]\n >\n{\n name = \"reference-assets-transforms\";\n\n apply(player: Player) {\n player.registerPlugin(\n new AssetTransformPlugin([\n [{ type: \"action\" }, actionTransform],\n [{ type: \"input\" }, inputTransform],\n [{ type: \"image\" }, imageTransform],\n [{ type: \"info\" }, infoTransform],\n [{ type: \"choice\" }, choiceTransform],\n [{ type: \"chat-message\" }, chatMessageTransform],\n ]),\n );\n }\n}\n"],"mappings":";AAMO,IAAM,iBAAkE,CAC7E,OACA,YACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,KAAK;AACV,UAAI,MAAM,YAAY,QAAW;AAC/B,eAAO;AAAA,MACT;AAEA,aAAO,QAAQ,KAAK,OAAO,MAAM,SAAS,GAAG;AAAA,IAC/C;AAAA,IACA,IAAI,KAAK;AACP,UAAI,MAAM,YAAY,QAAW;AAC/B;AAAA,MACF;AAEA,aAAO,QAAQ,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,SAAS,GAAG,CAAC,GAAG;AAAA,QACpD,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,IACA,OACE,MAAM,YAAY,SACd,KACA,QAAQ,KAAK,MAAM,IAAI,MAAM,SAAS;AAAA,MACpC,gBAAgB;AAAA,MAChB,WAAW;AAAA,IACb,CAAC;AAAA,IACP,YACE,MAAM,YAAY,SACd,SACA,QAAQ,YAAY,IAAI,MAAM,SAAS,EAAE,OAAO,KAAK,CAAC;AAAA,IAC5D,UACE,MAA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AO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP,OAAO;AAAA,IACP,YAAY,kBACR,QAAQ,YAAY,IAAI,SAAS,EAAE,OAAO,KAAK,CAAC,IAChD;AAAA,IACJ,UAAU,kBAAkB,QAAQ,YAAY,KAAK,OAAO,IAAI;AAAA,EAClE;AACF;;;ACjDA,SAAS,iBAAAA,gBAAe,WAAAC,gBAAe;AACvC,SAAS,sBAAsB;AASxB,IAAMC,aAAuD,CAAC,UAAU;AAC7E,QAAM,WAAW,MAAM,WAAW,CAAC,GAAG;AAEtC,MAAI,CAAC,UAAU;AACb,WAAO,eAAe,MAAM,MAAM,IAAI,YAAY;AAAA,EACpD;AACA,SAAO,eAAe,MAAM,MAAM,IAAI,cAAc,QAAQ;AAC9D;AAEO,IAAM,uBAA2CD;AAAA,EACtDD,eAAcE,UAAS;AACzB;;;ACzBA,SAAS,4BAA4B;AAuB9B,IAAM,wBAAN,MAcP;AAAA,EAdO;AAeL,gBAAO;AAAA;AAAA,EAEP,MAAM,QAAgB;AACpB,WAAO;AAAA,MACL,IAAI,qBAAqB;AAAA,QACvB,CAAC,EAAE,MAAM,SAAS,GAAG,eAAe;AAAA,QACpC,CAAC,EAAE,MAAM,QAAQ,GAAG,cAAc;AAAA,QAClC,CAAC,EAAE,MAAM,QAAQ,GAAG,cAAc;AAAA,QAClC,CAAC,EAAE,MAAM,OAAO,GAAG,aAAa;AAAA,QAChC,CAAC,EAAE,MAAM,SAAS,GAAG,eAAe;AAAA,QACpC,CAAC,EAAE,MAAM,eAAe,GAAG,oBAAoB;AAAA,MACjD,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["composeBefore","compose","transform"]}
@@ -1,5 +1,5 @@
1
1
  {
2
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/action/types.ts",
2
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/action/types.ts",
3
3
  "name": "ActionAsset",
4
4
  "type": "object",
5
5
  "properties": {
@@ -51,7 +51,7 @@
51
51
  "beacon": {
52
52
  "required": false,
53
53
  "node": {
54
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+beacon-plugin@0.0.0/node_modules/@player-ui/beacon-plugin/types/beacon.d.ts",
54
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+beacon-plugin@0.0.0/node_modules/@player-ui/beacon-plugin/types/beacon.d.ts",
55
55
  "name": "BeaconDataType",
56
56
  "type": "or",
57
57
  "or": [
@@ -0,0 +1,27 @@
1
+ {
2
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/chat-message/types.ts",
3
+ "name": "ChatMessageAsset",
4
+ "type": "object",
5
+ "properties": {
6
+ "value": {
7
+ "required": false,
8
+ "node": {
9
+ "type": "ref",
10
+ "ref": "AssetWrapper",
11
+ "title": "ChatMessageAsset.value"
12
+ }
13
+ }
14
+ },
15
+ "additionalProperties": false,
16
+ "title": "ChatMessageAsset",
17
+ "extends": {
18
+ "type": "ref",
19
+ "ref": "Asset<\"chat-message\">",
20
+ "genericArguments": [
21
+ {
22
+ "type": "string",
23
+ "const": "chat-message"
24
+ }
25
+ ]
26
+ }
27
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/choice/types.ts",
2
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/choice/types.ts",
3
3
  "name": "ChoiceAsset",
4
4
  "type": "object",
5
5
  "properties": {
@@ -47,7 +47,7 @@
47
47
  "node": {
48
48
  "type": "array",
49
49
  "elementType": {
50
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/choice/types.ts",
50
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/choice/types.ts",
51
51
  "name": "ChoiceItem",
52
52
  "type": "object",
53
53
  "properties": {
@@ -77,7 +77,7 @@
77
77
  "value": {
78
78
  "required": false,
79
79
  "node": {
80
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/choice/types.ts",
80
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/choice/types.ts",
81
81
  "name": "ValueType",
82
82
  "type": "or",
83
83
  "or": [
@@ -125,14 +125,14 @@
125
125
  "metaData": {
126
126
  "required": false,
127
127
  "node": {
128
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+beacon-plugin@0.0.0/node_modules/@player-ui/beacon-plugin/types/beacon.d.ts",
128
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+beacon-plugin@0.0.0/node_modules/@player-ui/beacon-plugin/types/beacon.d.ts",
129
129
  "name": "BeaconMetaData",
130
130
  "type": "object",
131
131
  "properties": {
132
132
  "beacon": {
133
133
  "required": false,
134
134
  "node": {
135
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+beacon-plugin@0.0.0/node_modules/@player-ui/beacon-plugin/types/beacon.d.ts",
135
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+beacon-plugin@0.0.0/node_modules/@player-ui/beacon-plugin/types/beacon.d.ts",
136
136
  "name": "BeaconDataType",
137
137
  "type": "or",
138
138
  "or": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/collection/types.ts",
2
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/collection/types.ts",
3
3
  "name": "CollectionAsset",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,12 +1,12 @@
1
1
  {
2
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/image/types.ts",
2
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/image/types.ts",
3
3
  "name": "ImageAsset",
4
4
  "type": "object",
5
5
  "properties": {
6
6
  "metaData": {
7
7
  "required": true,
8
8
  "node": {
9
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/image/types.ts",
9
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/image/types.ts",
10
10
  "name": "ImageMetaData",
11
11
  "type": "object",
12
12
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/info/types.ts",
2
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/info/types.ts",
3
3
  "name": "InfoAsset",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/input/types.ts",
2
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/input/types.ts",
3
3
  "name": "InputAsset",
4
4
  "type": "object",
5
5
  "properties": {
@@ -50,7 +50,7 @@
50
50
  "beacon": {
51
51
  "required": false,
52
52
  "node": {
53
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+beacon-plugin@0.0.0/node_modules/@player-ui/beacon-plugin/types/beacon.d.ts",
53
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+beacon-plugin@0.0.0/node_modules/@player-ui/beacon-plugin/types/beacon.d.ts",
54
54
  "name": "BeaconDataType",
55
55
  "type": "or",
56
56
  "or": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/text/types.ts",
2
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/text/types.ts",
3
3
  "name": "TextAsset",
4
4
  "type": "object",
5
5
  "properties": {
@@ -16,12 +16,12 @@
16
16
  "node": {
17
17
  "type": "array",
18
18
  "elementType": {
19
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/text/types.ts",
19
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/text/types.ts",
20
20
  "name": "TextModifier",
21
21
  "type": "or",
22
22
  "or": [
23
23
  {
24
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/text/types.ts",
24
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/text/types.ts",
25
25
  "name": "BasicTextModifier",
26
26
  "type": "object",
27
27
  "properties": {
@@ -48,7 +48,7 @@
48
48
  "title": "BasicTextModifier"
49
49
  },
50
50
  {
51
- "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2162/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/text/types.ts",
51
+ "source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2192/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/text/types.ts",
52
52
  "name": "LinkModifier",
53
53
  "type": "object",
54
54
  "properties": {
@@ -4,12 +4,13 @@ const ImageAsset = require("./ImageAsset.json")
4
4
  const TextAsset = require("./TextAsset.json")
5
5
  const CollectionAsset = require("./CollectionAsset.json")
6
6
  const ChoiceAsset = require("./ChoiceAsset.json")
7
+ const ChatMessageAsset = require("./ChatMessageAsset.json")
7
8
  const InfoAsset = require("./InfoAsset.json")
8
9
 
9
10
  module.exports = {
10
11
  "pluginName": "reference-assets-transforms",
11
12
  "capabilities": {
12
- "Assets":[ActionAsset,InputAsset,ImageAsset,TextAsset,CollectionAsset,ChoiceAsset],
13
+ "Assets":[ActionAsset,InputAsset,ImageAsset,TextAsset,CollectionAsset,ChoiceAsset,ChatMessageAsset],
13
14
  "Views":[InfoAsset],
14
15
  },
15
16
  "customPrimitives": [
@@ -7,7 +7,8 @@
7
7
  "ImageAsset",
8
8
  "TextAsset",
9
9
  "CollectionAsset",
10
- "ChoiceAsset"
10
+ "ChoiceAsset",
11
+ "ChatMessageAsset"
11
12
  ],
12
13
  "Views": [
13
14
  "InfoAsset"
package/package.json CHANGED
@@ -6,11 +6,12 @@
6
6
  "types"
7
7
  ],
8
8
  "name": "@player-ui/reference-assets-plugin",
9
- "version": "0.10.4-next.2",
9
+ "version": "0.10.4",
10
10
  "main": "dist/cjs/index.cjs",
11
11
  "dependencies": {
12
- "@player-ui/asset-transform-plugin": "0.10.4-next.2",
13
- "@player-ui/beacon-plugin": "0.10.4-next.2",
12
+ "@player-ui/asset-transform-plugin": "0.10.4",
13
+ "@player-ui/beacon-plugin": "0.10.4",
14
+ "@player-ui/async-node-plugin": "0.10.4",
14
15
  "tslib": "^2.6.2"
15
16
  },
16
17
  "devDependencies": {
@@ -18,7 +19,7 @@
18
19
  "@player-ui/common-types-plugin": "workspace:*"
19
20
  },
20
21
  "peerDependencies": {
21
- "@player-ui/player": "0.10.4-next.2"
22
+ "@player-ui/player": "0.10.4"
22
23
  },
23
24
  "module": "dist/index.legacy-esm.js",
24
25
  "types": "types/index.d.ts",
@@ -0,0 +1,61 @@
1
+ import { describe, it, expect, vitest } from "vitest";
2
+ import { runTransform } from "@player-ui/asset-testing-library";
3
+ import { chatMessageTransform } from "..";
4
+ import {
5
+ AsyncNodePlugin,
6
+ AsyncNodePluginPlugin,
7
+ } from "@player-ui/async-node-plugin";
8
+ import { waitFor } from "@testing-library/react";
9
+
10
+ describe("chatMessage transform", () => {
11
+ it("generates a new multi-node with async node placeholder", async () => {
12
+ const plugin = new AsyncNodePlugin({
13
+ plugins: [new AsyncNodePluginPlugin()],
14
+ });
15
+
16
+ const test = vitest.fn();
17
+
18
+ plugin.hooks.onAsyncNode.tap("test", async (node) => test());
19
+
20
+ const ref = runTransform(
21
+ "chat-message",
22
+ chatMessageTransform,
23
+ {
24
+ type: "chat-message",
25
+ id: "1",
26
+ value: {
27
+ asset: {
28
+ id: "1",
29
+ type: "text",
30
+ value: "chat message",
31
+ },
32
+ },
33
+ },
34
+ [plugin],
35
+ );
36
+
37
+ /**
38
+ * Check if async node exists in ASTMap after transform and resolve
39
+ * onAsyncNode hook is only called when there is async node
40
+ */
41
+ await waitFor(() => {
42
+ expect(test).toBeCalled();
43
+ });
44
+
45
+ expect(ref.current).toMatchObject({
46
+ id: expect.any(String),
47
+ type: "collection",
48
+ values: [
49
+ {
50
+ asset: {
51
+ id: "1",
52
+ type: "text",
53
+ value: "chat message",
54
+ },
55
+ },
56
+ ],
57
+ });
58
+
59
+ expect(test).toHaveBeenCalled();
60
+ });
61
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./transform";
2
+ export * from "./types";
@@ -0,0 +1,27 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
2
+ import type {
3
+ BeforeTransformFunction,
4
+ TransformFunctions,
5
+ } from "@player-ui/player";
6
+ import { composeBefore, compose } from "@player-ui/asset-transform-plugin";
7
+ import { asyncTransform } from "@player-ui/async-node-plugin";
8
+ import { ChatMessageAsset } from "./types";
9
+ /**
10
+ * In beforeTransform function, pass in flatten marker and call beforeResolve function.
11
+ * Flatten default value is true.
12
+ * input: ChatMessageAsset
13
+ * @param asset - Asset to apply the transform to
14
+ * @returns - transformed asset with async node and asset node
15
+ */
16
+ export const transform: BeforeTransformFunction<ChatMessageAsset> = (asset) => {
17
+ const newAsset = asset.children?.[0]?.value;
18
+
19
+ if (!newAsset) {
20
+ return asyncTransform(asset.value.id, "collection");
21
+ }
22
+ return asyncTransform(asset.value.id, "collection", newAsset);
23
+ };
24
+
25
+ export const chatMessageTransform: TransformFunctions = compose(
26
+ composeBefore(transform),
27
+ );