@sparted/shared-library 1.1.6 → 1.1.8

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.
@@ -58,18 +58,19 @@ export type PictureSpot = {
58
58
  description: MultilingualLabel;
59
59
  }[];
60
60
  };
61
+ export type SwipingCardPosition = 'left' | 'right' | 'top' | 'bottom';
61
62
  export type SwipingCards = {
62
63
  type: 'swiping-cards';
63
64
  explanation?: MultilingualLabel;
64
65
  question?: MultilingualLabel;
65
66
  zones?: {
66
- position: 'left' | 'right' | 'top' | 'bottom';
67
+ position: SwipingCardPosition;
67
68
  text: MultilingualLabel;
68
69
  }[];
69
70
  cards?: {
70
71
  image?: Image;
71
72
  text?: MultilingualLabel;
72
- answer: 'left' | 'right' | 'top' | 'bottom';
73
+ answer: SwipingCardPosition;
73
74
  }[];
74
75
  };
75
76
  export type Game = ErrorText | MultipleChoiceQuestion | NoInteraction | OpenQuestion | OrderingCards | PictureSpot | SwipingCards;
@@ -1005,7 +1006,7 @@ export declare const isPartialGameSwipingCards: (game: DeepPartial<Game>) => gam
1005
1006
  "th-TH"?: string | undefined;
1006
1007
  } | undefined;
1007
1008
  zones?: ({
1008
- position?: "left" | "right" | "top" | "bottom" | undefined;
1009
+ position?: SwipingCardPosition | undefined;
1009
1010
  text?: {
1010
1011
  sk?: string | undefined;
1011
1012
  sl?: string | undefined;
@@ -1087,6 +1088,6 @@ export declare const isPartialGameSwipingCards: (game: DeepPartial<Game>) => gam
1087
1088
  "lv-LV"?: string | undefined;
1088
1089
  "th-TH"?: string | undefined;
1089
1090
  } | undefined;
1090
- answer?: "left" | "right" | "top" | "bottom" | undefined;
1091
+ answer?: SwipingCardPosition | undefined;
1091
1092
  } | undefined)[] | undefined;
1092
1093
  };
