import { ConfigPlugin } from "@expo/config-plugins" ; import { Props , Sticker , withStickerAssets } from "./withStickerAssets" ; import { withStickersPlist } from "./withStickerInfoPlist" ; import { withStickerXcodeTarget } from "./withStickerXcodeTarget" ; import path from "path" ; const sizeColumnMap = { 4 : "small" , 3 : "regular" , 2 : "large" , } ; export function normalizeStickersProps ( props = [ ] ) { const imagesObj = props . map ( ( prop ) => { if ( typeof prop === "string" ) { return { image : prop } ; } return prop ; } ) ; return imagesObj . map ( ( sticker ) => { sticker . name = sticker . name || path . basename ( sticker . image , path . extname ( sticker . image ) ) ; return sticker ; } ) ; } const withStickerPack = ( config , { stickers , icon , name , columns = 3 } = { } ) => { const size = sizeColumnMap [ columns ] || "regular" ; if ( ! size ) { throw new Error ( `Column size "${ columns }" is invalid. Expected one of: ${ Object . keys ( sizeColumnMap ) . join ( ", " ) }` ) ; } const _stickers = normalizeStickersProps ( stickers ) ; config = withStickersPlist ( config , { name } ) ; config = withStickerAssets ( config , { stickers : _stickers , icon , size } ) ; config = withStickerXcodeTarget ( config ) ; return config ; } ; export default withStickerPack ;