@@ -1 +1 @@
1
- {"version":3,"file":"content.js","sources":["../../../src/business/types/content.ts"],"sourcesContent":["import { DeepPartial } from 'ts-essentials';\n\nimport { LanguageCode, MultilingualLabel } from './multilingual';\nimport { Image, Media } from './media';\nimport { Thematic } from './thematic';\n\nexport type ErrorText = {\n type: 'error-text';\n gameMedia?: Media;\n explanationMedia?: Media;\n explanation?: MultilingualLabel;\n wrongText?: MultilingualLabel;\n correctText?: MultilingualLabel;\n};\n\nexport type MultipleChoiceQuestion = {\n type: 'mcq';\n gameMedia?: Media;\n question?: MultilingualLabel;\n explanation?: MultilingualLabel;\n explanationMedia?: Media;\n multiselect?: boolean;\n choices?: {\n correct: boolean;\n text: MultilingualLabel;\n }[];\n};\n\nexport type NoInteraction = {\n type: 'no-interaction';\n firstMedia?: Media;\n secondMedia?: Media;\n title?: MultilingualLabel;\n text?: MultilingualLabel;\n};\n\nexport type OpenQuestion = {\n type: 'open-question';\n gameMedia?: Media;\n question?: MultilingualLabel;\n answer?: MultilingualLabel;\n explanation?: MultilingualLabel;\n explanationMedia?: Media;\n levenshteinDistance?: number;\n};\n\nexport type OrderingCards = {\n type: 'ordering-cards';\n explanation?: MultilingualLabel;\n question?: MultilingualLabel;\n topLabel?: MultilingualLabel;\n bottomLabel?: MultilingualLabel;\n cards: MultilingualLabel[];\n};\n\nexport type PictureSpot = {\n type: 'picture-spot';\n image?: Image;\n explanation?: MultilingualLabel;\n items?: {\n x: number;\n y: number;\n r: number;\n question: MultilingualLabel;\n description: MultilingualLabel;\n }[];\n};\n\nexport type SwipingCards = {\n type: 'swiping-cards';\n explanation?: MultilingualLabel;\n question?: MultilingualLabel;\n zones?: {\n position: 'left' | 'right' | 'top' | 'bottom';\n text: MultilingualLabel;\n }[];\n cards?: {\n image?: Image;\n text?: MultilingualLabel;\n answer: 'left' | 'right' | 'top' | 'bottom';\n }[];\n};\n\nexport type Game =\n | ErrorText\n | MultipleChoiceQuestion\n | NoInteraction\n | OpenQuestion\n | OrderingCards\n | PictureSpot\n | SwipingCards;\n\nexport type GameType =\n | 'error-text'\n | 'mcq'\n | 'open-question'\n | 'no-interaction'\n | 'picture-spot'\n | 'swiping-cards'\n | 'ordering-cards';\n\nexport const GAME_TYPE: Record<string, GameType> = {\n MCQ: 'mcq',\n ERROR_TEXT: 'error-text',\n OPEN_QUESTION: 'open-question',\n NO_INTERACTION: 'no-interaction',\n PICTURE_SPOT: 'picture-spot',\n ORDERING_CARDS: 'ordering-cards',\n SWIPING_CARDS: 'swiping-cards',\n};\n\nexport type ContentStatuses = Partial<{\n [languageCode in LanguageCode]: 'draft' | 'validated' | 'waiting-translation' | 'waiting-validation';\n}>;\n\nexport type Content = {\n archived: boolean;\n id: number;\n metadata: {\n coverImage: Image;\n identifier?: string;\n name: MultilingualLabel;\n thematic: Thematic;\n explanation?: string;\n knowMore?: string;\n };\n statuses: ContentStatuses;\n game?: Game;\n};\n\nexport const isGameMultipleChoiceQuestion = (game: Game): game is MultipleChoiceQuestion => game.type === GAME_TYPE.MCQ;\nexport const isGameErrorText = (game: Game): game is ErrorText => game.type === GAME_TYPE.ERROR_TEXT;\nexport const isGameOpenQuestion = (game: Game): game is OpenQuestion => game.type === GAME_TYPE.OPEN_QUESTION;\nexport const isGameNoInteraction = (game: Game): game is NoInteraction => game.type === GAME_TYPE.NO_INTERACTION;\nexport const isGamePictureSpot = (game: Game): game is PictureSpot => game.type === GAME_TYPE.PICTURE_SPOT;\nexport const isGameOrderingCards = (game: Game): game is OrderingCards => game.type === GAME_TYPE.ORDERING_CARDS;\nexport const isGameSwipingCards = (game: Game): game is SwipingCards => game.type === GAME_TYPE.SWIPING_CARDS;\n\nexport const isPartialGameMultipleChoiceQuestion = (\n game: DeepPartial<Game>,\n): game is DeepPartial<MultipleChoiceQuestion> => game.type === GAME_TYPE.MCQ;\nexport const isPartialGameErrorText = (game: DeepPartial<Game>): game is DeepPartial<ErrorText> =>\n game.type === GAME_TYPE.ERROR_TEXT;\nexport const isPartialGameOpenQuestion = (game: DeepPartial<Game>): game is DeepPartial<OpenQuestion> =>\n game.type === GAME_TYPE.OPEN_QUESTION;\nexport const isPartialGameNoInteraction = (game: DeepPartial<Game>): game is DeepPartial<NoInteraction> =>\n game.type === GAME_TYPE.NO_INTERACTION;\nexport const isPartialGamePictureSpot = (game: DeepPartial<Game>): game is DeepPartial<PictureSpot> =>\n game.type === GAME_TYPE.PICTURE_SPOT;\nexport const isPartialGameOrderingCards = (game: DeepPartial<Game>): game is DeepPartial<OrderingCards> =>\n game.type === GAME_TYPE.ORDERING_CARDS;\nexport const isPartialGameSwipingCards = (game: DeepPartial<Game>): game is DeepPartial<SwipingCards> =>\n game.type === GAME_TYPE.SWIPING_CARDS;\n"],"names":[],"mappings":";;;;AAqGa,MAAA,SAAS,GAA6B;AACjD,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,aAAa,EAAE,eAAe;AAC9B,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,aAAa,EAAE,eAAe;EAC9B;AAqBW,MAAA,4BAA4B,GAAG,CAAC,IAAU,KAAqC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI;AAC3G,MAAA,eAAe,GAAG,CAAC,IAAU,KAAwB,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,WAAW;AACxF,MAAA,kBAAkB,GAAG,CAAC,IAAU,KAA2B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,cAAc;AACjG,MAAA,mBAAmB,GAAG,CAAC,IAAU,KAA4B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,eAAe;AACpG,MAAA,iBAAiB,GAAG,CAAC,IAAU,KAA0B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,aAAa;AAC9F,MAAA,mBAAmB,GAAG,CAAC,IAAU,KAA4B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,eAAe;AACpG,MAAA,kBAAkB,GAAG,CAAC,IAAU,KAA2B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,cAAc;AAEjG,MAAA,mCAAmC,GAAG,CACjD,IAAuB,KACyB,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI;AACjE,MAAA,sBAAsB,GAAG,CAAC,IAAuB,KAC5D,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,WAAW;AACxB,MAAA,yBAAyB,GAAG,CAAC,IAAuB,KAC/D,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,cAAc;AAC3B,MAAA,0BAA0B,GAAG,CAAC,IAAuB,KAChE,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,eAAe;AAC5B,MAAA,wBAAwB,GAAG,CAAC,IAAuB,KAC9D,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,aAAa;AAC1B,MAAA,0BAA0B,GAAG,CAAC,IAAuB,KAChE,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,eAAe;AAC5B,MAAA,yBAAyB,GAAG,CAAC,IAAuB,KAC/D,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"content.js","sources":["../../../src/business/types/content.ts"],"sourcesContent":["import { DeepPartial } from 'ts-essentials';\n\nimport { LanguageCode, MultilingualLabel } from './multilingual';\nimport { Image, Media } from './media';\nimport { Thematic } from './thematic';\n\nexport type ErrorText = {\n type: 'error-text';\n gameMedia?: Media;\n explanationMedia?: Media;\n explanation?: MultilingualLabel;\n wrongText?: MultilingualLabel;\n correctText?: MultilingualLabel;\n};\n\nexport type MultipleChoiceQuestion = {\n type: 'mcq';\n gameMedia?: Media;\n question?: MultilingualLabel;\n explanation?: MultilingualLabel;\n explanationMedia?: Media;\n multiselect?: boolean;\n choices?: {\n correct: boolean;\n text: MultilingualLabel;\n }[];\n};\n\nexport type NoInteraction = {\n type: 'no-interaction';\n firstMedia?: Media;\n secondMedia?: Media;\n title?: MultilingualLabel;\n text?: MultilingualLabel;\n};\n\nexport type OpenQuestion = {\n type: 'open-question';\n gameMedia?: Media;\n question?: MultilingualLabel;\n answer?: MultilingualLabel;\n explanation?: MultilingualLabel;\n explanationMedia?: Media;\n levenshteinDistance?: number;\n};\n\nexport type OrderingCards = {\n type: 'ordering-cards';\n explanation?: MultilingualLabel;\n question?: MultilingualLabel;\n topLabel?: MultilingualLabel;\n bottomLabel?: MultilingualLabel;\n cards: MultilingualLabel[];\n};\n\nexport type PictureSpot = {\n type: 'picture-spot';\n image?: Image;\n explanation?: MultilingualLabel;\n items?: {\n x: number;\n y: number;\n r: number;\n question: MultilingualLabel;\n description: MultilingualLabel;\n }[];\n};\n\nexport type SwipingCardPosition = 'left' | 'right' | 'top' | 'bottom';\n\nexport type SwipingCards = {\n type: 'swiping-cards';\n explanation?: MultilingualLabel;\n question?: MultilingualLabel;\n zones?: {\n position: SwipingCardPosition;\n text: MultilingualLabel;\n }[];\n cards?: {\n image?: Image;\n text?: MultilingualLabel;\n answer: SwipingCardPosition;\n }[];\n};\n\nexport type Game =\n | ErrorText\n | MultipleChoiceQuestion\n | NoInteraction\n | OpenQuestion\n | OrderingCards\n | PictureSpot\n | SwipingCards;\n\nexport type GameType =\n | 'error-text'\n | 'mcq'\n | 'open-question'\n | 'no-interaction'\n | 'picture-spot'\n | 'swiping-cards'\n | 'ordering-cards';\n\nexport const GAME_TYPE: Record<string, GameType> = {\n MCQ: 'mcq',\n ERROR_TEXT: 'error-text',\n OPEN_QUESTION: 'open-question',\n NO_INTERACTION: 'no-interaction',\n PICTURE_SPOT: 'picture-spot',\n ORDERING_CARDS: 'ordering-cards',\n SWIPING_CARDS: 'swiping-cards',\n};\n\nexport type ContentStatuses = Partial<{\n [languageCode in LanguageCode]: 'draft' | 'validated' | 'waiting-translation' | 'waiting-validation';\n}>;\n\nexport type Content = {\n archived: boolean;\n id: number;\n metadata: {\n coverImage: Image;\n identifier?: string;\n name: MultilingualLabel;\n thematic: Thematic;\n explanation?: string;\n knowMore?: string;\n };\n statuses: ContentStatuses;\n game?: Game;\n};\n\nexport const isGameMultipleChoiceQuestion = (game: Game): game is MultipleChoiceQuestion => game.type === GAME_TYPE.MCQ;\nexport const isGameErrorText = (game: Game): game is ErrorText => game.type === GAME_TYPE.ERROR_TEXT;\nexport const isGameOpenQuestion = (game: Game): game is OpenQuestion => game.type === GAME_TYPE.OPEN_QUESTION;\nexport const isGameNoInteraction = (game: Game): game is NoInteraction => game.type === GAME_TYPE.NO_INTERACTION;\nexport const isGamePictureSpot = (game: Game): game is PictureSpot => game.type === GAME_TYPE.PICTURE_SPOT;\nexport const isGameOrderingCards = (game: Game): game is OrderingCards => game.type === GAME_TYPE.ORDERING_CARDS;\nexport const isGameSwipingCards = (game: Game): game is SwipingCards => game.type === GAME_TYPE.SWIPING_CARDS;\n\nexport const isPartialGameMultipleChoiceQuestion = (\n game: DeepPartial<Game>,\n): game is DeepPartial<MultipleChoiceQuestion> => game.type === GAME_TYPE.MCQ;\nexport const isPartialGameErrorText = (game: DeepPartial<Game>): game is DeepPartial<ErrorText> =>\n game.type === GAME_TYPE.ERROR_TEXT;\nexport const isPartialGameOpenQuestion = (game: DeepPartial<Game>): game is DeepPartial<OpenQuestion> =>\n game.type === GAME_TYPE.OPEN_QUESTION;\nexport const isPartialGameNoInteraction = (game: DeepPartial<Game>): game is DeepPartial<NoInteraction> =>\n game.type === GAME_TYPE.NO_INTERACTION;\nexport const isPartialGamePictureSpot = (game: DeepPartial<Game>): game is DeepPartial<PictureSpot> =>\n game.type === GAME_TYPE.PICTURE_SPOT;\nexport const isPartialGameOrderingCards = (game: DeepPartial<Game>): game is DeepPartial<OrderingCards> =>\n game.type === GAME_TYPE.ORDERING_CARDS;\nexport const isPartialGameSwipingCards = (game: DeepPartial<Game>): game is DeepPartial<SwipingCards> =>\n game.type === GAME_TYPE.SWIPING_CARDS;\n"],"names":[],"mappings":";;;;AAuGa,MAAA,SAAS,GAA6B;AACjD,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,aAAa,EAAE,eAAe;AAC9B,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,YAAY,EAAE,cAA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MAAA,yBAAyB,GAAG,CAAC,IAAuB,KAC/D,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;;;;;;;;;;;;;;;;;;"}
@@ -20,7 +20,7 @@ const imgixTransformationQueries = ({ fit, width, height, quality, compress = tr
20
20
  return searchParams ? `${searchParams}` : '';
21
21
  };
22
22
  const twicpicsTransformationQueries = (params) => {
23
- const quality = params.quality || 90;
23
+ const quality = params.quality || 70;
24
24
  const transformations = [['quality', quality]];
25
25
  const dpr = params.devicePixelRatio || 1;
26
26
  const width = params.width ? Math.round(params.width * dpr) : '-';
@@ -1 +1 @@
1
- {"version":3,"file":"cdn.factory.js","sources":["../../src/cdn/cdn.factory.ts"],"sourcesContent":["import { buildSearchParams } from '../http/build-search-params';\nimport type { CdnConfig, CdnType, TransformationQueries, TwicpicsTransformationChain } from './types';\nimport { getCdnFromS3UrlFactory } from './utils/get-cdn-from-s3-url.util';\nimport { getCdnUrlFactory } from './utils/get-cdn-url.util';\nimport { twicpicsTransformationChainToString } from './utils/twicpics-transformations.util';\n\nexport const imgixTransformationQueries: TransformationQueries = ({\n fit,\n width,\n height,\n quality,\n compress = true,\n devicePixelRatio,\n}) => {\n const params = {\n auto: compress ? 'compress,format' : undefined,\n fit: fit === 'crop' ? 'crop' : undefined,\n dpr: Number.isFinite(devicePixelRatio) ? devicePixelRatio : undefined,\n h: Number.isFinite(height) ? height : undefined,\n w: Number.isFinite(width) ? width : undefined,\n q: quality !== undefined && quality >= 0 && quality <= 100 ? quality : undefined,\n };\n const searchParams = buildSearchParams(params).toString();\n\n return searchParams ? `${searchParams}` : '';\n};\n\nexport const twicpicsTransformationQueries: TransformationQueries = (params) => {\n const quality = params.quality || 90;\n const transformations: TwicpicsTransformationChain = [['quality', quality]];\n const dpr = params.devicePixelRatio || 1;\n\n const width = params.width ? Math.round(params.width * dpr) : '-';\n const height = params.height ? Math.round(params.height * dpr) : '-';\n const fit = params.fit || 'cover';\n\n if (params.width !== undefined || params.height !== undefined) {\n transformations.push([fit, `${width}x${height}`]);\n }\n\n if (params.output !== undefined) {\n transformations.push(['output', params.output]);\n }\n\n return twicpicsTransformationChainToString(transformations);\n};\n\n/**\n *\n * @param type cdn provider: 'twicpics' | 'imgix'\n * @param domain provider domain\n * @param instanceMapper domain + the result of the instanceMapper will form the base path\n * @param cacheVersion\n * @returns \\{ getCdnUrl, transformationQueries \\}\n */\nexport const createCdn = <T extends CdnType>({ type, domain, instanceMapper, cacheVersion }: CdnConfig<T>) => {\n const getCdnUrl = getCdnUrlFactory({\n domain,\n instanceMapper,\n transformationQueries: type === 'imgix' ? imgixTransformationQueries : twicpicsTransformationQueries,\n cacheVersion,\n });\n\n return {\n getCdnUrl,\n getCdnFromS3Url: getCdnFromS3UrlFactory({\n getCdnUrl,\n }),\n };\n};\n"],"names":["buildSearchParams","twicpicsTransformationChainToString","getCdnUrlFactory","getCdnFromS3UrlFactory"],"mappings":";;;;;;;;;MAMa,0BAA0B,GAA0B,CAAC,EAChE,GAAG,EACH,KAAK,EACL,MAAM,EACN,OAAO,EACP,QAAQ,GAAG,IAAI,EACf,gBAAgB,GACjB,KAAI;AACH,IAAA,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,QAAQ,GAAG,iBAAiB,GAAG,SAAS;QAC9C,GAAG,EAAE,GAAG,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS;AACxC,QAAA,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,GAAG,SAAS;AACrE,QAAA,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS;AAC/C,QAAA,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,SAAS;AAC7C,QAAA,CAAC,EAAE,OAAO,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,IAAI,GAAG,GAAG,OAAO,GAAG,SAAS;KACjF,CAAC;IACF,MAAM,Y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,MAAM,EAAE,cAAc,EAAE,YAAY,EAAgB,KAAI;IAC3G,MAAM,SAAS,GAAGC,+BAAgB,CAAC;QACjC,MAAM;QACN,cAAc;QACd,qBAAqB,EAAE,IAAI,KAAK,OAAO,GAAG,0BAA0B,GAAG,6BAA6B;QACpG,YAAY;AACb,KAAA,CAAC,CAAC;IAEH,OAAO;QACL,SAAS;QACT,eAAe,EAAEC,2CAAsB,CAAC;YACtC,SAAS;SACV,CAAC;KACH,CAAC;AACJ;;;;;;"}
1
+ {"version":3,"file":"cdn.factory.js","sources":["../../src/cdn/cdn.factory.ts"],"sourcesContent":["import { buildSearchParams } from '../http/build-search-params';\nimport type { CdnConfig, CdnType, TransformationQueries, TwicpicsTransformationChain } from './types';\nimport { getCdnFromS3UrlFactory } from './utils/get-cdn-from-s3-url.util';\nimport { getCdnUrlFactory } from './utils/get-cdn-url.util';\nimport { twicpicsTransformationChainToString } from './utils/twicpics-transformations.util';\n\nexport const imgixTransformationQueries: TransformationQueries = ({\n fit,\n width,\n height,\n quality,\n compress = true,\n devicePixelRatio,\n}) => {\n const params = {\n auto: compress ? 'compress,format' : undefined,\n fit: fit === 'crop' ? 'crop' : undefined,\n dpr: Number.isFinite(devicePixelRatio) ? devicePixelRatio : undefined,\n h: Number.isFinite(height) ? height : undefined,\n w: Number.isFinite(width) ? width : undefined,\n q: quality !== undefined && quality >= 0 && quality <= 100 ? quality : undefined,\n };\n const searchParams = buildSearchParams(params).toString();\n\n return searchParams ? `${searchParams}` : '';\n};\n\nexport const twicpicsTransformationQueries: TransformationQueries = (params) => {\n const quality = params.quality || 70;\n const transformations: TwicpicsTransformationChain = [['quality', quality]];\n const dpr = params.devicePixelRatio || 1;\n\n const width = params.width ? Math.round(params.width * dpr) : '-';\n const height = params.height ? Math.round(params.height * dpr) : '-';\n const fit = params.fit || 'cover';\n\n if (params.width !== undefined || params.height !== undefined) {\n transformations.push([fit, `${width}x${height}`]);\n }\n\n if (params.output !== undefined) {\n transformations.push(['output', params.output]);\n }\n\n return twicpicsTransformationChainToString(transformations);\n};\n\n/**\n *\n * @param type cdn provider: 'twicpics' | 'imgix'\n * @param domain provider domain\n * @param instanceMapper domain + the result of the instanceMapper will form the base path\n * @param cacheVersion\n * @returns \\{ getCdnUrl, transformationQueries \\}\n */\nexport const createCdn = <T extends CdnType>({ type, domain, instanceMapper, cacheVersion }: CdnConfig<T>) => {\n const getCdnUrl = getCdnUrlFactory({\n domain,\n instanceMapper,\n transformationQueries: type === 'imgix' ? imgixTransformationQueries : twicpicsTransformationQueries,\n cacheVersion,\n });\n\n return {\n getCdnUrl,\n getCdnFromS3Url: getCdnFromS3UrlFactory({\n getCdnUrl,\n }),\n };\n};\n"],"names":["buildSearchParams","twicpicsTransformationChainToString","getCdnUrlFactory","getCdnFromS3UrlFactory"],"mappings":";;;;;;;;;MAMa,0BAA0B,GAA0B,CAAC,EAChE,GAAG,EACH,KAAK,EACL,MAAM,EACN,OAAO,EACP,QAAQ,GAAG,IAAI,EACf,gBAAgB,GACjB,KAAI;AACH,IAAA,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,QAAQ,GAAG,iBAAiB,GAAG,SAAS;QAC9C,GAAG,EAAE,GAAG,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS;AACxC,QAAA,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,GAAG,SAAS;AACrE,QAAA,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS;AAC/C,QAAA,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,SAAS;AAC7C,QAAA,CAAC,EAAE,OAAO,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,IAAI,GAAG,GAAG,OAAO,GAAG,SAAS;KACjF,CAAC;IACF,MAAM,YAAY,GAAGA,mCAAiB,CAAC,MAAM,CAAC,CAAC,QAAQ,EAA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M,SAAS,GAAGC,+BAAgB,CAAC;QACjC,MAAM;QACN,cAAc;QACd,qBAAqB,EAAE,IAAI,KAAK,OAAO,GAAG,0BAA0B,GAAG,6BAA6B;QACpG,YAAY;AACb,KAAA,CAAC,CAAC;IAEH,OAAO;QACL,SAAS;QACT,eAAe,EAAEC,2CAAsB,CAAC;YACtC,SAAS;SACV,CAAC;KACH,CAAC;AACJ;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparted/shared-library",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "repository": "git@github.com:Sparted/shared-library.git",
5
5
  "author": {
6
6
  "name": "Sparted",