@localazy/cdn-client 1.5.14 → 1.5.16

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/README.md CHANGED
@@ -11,11 +11,11 @@
11
11
 
12
12
  Node.js module that allows you to easily interact with the [Localazy CDN](https://localazy.com/docs/cdn/cdn-introduction).
13
13
 
14
- [![npm](https://raw.githubusercontent.com/localazy/cdn-client/main/.github/badges/npm.svg)](https://www.npmjs.com/package/@localazy/cdn-client)
15
- [![maintainer](https://raw.githubusercontent.com/localazy/cdn-client/main/.github/badges/maintainer.svg)](https://github.com/localazy)
16
- [![license](https://raw.githubusercontent.com/localazy/cdn-client/main/.github/badges/license.svg)](https://github.com/localazy/cdn-client/blob/main/LICENSE)<br>
17
- [![coverage](https://raw.githubusercontent.com/localazy/cdn-client/main/.github/badges/coverage.svg)](https://github.com/localazy/cdn-client/actions)
18
- [![size](https://raw.githubusercontent.com/localazy/cdn-client/main/.github/badges/size.svg)](https://bundlephobia.com/package/@localazy/cdn-client)
14
+ [![npm](https://raw.githubusercontent.com/localazy/cdn-client/main/.github/badges/cdn-client/version.svg)](https://www.npmjs.com/package/@localazy/cdn-client)
15
+ [![maintainer](https://raw.githubusercontent.com/localazy/cdn-client/main/.github/badges/cdn-client/maintainer.svg)](https://github.com/localazy)
16
+ [![license](https://raw.githubusercontent.com/localazy/cdn-client/main/.github/badges/cdn-client/license.svg)](https://github.com/localazy/cdn-client/blob/main/LICENSE)<br>
17
+ [![coverage](https://raw.githubusercontent.com/localazy/cdn-client/main/.github/badges/cdn-client/coverage.svg)](https://github.com/localazy/cdn-client/actions)
18
+ [![size](https://raw.githubusercontent.com/localazy/cdn-client/main/.github/badges/cdn-client/size.svg)](https://bundlephobia.com/package/@localazy/cdn-client)
19
19
 
20
20
  </div>
21
21
 
@@ -1,4 +1,4 @@
1
- /* @localazy/cdn-client@1.5.14
1
+ /* @localazy/cdn-client@1.5.16
2
2
  * (c) 2026 Localazy <team@localazy.com>
3
3
  * @license MIT */
4
4
  (function(e, t) {
@@ -394,7 +394,7 @@
394
394
  metafile;
395
395
  cache;
396
396
  context;
397
- static version = "1.5.14";
397
+ static version = "1.5.16";
398
398
  constructor(e) {
399
399
  const t = new g(e), s = new w(t.params.baseUrl);
400
400
  this.context = new u({
@@ -1 +1 @@
1
- {"version":3,"file":"localazy-cdn-client.umd.min.js","names":[],"sources":["../../src/cdn/api/api.ts","../../src/cdn/cache/memory-cache-adapter.ts","../../src/cdn/utils.ts","../../src/cdn/cache/locales-cache.ts","../../src/cdn/response/response-factory.ts","../../src/cdn/context/context.ts","../../src/cdn/metafile/metafile-file.ts","../../src/cdn/metafile/metafile-locale.ts","../../src/cdn/metafile/metafile-data.ts","../../src/cdn/metafile/metafile-params.ts","../../src/cdn/context/metafile-context.ts","../../src/cdn/http/fetch-http-adapter.ts","../../src/cdn/methods/cdn-base.ts","../../src/cdn/methods/cdn-cache.ts","../../src/cdn/methods/cdn-metafile.ts","../../src/cdn/request/locales-map.ts","../../src/cdn/request/request.ts","../../src/cdn/request/request-builder.ts","../../src/cdn/cdn-client.ts"],"sourcesContent":["import type { Context } from '@/cdn/context/context.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\n\nexport class Api {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public async fetchLocale(options: ApiLocaleRequest): Promise<object | string> {\n if (this.context.cache.has(options)) {\n return new Promise((resolve): void => {\n resolve(this.context.cache.get(options) as object | string);\n });\n }\n\n return this.context.client.get(options.metafileLocale.uri);\n }\n\n public async fetchMetafile(): Promise<IMetafile> {\n return (await this.context.client.get(this.context.metafile.params.jsonPath)) as IMetafile;\n }\n}\n","import type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\n\nexport class MemoryCacheAdapter<K, V> implements ICacheAdapter<K, V> {\n protected map: Map<K, V>;\n\n constructor() {\n this.map = new Map();\n }\n\n public get(key: K): V | undefined {\n return this.map.get(key);\n }\n\n public has(key: K): boolean {\n return this.map.has(key);\n }\n\n public set(key: K, value: V): void {\n this.map.set(key, value);\n }\n\n public flush(): void {\n this.map = new Map();\n }\n}\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isUndefined = (value: unknown): value is undefined => typeof value === 'undefined';\n\nexport const isArray = <T>(value: unknown): value is T[] => Array.isArray(value);\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n Object.prototype.toString.call(value) === '[object Object]';\n\nexport const uniq = <T>(array: T[]): T[] => [...new Set(array)];\n\nexport const uniqBy = <T>(array: T[], predicate: (item: T) => string): T[] => {\n const seen: Record<string, boolean> = {};\n\n return array.filter((item: T): boolean => {\n const key: string = predicate(item);\n\n if (!Object.hasOwn(seen, key)) {\n seen[key] = true;\n\n return true;\n }\n\n return false;\n });\n};\n","import { MemoryCacheAdapter } from '@/cdn/cache/memory-cache-adapter.js';\nimport type { Context } from '@/cdn/context/context.js';\nimport { uniq } from '@/cdn/utils.js';\nimport type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\nimport type { CacheGetLocalesRequest } from '@/types/cache-get-locales-request.js';\nimport type { CacheHasLocalesRequest } from '@/types/cache-has-locales-request.js';\nimport type { CacheKeyMetafileOptions } from '@/types/cache-key-metafile-options.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\n\nexport class LocalesCache {\n protected context: Context;\n\n protected cacheAdapter: ICacheAdapter<string, object | string>;\n\n constructor(context: Context) {\n this.context = context;\n this.cacheAdapter = new MemoryCacheAdapter();\n }\n\n public setIfMissed(options: CacheStoreLocalesRequest): void {\n const { metafileFile, metafileLocale, data }: CacheStoreLocalesRequest = options;\n\n const key: string = this.keyFromMetafile({\n metafileFile,\n metafileLocale,\n });\n\n if (!this.cacheAdapter.has(key)) {\n this.cacheAdapter.set(key, data);\n }\n }\n\n public has(options: CacheHasLocalesRequest): boolean {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.has(key);\n }\n\n public get(options: CacheGetLocalesRequest): object | string | undefined {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.get(key);\n }\n\n public flush(): void {\n this.cacheAdapter.flush();\n }\n\n protected keyFromMetafile(options: CacheKeyMetafileOptions): string {\n const { metafileFile, metafileLocale }: CacheKeyMetafileOptions = options;\n const productFlavors: string = [...uniq(metafileFile.productFlavors)].sort().join('-');\n\n const indices: string[] = [\n this.context.metafile.params.cdnId,\n metafileFile.id,\n metafileFile.file,\n metafileFile.path,\n metafileFile.library,\n metafileFile.module,\n metafileFile.buildType,\n productFlavors,\n metafileLocale.locale,\n metafileLocale.timestamp.toString(),\n ];\n\n return indices.filter((key: string): boolean => key !== '').join('-');\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\nimport type { ResponseFactoryOptions } from '@/types/response-factory-options.js';\n\nexport class ResponseFactory {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public createCdnResponse(options: ResponseFactoryOptions): CdnResponse {\n const {\n requests,\n responses,\n hasSingleFileResponse,\n hasSingleLocaleResponse,\n }: ResponseFactoryOptions = options;\n\n if (responses.length === 0 || typeof responses[0] === 'undefined') {\n return {};\n }\n\n this.cacheResponses(requests, responses);\n\n return hasSingleFileResponse && hasSingleLocaleResponse\n ? responses[0]\n : ResponseFactory.transformResponses(options);\n }\n\n protected cacheResponses(requests: ApiLocaleRequest[], responses: (object | string)[]): void {\n responses.forEach((response: object | string, index: number): void => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n this.context.cache.setIfMissed({ metafileFile, metafileLocale, data: response });\n }\n }\n });\n }\n\n protected static transformResponses(options: ResponseFactoryOptions): CdnResponse {\n const { requests, responses, hasSingleFileResponse }: ResponseFactoryOptions = options;\n\n return responses.reduce((acc: CdnResponse, cur: object | string, index: number) => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n if (hasSingleFileResponse) {\n // @ts-expect-error fix output type\n acc[metafileLocale.locale] = cur;\n } else {\n // @ts-expect-error fix output type\n if (!acc[metafileFile.id]) {\n // @ts-expect-error fix output type\n acc[metafileFile.id] = {};\n }\n\n // @ts-expect-error fix output type\n acc[metafileFile.id][metafileLocale.locale] = cur;\n }\n }\n }\n\n return acc;\n }, {});\n }\n}\n","import { Api } from '@/cdn/api/api.js';\nimport { LocalesCache } from '@/cdn/cache/locales-cache.js';\nimport type { CdnClient } from '@/cdn/cdn-client.js';\nimport type { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { ResponseFactory } from '@/cdn/response/response-factory.js';\nimport type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\nimport type { ContextOptions } from '@/types/context-options.js';\n\nexport class Context {\n public metafile: MetafileContext;\n\n public cdn: CdnClient;\n\n public client: IHttpAdapter;\n\n public api: Api;\n\n public cache: LocalesCache;\n\n public responseFactory: ResponseFactory;\n\n constructor(options: ContextOptions) {\n this.metafile = options.metafileContext;\n this.cdn = options.cdn;\n this.client = options.client;\n this.api = new Api(this);\n this.cache = new LocalesCache(this);\n this.responseFactory = new ResponseFactory(this);\n }\n}\n","import type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { IMetafileFile } from '@/interfaces/i-metafile-file.js';\nimport type { CdnFileLocale } from '@/types/cdn-file-locale.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { MetafileFileOptions } from '@/types/metafile-file-options.js';\n\nexport class MetafileFile implements Omit<IMetafileFile, 'locales'> {\n public id: string;\n\n public file: string;\n\n public path: string;\n\n public library: string;\n\n public module: string;\n\n public buildType: string;\n\n public timestamp: number;\n\n public productFlavors: string[];\n\n public locales: MetafileLocale[];\n\n protected baseUrl: string;\n\n constructor(options: MetafileFileOptions) {\n this.id = options.id;\n this.file = options.file;\n this.path = options.path;\n this.library = options.library;\n this.module = options.module;\n this.buildType = options.buildType;\n this.timestamp = options.timestamp;\n this.productFlavors = options.productFlavors;\n this.locales = options.locales;\n this.baseUrl = options.baseUrl;\n }\n\n public toCdnFile(): CdnFile {\n return {\n id: this.id,\n file: this.file,\n path: this.path,\n library: this.library,\n module: this.module,\n buildType: this.buildType,\n productFlavors: this.productFlavors,\n locales: this.locales.map(\n (locale: MetafileLocale): CdnFileLocale => ({\n locale: locale.locale,\n isBaseLocale: locale.isBaseLocale,\n uri: `${this.baseUrl}${locale.uri}`,\n }),\n ),\n };\n }\n}\n","import type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\n\nexport class MetafileLocale implements IMetafileFileLocale {\n public language: string;\n\n public region: string;\n\n public script: string;\n\n public isRtl: boolean;\n\n public name: string;\n\n public localizedName: string;\n\n public uri: string;\n\n public timestamp: number;\n\n protected baseLocale: string;\n\n constructor(options: IMetafileFileLocale, baseLocale: string) {\n this.language = options.language;\n this.region = options.region;\n this.script = options.script;\n this.isRtl = options.isRtl;\n this.name = options.name;\n this.localizedName = options.localizedName;\n this.uri = options.uri;\n this.timestamp = options.timestamp;\n this.baseLocale = baseLocale;\n }\n\n get locale(): string {\n if (this.language && this.region && this.script) {\n return `${this.language}_${this.region}#${this.script}`;\n }\n\n if (this.language && this.script) {\n return `${this.language}#${this.script}`;\n }\n\n if (this.language && this.region) {\n return `${this.language}_${this.region}`;\n }\n\n return this.language;\n }\n\n get isBaseLocale(): boolean {\n return this.locale === this.baseLocale;\n }\n\n public toCdnLocale(): CdnLocale {\n return {\n locale: this.locale,\n isBaseLocale: this.isBaseLocale,\n language: this.language,\n region: this.region,\n script: this.script,\n isRtl: this.isRtl,\n name: this.name,\n localizedName: this.localizedName,\n };\n }\n}\n","import { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { uniqBy } from '@/cdn/utils.js';\nimport type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { IMetafileFiles } from '@/interfaces/i-metafile-files.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { FilesMap } from '@/types/files-map.js';\nimport type { MetafileOptions } from '@/types/metafile-options.js';\n\nexport class MetafileData implements Omit<IMetafile, 'files' | 'baseLocale'> {\n public projectUrl: string;\n\n public baseLocale: CdnLocale;\n\n public locales: CdnLocale[];\n\n public timestamp: number;\n\n public files: MetafileFile[];\n\n public filesMap: FilesMap;\n\n constructor(options: MetafileOptions, params: MetafileParams) {\n this.projectUrl = options.projectUrl;\n this.timestamp = options.timestamp;\n this.files = MetafileData.filesFactory(options.files, options.baseLocale, params);\n this.filesMap = MetafileData.filesMapFactory(this.files);\n this.locales = MetafileData.localesFactory(this.files);\n this.baseLocale = this.locales.find((locale: CdnLocale) => locale.isBaseLocale) as CdnLocale;\n }\n\n public static createEmpty(params: MetafileParams): MetafileData {\n return new MetafileData(\n {\n projectUrl: '',\n baseLocale: '',\n timestamp: 0,\n files: {},\n },\n params,\n );\n }\n\n protected static filesFactory(\n files: IMetafileFiles,\n baseLocale: string,\n params: MetafileParams,\n ): MetafileFile[] {\n return Object.keys(files).reduce((acc: MetafileFile[], cur: string) => {\n if (typeof files[cur] !== 'undefined') {\n const locales: MetafileLocale[] = files[cur].locales.map(\n (locale: IMetafileFileLocale) => new MetafileLocale(locale, baseLocale),\n );\n\n acc.push(\n new MetafileFile({\n ...files[cur],\n id: cur,\n locales,\n baseUrl: params.baseUrl,\n }),\n );\n }\n\n return acc;\n }, []);\n }\n\n protected static filesMapFactory(files: MetafileFile[]): FilesMap {\n return files.reduce((acc: FilesMap, cur: MetafileFile) => {\n acc[cur.id] = cur;\n\n return acc;\n }, {});\n }\n\n protected static localesFactory(files: MetafileFile[]): CdnLocale[] {\n const locales: CdnLocale[] = files.reduce((acc: CdnLocale[], cur: MetafileFile) => {\n acc.push(...cur.locales.map((locale: MetafileLocale): CdnLocale => locale.toCdnLocale()));\n return acc;\n }, []);\n\n return uniqBy(locales, (cdnLocale: CdnLocale): string => cdnLocale.locale);\n }\n}\n","import type { IMetafileParams } from '@/interfaces/i-metafile-params.js';\n\nexport class MetafileParams implements IMetafileParams {\n protected options: IMetafileParams;\n\n constructor(metafileUrl: string) {\n this.options = MetafileParams.parseMetafileUrl(metafileUrl);\n }\n\n get url(): string {\n return this.options.url;\n }\n\n get baseUrl(): string {\n return this.options.baseUrl;\n }\n\n get cdnId(): string {\n return this.options.cdnId;\n }\n\n get jsonPath(): string {\n return this.options.jsonPath;\n }\n\n protected static parseMetafileUrl(metafileUrl: string): IMetafileParams {\n let url: URL;\n\n try {\n url = new URL(metafileUrl);\n } catch {\n throw new Error('Invalid param: \"options.metafile\" cannot be parsed as url.');\n }\n\n const matches: string[] | null = /^\\/(.*?)\\/(.*?)\\.(v2.json|js|ts)$/.exec(url.pathname);\n\n if (\n matches === null ||\n matches.length !== 4 ||\n typeof matches[1] === 'undefined' ||\n typeof matches[2] === 'undefined'\n ) {\n throw new Error('Invalid param: \"options.metafile\" contains invalid metafile url.');\n }\n\n const cdnId: string = matches[1];\n const tagId: string = matches[2];\n\n return {\n url: metafileUrl,\n baseUrl: url.origin,\n cdnId,\n jsonPath: `/${cdnId}/${tagId}.v2.json`,\n };\n }\n}\n","import { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\n\nexport class MetafileContext {\n public params: MetafileParams;\n\n public parsedData: IMetafile | null;\n\n public data: MetafileData;\n\n constructor(options: CdnClientOptions) {\n this.params = new MetafileParams(options.metafile);\n this.parsedData = null;\n this.data = MetafileData.createEmpty(this.params);\n }\n\n public setMetafile(metafile: IMetafile): void {\n this.parsedData = metafile;\n\n this.data = new MetafileData(metafile, this.params);\n }\n}\n","import type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\n\nexport class FetchHttpAdapter implements IHttpAdapter {\n protected baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async get(url: string): Promise<string | object> {\n const response: Response = await fetch(`${this.baseUrl}${url}`);\n const contentType: string | null = response.headers.get('content-type');\n const isJson: boolean =\n contentType === 'application/json5' || contentType === 'application/json';\n\n if (response.status >= 400) {\n throw new Error(`Request failed with status code ${response.status.toString()}`);\n }\n\n let result: string | object;\n\n if (isJson) {\n result = (await response.json()) as object;\n } else {\n result = await response.text();\n }\n\n return result;\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\n\nexport abstract class CdnBase {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n}\n","import { CdnBase } from '@/cdn/methods/cdn-base.js';\n\nexport class CdnCache extends CdnBase {\n public flush = (): void => {\n this.context.cache.flush();\n };\n}\n","import type { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { CdnBase } from '@/cdn/methods/cdn-base.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { CdnLocalesOptions } from '@/types/cdn-locales-options.js';\n\nexport class CdnMetafile extends CdnBase {\n get projectUrl(): string {\n return this.context.metafile.data.projectUrl;\n }\n\n get baseLocale(): CdnLocale {\n return this.context.metafile.data.baseLocale;\n }\n\n get url(): string {\n return this.context.metafile.params.url;\n }\n\n get files(): CdnFile[] {\n return this.context.metafile.data.files.map((file: MetafileFile): CdnFile => file.toCdnFile());\n }\n\n public locales = (options?: CdnLocalesOptions): CdnLocale[] => {\n const { excludeBaseLocale }: CdnLocalesOptions = options || {};\n const { locales }: MetafileData = this.context.metafile.data;\n\n return excludeBaseLocale\n ? locales.filter((cdnLocale: CdnLocale): boolean => !cdnLocale.isBaseLocale)\n : locales;\n };\n\n public refresh = async (): Promise<void> => {\n const response: IMetafile = await this.context.api.fetchMetafile();\n\n this.context.metafile.setMetafile(response);\n };\n\n public switch = async (options: CdnClientOptions): Promise<void> => {\n this.context.metafile.params = new MetafileParams(options.metafile);\n\n await this.refresh();\n };\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { LocalesMapData } from '@/types/locales-map-data.js';\nimport type { LocalesMapOptions } from '@/types/locales-map-options.js';\n\nexport class LocalesMap {\n public data: LocalesMapData;\n\n protected context: Context;\n\n constructor(options: LocalesMapOptions) {\n this.context = options.context;\n this.data = options.data || {};\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport { LocalesMap } from '@/cdn/request/locales-map.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class Request {\n public files: MetafileFile[];\n\n public localesMap: LocalesMap;\n\n public hasSingleFileResponse: boolean;\n\n public hasSingleLocaleResponse: boolean;\n\n protected context: Context;\n\n constructor(context: Context) {\n this.files = [];\n this.localesMap = new LocalesMap({ context });\n this.hasSingleFileResponse = false;\n this.hasSingleLocaleResponse = false;\n this.context = context;\n }\n\n public async execute(): Promise<CdnResponse> {\n const payload: [Promise<string | object>, ApiLocaleRequest][] = this.getPromises();\n const promises: Promise<string | object>[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[0],\n );\n const requests: ApiLocaleRequest[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[1],\n );\n const responses: (string | object)[] = await Promise.all(promises);\n\n return this.context.responseFactory.createCdnResponse({\n requests,\n responses,\n localesMap: this.localesMap,\n hasSingleFileResponse: this.hasSingleFileResponse,\n hasSingleLocaleResponse: this.hasSingleLocaleResponse,\n });\n }\n\n protected getPromises(): [Promise<string | object>, ApiLocaleRequest][] {\n return this.files.reduce(\n (acc: [Promise<string | object>, ApiLocaleRequest][], cur: MetafileFile) => {\n if (typeof this.localesMap.data?.[cur.id] !== 'undefined') {\n acc.push(\n ...this.localesMap.data[cur.id].map(\n (metafileLocale: MetafileLocale): [Promise<string | object>, ApiLocaleRequest] => {\n const request: ApiLocaleRequest = {\n metafileFile: cur,\n metafileLocale,\n };\n\n return [this.context.api.fetchLocale(request), request];\n },\n ),\n );\n }\n return acc;\n },\n [],\n );\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { LocalesMap } from '@/cdn/request/locales-map.js';\nimport { Request } from '@/cdn/request/request.js';\nimport { isArray, isPlainObject, isString, isUndefined } from '@/cdn/utils.js';\nimport type { IRequestBuilder } from '@/interfaces/i-request-builder.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\n\nexport class RequestBuilder implements IRequestBuilder {\n protected context: Context;\n\n protected request: Request;\n\n constructor(context: Context) {\n this.context = context;\n this.request = new Request(this.context);\n }\n\n public addFiles(files?: (CdnFile | string)[] | CdnFile | string): this {\n if (!(isPlainObject(files) || isString(files) || isUndefined(files) || isArray(files))) {\n throw new Error('Invalid param: \"request.files\" must be object, array, string or undefined.');\n }\n\n if (isArray(files)) {\n files.forEach((i: CdnFile | string): void => {\n if (!(isPlainObject(i) || isString(i))) {\n throw new Error('Invalid param: array \"request.files\" must contain objects or strings.');\n }\n });\n }\n\n if (isString(files)) {\n this.request.hasSingleFileResponse = true;\n\n const file: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files,\n );\n\n if (!(file instanceof MetafileFile)) {\n throw new Error(`File not found: \"${files}\".`);\n }\n\n this.request.files = [file];\n } else if (isUndefined(files)) {\n this.request.files = [...this.context.metafile.data.files];\n } else if (isArray(files)) {\n this.request.files = files.map((file: CdnFile | string): MetafileFile => {\n let metafileFile: MetafileFile;\n\n if (isString(file)) {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file}\".`);\n }\n\n metafileFile = foundFile;\n } else {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file.id}\".`);\n }\n\n metafileFile = foundFile;\n }\n\n return metafileFile;\n });\n } else if (isPlainObject(files)) {\n this.request.hasSingleFileResponse = true;\n\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${files.id}\".`);\n }\n\n this.request.files = [foundFile];\n }\n\n return this;\n }\n\n public addLocales(locales?: string[] | string, excludeBaseLocale?: boolean): this {\n if (!(isString(locales) || isUndefined(locales) || isArray(locales))) {\n throw new Error('Invalid param: \"request.locales\" must be array, string or undefined.');\n }\n\n if (isArray(locales)) {\n locales.forEach((i: MetafileFile | string): void => {\n if (!isString(i)) {\n throw new Error('Invalid param: array \"request.locales\" must contain strings.');\n }\n });\n }\n\n if (isString(locales)) {\n this.request.hasSingleLocaleResponse = true;\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => metafileLocale.locale === locales,\n );\n\n return acc;\n }, this.request.localesMap);\n } else if (isUndefined(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = excludeBaseLocale\n ? cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => !metafileLocale.isBaseLocale,\n )\n : cur.locales;\n\n return acc;\n }, this.request.localesMap);\n } else if (isArray(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter((metafileLocale: MetafileLocale) =>\n locales.includes(metafileLocale.locale),\n );\n\n return acc;\n }, this.request.localesMap);\n }\n\n return this;\n }\n\n public getCdnRequest(): Request {\n const result: Request = this.request;\n this.request = new Request(this.context);\n return result;\n }\n}\n","import { Context } from '@/cdn/context/context.js';\nimport { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { FetchHttpAdapter } from '@/cdn/http/fetch-http-adapter.js';\nimport { CdnCache } from '@/cdn/methods/cdn-cache.js';\nimport { CdnMetafile } from '@/cdn/methods/cdn-metafile.js';\nimport { RequestBuilder } from '@/cdn/request/request-builder.js';\nimport { isString } from '@/cdn/utils.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFetchOptions } from '@/types/cdn-fetch-options.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class CdnClient {\n public metafile: CdnMetafile;\n\n public cache: CdnCache;\n\n protected context: Context;\n\n public static version = '__CLIENT_VERSION__';\n\n protected constructor(options: CdnClientOptions) {\n const metafileContext: MetafileContext = new MetafileContext(options);\n const client: FetchHttpAdapter = new FetchHttpAdapter(metafileContext.params.baseUrl);\n\n this.context = new Context({ metafileContext, cdn: this, client });\n this.metafile = new CdnMetafile(this.context);\n this.cache = new CdnCache(this.context);\n }\n\n public fetch = async (options?: CdnFetchOptions): Promise<CdnResponse> => {\n const { files, locales, excludeBaseLocale }: CdnFetchOptions = options || {};\n const requestBuilder: RequestBuilder = new RequestBuilder(this.context)\n .addFiles(files)\n .addLocales(locales, excludeBaseLocale);\n\n return requestBuilder.getCdnRequest().execute();\n };\n\n public static async create(options: CdnClientOptions): Promise<CdnClient> {\n if (!options) {\n throw new Error('Invalid param: missing required \"options\" parameter.');\n }\n\n if (!isString(options.metafile)) {\n throw new Error('Invalid param: \"options.metafile\" must be string.');\n }\n\n const cdn: CdnClient = new CdnClient(options);\n\n await cdn.metafile.refresh();\n\n return cdn;\n }\n}\n"],"mappings":";;;;;;;CAIA,IAAa,IAAb,MAAA;EACE;EAEA,YAAY,GAAA;AACV,QAAK,UAAU;;EAGjB,MAAA,YAAyB,GAAA;AACvB,UAAI,KAAK,QAAQ,MAAM,IAAI,EAAA,GAClB,IAAI,SAAS,MAAA;AAClB,MAAQ,KAAK,QAAQ,MAAM,IAAI,EAAA,CAAA;KAAA,GAI5B,KAAK,QAAQ,OAAO,IAAI,EAAQ,eAAe,IAAA;;EAGxD,MAAA,gBAAa;AACX,UAAA,MAAc,KAAK,QAAQ,OAAO,IAAI,KAAK,QAAQ,SAAS,OAAO,SAAA;;ICpB1D,IAAb,MAAA;EACE;EAEA,cAAA;AACE,QAAK,sBAAM,IAAI,KAAA;;EAGjB,IAAW,GAAA;AACT,UAAO,KAAK,IAAI,IAAI,EAAA;;EAGtB,IAAW,GAAA;AACT,UAAO,KAAK,IAAI,IAAI,EAAA;;EAGtB,IAAW,GAAQ,GAAA;AACjB,QAAK,IAAI,IAAI,GAAK,EAAA;;EAGpB,QAAA;AACE,QAAK,sBAAM,IAAI,KAAA;;ICtBN,KAAY,MAAqD,YAAA,OAAV,GAEvD,KAAe,MAAA,KAAwD,MAAV,GAE7D,KAAc,MAAiC,MAAM,QAAQ,EAAA,EAE7D,KAAiB,MACc,sBAA1C,OAAO,UAAU,SAAS,KAAK,EAAA,EAEpB,KAAW,MAAoB,CAAA,GAAI,IAAI,IAAI,EAAA,CAAA,EAE3C,KAAa,GAAY,MAAA;EACpC,MAAM,IAAgC,EAAA;AAEtC,SAAO,EAAM,QAAQ,MAAA;GACnB,MAAM,IAAc,EAAU,EAAA;AAE9B,UAAA,CAAK,OAAO,OA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qBAAA,GAAA,EAAA,kBAAA,GAAA,EAAA,eAAA,GAAA,EAAA,eAAA,GAAA,EAAA,iBAAA,GAAA,EAAA,iBAAA,GAAA,EAAA,UAAA,GAAA,EAAA,iBAAA,GAAA,EAAA,kBAAA,GAAA,EAAA,UAAA,GAAA,EAAA,gBAAA,GAAA,EAAA,WAAA,GAAA,EAAA,cAAA,GAAA,EAAA,OAAA,GAAA,EAAA,SAAA;EAAA"}
1
+ {"version":3,"file":"localazy-cdn-client.umd.min.js","names":[],"sources":["../../src/cdn/api/api.ts","../../src/cdn/cache/memory-cache-adapter.ts","../../src/cdn/utils.ts","../../src/cdn/cache/locales-cache.ts","../../src/cdn/response/response-factory.ts","../../src/cdn/context/context.ts","../../src/cdn/metafile/metafile-file.ts","../../src/cdn/metafile/metafile-locale.ts","../../src/cdn/metafile/metafile-data.ts","../../src/cdn/metafile/metafile-params.ts","../../src/cdn/context/metafile-context.ts","../../src/cdn/http/fetch-http-adapter.ts","../../src/cdn/methods/cdn-base.ts","../../src/cdn/methods/cdn-cache.ts","../../src/cdn/methods/cdn-metafile.ts","../../src/cdn/request/locales-map.ts","../../src/cdn/request/request.ts","../../src/cdn/request/request-builder.ts","../../src/cdn/cdn-client.ts"],"sourcesContent":["import type { Context } from '@/cdn/context/context.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\n\nexport class Api {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public async fetchLocale(options: ApiLocaleRequest): Promise<object | string> {\n if (this.context.cache.has(options)) {\n return new Promise((resolve): void => {\n resolve(this.context.cache.get(options) as object | string);\n });\n }\n\n return this.context.client.get(options.metafileLocale.uri);\n }\n\n public async fetchMetafile(): Promise<IMetafile> {\n return (await this.context.client.get(this.context.metafile.params.jsonPath)) as IMetafile;\n }\n}\n","import type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\n\nexport class MemoryCacheAdapter<K, V> implements ICacheAdapter<K, V> {\n protected map: Map<K, V>;\n\n constructor() {\n this.map = new Map();\n }\n\n public get(key: K): V | undefined {\n return this.map.get(key);\n }\n\n public has(key: K): boolean {\n return this.map.has(key);\n }\n\n public set(key: K, value: V): void {\n this.map.set(key, value);\n }\n\n public flush(): void {\n this.map = new Map();\n }\n}\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isUndefined = (value: unknown): value is undefined => typeof value === 'undefined';\n\nexport const isArray = <T>(value: unknown): value is T[] => Array.isArray(value);\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n Object.prototype.toString.call(value) === '[object Object]';\n\nexport const uniq = <T>(array: T[]): T[] => [...new Set(array)];\n\nexport const uniqBy = <T>(array: T[], predicate: (item: T) => string): T[] => {\n const seen: Record<string, boolean> = {};\n\n return array.filter((item: T): boolean => {\n const key: string = predicate(item);\n\n if (!Object.hasOwn(seen, key)) {\n seen[key] = true;\n\n return true;\n }\n\n return false;\n });\n};\n","import { MemoryCacheAdapter } from '@/cdn/cache/memory-cache-adapter.js';\nimport type { Context } from '@/cdn/context/context.js';\nimport { uniq } from '@/cdn/utils.js';\nimport type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\nimport type { CacheGetLocalesRequest } from '@/types/cache-get-locales-request.js';\nimport type { CacheHasLocalesRequest } from '@/types/cache-has-locales-request.js';\nimport type { CacheKeyMetafileOptions } from '@/types/cache-key-metafile-options.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\n\nexport class LocalesCache {\n protected context: Context;\n\n protected cacheAdapter: ICacheAdapter<string, object | string>;\n\n constructor(context: Context) {\n this.context = context;\n this.cacheAdapter = new MemoryCacheAdapter();\n }\n\n public setIfMissed(options: CacheStoreLocalesRequest): void {\n const { metafileFile, metafileLocale, data }: CacheStoreLocalesRequest = options;\n\n const key: string = this.keyFromMetafile({\n metafileFile,\n metafileLocale,\n });\n\n if (!this.cacheAdapter.has(key)) {\n this.cacheAdapter.set(key, data);\n }\n }\n\n public has(options: CacheHasLocalesRequest): boolean {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.has(key);\n }\n\n public get(options: CacheGetLocalesRequest): object | string | undefined {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.get(key);\n }\n\n public flush(): void {\n this.cacheAdapter.flush();\n }\n\n protected keyFromMetafile(options: CacheKeyMetafileOptions): string {\n const { metafileFile, metafileLocale }: CacheKeyMetafileOptions = options;\n const productFlavors: string = [...uniq(metafileFile.productFlavors)].sort().join('-');\n\n const indices: string[] = [\n this.context.metafile.params.cdnId,\n metafileFile.id,\n metafileFile.file,\n metafileFile.path,\n metafileFile.library,\n metafileFile.module,\n metafileFile.buildType,\n productFlavors,\n metafileLocale.locale,\n metafileLocale.timestamp.toString(),\n ];\n\n return indices.filter((key: string): boolean => key !== '').join('-');\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\nimport type { ResponseFactoryOptions } from '@/types/response-factory-options.js';\n\nexport class ResponseFactory {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public createCdnResponse(options: ResponseFactoryOptions): CdnResponse {\n const {\n requests,\n responses,\n hasSingleFileResponse,\n hasSingleLocaleResponse,\n }: ResponseFactoryOptions = options;\n\n if (responses.length === 0 || typeof responses[0] === 'undefined') {\n return {};\n }\n\n this.cacheResponses(requests, responses);\n\n return hasSingleFileResponse && hasSingleLocaleResponse\n ? responses[0]\n : ResponseFactory.transformResponses(options);\n }\n\n protected cacheResponses(requests: ApiLocaleRequest[], responses: (object | string)[]): void {\n responses.forEach((response: object | string, index: number): void => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n this.context.cache.setIfMissed({ metafileFile, metafileLocale, data: response });\n }\n }\n });\n }\n\n protected static transformResponses(options: ResponseFactoryOptions): CdnResponse {\n const { requests, responses, hasSingleFileResponse }: ResponseFactoryOptions = options;\n\n return responses.reduce((acc: CdnResponse, cur: object | string, index: number) => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n if (hasSingleFileResponse) {\n // @ts-expect-error fix output type\n acc[metafileLocale.locale] = cur;\n } else {\n // @ts-expect-error fix output type\n if (!acc[metafileFile.id]) {\n // @ts-expect-error fix output type\n acc[metafileFile.id] = {};\n }\n\n // @ts-expect-error fix output type\n acc[metafileFile.id][metafileLocale.locale] = cur;\n }\n }\n }\n\n return acc;\n }, {});\n }\n}\n","import { Api } from '@/cdn/api/api.js';\nimport { LocalesCache } from '@/cdn/cache/locales-cache.js';\nimport type { CdnClient } from '@/cdn/cdn-client.js';\nimport type { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { ResponseFactory } from '@/cdn/response/response-factory.js';\nimport type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\nimport type { ContextOptions } from '@/types/context-options.js';\n\nexport class Context {\n public metafile: MetafileContext;\n\n public cdn: CdnClient;\n\n public client: IHttpAdapter;\n\n public api: Api;\n\n public cache: LocalesCache;\n\n public responseFactory: ResponseFactory;\n\n constructor(options: ContextOptions) {\n this.metafile = options.metafileContext;\n this.cdn = options.cdn;\n this.client = options.client;\n this.api = new Api(this);\n this.cache = new LocalesCache(this);\n this.responseFactory = new ResponseFactory(this);\n }\n}\n","import type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { IMetafileFile } from '@/interfaces/i-metafile-file.js';\nimport type { CdnFileLocale } from '@/types/cdn-file-locale.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { MetafileFileOptions } from '@/types/metafile-file-options.js';\n\nexport class MetafileFile implements Omit<IMetafileFile, 'locales'> {\n public id: string;\n\n public file: string;\n\n public path: string;\n\n public library: string;\n\n public module: string;\n\n public buildType: string;\n\n public timestamp: number;\n\n public productFlavors: string[];\n\n public locales: MetafileLocale[];\n\n protected baseUrl: string;\n\n constructor(options: MetafileFileOptions) {\n this.id = options.id;\n this.file = options.file;\n this.path = options.path;\n this.library = options.library;\n this.module = options.module;\n this.buildType = options.buildType;\n this.timestamp = options.timestamp;\n this.productFlavors = options.productFlavors;\n this.locales = options.locales;\n this.baseUrl = options.baseUrl;\n }\n\n public toCdnFile(): CdnFile {\n return {\n id: this.id,\n file: this.file,\n path: this.path,\n library: this.library,\n module: this.module,\n buildType: this.buildType,\n productFlavors: this.productFlavors,\n locales: this.locales.map(\n (locale: MetafileLocale): CdnFileLocale => ({\n locale: locale.locale,\n isBaseLocale: locale.isBaseLocale,\n uri: `${this.baseUrl}${locale.uri}`,\n }),\n ),\n };\n }\n}\n","import type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\n\nexport class MetafileLocale implements IMetafileFileLocale {\n public language: string;\n\n public region: string;\n\n public script: string;\n\n public isRtl: boolean;\n\n public name: string;\n\n public localizedName: string;\n\n public uri: string;\n\n public timestamp: number;\n\n protected baseLocale: string;\n\n constructor(options: IMetafileFileLocale, baseLocale: string) {\n this.language = options.language;\n this.region = options.region;\n this.script = options.script;\n this.isRtl = options.isRtl;\n this.name = options.name;\n this.localizedName = options.localizedName;\n this.uri = options.uri;\n this.timestamp = options.timestamp;\n this.baseLocale = baseLocale;\n }\n\n get locale(): string {\n if (this.language && this.region && this.script) {\n return `${this.language}_${this.region}#${this.script}`;\n }\n\n if (this.language && this.script) {\n return `${this.language}#${this.script}`;\n }\n\n if (this.language && this.region) {\n return `${this.language}_${this.region}`;\n }\n\n return this.language;\n }\n\n get isBaseLocale(): boolean {\n return this.locale === this.baseLocale;\n }\n\n public toCdnLocale(): CdnLocale {\n return {\n locale: this.locale,\n isBaseLocale: this.isBaseLocale,\n language: this.language,\n region: this.region,\n script: this.script,\n isRtl: this.isRtl,\n name: this.name,\n localizedName: this.localizedName,\n };\n }\n}\n","import { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { uniqBy } from '@/cdn/utils.js';\nimport type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { IMetafileFiles } from '@/interfaces/i-metafile-files.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { FilesMap } from '@/types/files-map.js';\nimport type { MetafileOptions } from '@/types/metafile-options.js';\n\nexport class MetafileData implements Omit<IMetafile, 'files' | 'baseLocale'> {\n public projectUrl: string;\n\n public baseLocale: CdnLocale;\n\n public locales: CdnLocale[];\n\n public timestamp: number;\n\n public files: MetafileFile[];\n\n public filesMap: FilesMap;\n\n constructor(options: MetafileOptions, params: MetafileParams) {\n this.projectUrl = options.projectUrl;\n this.timestamp = options.timestamp;\n this.files = MetafileData.filesFactory(options.files, options.baseLocale, params);\n this.filesMap = MetafileData.filesMapFactory(this.files);\n this.locales = MetafileData.localesFactory(this.files);\n this.baseLocale = this.locales.find((locale: CdnLocale) => locale.isBaseLocale) as CdnLocale;\n }\n\n public static createEmpty(params: MetafileParams): MetafileData {\n return new MetafileData(\n {\n projectUrl: '',\n baseLocale: '',\n timestamp: 0,\n files: {},\n },\n params,\n );\n }\n\n protected static filesFactory(\n files: IMetafileFiles,\n baseLocale: string,\n params: MetafileParams,\n ): MetafileFile[] {\n return Object.keys(files).reduce((acc: MetafileFile[], cur: string) => {\n if (typeof files[cur] !== 'undefined') {\n const locales: MetafileLocale[] = files[cur].locales.map(\n (locale: IMetafileFileLocale) => new MetafileLocale(locale, baseLocale),\n );\n\n acc.push(\n new MetafileFile({\n ...files[cur],\n id: cur,\n locales,\n baseUrl: params.baseUrl,\n }),\n );\n }\n\n return acc;\n }, []);\n }\n\n protected static filesMapFactory(files: MetafileFile[]): FilesMap {\n return files.reduce((acc: FilesMap, cur: MetafileFile) => {\n acc[cur.id] = cur;\n\n return acc;\n }, {});\n }\n\n protected static localesFactory(files: MetafileFile[]): CdnLocale[] {\n const locales: CdnLocale[] = files.reduce((acc: CdnLocale[], cur: MetafileFile) => {\n acc.push(...cur.locales.map((locale: MetafileLocale): CdnLocale => locale.toCdnLocale()));\n return acc;\n }, []);\n\n return uniqBy(locales, (cdnLocale: CdnLocale): string => cdnLocale.locale);\n }\n}\n","import type { IMetafileParams } from '@/interfaces/i-metafile-params.js';\n\nexport class MetafileParams implements IMetafileParams {\n protected options: IMetafileParams;\n\n constructor(metafileUrl: string) {\n this.options = MetafileParams.parseMetafileUrl(metafileUrl);\n }\n\n get url(): string {\n return this.options.url;\n }\n\n get baseUrl(): string {\n return this.options.baseUrl;\n }\n\n get cdnId(): string {\n return this.options.cdnId;\n }\n\n get jsonPath(): string {\n return this.options.jsonPath;\n }\n\n protected static parseMetafileUrl(metafileUrl: string): IMetafileParams {\n let url: URL;\n\n try {\n url = new URL(metafileUrl);\n } catch {\n throw new Error('Invalid param: \"options.metafile\" cannot be parsed as url.');\n }\n\n const matches: string[] | null = /^\\/(.*?)\\/(.*?)\\.(v2.json|js|ts)$/.exec(url.pathname);\n\n if (\n matches === null ||\n matches.length !== 4 ||\n typeof matches[1] === 'undefined' ||\n typeof matches[2] === 'undefined'\n ) {\n throw new Error('Invalid param: \"options.metafile\" contains invalid metafile url.');\n }\n\n const cdnId: string = matches[1];\n const tagId: string = matches[2];\n\n return {\n url: metafileUrl,\n baseUrl: url.origin,\n cdnId,\n jsonPath: `/${cdnId}/${tagId}.v2.json`,\n };\n }\n}\n","import { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\n\nexport class MetafileContext {\n public params: MetafileParams;\n\n public parsedData: IMetafile | null;\n\n public data: MetafileData;\n\n constructor(options: CdnClientOptions) {\n this.params = new MetafileParams(options.metafile);\n this.parsedData = null;\n this.data = MetafileData.createEmpty(this.params);\n }\n\n public setMetafile(metafile: IMetafile): void {\n this.parsedData = metafile;\n\n this.data = new MetafileData(metafile, this.params);\n }\n}\n","import type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\n\nexport class FetchHttpAdapter implements IHttpAdapter {\n protected baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async get(url: string): Promise<string | object> {\n const response: Response = await fetch(`${this.baseUrl}${url}`);\n const contentType: string | null = response.headers.get('content-type');\n const isJson: boolean =\n contentType === 'application/json5' || contentType === 'application/json';\n\n if (response.status >= 400) {\n throw new Error(`Request failed with status code ${response.status.toString()}`);\n }\n\n let result: string | object;\n\n if (isJson) {\n result = (await response.json()) as object;\n } else {\n result = await response.text();\n }\n\n return result;\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\n\nexport abstract class CdnBase {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n}\n","import { CdnBase } from '@/cdn/methods/cdn-base.js';\n\nexport class CdnCache extends CdnBase {\n public flush = (): void => {\n this.context.cache.flush();\n };\n}\n","import type { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { CdnBase } from '@/cdn/methods/cdn-base.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { CdnLocalesOptions } from '@/types/cdn-locales-options.js';\n\nexport class CdnMetafile extends CdnBase {\n get projectUrl(): string {\n return this.context.metafile.data.projectUrl;\n }\n\n get baseLocale(): CdnLocale {\n return this.context.metafile.data.baseLocale;\n }\n\n get url(): string {\n return this.context.metafile.params.url;\n }\n\n get files(): CdnFile[] {\n return this.context.metafile.data.files.map((file: MetafileFile): CdnFile => file.toCdnFile());\n }\n\n public locales = (options?: CdnLocalesOptions): CdnLocale[] => {\n const { excludeBaseLocale }: CdnLocalesOptions = options || {};\n const { locales }: MetafileData = this.context.metafile.data;\n\n return excludeBaseLocale\n ? locales.filter((cdnLocale: CdnLocale): boolean => !cdnLocale.isBaseLocale)\n : locales;\n };\n\n public refresh = async (): Promise<void> => {\n const response: IMetafile = await this.context.api.fetchMetafile();\n\n this.context.metafile.setMetafile(response);\n };\n\n public switch = async (options: CdnClientOptions): Promise<void> => {\n this.context.metafile.params = new MetafileParams(options.metafile);\n\n await this.refresh();\n };\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { LocalesMapData } from '@/types/locales-map-data.js';\nimport type { LocalesMapOptions } from '@/types/locales-map-options.js';\n\nexport class LocalesMap {\n public data: LocalesMapData;\n\n protected context: Context;\n\n constructor(options: LocalesMapOptions) {\n this.context = options.context;\n this.data = options.data || {};\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport { LocalesMap } from '@/cdn/request/locales-map.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class Request {\n public files: MetafileFile[];\n\n public localesMap: LocalesMap;\n\n public hasSingleFileResponse: boolean;\n\n public hasSingleLocaleResponse: boolean;\n\n protected context: Context;\n\n constructor(context: Context) {\n this.files = [];\n this.localesMap = new LocalesMap({ context });\n this.hasSingleFileResponse = false;\n this.hasSingleLocaleResponse = false;\n this.context = context;\n }\n\n public async execute(): Promise<CdnResponse> {\n const payload: [Promise<string | object>, ApiLocaleRequest][] = this.getPromises();\n const promises: Promise<string | object>[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[0],\n );\n const requests: ApiLocaleRequest[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[1],\n );\n const responses: (string | object)[] = await Promise.all(promises);\n\n return this.context.responseFactory.createCdnResponse({\n requests,\n responses,\n localesMap: this.localesMap,\n hasSingleFileResponse: this.hasSingleFileResponse,\n hasSingleLocaleResponse: this.hasSingleLocaleResponse,\n });\n }\n\n protected getPromises(): [Promise<string | object>, ApiLocaleRequest][] {\n return this.files.reduce(\n (acc: [Promise<string | object>, ApiLocaleRequest][], cur: MetafileFile) => {\n if (typeof this.localesMap.data?.[cur.id] !== 'undefined') {\n acc.push(\n ...this.localesMap.data[cur.id].map(\n (metafileLocale: MetafileLocale): [Promise<string | object>, ApiLocaleRequest] => {\n const request: ApiLocaleRequest = {\n metafileFile: cur,\n metafileLocale,\n };\n\n return [this.context.api.fetchLocale(request), request];\n },\n ),\n );\n }\n return acc;\n },\n [],\n );\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { LocalesMap } from '@/cdn/request/locales-map.js';\nimport { Request } from '@/cdn/request/request.js';\nimport { isArray, isPlainObject, isString, isUndefined } from '@/cdn/utils.js';\nimport type { IRequestBuilder } from '@/interfaces/i-request-builder.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\n\nexport class RequestBuilder implements IRequestBuilder {\n protected context: Context;\n\n protected request: Request;\n\n constructor(context: Context) {\n this.context = context;\n this.request = new Request(this.context);\n }\n\n public addFiles(files?: (CdnFile | string)[] | CdnFile | string): this {\n if (!(isPlainObject(files) || isString(files) || isUndefined(files) || isArray(files))) {\n throw new Error('Invalid param: \"request.files\" must be object, array, string or undefined.');\n }\n\n if (isArray(files)) {\n files.forEach((i: CdnFile | string): void => {\n if (!(isPlainObject(i) || isString(i))) {\n throw new Error('Invalid param: array \"request.files\" must contain objects or strings.');\n }\n });\n }\n\n if (isString(files)) {\n this.request.hasSingleFileResponse = true;\n\n const file: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files,\n );\n\n if (!(file instanceof MetafileFile)) {\n throw new Error(`File not found: \"${files}\".`);\n }\n\n this.request.files = [file];\n } else if (isUndefined(files)) {\n this.request.files = [...this.context.metafile.data.files];\n } else if (isArray(files)) {\n this.request.files = files.map((file: CdnFile | string): MetafileFile => {\n let metafileFile: MetafileFile;\n\n if (isString(file)) {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file}\".`);\n }\n\n metafileFile = foundFile;\n } else {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file.id}\".`);\n }\n\n metafileFile = foundFile;\n }\n\n return metafileFile;\n });\n } else if (isPlainObject(files)) {\n this.request.hasSingleFileResponse = true;\n\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${files.id}\".`);\n }\n\n this.request.files = [foundFile];\n }\n\n return this;\n }\n\n public addLocales(locales?: string[] | string, excludeBaseLocale?: boolean): this {\n if (!(isString(locales) || isUndefined(locales) || isArray(locales))) {\n throw new Error('Invalid param: \"request.locales\" must be array, string or undefined.');\n }\n\n if (isArray(locales)) {\n locales.forEach((i: MetafileFile | string): void => {\n if (!isString(i)) {\n throw new Error('Invalid param: array \"request.locales\" must contain strings.');\n }\n });\n }\n\n if (isString(locales)) {\n this.request.hasSingleLocaleResponse = true;\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => metafileLocale.locale === locales,\n );\n\n return acc;\n }, this.request.localesMap);\n } else if (isUndefined(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = excludeBaseLocale\n ? cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => !metafileLocale.isBaseLocale,\n )\n : cur.locales;\n\n return acc;\n }, this.request.localesMap);\n } else if (isArray(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter((metafileLocale: MetafileLocale) =>\n locales.includes(metafileLocale.locale),\n );\n\n return acc;\n }, this.request.localesMap);\n }\n\n return this;\n }\n\n public getCdnRequest(): Request {\n const result: Request = this.request;\n this.request = new Request(this.context);\n return result;\n }\n}\n","import { Context } from '@/cdn/context/context.js';\nimport { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { FetchHttpAdapter } from '@/cdn/http/fetch-http-adapter.js';\nimport { CdnCache } from '@/cdn/methods/cdn-cache.js';\nimport { CdnMetafile } from '@/cdn/methods/cdn-metafile.js';\nimport { RequestBuilder } from '@/cdn/request/request-builder.js';\nimport { isString } from '@/cdn/utils.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFetchOptions } from '@/types/cdn-fetch-options.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class CdnClient {\n public metafile: CdnMetafile;\n\n public cache: CdnCache;\n\n protected context: Context;\n\n public static version = '__CLIENT_VERSION__';\n\n protected constructor(options: CdnClientOptions) {\n const metafileContext: MetafileContext = new MetafileContext(options);\n const client: FetchHttpAdapter = new FetchHttpAdapter(metafileContext.params.baseUrl);\n\n this.context = new Context({ metafileContext, cdn: this, client });\n this.metafile = new CdnMetafile(this.context);\n this.cache = new CdnCache(this.context);\n }\n\n public fetch = async (options?: CdnFetchOptions): Promise<CdnResponse> => {\n const { files, locales, excludeBaseLocale }: CdnFetchOptions = options || {};\n const requestBuilder: RequestBuilder = new RequestBuilder(this.context)\n .addFiles(files)\n .addLocales(locales, excludeBaseLocale);\n\n return requestBuilder.getCdnRequest().execute();\n };\n\n public static async create(options: CdnClientOptions): Promise<CdnClient> {\n if (!options) {\n throw new Error('Invalid param: missing required \"options\" parameter.');\n }\n\n if (!isString(options.metafile)) {\n throw new Error('Invalid param: \"options.metafile\" must be string.');\n }\n\n const cdn: CdnClient = new CdnClient(options);\n\n await cdn.metafile.refresh();\n\n return cdn;\n }\n}\n"],"mappings":";;;;;;;CAIA,IAAa,IAAb,MAAA;EACE;EAEA,YAAY,GAAA;GACV,KAAK,UAAU;EACjB;EAEA,MAAA,YAAyB,GAAA;GACvB,OAAI,KAAK,QAAQ,MAAM,IAAI,CAAA,IAClB,IAAI,SAAS,MAAA;IAClB,EAAQ,KAAK,QAAQ,MAAM,IAAI,CAAA,CAAA;GAAA,CAAA,IAI5B,KAAK,QAAQ,OAAO,IAAI,EAAQ,eAAe,GAAA;EACxD;EAEA,MAAA,gBAAa;GACX,OAAA,MAAc,KAAK,QAAQ,OAAO,IAAI,KAAK,QAAQ,SAAS,OAAO,QAAA;EACrE;CAAA,GCrBW,IAAb,MAAA;EACE;EAEA,cAAA;GACE,KAAK,sBAAM,IAAI,IAAA;EACjB;EAEA,IAAW,GAAA;GACT,OAAO,KAAK,IAAI,IAAI,CAAA;EACtB;EAEA,IAAW,GAAA;GACT,OAAO,KAAK,IAAI,IAAI,CAAA;EACtB;EAEA,IAAW,GAAQ,GAAA;GACjB,KAAK,IAAI,IAAI,GAAK,CAAA;EACpB;EAEA,QAAA;GACE,KAAK,sBAAM,IAAI,IAAA;EACjB;CAAA,GCvBW,KAAY,MAAqD,YAAA,OAAV,GAEvD,KAAe,MAAA,KAAwD,MAAV,GAE7D,KAAc,MAAiC,MAAM,QAAQ,CAAA,GAE7D,KAAiB,MACc,sBAA1C,OAAO,UAAU,SAAS,KAAK,CAAA,GAEpB,KAAW,MAAoB,CAAA,GAAI,IAAI,IAAI,CAAA,CAAA,GAE3C,KAAa,GAAY,M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;EAEA,QAAe,OAAO,MAAA;GACpB,MAAA,EAAM,OAAE,GAAA,SAAO,GAAA,mBAAS,MAAuC,KAAW,CAAC;GAK3E,OAJuC,IAAI,EAAe,KAAK,OAAA,EAC5D,SAAS,CAAA,EACT,WAAW,GAAS,CAAA,EAED,cAAA,EAAgB,QAAA;EAAA;EAGxC,aAAA,OAA2B,GAAA;GACzB,IAAA,CAAK,GACH,MAAM,IAAI,MAAM,wDAAA;GAGlB,IAAA,CAAK,EAAS,EAAQ,QAAA,GACpB,MAAM,IAAI,MAAM,qDAAA;GAGlB,MAAM,IAAiB,IAAI,EAAU,CAAA;GAIrC,OAAA,MAFM,EAAI,SAAS,QAAA,GAEZ;EACT;CAAA,GAAA,EAAA,cAAA,GAAA,EAAA,UAAA,GAAA,EAAA,mBAAA,GAAA,EAAA,eAAA,GAAA,EAAA,aAAA,GAAA,EAAA,qBAAA,GAAA,EAAA,kBAAA,GAAA,EAAA,eAAA,GAAA,EAAA,eAAA,GAAA,EAAA,iBAAA,GAAA,EAAA,iBAAA,GAAA,EAAA,UAAA,GAAA,EAAA,iBAAA,GAAA,EAAA,kBAAA,GAAA,EAAA,UAAA,GAAA,EAAA,gBAAA,GAAA,EAAA,WAAA,GAAA,EAAA,cAAA,GAAA,EAAA,OAAA,GAAA,EAAA,SAAA;AAAA,CAAA"}
@@ -1,4 +1,4 @@
1
- /* @localazy/cdn-client@1.5.14
1
+ /* @localazy/cdn-client@1.5.16
2
2
  * (c) 2026 Localazy <team@localazy.com>
3
3
  * @license MIT */
4
4
  //#region src/cdn/api/api.ts
@@ -538,7 +538,7 @@ var CdnClient = class CdnClient {
538
538
  metafile;
539
539
  cache;
540
540
  context;
541
- static version = "1.5.14";
541
+ static version = "1.5.16";
542
542
  constructor(options) {
543
543
  const metafileContext = new MetafileContext(options);
544
544
  const client = new FetchHttpAdapter(metafileContext.params.baseUrl);
@@ -1 +1 @@
1
- {"version":3,"file":"localazy-cdn-client.js","names":[],"sources":["../src/cdn/api/api.ts","../src/cdn/cache/memory-cache-adapter.ts","../src/cdn/utils.ts","../src/cdn/cache/locales-cache.ts","../src/cdn/response/response-factory.ts","../src/cdn/context/context.ts","../src/cdn/metafile/metafile-file.ts","../src/cdn/metafile/metafile-locale.ts","../src/cdn/metafile/metafile-data.ts","../src/cdn/metafile/metafile-params.ts","../src/cdn/context/metafile-context.ts","../src/cdn/http/fetch-http-adapter.ts","../src/cdn/methods/cdn-base.ts","../src/cdn/methods/cdn-cache.ts","../src/cdn/methods/cdn-metafile.ts","../src/cdn/request/locales-map.ts","../src/cdn/request/request.ts","../src/cdn/request/request-builder.ts","../src/cdn/cdn-client.ts"],"sourcesContent":["import type { Context } from '@/cdn/context/context.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\n\nexport class Api {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public async fetchLocale(options: ApiLocaleRequest): Promise<object | string> {\n if (this.context.cache.has(options)) {\n return new Promise((resolve): void => {\n resolve(this.context.cache.get(options) as object | string);\n });\n }\n\n return this.context.client.get(options.metafileLocale.uri);\n }\n\n public async fetchMetafile(): Promise<IMetafile> {\n return (await this.context.client.get(this.context.metafile.params.jsonPath)) as IMetafile;\n }\n}\n","import type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\n\nexport class MemoryCacheAdapter<K, V> implements ICacheAdapter<K, V> {\n protected map: Map<K, V>;\n\n constructor() {\n this.map = new Map();\n }\n\n public get(key: K): V | undefined {\n return this.map.get(key);\n }\n\n public has(key: K): boolean {\n return this.map.has(key);\n }\n\n public set(key: K, value: V): void {\n this.map.set(key, value);\n }\n\n public flush(): void {\n this.map = new Map();\n }\n}\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isUndefined = (value: unknown): value is undefined => typeof value === 'undefined';\n\nexport const isArray = <T>(value: unknown): value is T[] => Array.isArray(value);\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n Object.prototype.toString.call(value) === '[object Object]';\n\nexport const uniq = <T>(array: T[]): T[] => [...new Set(array)];\n\nexport const uniqBy = <T>(array: T[], predicate: (item: T) => string): T[] => {\n const seen: Record<string, boolean> = {};\n\n return array.filter((item: T): boolean => {\n const key: string = predicate(item);\n\n if (!Object.hasOwn(seen, key)) {\n seen[key] = true;\n\n return true;\n }\n\n return false;\n });\n};\n","import { MemoryCacheAdapter } from '@/cdn/cache/memory-cache-adapter.js';\nimport type { Context } from '@/cdn/context/context.js';\nimport { uniq } from '@/cdn/utils.js';\nimport type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\nimport type { CacheGetLocalesRequest } from '@/types/cache-get-locales-request.js';\nimport type { CacheHasLocalesRequest } from '@/types/cache-has-locales-request.js';\nimport type { CacheKeyMetafileOptions } from '@/types/cache-key-metafile-options.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\n\nexport class LocalesCache {\n protected context: Context;\n\n protected cacheAdapter: ICacheAdapter<string, object | string>;\n\n constructor(context: Context) {\n this.context = context;\n this.cacheAdapter = new MemoryCacheAdapter();\n }\n\n public setIfMissed(options: CacheStoreLocalesRequest): void {\n const { metafileFile, metafileLocale, data }: CacheStoreLocalesRequest = options;\n\n const key: string = this.keyFromMetafile({\n metafileFile,\n metafileLocale,\n });\n\n if (!this.cacheAdapter.has(key)) {\n this.cacheAdapter.set(key, data);\n }\n }\n\n public has(options: CacheHasLocalesRequest): boolean {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.has(key);\n }\n\n public get(options: CacheGetLocalesRequest): object | string | undefined {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.get(key);\n }\n\n public flush(): void {\n this.cacheAdapter.flush();\n }\n\n protected keyFromMetafile(options: CacheKeyMetafileOptions): string {\n const { metafileFile, metafileLocale }: CacheKeyMetafileOptions = options;\n const productFlavors: string = [...uniq(metafileFile.productFlavors)].sort().join('-');\n\n const indices: string[] = [\n this.context.metafile.params.cdnId,\n metafileFile.id,\n metafileFile.file,\n metafileFile.path,\n metafileFile.library,\n metafileFile.module,\n metafileFile.buildType,\n productFlavors,\n metafileLocale.locale,\n metafileLocale.timestamp.toString(),\n ];\n\n return indices.filter((key: string): boolean => key !== '').join('-');\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\nimport type { ResponseFactoryOptions } from '@/types/response-factory-options.js';\n\nexport class ResponseFactory {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public createCdnResponse(options: ResponseFactoryOptions): CdnResponse {\n const {\n requests,\n responses,\n hasSingleFileResponse,\n hasSingleLocaleResponse,\n }: ResponseFactoryOptions = options;\n\n if (responses.length === 0 || typeof responses[0] === 'undefined') {\n return {};\n }\n\n this.cacheResponses(requests, responses);\n\n return hasSingleFileResponse && hasSingleLocaleResponse\n ? responses[0]\n : ResponseFactory.transformResponses(options);\n }\n\n protected cacheResponses(requests: ApiLocaleRequest[], responses: (object | string)[]): void {\n responses.forEach((response: object | string, index: number): void => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n this.context.cache.setIfMissed({ metafileFile, metafileLocale, data: response });\n }\n }\n });\n }\n\n protected static transformResponses(options: ResponseFactoryOptions): CdnResponse {\n const { requests, responses, hasSingleFileResponse }: ResponseFactoryOptions = options;\n\n return responses.reduce((acc: CdnResponse, cur: object | string, index: number) => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n if (hasSingleFileResponse) {\n // @ts-expect-error fix output type\n acc[metafileLocale.locale] = cur;\n } else {\n // @ts-expect-error fix output type\n if (!acc[metafileFile.id]) {\n // @ts-expect-error fix output type\n acc[metafileFile.id] = {};\n }\n\n // @ts-expect-error fix output type\n acc[metafileFile.id][metafileLocale.locale] = cur;\n }\n }\n }\n\n return acc;\n }, {});\n }\n}\n","import { Api } from '@/cdn/api/api.js';\nimport { LocalesCache } from '@/cdn/cache/locales-cache.js';\nimport type { CdnClient } from '@/cdn/cdn-client.js';\nimport type { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { ResponseFactory } from '@/cdn/response/response-factory.js';\nimport type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\nimport type { ContextOptions } from '@/types/context-options.js';\n\nexport class Context {\n public metafile: MetafileContext;\n\n public cdn: CdnClient;\n\n public client: IHttpAdapter;\n\n public api: Api;\n\n public cache: LocalesCache;\n\n public responseFactory: ResponseFactory;\n\n constructor(options: ContextOptions) {\n this.metafile = options.metafileContext;\n this.cdn = options.cdn;\n this.client = options.client;\n this.api = new Api(this);\n this.cache = new LocalesCache(this);\n this.responseFactory = new ResponseFactory(this);\n }\n}\n","import type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { IMetafileFile } from '@/interfaces/i-metafile-file.js';\nimport type { CdnFileLocale } from '@/types/cdn-file-locale.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { MetafileFileOptions } from '@/types/metafile-file-options.js';\n\nexport class MetafileFile implements Omit<IMetafileFile, 'locales'> {\n public id: string;\n\n public file: string;\n\n public path: string;\n\n public library: string;\n\n public module: string;\n\n public buildType: string;\n\n public timestamp: number;\n\n public productFlavors: string[];\n\n public locales: MetafileLocale[];\n\n protected baseUrl: string;\n\n constructor(options: MetafileFileOptions) {\n this.id = options.id;\n this.file = options.file;\n this.path = options.path;\n this.library = options.library;\n this.module = options.module;\n this.buildType = options.buildType;\n this.timestamp = options.timestamp;\n this.productFlavors = options.productFlavors;\n this.locales = options.locales;\n this.baseUrl = options.baseUrl;\n }\n\n public toCdnFile(): CdnFile {\n return {\n id: this.id,\n file: this.file,\n path: this.path,\n library: this.library,\n module: this.module,\n buildType: this.buildType,\n productFlavors: this.productFlavors,\n locales: this.locales.map(\n (locale: MetafileLocale): CdnFileLocale => ({\n locale: locale.locale,\n isBaseLocale: locale.isBaseLocale,\n uri: `${this.baseUrl}${locale.uri}`,\n }),\n ),\n };\n }\n}\n","import type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\n\nexport class MetafileLocale implements IMetafileFileLocale {\n public language: string;\n\n public region: string;\n\n public script: string;\n\n public isRtl: boolean;\n\n public name: string;\n\n public localizedName: string;\n\n public uri: string;\n\n public timestamp: number;\n\n protected baseLocale: string;\n\n constructor(options: IMetafileFileLocale, baseLocale: string) {\n this.language = options.language;\n this.region = options.region;\n this.script = options.script;\n this.isRtl = options.isRtl;\n this.name = options.name;\n this.localizedName = options.localizedName;\n this.uri = options.uri;\n this.timestamp = options.timestamp;\n this.baseLocale = baseLocale;\n }\n\n get locale(): string {\n if (this.language && this.region && this.script) {\n return `${this.language}_${this.region}#${this.script}`;\n }\n\n if (this.language && this.script) {\n return `${this.language}#${this.script}`;\n }\n\n if (this.language && this.region) {\n return `${this.language}_${this.region}`;\n }\n\n return this.language;\n }\n\n get isBaseLocale(): boolean {\n return this.locale === this.baseLocale;\n }\n\n public toCdnLocale(): CdnLocale {\n return {\n locale: this.locale,\n isBaseLocale: this.isBaseLocale,\n language: this.language,\n region: this.region,\n script: this.script,\n isRtl: this.isRtl,\n name: this.name,\n localizedName: this.localizedName,\n };\n }\n}\n","import { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { uniqBy } from '@/cdn/utils.js';\nimport type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { IMetafileFiles } from '@/interfaces/i-metafile-files.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { FilesMap } from '@/types/files-map.js';\nimport type { MetafileOptions } from '@/types/metafile-options.js';\n\nexport class MetafileData implements Omit<IMetafile, 'files' | 'baseLocale'> {\n public projectUrl: string;\n\n public baseLocale: CdnLocale;\n\n public locales: CdnLocale[];\n\n public timestamp: number;\n\n public files: MetafileFile[];\n\n public filesMap: FilesMap;\n\n constructor(options: MetafileOptions, params: MetafileParams) {\n this.projectUrl = options.projectUrl;\n this.timestamp = options.timestamp;\n this.files = MetafileData.filesFactory(options.files, options.baseLocale, params);\n this.filesMap = MetafileData.filesMapFactory(this.files);\n this.locales = MetafileData.localesFactory(this.files);\n this.baseLocale = this.locales.find((locale: CdnLocale) => locale.isBaseLocale) as CdnLocale;\n }\n\n public static createEmpty(params: MetafileParams): MetafileData {\n return new MetafileData(\n {\n projectUrl: '',\n baseLocale: '',\n timestamp: 0,\n files: {},\n },\n params,\n );\n }\n\n protected static filesFactory(\n files: IMetafileFiles,\n baseLocale: string,\n params: MetafileParams,\n ): MetafileFile[] {\n return Object.keys(files).reduce((acc: MetafileFile[], cur: string) => {\n if (typeof files[cur] !== 'undefined') {\n const locales: MetafileLocale[] = files[cur].locales.map(\n (locale: IMetafileFileLocale) => new MetafileLocale(locale, baseLocale),\n );\n\n acc.push(\n new MetafileFile({\n ...files[cur],\n id: cur,\n locales,\n baseUrl: params.baseUrl,\n }),\n );\n }\n\n return acc;\n }, []);\n }\n\n protected static filesMapFactory(files: MetafileFile[]): FilesMap {\n return files.reduce((acc: FilesMap, cur: MetafileFile) => {\n acc[cur.id] = cur;\n\n return acc;\n }, {});\n }\n\n protected static localesFactory(files: MetafileFile[]): CdnLocale[] {\n const locales: CdnLocale[] = files.reduce((acc: CdnLocale[], cur: MetafileFile) => {\n acc.push(...cur.locales.map((locale: MetafileLocale): CdnLocale => locale.toCdnLocale()));\n return acc;\n }, []);\n\n return uniqBy(locales, (cdnLocale: CdnLocale): string => cdnLocale.locale);\n }\n}\n","import type { IMetafileParams } from '@/interfaces/i-metafile-params.js';\n\nexport class MetafileParams implements IMetafileParams {\n protected options: IMetafileParams;\n\n constructor(metafileUrl: string) {\n this.options = MetafileParams.parseMetafileUrl(metafileUrl);\n }\n\n get url(): string {\n return this.options.url;\n }\n\n get baseUrl(): string {\n return this.options.baseUrl;\n }\n\n get cdnId(): string {\n return this.options.cdnId;\n }\n\n get jsonPath(): string {\n return this.options.jsonPath;\n }\n\n protected static parseMetafileUrl(metafileUrl: string): IMetafileParams {\n let url: URL;\n\n try {\n url = new URL(metafileUrl);\n } catch {\n throw new Error('Invalid param: \"options.metafile\" cannot be parsed as url.');\n }\n\n const matches: string[] | null = /^\\/(.*?)\\/(.*?)\\.(v2.json|js|ts)$/.exec(url.pathname);\n\n if (\n matches === null ||\n matches.length !== 4 ||\n typeof matches[1] === 'undefined' ||\n typeof matches[2] === 'undefined'\n ) {\n throw new Error('Invalid param: \"options.metafile\" contains invalid metafile url.');\n }\n\n const cdnId: string = matches[1];\n const tagId: string = matches[2];\n\n return {\n url: metafileUrl,\n baseUrl: url.origin,\n cdnId,\n jsonPath: `/${cdnId}/${tagId}.v2.json`,\n };\n }\n}\n","import { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\n\nexport class MetafileContext {\n public params: MetafileParams;\n\n public parsedData: IMetafile | null;\n\n public data: MetafileData;\n\n constructor(options: CdnClientOptions) {\n this.params = new MetafileParams(options.metafile);\n this.parsedData = null;\n this.data = MetafileData.createEmpty(this.params);\n }\n\n public setMetafile(metafile: IMetafile): void {\n this.parsedData = metafile;\n\n this.data = new MetafileData(metafile, this.params);\n }\n}\n","import type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\n\nexport class FetchHttpAdapter implements IHttpAdapter {\n protected baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async get(url: string): Promise<string | object> {\n const response: Response = await fetch(`${this.baseUrl}${url}`);\n const contentType: string | null = response.headers.get('content-type');\n const isJson: boolean =\n contentType === 'application/json5' || contentType === 'application/json';\n\n if (response.status >= 400) {\n throw new Error(`Request failed with status code ${response.status.toString()}`);\n }\n\n let result: string | object;\n\n if (isJson) {\n result = (await response.json()) as object;\n } else {\n result = await response.text();\n }\n\n return result;\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\n\nexport abstract class CdnBase {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n}\n","import { CdnBase } from '@/cdn/methods/cdn-base.js';\n\nexport class CdnCache extends CdnBase {\n public flush = (): void => {\n this.context.cache.flush();\n };\n}\n","import type { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { CdnBase } from '@/cdn/methods/cdn-base.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { CdnLocalesOptions } from '@/types/cdn-locales-options.js';\n\nexport class CdnMetafile extends CdnBase {\n get projectUrl(): string {\n return this.context.metafile.data.projectUrl;\n }\n\n get baseLocale(): CdnLocale {\n return this.context.metafile.data.baseLocale;\n }\n\n get url(): string {\n return this.context.metafile.params.url;\n }\n\n get files(): CdnFile[] {\n return this.context.metafile.data.files.map((file: MetafileFile): CdnFile => file.toCdnFile());\n }\n\n public locales = (options?: CdnLocalesOptions): CdnLocale[] => {\n const { excludeBaseLocale }: CdnLocalesOptions = options || {};\n const { locales }: MetafileData = this.context.metafile.data;\n\n return excludeBaseLocale\n ? locales.filter((cdnLocale: CdnLocale): boolean => !cdnLocale.isBaseLocale)\n : locales;\n };\n\n public refresh = async (): Promise<void> => {\n const response: IMetafile = await this.context.api.fetchMetafile();\n\n this.context.metafile.setMetafile(response);\n };\n\n public switch = async (options: CdnClientOptions): Promise<void> => {\n this.context.metafile.params = new MetafileParams(options.metafile);\n\n await this.refresh();\n };\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { LocalesMapData } from '@/types/locales-map-data.js';\nimport type { LocalesMapOptions } from '@/types/locales-map-options.js';\n\nexport class LocalesMap {\n public data: LocalesMapData;\n\n protected context: Context;\n\n constructor(options: LocalesMapOptions) {\n this.context = options.context;\n this.data = options.data || {};\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport { LocalesMap } from '@/cdn/request/locales-map.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class Request {\n public files: MetafileFile[];\n\n public localesMap: LocalesMap;\n\n public hasSingleFileResponse: boolean;\n\n public hasSingleLocaleResponse: boolean;\n\n protected context: Context;\n\n constructor(context: Context) {\n this.files = [];\n this.localesMap = new LocalesMap({ context });\n this.hasSingleFileResponse = false;\n this.hasSingleLocaleResponse = false;\n this.context = context;\n }\n\n public async execute(): Promise<CdnResponse> {\n const payload: [Promise<string | object>, ApiLocaleRequest][] = this.getPromises();\n const promises: Promise<string | object>[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[0],\n );\n const requests: ApiLocaleRequest[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[1],\n );\n const responses: (string | object)[] = await Promise.all(promises);\n\n return this.context.responseFactory.createCdnResponse({\n requests,\n responses,\n localesMap: this.localesMap,\n hasSingleFileResponse: this.hasSingleFileResponse,\n hasSingleLocaleResponse: this.hasSingleLocaleResponse,\n });\n }\n\n protected getPromises(): [Promise<string | object>, ApiLocaleRequest][] {\n return this.files.reduce(\n (acc: [Promise<string | object>, ApiLocaleRequest][], cur: MetafileFile) => {\n if (typeof this.localesMap.data?.[cur.id] !== 'undefined') {\n acc.push(\n ...this.localesMap.data[cur.id].map(\n (metafileLocale: MetafileLocale): [Promise<string | object>, ApiLocaleRequest] => {\n const request: ApiLocaleRequest = {\n metafileFile: cur,\n metafileLocale,\n };\n\n return [this.context.api.fetchLocale(request), request];\n },\n ),\n );\n }\n return acc;\n },\n [],\n );\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { LocalesMap } from '@/cdn/request/locales-map.js';\nimport { Request } from '@/cdn/request/request.js';\nimport { isArray, isPlainObject, isString, isUndefined } from '@/cdn/utils.js';\nimport type { IRequestBuilder } from '@/interfaces/i-request-builder.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\n\nexport class RequestBuilder implements IRequestBuilder {\n protected context: Context;\n\n protected request: Request;\n\n constructor(context: Context) {\n this.context = context;\n this.request = new Request(this.context);\n }\n\n public addFiles(files?: (CdnFile | string)[] | CdnFile | string): this {\n if (!(isPlainObject(files) || isString(files) || isUndefined(files) || isArray(files))) {\n throw new Error('Invalid param: \"request.files\" must be object, array, string or undefined.');\n }\n\n if (isArray(files)) {\n files.forEach((i: CdnFile | string): void => {\n if (!(isPlainObject(i) || isString(i))) {\n throw new Error('Invalid param: array \"request.files\" must contain objects or strings.');\n }\n });\n }\n\n if (isString(files)) {\n this.request.hasSingleFileResponse = true;\n\n const file: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files,\n );\n\n if (!(file instanceof MetafileFile)) {\n throw new Error(`File not found: \"${files}\".`);\n }\n\n this.request.files = [file];\n } else if (isUndefined(files)) {\n this.request.files = [...this.context.metafile.data.files];\n } else if (isArray(files)) {\n this.request.files = files.map((file: CdnFile | string): MetafileFile => {\n let metafileFile: MetafileFile;\n\n if (isString(file)) {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file}\".`);\n }\n\n metafileFile = foundFile;\n } else {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file.id}\".`);\n }\n\n metafileFile = foundFile;\n }\n\n return metafileFile;\n });\n } else if (isPlainObject(files)) {\n this.request.hasSingleFileResponse = true;\n\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${files.id}\".`);\n }\n\n this.request.files = [foundFile];\n }\n\n return this;\n }\n\n public addLocales(locales?: string[] | string, excludeBaseLocale?: boolean): this {\n if (!(isString(locales) || isUndefined(locales) || isArray(locales))) {\n throw new Error('Invalid param: \"request.locales\" must be array, string or undefined.');\n }\n\n if (isArray(locales)) {\n locales.forEach((i: MetafileFile | string): void => {\n if (!isString(i)) {\n throw new Error('Invalid param: array \"request.locales\" must contain strings.');\n }\n });\n }\n\n if (isString(locales)) {\n this.request.hasSingleLocaleResponse = true;\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => metafileLocale.locale === locales,\n );\n\n return acc;\n }, this.request.localesMap);\n } else if (isUndefined(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = excludeBaseLocale\n ? cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => !metafileLocale.isBaseLocale,\n )\n : cur.locales;\n\n return acc;\n }, this.request.localesMap);\n } else if (isArray(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter((metafileLocale: MetafileLocale) =>\n locales.includes(metafileLocale.locale),\n );\n\n return acc;\n }, this.request.localesMap);\n }\n\n return this;\n }\n\n public getCdnRequest(): Request {\n const result: Request = this.request;\n this.request = new Request(this.context);\n return result;\n }\n}\n","import { Context } from '@/cdn/context/context.js';\nimport { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { FetchHttpAdapter } from '@/cdn/http/fetch-http-adapter.js';\nimport { CdnCache } from '@/cdn/methods/cdn-cache.js';\nimport { CdnMetafile } from '@/cdn/methods/cdn-metafile.js';\nimport { RequestBuilder } from '@/cdn/request/request-builder.js';\nimport { isString } from '@/cdn/utils.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFetchOptions } from '@/types/cdn-fetch-options.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class CdnClient {\n public metafile: CdnMetafile;\n\n public cache: CdnCache;\n\n protected context: Context;\n\n public static version = '__CLIENT_VERSION__';\n\n protected constructor(options: CdnClientOptions) {\n const metafileContext: MetafileContext = new MetafileContext(options);\n const client: FetchHttpAdapter = new FetchHttpAdapter(metafileContext.params.baseUrl);\n\n this.context = new Context({ metafileContext, cdn: this, client });\n this.metafile = new CdnMetafile(this.context);\n this.cache = new CdnCache(this.context);\n }\n\n public fetch = async (options?: CdnFetchOptions): Promise<CdnResponse> => {\n const { files, locales, excludeBaseLocale }: CdnFetchOptions = options || {};\n const requestBuilder: RequestBuilder = new RequestBuilder(this.context)\n .addFiles(files)\n .addLocales(locales, excludeBaseLocale);\n\n return requestBuilder.getCdnRequest().execute();\n };\n\n public static async create(options: CdnClientOptions): Promise<CdnClient> {\n if (!options) {\n throw new Error('Invalid param: missing required \"options\" parameter.');\n }\n\n if (!isString(options.metafile)) {\n throw new Error('Invalid param: \"options.metafile\" must be string.');\n }\n\n const cdn: CdnClient = new CdnClient(options);\n\n await cdn.metafile.refresh();\n\n return cdn;\n }\n}\n"],"mappings":";;;;AAIA,IAAa,MAAb,MAAiB;CACf;CAEA,YAAY,SAAkB;AAC5B,OAAK,UAAU;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MAAiB,IAAI,UAAU,QAAQ;AAE7C,QAAM,IAAI,SAAS,SAAS;AAE5B,SAAO"}
1
+ {"version":3,"file":"localazy-cdn-client.js","names":[],"sources":["../src/cdn/api/api.ts","../src/cdn/cache/memory-cache-adapter.ts","../src/cdn/utils.ts","../src/cdn/cache/locales-cache.ts","../src/cdn/response/response-factory.ts","../src/cdn/context/context.ts","../src/cdn/metafile/metafile-file.ts","../src/cdn/metafile/metafile-locale.ts","../src/cdn/metafile/metafile-data.ts","../src/cdn/metafile/metafile-params.ts","../src/cdn/context/metafile-context.ts","../src/cdn/http/fetch-http-adapter.ts","../src/cdn/methods/cdn-base.ts","../src/cdn/methods/cdn-cache.ts","../src/cdn/methods/cdn-metafile.ts","../src/cdn/request/locales-map.ts","../src/cdn/request/request.ts","../src/cdn/request/request-builder.ts","../src/cdn/cdn-client.ts"],"sourcesContent":["import type { Context } from '@/cdn/context/context.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\n\nexport class Api {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public async fetchLocale(options: ApiLocaleRequest): Promise<object | string> {\n if (this.context.cache.has(options)) {\n return new Promise((resolve): void => {\n resolve(this.context.cache.get(options) as object | string);\n });\n }\n\n return this.context.client.get(options.metafileLocale.uri);\n }\n\n public async fetchMetafile(): Promise<IMetafile> {\n return (await this.context.client.get(this.context.metafile.params.jsonPath)) as IMetafile;\n }\n}\n","import type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\n\nexport class MemoryCacheAdapter<K, V> implements ICacheAdapter<K, V> {\n protected map: Map<K, V>;\n\n constructor() {\n this.map = new Map();\n }\n\n public get(key: K): V | undefined {\n return this.map.get(key);\n }\n\n public has(key: K): boolean {\n return this.map.has(key);\n }\n\n public set(key: K, value: V): void {\n this.map.set(key, value);\n }\n\n public flush(): void {\n this.map = new Map();\n }\n}\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isUndefined = (value: unknown): value is undefined => typeof value === 'undefined';\n\nexport const isArray = <T>(value: unknown): value is T[] => Array.isArray(value);\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n Object.prototype.toString.call(value) === '[object Object]';\n\nexport const uniq = <T>(array: T[]): T[] => [...new Set(array)];\n\nexport const uniqBy = <T>(array: T[], predicate: (item: T) => string): T[] => {\n const seen: Record<string, boolean> = {};\n\n return array.filter((item: T): boolean => {\n const key: string = predicate(item);\n\n if (!Object.hasOwn(seen, key)) {\n seen[key] = true;\n\n return true;\n }\n\n return false;\n });\n};\n","import { MemoryCacheAdapter } from '@/cdn/cache/memory-cache-adapter.js';\nimport type { Context } from '@/cdn/context/context.js';\nimport { uniq } from '@/cdn/utils.js';\nimport type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\nimport type { CacheGetLocalesRequest } from '@/types/cache-get-locales-request.js';\nimport type { CacheHasLocalesRequest } from '@/types/cache-has-locales-request.js';\nimport type { CacheKeyMetafileOptions } from '@/types/cache-key-metafile-options.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\n\nexport class LocalesCache {\n protected context: Context;\n\n protected cacheAdapter: ICacheAdapter<string, object | string>;\n\n constructor(context: Context) {\n this.context = context;\n this.cacheAdapter = new MemoryCacheAdapter();\n }\n\n public setIfMissed(options: CacheStoreLocalesRequest): void {\n const { metafileFile, metafileLocale, data }: CacheStoreLocalesRequest = options;\n\n const key: string = this.keyFromMetafile({\n metafileFile,\n metafileLocale,\n });\n\n if (!this.cacheAdapter.has(key)) {\n this.cacheAdapter.set(key, data);\n }\n }\n\n public has(options: CacheHasLocalesRequest): boolean {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.has(key);\n }\n\n public get(options: CacheGetLocalesRequest): object | string | undefined {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.get(key);\n }\n\n public flush(): void {\n this.cacheAdapter.flush();\n }\n\n protected keyFromMetafile(options: CacheKeyMetafileOptions): string {\n const { metafileFile, metafileLocale }: CacheKeyMetafileOptions = options;\n const productFlavors: string = [...uniq(metafileFile.productFlavors)].sort().join('-');\n\n const indices: string[] = [\n this.context.metafile.params.cdnId,\n metafileFile.id,\n metafileFile.file,\n metafileFile.path,\n metafileFile.library,\n metafileFile.module,\n metafileFile.buildType,\n productFlavors,\n metafileLocale.locale,\n metafileLocale.timestamp.toString(),\n ];\n\n return indices.filter((key: string): boolean => key !== '').join('-');\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\nimport type { ResponseFactoryOptions } from '@/types/response-factory-options.js';\n\nexport class ResponseFactory {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public createCdnResponse(options: ResponseFactoryOptions): CdnResponse {\n const {\n requests,\n responses,\n hasSingleFileResponse,\n hasSingleLocaleResponse,\n }: ResponseFactoryOptions = options;\n\n if (responses.length === 0 || typeof responses[0] === 'undefined') {\n return {};\n }\n\n this.cacheResponses(requests, responses);\n\n return hasSingleFileResponse && hasSingleLocaleResponse\n ? responses[0]\n : ResponseFactory.transformResponses(options);\n }\n\n protected cacheResponses(requests: ApiLocaleRequest[], responses: (object | string)[]): void {\n responses.forEach((response: object | string, index: number): void => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n this.context.cache.setIfMissed({ metafileFile, metafileLocale, data: response });\n }\n }\n });\n }\n\n protected static transformResponses(options: ResponseFactoryOptions): CdnResponse {\n const { requests, responses, hasSingleFileResponse }: ResponseFactoryOptions = options;\n\n return responses.reduce((acc: CdnResponse, cur: object | string, index: number) => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n if (hasSingleFileResponse) {\n // @ts-expect-error fix output type\n acc[metafileLocale.locale] = cur;\n } else {\n // @ts-expect-error fix output type\n if (!acc[metafileFile.id]) {\n // @ts-expect-error fix output type\n acc[metafileFile.id] = {};\n }\n\n // @ts-expect-error fix output type\n acc[metafileFile.id][metafileLocale.locale] = cur;\n }\n }\n }\n\n return acc;\n }, {});\n }\n}\n","import { Api } from '@/cdn/api/api.js';\nimport { LocalesCache } from '@/cdn/cache/locales-cache.js';\nimport type { CdnClient } from '@/cdn/cdn-client.js';\nimport type { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { ResponseFactory } from '@/cdn/response/response-factory.js';\nimport type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\nimport type { ContextOptions } from '@/types/context-options.js';\n\nexport class Context {\n public metafile: MetafileContext;\n\n public cdn: CdnClient;\n\n public client: IHttpAdapter;\n\n public api: Api;\n\n public cache: LocalesCache;\n\n public responseFactory: ResponseFactory;\n\n constructor(options: ContextOptions) {\n this.metafile = options.metafileContext;\n this.cdn = options.cdn;\n this.client = options.client;\n this.api = new Api(this);\n this.cache = new LocalesCache(this);\n this.responseFactory = new ResponseFactory(this);\n }\n}\n","import type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { IMetafileFile } from '@/interfaces/i-metafile-file.js';\nimport type { CdnFileLocale } from '@/types/cdn-file-locale.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { MetafileFileOptions } from '@/types/metafile-file-options.js';\n\nexport class MetafileFile implements Omit<IMetafileFile, 'locales'> {\n public id: string;\n\n public file: string;\n\n public path: string;\n\n public library: string;\n\n public module: string;\n\n public buildType: string;\n\n public timestamp: number;\n\n public productFlavors: string[];\n\n public locales: MetafileLocale[];\n\n protected baseUrl: string;\n\n constructor(options: MetafileFileOptions) {\n this.id = options.id;\n this.file = options.file;\n this.path = options.path;\n this.library = options.library;\n this.module = options.module;\n this.buildType = options.buildType;\n this.timestamp = options.timestamp;\n this.productFlavors = options.productFlavors;\n this.locales = options.locales;\n this.baseUrl = options.baseUrl;\n }\n\n public toCdnFile(): CdnFile {\n return {\n id: this.id,\n file: this.file,\n path: this.path,\n library: this.library,\n module: this.module,\n buildType: this.buildType,\n productFlavors: this.productFlavors,\n locales: this.locales.map(\n (locale: MetafileLocale): CdnFileLocale => ({\n locale: locale.locale,\n isBaseLocale: locale.isBaseLocale,\n uri: `${this.baseUrl}${locale.uri}`,\n }),\n ),\n };\n }\n}\n","import type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\n\nexport class MetafileLocale implements IMetafileFileLocale {\n public language: string;\n\n public region: string;\n\n public script: string;\n\n public isRtl: boolean;\n\n public name: string;\n\n public localizedName: string;\n\n public uri: string;\n\n public timestamp: number;\n\n protected baseLocale: string;\n\n constructor(options: IMetafileFileLocale, baseLocale: string) {\n this.language = options.language;\n this.region = options.region;\n this.script = options.script;\n this.isRtl = options.isRtl;\n this.name = options.name;\n this.localizedName = options.localizedName;\n this.uri = options.uri;\n this.timestamp = options.timestamp;\n this.baseLocale = baseLocale;\n }\n\n get locale(): string {\n if (this.language && this.region && this.script) {\n return `${this.language}_${this.region}#${this.script}`;\n }\n\n if (this.language && this.script) {\n return `${this.language}#${this.script}`;\n }\n\n if (this.language && this.region) {\n return `${this.language}_${this.region}`;\n }\n\n return this.language;\n }\n\n get isBaseLocale(): boolean {\n return this.locale === this.baseLocale;\n }\n\n public toCdnLocale(): CdnLocale {\n return {\n locale: this.locale,\n isBaseLocale: this.isBaseLocale,\n language: this.language,\n region: this.region,\n script: this.script,\n isRtl: this.isRtl,\n name: this.name,\n localizedName: this.localizedName,\n };\n }\n}\n","import { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { uniqBy } from '@/cdn/utils.js';\nimport type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { IMetafileFiles } from '@/interfaces/i-metafile-files.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { FilesMap } from '@/types/files-map.js';\nimport type { MetafileOptions } from '@/types/metafile-options.js';\n\nexport class MetafileData implements Omit<IMetafile, 'files' | 'baseLocale'> {\n public projectUrl: string;\n\n public baseLocale: CdnLocale;\n\n public locales: CdnLocale[];\n\n public timestamp: number;\n\n public files: MetafileFile[];\n\n public filesMap: FilesMap;\n\n constructor(options: MetafileOptions, params: MetafileParams) {\n this.projectUrl = options.projectUrl;\n this.timestamp = options.timestamp;\n this.files = MetafileData.filesFactory(options.files, options.baseLocale, params);\n this.filesMap = MetafileData.filesMapFactory(this.files);\n this.locales = MetafileData.localesFactory(this.files);\n this.baseLocale = this.locales.find((locale: CdnLocale) => locale.isBaseLocale) as CdnLocale;\n }\n\n public static createEmpty(params: MetafileParams): MetafileData {\n return new MetafileData(\n {\n projectUrl: '',\n baseLocale: '',\n timestamp: 0,\n files: {},\n },\n params,\n );\n }\n\n protected static filesFactory(\n files: IMetafileFiles,\n baseLocale: string,\n params: MetafileParams,\n ): MetafileFile[] {\n return Object.keys(files).reduce((acc: MetafileFile[], cur: string) => {\n if (typeof files[cur] !== 'undefined') {\n const locales: MetafileLocale[] = files[cur].locales.map(\n (locale: IMetafileFileLocale) => new MetafileLocale(locale, baseLocale),\n );\n\n acc.push(\n new MetafileFile({\n ...files[cur],\n id: cur,\n locales,\n baseUrl: params.baseUrl,\n }),\n );\n }\n\n return acc;\n }, []);\n }\n\n protected static filesMapFactory(files: MetafileFile[]): FilesMap {\n return files.reduce((acc: FilesMap, cur: MetafileFile) => {\n acc[cur.id] = cur;\n\n return acc;\n }, {});\n }\n\n protected static localesFactory(files: MetafileFile[]): CdnLocale[] {\n const locales: CdnLocale[] = files.reduce((acc: CdnLocale[], cur: MetafileFile) => {\n acc.push(...cur.locales.map((locale: MetafileLocale): CdnLocale => locale.toCdnLocale()));\n return acc;\n }, []);\n\n return uniqBy(locales, (cdnLocale: CdnLocale): string => cdnLocale.locale);\n }\n}\n","import type { IMetafileParams } from '@/interfaces/i-metafile-params.js';\n\nexport class MetafileParams implements IMetafileParams {\n protected options: IMetafileParams;\n\n constructor(metafileUrl: string) {\n this.options = MetafileParams.parseMetafileUrl(metafileUrl);\n }\n\n get url(): string {\n return this.options.url;\n }\n\n get baseUrl(): string {\n return this.options.baseUrl;\n }\n\n get cdnId(): string {\n return this.options.cdnId;\n }\n\n get jsonPath(): string {\n return this.options.jsonPath;\n }\n\n protected static parseMetafileUrl(metafileUrl: string): IMetafileParams {\n let url: URL;\n\n try {\n url = new URL(metafileUrl);\n } catch {\n throw new Error('Invalid param: \"options.metafile\" cannot be parsed as url.');\n }\n\n const matches: string[] | null = /^\\/(.*?)\\/(.*?)\\.(v2.json|js|ts)$/.exec(url.pathname);\n\n if (\n matches === null ||\n matches.length !== 4 ||\n typeof matches[1] === 'undefined' ||\n typeof matches[2] === 'undefined'\n ) {\n throw new Error('Invalid param: \"options.metafile\" contains invalid metafile url.');\n }\n\n const cdnId: string = matches[1];\n const tagId: string = matches[2];\n\n return {\n url: metafileUrl,\n baseUrl: url.origin,\n cdnId,\n jsonPath: `/${cdnId}/${tagId}.v2.json`,\n };\n }\n}\n","import { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\n\nexport class MetafileContext {\n public params: MetafileParams;\n\n public parsedData: IMetafile | null;\n\n public data: MetafileData;\n\n constructor(options: CdnClientOptions) {\n this.params = new MetafileParams(options.metafile);\n this.parsedData = null;\n this.data = MetafileData.createEmpty(this.params);\n }\n\n public setMetafile(metafile: IMetafile): void {\n this.parsedData = metafile;\n\n this.data = new MetafileData(metafile, this.params);\n }\n}\n","import type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\n\nexport class FetchHttpAdapter implements IHttpAdapter {\n protected baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async get(url: string): Promise<string | object> {\n const response: Response = await fetch(`${this.baseUrl}${url}`);\n const contentType: string | null = response.headers.get('content-type');\n const isJson: boolean =\n contentType === 'application/json5' || contentType === 'application/json';\n\n if (response.status >= 400) {\n throw new Error(`Request failed with status code ${response.status.toString()}`);\n }\n\n let result: string | object;\n\n if (isJson) {\n result = (await response.json()) as object;\n } else {\n result = await response.text();\n }\n\n return result;\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\n\nexport abstract class CdnBase {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n}\n","import { CdnBase } from '@/cdn/methods/cdn-base.js';\n\nexport class CdnCache extends CdnBase {\n public flush = (): void => {\n this.context.cache.flush();\n };\n}\n","import type { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { CdnBase } from '@/cdn/methods/cdn-base.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { CdnLocalesOptions } from '@/types/cdn-locales-options.js';\n\nexport class CdnMetafile extends CdnBase {\n get projectUrl(): string {\n return this.context.metafile.data.projectUrl;\n }\n\n get baseLocale(): CdnLocale {\n return this.context.metafile.data.baseLocale;\n }\n\n get url(): string {\n return this.context.metafile.params.url;\n }\n\n get files(): CdnFile[] {\n return this.context.metafile.data.files.map((file: MetafileFile): CdnFile => file.toCdnFile());\n }\n\n public locales = (options?: CdnLocalesOptions): CdnLocale[] => {\n const { excludeBaseLocale }: CdnLocalesOptions = options || {};\n const { locales }: MetafileData = this.context.metafile.data;\n\n return excludeBaseLocale\n ? locales.filter((cdnLocale: CdnLocale): boolean => !cdnLocale.isBaseLocale)\n : locales;\n };\n\n public refresh = async (): Promise<void> => {\n const response: IMetafile = await this.context.api.fetchMetafile();\n\n this.context.metafile.setMetafile(response);\n };\n\n public switch = async (options: CdnClientOptions): Promise<void> => {\n this.context.metafile.params = new MetafileParams(options.metafile);\n\n await this.refresh();\n };\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { LocalesMapData } from '@/types/locales-map-data.js';\nimport type { LocalesMapOptions } from '@/types/locales-map-options.js';\n\nexport class LocalesMap {\n public data: LocalesMapData;\n\n protected context: Context;\n\n constructor(options: LocalesMapOptions) {\n this.context = options.context;\n this.data = options.data || {};\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport { LocalesMap } from '@/cdn/request/locales-map.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class Request {\n public files: MetafileFile[];\n\n public localesMap: LocalesMap;\n\n public hasSingleFileResponse: boolean;\n\n public hasSingleLocaleResponse: boolean;\n\n protected context: Context;\n\n constructor(context: Context) {\n this.files = [];\n this.localesMap = new LocalesMap({ context });\n this.hasSingleFileResponse = false;\n this.hasSingleLocaleResponse = false;\n this.context = context;\n }\n\n public async execute(): Promise<CdnResponse> {\n const payload: [Promise<string | object>, ApiLocaleRequest][] = this.getPromises();\n const promises: Promise<string | object>[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[0],\n );\n const requests: ApiLocaleRequest[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[1],\n );\n const responses: (string | object)[] = await Promise.all(promises);\n\n return this.context.responseFactory.createCdnResponse({\n requests,\n responses,\n localesMap: this.localesMap,\n hasSingleFileResponse: this.hasSingleFileResponse,\n hasSingleLocaleResponse: this.hasSingleLocaleResponse,\n });\n }\n\n protected getPromises(): [Promise<string | object>, ApiLocaleRequest][] {\n return this.files.reduce(\n (acc: [Promise<string | object>, ApiLocaleRequest][], cur: MetafileFile) => {\n if (typeof this.localesMap.data?.[cur.id] !== 'undefined') {\n acc.push(\n ...this.localesMap.data[cur.id].map(\n (metafileLocale: MetafileLocale): [Promise<string | object>, ApiLocaleRequest] => {\n const request: ApiLocaleRequest = {\n metafileFile: cur,\n metafileLocale,\n };\n\n return [this.context.api.fetchLocale(request), request];\n },\n ),\n );\n }\n return acc;\n },\n [],\n );\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { LocalesMap } from '@/cdn/request/locales-map.js';\nimport { Request } from '@/cdn/request/request.js';\nimport { isArray, isPlainObject, isString, isUndefined } from '@/cdn/utils.js';\nimport type { IRequestBuilder } from '@/interfaces/i-request-builder.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\n\nexport class RequestBuilder implements IRequestBuilder {\n protected context: Context;\n\n protected request: Request;\n\n constructor(context: Context) {\n this.context = context;\n this.request = new Request(this.context);\n }\n\n public addFiles(files?: (CdnFile | string)[] | CdnFile | string): this {\n if (!(isPlainObject(files) || isString(files) || isUndefined(files) || isArray(files))) {\n throw new Error('Invalid param: \"request.files\" must be object, array, string or undefined.');\n }\n\n if (isArray(files)) {\n files.forEach((i: CdnFile | string): void => {\n if (!(isPlainObject(i) || isString(i))) {\n throw new Error('Invalid param: array \"request.files\" must contain objects or strings.');\n }\n });\n }\n\n if (isString(files)) {\n this.request.hasSingleFileResponse = true;\n\n const file: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files,\n );\n\n if (!(file instanceof MetafileFile)) {\n throw new Error(`File not found: \"${files}\".`);\n }\n\n this.request.files = [file];\n } else if (isUndefined(files)) {\n this.request.files = [...this.context.metafile.data.files];\n } else if (isArray(files)) {\n this.request.files = files.map((file: CdnFile | string): MetafileFile => {\n let metafileFile: MetafileFile;\n\n if (isString(file)) {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file}\".`);\n }\n\n metafileFile = foundFile;\n } else {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file.id}\".`);\n }\n\n metafileFile = foundFile;\n }\n\n return metafileFile;\n });\n } else if (isPlainObject(files)) {\n this.request.hasSingleFileResponse = true;\n\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${files.id}\".`);\n }\n\n this.request.files = [foundFile];\n }\n\n return this;\n }\n\n public addLocales(locales?: string[] | string, excludeBaseLocale?: boolean): this {\n if (!(isString(locales) || isUndefined(locales) || isArray(locales))) {\n throw new Error('Invalid param: \"request.locales\" must be array, string or undefined.');\n }\n\n if (isArray(locales)) {\n locales.forEach((i: MetafileFile | string): void => {\n if (!isString(i)) {\n throw new Error('Invalid param: array \"request.locales\" must contain strings.');\n }\n });\n }\n\n if (isString(locales)) {\n this.request.hasSingleLocaleResponse = true;\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => metafileLocale.locale === locales,\n );\n\n return acc;\n }, this.request.localesMap);\n } else if (isUndefined(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = excludeBaseLocale\n ? cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => !metafileLocale.isBaseLocale,\n )\n : cur.locales;\n\n return acc;\n }, this.request.localesMap);\n } else if (isArray(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter((metafileLocale: MetafileLocale) =>\n locales.includes(metafileLocale.locale),\n );\n\n return acc;\n }, this.request.localesMap);\n }\n\n return this;\n }\n\n public getCdnRequest(): Request {\n const result: Request = this.request;\n this.request = new Request(this.context);\n return result;\n }\n}\n","import { Context } from '@/cdn/context/context.js';\nimport { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { FetchHttpAdapter } from '@/cdn/http/fetch-http-adapter.js';\nimport { CdnCache } from '@/cdn/methods/cdn-cache.js';\nimport { CdnMetafile } from '@/cdn/methods/cdn-metafile.js';\nimport { RequestBuilder } from '@/cdn/request/request-builder.js';\nimport { isString } from '@/cdn/utils.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFetchOptions } from '@/types/cdn-fetch-options.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class CdnClient {\n public metafile: CdnMetafile;\n\n public cache: CdnCache;\n\n protected context: Context;\n\n public static version = '__CLIENT_VERSION__';\n\n protected constructor(options: CdnClientOptions) {\n const metafileContext: MetafileContext = new MetafileContext(options);\n const client: FetchHttpAdapter = new FetchHttpAdapter(metafileContext.params.baseUrl);\n\n this.context = new Context({ metafileContext, cdn: this, client });\n this.metafile = new CdnMetafile(this.context);\n this.cache = new CdnCache(this.context);\n }\n\n public fetch = async (options?: CdnFetchOptions): Promise<CdnResponse> => {\n const { files, locales, excludeBaseLocale }: CdnFetchOptions = options || {};\n const requestBuilder: RequestBuilder = new RequestBuilder(this.context)\n .addFiles(files)\n .addLocales(locales, excludeBaseLocale);\n\n return requestBuilder.getCdnRequest().execute();\n };\n\n public static async create(options: CdnClientOptions): Promise<CdnClient> {\n if (!options) {\n throw new Error('Invalid param: missing required \"options\" parameter.');\n }\n\n if (!isString(options.metafile)) {\n throw new Error('Invalid param: \"options.metafile\" must be string.');\n }\n\n const cdn: CdnClient = new CdnCl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I,gBAAgB,OAAO;EACpE,MAAM,SAA2B,IAAI,iBAAiB,gBAAgB,OAAO,OAAO;EAEpF,KAAK,UAAU,IAAI,QAAQ;GAAE;GAAiB,KAAK;GAAM;EAAO,CAAC;EACjE,KAAK,WAAW,IAAI,YAAY,KAAK,OAAO;EAC5C,KAAK,QAAQ,IAAI,SAAS,KAAK,OAAO;CACxC;CAEA,QAAe,OAAO,YAAoD;EACxE,MAAM,EAAE,OAAO,SAAS,sBAAuC,WAAW,CAAC;EAK3E,OAJuC,IAAI,eAAe,KAAK,OAAO,EACnE,SAAS,KAAK,EACd,WAAW,SAAS,iBAEhB,EAAe,cAAc,EAAE,QAAQ;CAChD;CAEA,aAAoB,OAAO,SAA+C;EACxE,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,wDAAsD;EAGxE,IAAI,CAAC,SAAS,QAAQ,QAAQ,GAC5B,MAAM,IAAI,MAAM,qDAAmD;EAGrE,MAAM,MAAiB,IAAI,UAAU,OAAO;EAE5C,MAAM,IAAI,SAAS,QAAQ;EAE3B,OAAO;CACT;AACF"}
@@ -1,4 +1,4 @@
1
- /* @localazy/cdn-client@1.5.14
1
+ /* @localazy/cdn-client@1.5.16
2
2
  * (c) 2026 Localazy <team@localazy.com>
3
3
  * @license MIT */
4
4
  var e = class {
@@ -389,7 +389,7 @@ var e = class {
389
389
  metafile;
390
390
  cache;
391
391
  context;
392
- static version = "1.5.14";
392
+ static version = "1.5.16";
393
393
  constructor(e) {
394
394
  const t = new m(e), s = new g(t.params.baseUrl);
395
395
  this.context = new h({
@@ -1 +1 @@
1
- {"version":3,"file":"localazy-cdn-client.min.js","names":[],"sources":["../src/cdn/api/api.ts","../src/cdn/cache/memory-cache-adapter.ts","../src/cdn/utils.ts","../src/cdn/cache/locales-cache.ts","../src/cdn/response/response-factory.ts","../src/cdn/context/context.ts","../src/cdn/metafile/metafile-file.ts","../src/cdn/metafile/metafile-locale.ts","../src/cdn/metafile/metafile-data.ts","../src/cdn/metafile/metafile-params.ts","../src/cdn/context/metafile-context.ts","../src/cdn/http/fetch-http-adapter.ts","../src/cdn/methods/cdn-base.ts","../src/cdn/methods/cdn-cache.ts","../src/cdn/methods/cdn-metafile.ts","../src/cdn/request/locales-map.ts","../src/cdn/request/request.ts","../src/cdn/request/request-builder.ts","../src/cdn/cdn-client.ts"],"sourcesContent":["import type { Context } from '@/cdn/context/context.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\n\nexport class Api {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public async fetchLocale(options: ApiLocaleRequest): Promise<object | string> {\n if (this.context.cache.has(options)) {\n return new Promise((resolve): void => {\n resolve(this.context.cache.get(options) as object | string);\n });\n }\n\n return this.context.client.get(options.metafileLocale.uri);\n }\n\n public async fetchMetafile(): Promise<IMetafile> {\n return (await this.context.client.get(this.context.metafile.params.jsonPath)) as IMetafile;\n }\n}\n","import type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\n\nexport class MemoryCacheAdapter<K, V> implements ICacheAdapter<K, V> {\n protected map: Map<K, V>;\n\n constructor() {\n this.map = new Map();\n }\n\n public get(key: K): V | undefined {\n return this.map.get(key);\n }\n\n public has(key: K): boolean {\n return this.map.has(key);\n }\n\n public set(key: K, value: V): void {\n this.map.set(key, value);\n }\n\n public flush(): void {\n this.map = new Map();\n }\n}\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isUndefined = (value: unknown): value is undefined => typeof value === 'undefined';\n\nexport const isArray = <T>(value: unknown): value is T[] => Array.isArray(value);\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n Object.prototype.toString.call(value) === '[object Object]';\n\nexport const uniq = <T>(array: T[]): T[] => [...new Set(array)];\n\nexport const uniqBy = <T>(array: T[], predicate: (item: T) => string): T[] => {\n const seen: Record<string, boolean> = {};\n\n return array.filter((item: T): boolean => {\n const key: string = predicate(item);\n\n if (!Object.hasOwn(seen, key)) {\n seen[key] = true;\n\n return true;\n }\n\n return false;\n });\n};\n","import { MemoryCacheAdapter } from '@/cdn/cache/memory-cache-adapter.js';\nimport type { Context } from '@/cdn/context/context.js';\nimport { uniq } from '@/cdn/utils.js';\nimport type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\nimport type { CacheGetLocalesRequest } from '@/types/cache-get-locales-request.js';\nimport type { CacheHasLocalesRequest } from '@/types/cache-has-locales-request.js';\nimport type { CacheKeyMetafileOptions } from '@/types/cache-key-metafile-options.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\n\nexport class LocalesCache {\n protected context: Context;\n\n protected cacheAdapter: ICacheAdapter<string, object | string>;\n\n constructor(context: Context) {\n this.context = context;\n this.cacheAdapter = new MemoryCacheAdapter();\n }\n\n public setIfMissed(options: CacheStoreLocalesRequest): void {\n const { metafileFile, metafileLocale, data }: CacheStoreLocalesRequest = options;\n\n const key: string = this.keyFromMetafile({\n metafileFile,\n metafileLocale,\n });\n\n if (!this.cacheAdapter.has(key)) {\n this.cacheAdapter.set(key, data);\n }\n }\n\n public has(options: CacheHasLocalesRequest): boolean {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.has(key);\n }\n\n public get(options: CacheGetLocalesRequest): object | string | undefined {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.get(key);\n }\n\n public flush(): void {\n this.cacheAdapter.flush();\n }\n\n protected keyFromMetafile(options: CacheKeyMetafileOptions): string {\n const { metafileFile, metafileLocale }: CacheKeyMetafileOptions = options;\n const productFlavors: string = [...uniq(metafileFile.productFlavors)].sort().join('-');\n\n const indices: string[] = [\n this.context.metafile.params.cdnId,\n metafileFile.id,\n metafileFile.file,\n metafileFile.path,\n metafileFile.library,\n metafileFile.module,\n metafileFile.buildType,\n productFlavors,\n metafileLocale.locale,\n metafileLocale.timestamp.toString(),\n ];\n\n return indices.filter((key: string): boolean => key !== '').join('-');\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\nimport type { ResponseFactoryOptions } from '@/types/response-factory-options.js';\n\nexport class ResponseFactory {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public createCdnResponse(options: ResponseFactoryOptions): CdnResponse {\n const {\n requests,\n responses,\n hasSingleFileResponse,\n hasSingleLocaleResponse,\n }: ResponseFactoryOptions = options;\n\n if (responses.length === 0 || typeof responses[0] === 'undefined') {\n return {};\n }\n\n this.cacheResponses(requests, responses);\n\n return hasSingleFileResponse && hasSingleLocaleResponse\n ? responses[0]\n : ResponseFactory.transformResponses(options);\n }\n\n protected cacheResponses(requests: ApiLocaleRequest[], responses: (object | string)[]): void {\n responses.forEach((response: object | string, index: number): void => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n this.context.cache.setIfMissed({ metafileFile, metafileLocale, data: response });\n }\n }\n });\n }\n\n protected static transformResponses(options: ResponseFactoryOptions): CdnResponse {\n const { requests, responses, hasSingleFileResponse }: ResponseFactoryOptions = options;\n\n return responses.reduce((acc: CdnResponse, cur: object | string, index: number) => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n if (hasSingleFileResponse) {\n // @ts-expect-error fix output type\n acc[metafileLocale.locale] = cur;\n } else {\n // @ts-expect-error fix output type\n if (!acc[metafileFile.id]) {\n // @ts-expect-error fix output type\n acc[metafileFile.id] = {};\n }\n\n // @ts-expect-error fix output type\n acc[metafileFile.id][metafileLocale.locale] = cur;\n }\n }\n }\n\n return acc;\n }, {});\n }\n}\n","import { Api } from '@/cdn/api/api.js';\nimport { LocalesCache } from '@/cdn/cache/locales-cache.js';\nimport type { CdnClient } from '@/cdn/cdn-client.js';\nimport type { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { ResponseFactory } from '@/cdn/response/response-factory.js';\nimport type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\nimport type { ContextOptions } from '@/types/context-options.js';\n\nexport class Context {\n public metafile: MetafileContext;\n\n public cdn: CdnClient;\n\n public client: IHttpAdapter;\n\n public api: Api;\n\n public cache: LocalesCache;\n\n public responseFactory: ResponseFactory;\n\n constructor(options: ContextOptions) {\n this.metafile = options.metafileContext;\n this.cdn = options.cdn;\n this.client = options.client;\n this.api = new Api(this);\n this.cache = new LocalesCache(this);\n this.responseFactory = new ResponseFactory(this);\n }\n}\n","import type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { IMetafileFile } from '@/interfaces/i-metafile-file.js';\nimport type { CdnFileLocale } from '@/types/cdn-file-locale.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { MetafileFileOptions } from '@/types/metafile-file-options.js';\n\nexport class MetafileFile implements Omit<IMetafileFile, 'locales'> {\n public id: string;\n\n public file: string;\n\n public path: string;\n\n public library: string;\n\n public module: string;\n\n public buildType: string;\n\n public timestamp: number;\n\n public productFlavors: string[];\n\n public locales: MetafileLocale[];\n\n protected baseUrl: string;\n\n constructor(options: MetafileFileOptions) {\n this.id = options.id;\n this.file = options.file;\n this.path = options.path;\n this.library = options.library;\n this.module = options.module;\n this.buildType = options.buildType;\n this.timestamp = options.timestamp;\n this.productFlavors = options.productFlavors;\n this.locales = options.locales;\n this.baseUrl = options.baseUrl;\n }\n\n public toCdnFile(): CdnFile {\n return {\n id: this.id,\n file: this.file,\n path: this.path,\n library: this.library,\n module: this.module,\n buildType: this.buildType,\n productFlavors: this.productFlavors,\n locales: this.locales.map(\n (locale: MetafileLocale): CdnFileLocale => ({\n locale: locale.locale,\n isBaseLocale: locale.isBaseLocale,\n uri: `${this.baseUrl}${locale.uri}`,\n }),\n ),\n };\n }\n}\n","import type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\n\nexport class MetafileLocale implements IMetafileFileLocale {\n public language: string;\n\n public region: string;\n\n public script: string;\n\n public isRtl: boolean;\n\n public name: string;\n\n public localizedName: string;\n\n public uri: string;\n\n public timestamp: number;\n\n protected baseLocale: string;\n\n constructor(options: IMetafileFileLocale, baseLocale: string) {\n this.language = options.language;\n this.region = options.region;\n this.script = options.script;\n this.isRtl = options.isRtl;\n this.name = options.name;\n this.localizedName = options.localizedName;\n this.uri = options.uri;\n this.timestamp = options.timestamp;\n this.baseLocale = baseLocale;\n }\n\n get locale(): string {\n if (this.language && this.region && this.script) {\n return `${this.language}_${this.region}#${this.script}`;\n }\n\n if (this.language && this.script) {\n return `${this.language}#${this.script}`;\n }\n\n if (this.language && this.region) {\n return `${this.language}_${this.region}`;\n }\n\n return this.language;\n }\n\n get isBaseLocale(): boolean {\n return this.locale === this.baseLocale;\n }\n\n public toCdnLocale(): CdnLocale {\n return {\n locale: this.locale,\n isBaseLocale: this.isBaseLocale,\n language: this.language,\n region: this.region,\n script: this.script,\n isRtl: this.isRtl,\n name: this.name,\n localizedName: this.localizedName,\n };\n }\n}\n","import { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { uniqBy } from '@/cdn/utils.js';\nimport type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { IMetafileFiles } from '@/interfaces/i-metafile-files.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { FilesMap } from '@/types/files-map.js';\nimport type { MetafileOptions } from '@/types/metafile-options.js';\n\nexport class MetafileData implements Omit<IMetafile, 'files' | 'baseLocale'> {\n public projectUrl: string;\n\n public baseLocale: CdnLocale;\n\n public locales: CdnLocale[];\n\n public timestamp: number;\n\n public files: MetafileFile[];\n\n public filesMap: FilesMap;\n\n constructor(options: MetafileOptions, params: MetafileParams) {\n this.projectUrl = options.projectUrl;\n this.timestamp = options.timestamp;\n this.files = MetafileData.filesFactory(options.files, options.baseLocale, params);\n this.filesMap = MetafileData.filesMapFactory(this.files);\n this.locales = MetafileData.localesFactory(this.files);\n this.baseLocale = this.locales.find((locale: CdnLocale) => locale.isBaseLocale) as CdnLocale;\n }\n\n public static createEmpty(params: MetafileParams): MetafileData {\n return new MetafileData(\n {\n projectUrl: '',\n baseLocale: '',\n timestamp: 0,\n files: {},\n },\n params,\n );\n }\n\n protected static filesFactory(\n files: IMetafileFiles,\n baseLocale: string,\n params: MetafileParams,\n ): MetafileFile[] {\n return Object.keys(files).reduce((acc: MetafileFile[], cur: string) => {\n if (typeof files[cur] !== 'undefined') {\n const locales: MetafileLocale[] = files[cur].locales.map(\n (locale: IMetafileFileLocale) => new MetafileLocale(locale, baseLocale),\n );\n\n acc.push(\n new MetafileFile({\n ...files[cur],\n id: cur,\n locales,\n baseUrl: params.baseUrl,\n }),\n );\n }\n\n return acc;\n }, []);\n }\n\n protected static filesMapFactory(files: MetafileFile[]): FilesMap {\n return files.reduce((acc: FilesMap, cur: MetafileFile) => {\n acc[cur.id] = cur;\n\n return acc;\n }, {});\n }\n\n protected static localesFactory(files: MetafileFile[]): CdnLocale[] {\n const locales: CdnLocale[] = files.reduce((acc: CdnLocale[], cur: MetafileFile) => {\n acc.push(...cur.locales.map((locale: MetafileLocale): CdnLocale => locale.toCdnLocale()));\n return acc;\n }, []);\n\n return uniqBy(locales, (cdnLocale: CdnLocale): string => cdnLocale.locale);\n }\n}\n","import type { IMetafileParams } from '@/interfaces/i-metafile-params.js';\n\nexport class MetafileParams implements IMetafileParams {\n protected options: IMetafileParams;\n\n constructor(metafileUrl: string) {\n this.options = MetafileParams.parseMetafileUrl(metafileUrl);\n }\n\n get url(): string {\n return this.options.url;\n }\n\n get baseUrl(): string {\n return this.options.baseUrl;\n }\n\n get cdnId(): string {\n return this.options.cdnId;\n }\n\n get jsonPath(): string {\n return this.options.jsonPath;\n }\n\n protected static parseMetafileUrl(metafileUrl: string): IMetafileParams {\n let url: URL;\n\n try {\n url = new URL(metafileUrl);\n } catch {\n throw new Error('Invalid param: \"options.metafile\" cannot be parsed as url.');\n }\n\n const matches: string[] | null = /^\\/(.*?)\\/(.*?)\\.(v2.json|js|ts)$/.exec(url.pathname);\n\n if (\n matches === null ||\n matches.length !== 4 ||\n typeof matches[1] === 'undefined' ||\n typeof matches[2] === 'undefined'\n ) {\n throw new Error('Invalid param: \"options.metafile\" contains invalid metafile url.');\n }\n\n const cdnId: string = matches[1];\n const tagId: string = matches[2];\n\n return {\n url: metafileUrl,\n baseUrl: url.origin,\n cdnId,\n jsonPath: `/${cdnId}/${tagId}.v2.json`,\n };\n }\n}\n","import { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\n\nexport class MetafileContext {\n public params: MetafileParams;\n\n public parsedData: IMetafile | null;\n\n public data: MetafileData;\n\n constructor(options: CdnClientOptions) {\n this.params = new MetafileParams(options.metafile);\n this.parsedData = null;\n this.data = MetafileData.createEmpty(this.params);\n }\n\n public setMetafile(metafile: IMetafile): void {\n this.parsedData = metafile;\n\n this.data = new MetafileData(metafile, this.params);\n }\n}\n","import type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\n\nexport class FetchHttpAdapter implements IHttpAdapter {\n protected baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async get(url: string): Promise<string | object> {\n const response: Response = await fetch(`${this.baseUrl}${url}`);\n const contentType: string | null = response.headers.get('content-type');\n const isJson: boolean =\n contentType === 'application/json5' || contentType === 'application/json';\n\n if (response.status >= 400) {\n throw new Error(`Request failed with status code ${response.status.toString()}`);\n }\n\n let result: string | object;\n\n if (isJson) {\n result = (await response.json()) as object;\n } else {\n result = await response.text();\n }\n\n return result;\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\n\nexport abstract class CdnBase {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n}\n","import { CdnBase } from '@/cdn/methods/cdn-base.js';\n\nexport class CdnCache extends CdnBase {\n public flush = (): void => {\n this.context.cache.flush();\n };\n}\n","import type { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { CdnBase } from '@/cdn/methods/cdn-base.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { CdnLocalesOptions } from '@/types/cdn-locales-options.js';\n\nexport class CdnMetafile extends CdnBase {\n get projectUrl(): string {\n return this.context.metafile.data.projectUrl;\n }\n\n get baseLocale(): CdnLocale {\n return this.context.metafile.data.baseLocale;\n }\n\n get url(): string {\n return this.context.metafile.params.url;\n }\n\n get files(): CdnFile[] {\n return this.context.metafile.data.files.map((file: MetafileFile): CdnFile => file.toCdnFile());\n }\n\n public locales = (options?: CdnLocalesOptions): CdnLocale[] => {\n const { excludeBaseLocale }: CdnLocalesOptions = options || {};\n const { locales }: MetafileData = this.context.metafile.data;\n\n return excludeBaseLocale\n ? locales.filter((cdnLocale: CdnLocale): boolean => !cdnLocale.isBaseLocale)\n : locales;\n };\n\n public refresh = async (): Promise<void> => {\n const response: IMetafile = await this.context.api.fetchMetafile();\n\n this.context.metafile.setMetafile(response);\n };\n\n public switch = async (options: CdnClientOptions): Promise<void> => {\n this.context.metafile.params = new MetafileParams(options.metafile);\n\n await this.refresh();\n };\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { LocalesMapData } from '@/types/locales-map-data.js';\nimport type { LocalesMapOptions } from '@/types/locales-map-options.js';\n\nexport class LocalesMap {\n public data: LocalesMapData;\n\n protected context: Context;\n\n constructor(options: LocalesMapOptions) {\n this.context = options.context;\n this.data = options.data || {};\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport { LocalesMap } from '@/cdn/request/locales-map.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class Request {\n public files: MetafileFile[];\n\n public localesMap: LocalesMap;\n\n public hasSingleFileResponse: boolean;\n\n public hasSingleLocaleResponse: boolean;\n\n protected context: Context;\n\n constructor(context: Context) {\n this.files = [];\n this.localesMap = new LocalesMap({ context });\n this.hasSingleFileResponse = false;\n this.hasSingleLocaleResponse = false;\n this.context = context;\n }\n\n public async execute(): Promise<CdnResponse> {\n const payload: [Promise<string | object>, ApiLocaleRequest][] = this.getPromises();\n const promises: Promise<string | object>[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[0],\n );\n const requests: ApiLocaleRequest[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[1],\n );\n const responses: (string | object)[] = await Promise.all(promises);\n\n return this.context.responseFactory.createCdnResponse({\n requests,\n responses,\n localesMap: this.localesMap,\n hasSingleFileResponse: this.hasSingleFileResponse,\n hasSingleLocaleResponse: this.hasSingleLocaleResponse,\n });\n }\n\n protected getPromises(): [Promise<string | object>, ApiLocaleRequest][] {\n return this.files.reduce(\n (acc: [Promise<string | object>, ApiLocaleRequest][], cur: MetafileFile) => {\n if (typeof this.localesMap.data?.[cur.id] !== 'undefined') {\n acc.push(\n ...this.localesMap.data[cur.id].map(\n (metafileLocale: MetafileLocale): [Promise<string | object>, ApiLocaleRequest] => {\n const request: ApiLocaleRequest = {\n metafileFile: cur,\n metafileLocale,\n };\n\n return [this.context.api.fetchLocale(request), request];\n },\n ),\n );\n }\n return acc;\n },\n [],\n );\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { LocalesMap } from '@/cdn/request/locales-map.js';\nimport { Request } from '@/cdn/request/request.js';\nimport { isArray, isPlainObject, isString, isUndefined } from '@/cdn/utils.js';\nimport type { IRequestBuilder } from '@/interfaces/i-request-builder.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\n\nexport class RequestBuilder implements IRequestBuilder {\n protected context: Context;\n\n protected request: Request;\n\n constructor(context: Context) {\n this.context = context;\n this.request = new Request(this.context);\n }\n\n public addFiles(files?: (CdnFile | string)[] | CdnFile | string): this {\n if (!(isPlainObject(files) || isString(files) || isUndefined(files) || isArray(files))) {\n throw new Error('Invalid param: \"request.files\" must be object, array, string or undefined.');\n }\n\n if (isArray(files)) {\n files.forEach((i: CdnFile | string): void => {\n if (!(isPlainObject(i) || isString(i))) {\n throw new Error('Invalid param: array \"request.files\" must contain objects or strings.');\n }\n });\n }\n\n if (isString(files)) {\n this.request.hasSingleFileResponse = true;\n\n const file: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files,\n );\n\n if (!(file instanceof MetafileFile)) {\n throw new Error(`File not found: \"${files}\".`);\n }\n\n this.request.files = [file];\n } else if (isUndefined(files)) {\n this.request.files = [...this.context.metafile.data.files];\n } else if (isArray(files)) {\n this.request.files = files.map((file: CdnFile | string): MetafileFile => {\n let metafileFile: MetafileFile;\n\n if (isString(file)) {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file}\".`);\n }\n\n metafileFile = foundFile;\n } else {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file.id}\".`);\n }\n\n metafileFile = foundFile;\n }\n\n return metafileFile;\n });\n } else if (isPlainObject(files)) {\n this.request.hasSingleFileResponse = true;\n\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${files.id}\".`);\n }\n\n this.request.files = [foundFile];\n }\n\n return this;\n }\n\n public addLocales(locales?: string[] | string, excludeBaseLocale?: boolean): this {\n if (!(isString(locales) || isUndefined(locales) || isArray(locales))) {\n throw new Error('Invalid param: \"request.locales\" must be array, string or undefined.');\n }\n\n if (isArray(locales)) {\n locales.forEach((i: MetafileFile | string): void => {\n if (!isString(i)) {\n throw new Error('Invalid param: array \"request.locales\" must contain strings.');\n }\n });\n }\n\n if (isString(locales)) {\n this.request.hasSingleLocaleResponse = true;\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => metafileLocale.locale === locales,\n );\n\n return acc;\n }, this.request.localesMap);\n } else if (isUndefined(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = excludeBaseLocale\n ? cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => !metafileLocale.isBaseLocale,\n )\n : cur.locales;\n\n return acc;\n }, this.request.localesMap);\n } else if (isArray(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter((metafileLocale: MetafileLocale) =>\n locales.includes(metafileLocale.locale),\n );\n\n return acc;\n }, this.request.localesMap);\n }\n\n return this;\n }\n\n public getCdnRequest(): Request {\n const result: Request = this.request;\n this.request = new Request(this.context);\n return result;\n }\n}\n","import { Context } from '@/cdn/context/context.js';\nimport { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { FetchHttpAdapter } from '@/cdn/http/fetch-http-adapter.js';\nimport { CdnCache } from '@/cdn/methods/cdn-cache.js';\nimport { CdnMetafile } from '@/cdn/methods/cdn-metafile.js';\nimport { RequestBuilder } from '@/cdn/request/request-builder.js';\nimport { isString } from '@/cdn/utils.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFetchOptions } from '@/types/cdn-fetch-options.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class CdnClient {\n public metafile: CdnMetafile;\n\n public cache: CdnCache;\n\n protected context: Context;\n\n public static version = '__CLIENT_VERSION__';\n\n protected constructor(options: CdnClientOptions) {\n const metafileContext: MetafileContext = new MetafileContext(options);\n const client: FetchHttpAdapter = new FetchHttpAdapter(metafileContext.params.baseUrl);\n\n this.context = new Context({ metafileContext, cdn: this, client });\n this.metafile = new CdnMetafile(this.context);\n this.cache = new CdnCache(this.context);\n }\n\n public fetch = async (options?: CdnFetchOptions): Promise<CdnResponse> => {\n const { files, locales, excludeBaseLocale }: CdnFetchOptions = options || {};\n const requestBuilder: RequestBuilder = new RequestBuilder(this.context)\n .addFiles(files)\n .addLocales(locales, excludeBaseLocale);\n\n return requestBuilder.getCdnRequest().execute();\n };\n\n public static async create(options: CdnClientOptions): Promise<CdnClient> {\n if (!options) {\n throw new Error('Invalid param: missing required \"options\" parameter.');\n }\n\n if (!isString(options.metafile)) {\n throw new Error('Invalid param: \"options.metafile\" must be string.');\n }\n\n const cdn: CdnClient = new CdnClient(options);\n\n await cdn.metafile.refresh();\n\n return cdn;\n }\n}\n"],"mappings":";;;AAIA,IAAa,IAAb,MAAA;CACE;CAEA,YAAY,GAAA;AACV,OAAK,UAAU;;CAGjB,MAAA,YAAyB,GAAA;AACvB,SAAI,KAAK,QAAQ,MAAM,IAAI,EAAA,GAClB,IAAI,SAAS,MAAA;AAClB,KAAQ,KAAK,QAAQ,MAAM,IAAI,EAAA,CAAA;IAAA,GAI5B,KAAK,QAAQ,OAAO,IAAI,EAAQ,eAAe,IAAA;;C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AI,EAAQ;GAAE,iBAAA;GAAiB,KAAK;GAAM,QAAA;GAAA,CAAA,EACzD,KAAK,WAAW,IAAI,EAAY,KAAK,QAAA,EACrC,KAAK,QAAQ,IAAI,EAAS,KAAK,QAAA;;CAGjC,QAAe,OAAO,MAAA;EACpB,MAAA,EAAM,OAAE,GAAA,SAAO,GAAA,mBAAS,MAAuC,KAAW,EAAA;AAK1E,SAJuC,IAAI,EAAe,KAAK,QAAA,CAC5D,SAAS,EAAA,CACT,WAAW,GAAS,EAAA,CAED,eAAA,CAAgB,SAAA;;CAGxC,aAAA,OAA2B,GAAA;AACzB,MAAA,CAAK,EACH,OAAM,IAAI,MAAM,yDAAA;AAGlB,MAAA,CAAK,EAAS,EAAQ,SAAA,CACpB,OAAM,IAAI,MAAM,sDAAA;EAGlB,MAAM,IAAiB,IAAI,EAAU,EAAA;AAIrC,SAAA,MAFM,EAAI,SAAS,SAAA,EAEZ;;;AAAA,SAAA,KAAA,KAAA,KAAA,SAAA,KAAA,UAAA,KAAA,WAAA,KAAA,aAAA,KAAA,SAAA,KAAA,kBAAA,KAAA,cAAA,KAAA,YAAA,KAAA,oBAAA,KAAA,iBAAA,KAAA,cAAA,KAAA,cAAA,KAAA,gBAAA,KAAA,gBAAA,KAAA,SAAA,KAAA,gBAAA,KAAA,iBAAA,KAAA,SAAA,KAAA,eAAA,KAAA,UAAA,KAAA,aAAA,KAAA,MAAA,KAAA"}
1
+ {"version":3,"file":"localazy-cdn-client.min.js","names":[],"sources":["../src/cdn/api/api.ts","../src/cdn/cache/memory-cache-adapter.ts","../src/cdn/utils.ts","../src/cdn/cache/locales-cache.ts","../src/cdn/response/response-factory.ts","../src/cdn/context/context.ts","../src/cdn/metafile/metafile-file.ts","../src/cdn/metafile/metafile-locale.ts","../src/cdn/metafile/metafile-data.ts","../src/cdn/metafile/metafile-params.ts","../src/cdn/context/metafile-context.ts","../src/cdn/http/fetch-http-adapter.ts","../src/cdn/methods/cdn-base.ts","../src/cdn/methods/cdn-cache.ts","../src/cdn/methods/cdn-metafile.ts","../src/cdn/request/locales-map.ts","../src/cdn/request/request.ts","../src/cdn/request/request-builder.ts","../src/cdn/cdn-client.ts"],"sourcesContent":["import type { Context } from '@/cdn/context/context.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\n\nexport class Api {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public async fetchLocale(options: ApiLocaleRequest): Promise<object | string> {\n if (this.context.cache.has(options)) {\n return new Promise((resolve): void => {\n resolve(this.context.cache.get(options) as object | string);\n });\n }\n\n return this.context.client.get(options.metafileLocale.uri);\n }\n\n public async fetchMetafile(): Promise<IMetafile> {\n return (await this.context.client.get(this.context.metafile.params.jsonPath)) as IMetafile;\n }\n}\n","import type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\n\nexport class MemoryCacheAdapter<K, V> implements ICacheAdapter<K, V> {\n protected map: Map<K, V>;\n\n constructor() {\n this.map = new Map();\n }\n\n public get(key: K): V | undefined {\n return this.map.get(key);\n }\n\n public has(key: K): boolean {\n return this.map.has(key);\n }\n\n public set(key: K, value: V): void {\n this.map.set(key, value);\n }\n\n public flush(): void {\n this.map = new Map();\n }\n}\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isUndefined = (value: unknown): value is undefined => typeof value === 'undefined';\n\nexport const isArray = <T>(value: unknown): value is T[] => Array.isArray(value);\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n Object.prototype.toString.call(value) === '[object Object]';\n\nexport const uniq = <T>(array: T[]): T[] => [...new Set(array)];\n\nexport const uniqBy = <T>(array: T[], predicate: (item: T) => string): T[] => {\n const seen: Record<string, boolean> = {};\n\n return array.filter((item: T): boolean => {\n const key: string = predicate(item);\n\n if (!Object.hasOwn(seen, key)) {\n seen[key] = true;\n\n return true;\n }\n\n return false;\n });\n};\n","import { MemoryCacheAdapter } from '@/cdn/cache/memory-cache-adapter.js';\nimport type { Context } from '@/cdn/context/context.js';\nimport { uniq } from '@/cdn/utils.js';\nimport type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\nimport type { CacheGetLocalesRequest } from '@/types/cache-get-locales-request.js';\nimport type { CacheHasLocalesRequest } from '@/types/cache-has-locales-request.js';\nimport type { CacheKeyMetafileOptions } from '@/types/cache-key-metafile-options.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\n\nexport class LocalesCache {\n protected context: Context;\n\n protected cacheAdapter: ICacheAdapter<string, object | string>;\n\n constructor(context: Context) {\n this.context = context;\n this.cacheAdapter = new MemoryCacheAdapter();\n }\n\n public setIfMissed(options: CacheStoreLocalesRequest): void {\n const { metafileFile, metafileLocale, data }: CacheStoreLocalesRequest = options;\n\n const key: string = this.keyFromMetafile({\n metafileFile,\n metafileLocale,\n });\n\n if (!this.cacheAdapter.has(key)) {\n this.cacheAdapter.set(key, data);\n }\n }\n\n public has(options: CacheHasLocalesRequest): boolean {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.has(key);\n }\n\n public get(options: CacheGetLocalesRequest): object | string | undefined {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.get(key);\n }\n\n public flush(): void {\n this.cacheAdapter.flush();\n }\n\n protected keyFromMetafile(options: CacheKeyMetafileOptions): string {\n const { metafileFile, metafileLocale }: CacheKeyMetafileOptions = options;\n const productFlavors: string = [...uniq(metafileFile.productFlavors)].sort().join('-');\n\n const indices: string[] = [\n this.context.metafile.params.cdnId,\n metafileFile.id,\n metafileFile.file,\n metafileFile.path,\n metafileFile.library,\n metafileFile.module,\n metafileFile.buildType,\n productFlavors,\n metafileLocale.locale,\n metafileLocale.timestamp.toString(),\n ];\n\n return indices.filter((key: string): boolean => key !== '').join('-');\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\nimport type { ResponseFactoryOptions } from '@/types/response-factory-options.js';\n\nexport class ResponseFactory {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public createCdnResponse(options: ResponseFactoryOptions): CdnResponse {\n const {\n requests,\n responses,\n hasSingleFileResponse,\n hasSingleLocaleResponse,\n }: ResponseFactoryOptions = options;\n\n if (responses.length === 0 || typeof responses[0] === 'undefined') {\n return {};\n }\n\n this.cacheResponses(requests, responses);\n\n return hasSingleFileResponse && hasSingleLocaleResponse\n ? responses[0]\n : ResponseFactory.transformResponses(options);\n }\n\n protected cacheResponses(requests: ApiLocaleRequest[], responses: (object | string)[]): void {\n responses.forEach((response: object | string, index: number): void => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n this.context.cache.setIfMissed({ metafileFile, metafileLocale, data: response });\n }\n }\n });\n }\n\n protected static transformResponses(options: ResponseFactoryOptions): CdnResponse {\n const { requests, responses, hasSingleFileResponse }: ResponseFactoryOptions = options;\n\n return responses.reduce((acc: CdnResponse, cur: object | string, index: number) => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n if (hasSingleFileResponse) {\n // @ts-expect-error fix output type\n acc[metafileLocale.locale] = cur;\n } else {\n // @ts-expect-error fix output type\n if (!acc[metafileFile.id]) {\n // @ts-expect-error fix output type\n acc[metafileFile.id] = {};\n }\n\n // @ts-expect-error fix output type\n acc[metafileFile.id][metafileLocale.locale] = cur;\n }\n }\n }\n\n return acc;\n }, {});\n }\n}\n","import { Api } from '@/cdn/api/api.js';\nimport { LocalesCache } from '@/cdn/cache/locales-cache.js';\nimport type { CdnClient } from '@/cdn/cdn-client.js';\nimport type { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { ResponseFactory } from '@/cdn/response/response-factory.js';\nimport type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\nimport type { ContextOptions } from '@/types/context-options.js';\n\nexport class Context {\n public metafile: MetafileContext;\n\n public cdn: CdnClient;\n\n public client: IHttpAdapter;\n\n public api: Api;\n\n public cache: LocalesCache;\n\n public responseFactory: ResponseFactory;\n\n constructor(options: ContextOptions) {\n this.metafile = options.metafileContext;\n this.cdn = options.cdn;\n this.client = options.client;\n this.api = new Api(this);\n this.cache = new LocalesCache(this);\n this.responseFactory = new ResponseFactory(this);\n }\n}\n","import type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { IMetafileFile } from '@/interfaces/i-metafile-file.js';\nimport type { CdnFileLocale } from '@/types/cdn-file-locale.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { MetafileFileOptions } from '@/types/metafile-file-options.js';\n\nexport class MetafileFile implements Omit<IMetafileFile, 'locales'> {\n public id: string;\n\n public file: string;\n\n public path: string;\n\n public library: string;\n\n public module: string;\n\n public buildType: string;\n\n public timestamp: number;\n\n public productFlavors: string[];\n\n public locales: MetafileLocale[];\n\n protected baseUrl: string;\n\n constructor(options: MetafileFileOptions) {\n this.id = options.id;\n this.file = options.file;\n this.path = options.path;\n this.library = options.library;\n this.module = options.module;\n this.buildType = options.buildType;\n this.timestamp = options.timestamp;\n this.productFlavors = options.productFlavors;\n this.locales = options.locales;\n this.baseUrl = options.baseUrl;\n }\n\n public toCdnFile(): CdnFile {\n return {\n id: this.id,\n file: this.file,\n path: this.path,\n library: this.library,\n module: this.module,\n buildType: this.buildType,\n productFlavors: this.productFlavors,\n locales: this.locales.map(\n (locale: MetafileLocale): CdnFileLocale => ({\n locale: locale.locale,\n isBaseLocale: locale.isBaseLocale,\n uri: `${this.baseUrl}${locale.uri}`,\n }),\n ),\n };\n }\n}\n","import type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\n\nexport class MetafileLocale implements IMetafileFileLocale {\n public language: string;\n\n public region: string;\n\n public script: string;\n\n public isRtl: boolean;\n\n public name: string;\n\n public localizedName: string;\n\n public uri: string;\n\n public timestamp: number;\n\n protected baseLocale: string;\n\n constructor(options: IMetafileFileLocale, baseLocale: string) {\n this.language = options.language;\n this.region = options.region;\n this.script = options.script;\n this.isRtl = options.isRtl;\n this.name = options.name;\n this.localizedName = options.localizedName;\n this.uri = options.uri;\n this.timestamp = options.timestamp;\n this.baseLocale = baseLocale;\n }\n\n get locale(): string {\n if (this.language && this.region && this.script) {\n return `${this.language}_${this.region}#${this.script}`;\n }\n\n if (this.language && this.script) {\n return `${this.language}#${this.script}`;\n }\n\n if (this.language && this.region) {\n return `${this.language}_${this.region}`;\n }\n\n return this.language;\n }\n\n get isBaseLocale(): boolean {\n return this.locale === this.baseLocale;\n }\n\n public toCdnLocale(): CdnLocale {\n return {\n locale: this.locale,\n isBaseLocale: this.isBaseLocale,\n language: this.language,\n region: this.region,\n script: this.script,\n isRtl: this.isRtl,\n name: this.name,\n localizedName: this.localizedName,\n };\n }\n}\n","import { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { uniqBy } from '@/cdn/utils.js';\nimport type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { IMetafileFiles } from '@/interfaces/i-metafile-files.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { FilesMap } from '@/types/files-map.js';\nimport type { MetafileOptions } from '@/types/metafile-options.js';\n\nexport class MetafileData implements Omit<IMetafile, 'files' | 'baseLocale'> {\n public projectUrl: string;\n\n public baseLocale: CdnLocale;\n\n public locales: CdnLocale[];\n\n public timestamp: number;\n\n public files: MetafileFile[];\n\n public filesMap: FilesMap;\n\n constructor(options: MetafileOptions, params: MetafileParams) {\n this.projectUrl = options.projectUrl;\n this.timestamp = options.timestamp;\n this.files = MetafileData.filesFactory(options.files, options.baseLocale, params);\n this.filesMap = MetafileData.filesMapFactory(this.files);\n this.locales = MetafileData.localesFactory(this.files);\n this.baseLocale = this.locales.find((locale: CdnLocale) => locale.isBaseLocale) as CdnLocale;\n }\n\n public static createEmpty(params: MetafileParams): MetafileData {\n return new MetafileData(\n {\n projectUrl: '',\n baseLocale: '',\n timestamp: 0,\n files: {},\n },\n params,\n );\n }\n\n protected static filesFactory(\n files: IMetafileFiles,\n baseLocale: string,\n params: MetafileParams,\n ): MetafileFile[] {\n return Object.keys(files).reduce((acc: MetafileFile[], cur: string) => {\n if (typeof files[cur] !== 'undefined') {\n const locales: MetafileLocale[] = files[cur].locales.map(\n (locale: IMetafileFileLocale) => new MetafileLocale(locale, baseLocale),\n );\n\n acc.push(\n new MetafileFile({\n ...files[cur],\n id: cur,\n locales,\n baseUrl: params.baseUrl,\n }),\n );\n }\n\n return acc;\n }, []);\n }\n\n protected static filesMapFactory(files: MetafileFile[]): FilesMap {\n return files.reduce((acc: FilesMap, cur: MetafileFile) => {\n acc[cur.id] = cur;\n\n return acc;\n }, {});\n }\n\n protected static localesFactory(files: MetafileFile[]): CdnLocale[] {\n const locales: CdnLocale[] = files.reduce((acc: CdnLocale[], cur: MetafileFile) => {\n acc.push(...cur.locales.map((locale: MetafileLocale): CdnLocale => locale.toCdnLocale()));\n return acc;\n }, []);\n\n return uniqBy(locales, (cdnLocale: CdnLocale): string => cdnLocale.locale);\n }\n}\n","import type { IMetafileParams } from '@/interfaces/i-metafile-params.js';\n\nexport class MetafileParams implements IMetafileParams {\n protected options: IMetafileParams;\n\n constructor(metafileUrl: string) {\n this.options = MetafileParams.parseMetafileUrl(metafileUrl);\n }\n\n get url(): string {\n return this.options.url;\n }\n\n get baseUrl(): string {\n return this.options.baseUrl;\n }\n\n get cdnId(): string {\n return this.options.cdnId;\n }\n\n get jsonPath(): string {\n return this.options.jsonPath;\n }\n\n protected static parseMetafileUrl(metafileUrl: string): IMetafileParams {\n let url: URL;\n\n try {\n url = new URL(metafileUrl);\n } catch {\n throw new Error('Invalid param: \"options.metafile\" cannot be parsed as url.');\n }\n\n const matches: string[] | null = /^\\/(.*?)\\/(.*?)\\.(v2.json|js|ts)$/.exec(url.pathname);\n\n if (\n matches === null ||\n matches.length !== 4 ||\n typeof matches[1] === 'undefined' ||\n typeof matches[2] === 'undefined'\n ) {\n throw new Error('Invalid param: \"options.metafile\" contains invalid metafile url.');\n }\n\n const cdnId: string = matches[1];\n const tagId: string = matches[2];\n\n return {\n url: metafileUrl,\n baseUrl: url.origin,\n cdnId,\n jsonPath: `/${cdnId}/${tagId}.v2.json`,\n };\n }\n}\n","import { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\n\nexport class MetafileContext {\n public params: MetafileParams;\n\n public parsedData: IMetafile | null;\n\n public data: MetafileData;\n\n constructor(options: CdnClientOptions) {\n this.params = new MetafileParams(options.metafile);\n this.parsedData = null;\n this.data = MetafileData.createEmpty(this.params);\n }\n\n public setMetafile(metafile: IMetafile): void {\n this.parsedData = metafile;\n\n this.data = new MetafileData(metafile, this.params);\n }\n}\n","import type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\n\nexport class FetchHttpAdapter implements IHttpAdapter {\n protected baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async get(url: string): Promise<string | object> {\n const response: Response = await fetch(`${this.baseUrl}${url}`);\n const contentType: string | null = response.headers.get('content-type');\n const isJson: boolean =\n contentType === 'application/json5' || contentType === 'application/json';\n\n if (response.status >= 400) {\n throw new Error(`Request failed with status code ${response.status.toString()}`);\n }\n\n let result: string | object;\n\n if (isJson) {\n result = (await response.json()) as object;\n } else {\n result = await response.text();\n }\n\n return result;\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\n\nexport abstract class CdnBase {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n}\n","import { CdnBase } from '@/cdn/methods/cdn-base.js';\n\nexport class CdnCache extends CdnBase {\n public flush = (): void => {\n this.context.cache.flush();\n };\n}\n","import type { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { CdnBase } from '@/cdn/methods/cdn-base.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { CdnLocalesOptions } from '@/types/cdn-locales-options.js';\n\nexport class CdnMetafile extends CdnBase {\n get projectUrl(): string {\n return this.context.metafile.data.projectUrl;\n }\n\n get baseLocale(): CdnLocale {\n return this.context.metafile.data.baseLocale;\n }\n\n get url(): string {\n return this.context.metafile.params.url;\n }\n\n get files(): CdnFile[] {\n return this.context.metafile.data.files.map((file: MetafileFile): CdnFile => file.toCdnFile());\n }\n\n public locales = (options?: CdnLocalesOptions): CdnLocale[] => {\n const { excludeBaseLocale }: CdnLocalesOptions = options || {};\n const { locales }: MetafileData = this.context.metafile.data;\n\n return excludeBaseLocale\n ? locales.filter((cdnLocale: CdnLocale): boolean => !cdnLocale.isBaseLocale)\n : locales;\n };\n\n public refresh = async (): Promise<void> => {\n const response: IMetafile = await this.context.api.fetchMetafile();\n\n this.context.metafile.setMetafile(response);\n };\n\n public switch = async (options: CdnClientOptions): Promise<void> => {\n this.context.metafile.params = new MetafileParams(options.metafile);\n\n await this.refresh();\n };\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { LocalesMapData } from '@/types/locales-map-data.js';\nimport type { LocalesMapOptions } from '@/types/locales-map-options.js';\n\nexport class LocalesMap {\n public data: LocalesMapData;\n\n protected context: Context;\n\n constructor(options: LocalesMapOptions) {\n this.context = options.context;\n this.data = options.data || {};\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport { LocalesMap } from '@/cdn/request/locales-map.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class Request {\n public files: MetafileFile[];\n\n public localesMap: LocalesMap;\n\n public hasSingleFileResponse: boolean;\n\n public hasSingleLocaleResponse: boolean;\n\n protected context: Context;\n\n constructor(context: Context) {\n this.files = [];\n this.localesMap = new LocalesMap({ context });\n this.hasSingleFileResponse = false;\n this.hasSingleLocaleResponse = false;\n this.context = context;\n }\n\n public async execute(): Promise<CdnResponse> {\n const payload: [Promise<string | object>, ApiLocaleRequest][] = this.getPromises();\n const promises: Promise<string | object>[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[0],\n );\n const requests: ApiLocaleRequest[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[1],\n );\n const responses: (string | object)[] = await Promise.all(promises);\n\n return this.context.responseFactory.createCdnResponse({\n requests,\n responses,\n localesMap: this.localesMap,\n hasSingleFileResponse: this.hasSingleFileResponse,\n hasSingleLocaleResponse: this.hasSingleLocaleResponse,\n });\n }\n\n protected getPromises(): [Promise<string | object>, ApiLocaleRequest][] {\n return this.files.reduce(\n (acc: [Promise<string | object>, ApiLocaleRequest][], cur: MetafileFile) => {\n if (typeof this.localesMap.data?.[cur.id] !== 'undefined') {\n acc.push(\n ...this.localesMap.data[cur.id].map(\n (metafileLocale: MetafileLocale): [Promise<string | object>, ApiLocaleRequest] => {\n const request: ApiLocaleRequest = {\n metafileFile: cur,\n metafileLocale,\n };\n\n return [this.context.api.fetchLocale(request), request];\n },\n ),\n );\n }\n return acc;\n },\n [],\n );\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { LocalesMap } from '@/cdn/request/locales-map.js';\nimport { Request } from '@/cdn/request/request.js';\nimport { isArray, isPlainObject, isString, isUndefined } from '@/cdn/utils.js';\nimport type { IRequestBuilder } from '@/interfaces/i-request-builder.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\n\nexport class RequestBuilder implements IRequestBuilder {\n protected context: Context;\n\n protected request: Request;\n\n constructor(context: Context) {\n this.context = context;\n this.request = new Request(this.context);\n }\n\n public addFiles(files?: (CdnFile | string)[] | CdnFile | string): this {\n if (!(isPlainObject(files) || isString(files) || isUndefined(files) || isArray(files))) {\n throw new Error('Invalid param: \"request.files\" must be object, array, string or undefined.');\n }\n\n if (isArray(files)) {\n files.forEach((i: CdnFile | string): void => {\n if (!(isPlainObject(i) || isString(i))) {\n throw new Error('Invalid param: array \"request.files\" must contain objects or strings.');\n }\n });\n }\n\n if (isString(files)) {\n this.request.hasSingleFileResponse = true;\n\n const file: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files,\n );\n\n if (!(file instanceof MetafileFile)) {\n throw new Error(`File not found: \"${files}\".`);\n }\n\n this.request.files = [file];\n } else if (isUndefined(files)) {\n this.request.files = [...this.context.metafile.data.files];\n } else if (isArray(files)) {\n this.request.files = files.map((file: CdnFile | string): MetafileFile => {\n let metafileFile: MetafileFile;\n\n if (isString(file)) {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file}\".`);\n }\n\n metafileFile = foundFile;\n } else {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file.id}\".`);\n }\n\n metafileFile = foundFile;\n }\n\n return metafileFile;\n });\n } else if (isPlainObject(files)) {\n this.request.hasSingleFileResponse = true;\n\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${files.id}\".`);\n }\n\n this.request.files = [foundFile];\n }\n\n return this;\n }\n\n public addLocales(locales?: string[] | string, excludeBaseLocale?: boolean): this {\n if (!(isString(locales) || isUndefined(locales) || isArray(locales))) {\n throw new Error('Invalid param: \"request.locales\" must be array, string or undefined.');\n }\n\n if (isArray(locales)) {\n locales.forEach((i: MetafileFile | string): void => {\n if (!isString(i)) {\n throw new Error('Invalid param: array \"request.locales\" must contain strings.');\n }\n });\n }\n\n if (isString(locales)) {\n this.request.hasSingleLocaleResponse = true;\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => metafileLocale.locale === locales,\n );\n\n return acc;\n }, this.request.localesMap);\n } else if (isUndefined(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = excludeBaseLocale\n ? cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => !metafileLocale.isBaseLocale,\n )\n : cur.locales;\n\n return acc;\n }, this.request.localesMap);\n } else if (isArray(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter((metafileLocale: MetafileLocale) =>\n locales.includes(metafileLocale.locale),\n );\n\n return acc;\n }, this.request.localesMap);\n }\n\n return this;\n }\n\n public getCdnRequest(): Request {\n const result: Request = this.request;\n this.request = new Request(this.context);\n return result;\n }\n}\n","import { Context } from '@/cdn/context/context.js';\nimport { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { FetchHttpAdapter } from '@/cdn/http/fetch-http-adapter.js';\nimport { CdnCache } from '@/cdn/methods/cdn-cache.js';\nimport { CdnMetafile } from '@/cdn/methods/cdn-metafile.js';\nimport { RequestBuilder } from '@/cdn/request/request-builder.js';\nimport { isString } from '@/cdn/utils.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFetchOptions } from '@/types/cdn-fetch-options.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class CdnClient {\n public metafile: CdnMetafile;\n\n public cache: CdnCache;\n\n protected context: Context;\n\n public static version = '__CLIENT_VERSION__';\n\n protected constructor(options: CdnClientOptions) {\n const metafileContext: MetafileContext = new MetafileContext(options);\n const client: FetchHttpAdapter = new FetchHttpAdapter(metafileContext.params.baseUrl);\n\n this.context = new Context({ metafileContext, cdn: this, client });\n this.metafile = new CdnMetafile(this.context);\n this.cache = new CdnCache(this.context);\n }\n\n public fetch = async (options?: CdnFetchOptions): Promise<CdnResponse> => {\n const { files, locales, excludeBaseLocale }: CdnFetchOptions = options || {};\n const requestBuilder: RequestBuilder = new RequestBuilder(this.context)\n .addFiles(files)\n .addLocales(locales, excludeBaseLocale);\n\n return requestBuilder.getCdnRequest().execute();\n };\n\n public static async create(options: CdnClientOptions): Promise<CdnClient> {\n if (!options) {\n throw new Error('Invalid param: missing required \"options\" parameter.');\n }\n\n if (!isString(options.metafile)) {\n throw new Error('Invalid param: \"options.metafile\" must be string.');\n }\n\n const cdn: CdnClient = new CdnClient(options);\n\n await cdn.metafile.refresh();\n\n return cdn;\n }\n}\n"],"mappings":";;;AAIA,IAAa,IAAb,MAAA;CACE;CAEA,YAAY,GAAA;EACV,KAAK,UAAU;CACjB;CAEA,MAAA,YAAyB,GAAA;EACvB,OAAI,KAAK,QAAQ,MAAM,IAAI,CAAA,IAClB,IAAI,SAAS,MAAA;GAClB,EAAQ,KAAK,QAAQ,MAAM,IAAI,CAAA,CAAA;EAAA,CAAA,IAI5B,KAAK,QAAQ,OAAO,IAAI,EAAQ,eAAe,GAAA;CACxD;CAEA,MAAA,gBAAa;EACX,OAAA,MAAc,KAAK,QAAQ,OAAO,IAAI,KAAK,QAAQ,SAAS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KAAA,aAAA,KAAA,MAAA,KAAA"}
@@ -1,4 +1,4 @@
1
- /* @localazy/cdn-client@1.5.14
1
+ /* @localazy/cdn-client@1.5.16
2
2
  * (c) 2026 Localazy <team@localazy.com>
3
3
  * @license MIT */
4
4
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -539,7 +539,7 @@ var CdnClient = class CdnClient {
539
539
  metafile;
540
540
  cache;
541
541
  context;
542
- static version = "1.5.14";
542
+ static version = "1.5.16";
543
543
  constructor(options) {
544
544
  const metafileContext = new MetafileContext(options);
545
545
  const client = new FetchHttpAdapter(metafileContext.params.baseUrl);
@@ -1 +1 @@
1
- {"version":3,"file":"localazy-cdn-client.cjs","names":[],"sources":["../../src/cdn/api/api.ts","../../src/cdn/cache/memory-cache-adapter.ts","../../src/cdn/utils.ts","../../src/cdn/cache/locales-cache.ts","../../src/cdn/response/response-factory.ts","../../src/cdn/context/context.ts","../../src/cdn/metafile/metafile-file.ts","../../src/cdn/metafile/metafile-locale.ts","../../src/cdn/metafile/metafile-data.ts","../../src/cdn/metafile/metafile-params.ts","../../src/cdn/context/metafile-context.ts","../../src/cdn/http/fetch-http-adapter.ts","../../src/cdn/methods/cdn-base.ts","../../src/cdn/methods/cdn-cache.ts","../../src/cdn/methods/cdn-metafile.ts","../../src/cdn/request/locales-map.ts","../../src/cdn/request/request.ts","../../src/cdn/request/request-builder.ts","../../src/cdn/cdn-client.ts"],"sourcesContent":["import type { Context } from '@/cdn/context/context.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\n\nexport class Api {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public async fetchLocale(options: ApiLocaleRequest): Promise<object | string> {\n if (this.context.cache.has(options)) {\n return new Promise((resolve): void => {\n resolve(this.context.cache.get(options) as object | string);\n });\n }\n\n return this.context.client.get(options.metafileLocale.uri);\n }\n\n public async fetchMetafile(): Promise<IMetafile> {\n return (await this.context.client.get(this.context.metafile.params.jsonPath)) as IMetafile;\n }\n}\n","import type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\n\nexport class MemoryCacheAdapter<K, V> implements ICacheAdapter<K, V> {\n protected map: Map<K, V>;\n\n constructor() {\n this.map = new Map();\n }\n\n public get(key: K): V | undefined {\n return this.map.get(key);\n }\n\n public has(key: K): boolean {\n return this.map.has(key);\n }\n\n public set(key: K, value: V): void {\n this.map.set(key, value);\n }\n\n public flush(): void {\n this.map = new Map();\n }\n}\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isUndefined = (value: unknown): value is undefined => typeof value === 'undefined';\n\nexport const isArray = <T>(value: unknown): value is T[] => Array.isArray(value);\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n Object.prototype.toString.call(value) === '[object Object]';\n\nexport const uniq = <T>(array: T[]): T[] => [...new Set(array)];\n\nexport const uniqBy = <T>(array: T[], predicate: (item: T) => string): T[] => {\n const seen: Record<string, boolean> = {};\n\n return array.filter((item: T): boolean => {\n const key: string = predicate(item);\n\n if (!Object.hasOwn(seen, key)) {\n seen[key] = true;\n\n return true;\n }\n\n return false;\n });\n};\n","import { MemoryCacheAdapter } from '@/cdn/cache/memory-cache-adapter.js';\nimport type { Context } from '@/cdn/context/context.js';\nimport { uniq } from '@/cdn/utils.js';\nimport type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\nimport type { CacheGetLocalesRequest } from '@/types/cache-get-locales-request.js';\nimport type { CacheHasLocalesRequest } from '@/types/cache-has-locales-request.js';\nimport type { CacheKeyMetafileOptions } from '@/types/cache-key-metafile-options.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\n\nexport class LocalesCache {\n protected context: Context;\n\n protected cacheAdapter: ICacheAdapter<string, object | string>;\n\n constructor(context: Context) {\n this.context = context;\n this.cacheAdapter = new MemoryCacheAdapter();\n }\n\n public setIfMissed(options: CacheStoreLocalesRequest): void {\n const { metafileFile, metafileLocale, data }: CacheStoreLocalesRequest = options;\n\n const key: string = this.keyFromMetafile({\n metafileFile,\n metafileLocale,\n });\n\n if (!this.cacheAdapter.has(key)) {\n this.cacheAdapter.set(key, data);\n }\n }\n\n public has(options: CacheHasLocalesRequest): boolean {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.has(key);\n }\n\n public get(options: CacheGetLocalesRequest): object | string | undefined {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.get(key);\n }\n\n public flush(): void {\n this.cacheAdapter.flush();\n }\n\n protected keyFromMetafile(options: CacheKeyMetafileOptions): string {\n const { metafileFile, metafileLocale }: CacheKeyMetafileOptions = options;\n const productFlavors: string = [...uniq(metafileFile.productFlavors)].sort().join('-');\n\n const indices: string[] = [\n this.context.metafile.params.cdnId,\n metafileFile.id,\n metafileFile.file,\n metafileFile.path,\n metafileFile.library,\n metafileFile.module,\n metafileFile.buildType,\n productFlavors,\n metafileLocale.locale,\n metafileLocale.timestamp.toString(),\n ];\n\n return indices.filter((key: string): boolean => key !== '').join('-');\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\nimport type { ResponseFactoryOptions } from '@/types/response-factory-options.js';\n\nexport class ResponseFactory {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public createCdnResponse(options: ResponseFactoryOptions): CdnResponse {\n const {\n requests,\n responses,\n hasSingleFileResponse,\n hasSingleLocaleResponse,\n }: ResponseFactoryOptions = options;\n\n if (responses.length === 0 || typeof responses[0] === 'undefined') {\n return {};\n }\n\n this.cacheResponses(requests, responses);\n\n return hasSingleFileResponse && hasSingleLocaleResponse\n ? responses[0]\n : ResponseFactory.transformResponses(options);\n }\n\n protected cacheResponses(requests: ApiLocaleRequest[], responses: (object | string)[]): void {\n responses.forEach((response: object | string, index: number): void => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n this.context.cache.setIfMissed({ metafileFile, metafileLocale, data: response });\n }\n }\n });\n }\n\n protected static transformResponses(options: ResponseFactoryOptions): CdnResponse {\n const { requests, responses, hasSingleFileResponse }: ResponseFactoryOptions = options;\n\n return responses.reduce((acc: CdnResponse, cur: object | string, index: number) => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n if (hasSingleFileResponse) {\n // @ts-expect-error fix output type\n acc[metafileLocale.locale] = cur;\n } else {\n // @ts-expect-error fix output type\n if (!acc[metafileFile.id]) {\n // @ts-expect-error fix output type\n acc[metafileFile.id] = {};\n }\n\n // @ts-expect-error fix output type\n acc[metafileFile.id][metafileLocale.locale] = cur;\n }\n }\n }\n\n return acc;\n }, {});\n }\n}\n","import { Api } from '@/cdn/api/api.js';\nimport { LocalesCache } from '@/cdn/cache/locales-cache.js';\nimport type { CdnClient } from '@/cdn/cdn-client.js';\nimport type { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { ResponseFactory } from '@/cdn/response/response-factory.js';\nimport type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\nimport type { ContextOptions } from '@/types/context-options.js';\n\nexport class Context {\n public metafile: MetafileContext;\n\n public cdn: CdnClient;\n\n public client: IHttpAdapter;\n\n public api: Api;\n\n public cache: LocalesCache;\n\n public responseFactory: ResponseFactory;\n\n constructor(options: ContextOptions) {\n this.metafile = options.metafileContext;\n this.cdn = options.cdn;\n this.client = options.client;\n this.api = new Api(this);\n this.cache = new LocalesCache(this);\n this.responseFactory = new ResponseFactory(this);\n }\n}\n","import type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { IMetafileFile } from '@/interfaces/i-metafile-file.js';\nimport type { CdnFileLocale } from '@/types/cdn-file-locale.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { MetafileFileOptions } from '@/types/metafile-file-options.js';\n\nexport class MetafileFile implements Omit<IMetafileFile, 'locales'> {\n public id: string;\n\n public file: string;\n\n public path: string;\n\n public library: string;\n\n public module: string;\n\n public buildType: string;\n\n public timestamp: number;\n\n public productFlavors: string[];\n\n public locales: MetafileLocale[];\n\n protected baseUrl: string;\n\n constructor(options: MetafileFileOptions) {\n this.id = options.id;\n this.file = options.file;\n this.path = options.path;\n this.library = options.library;\n this.module = options.module;\n this.buildType = options.buildType;\n this.timestamp = options.timestamp;\n this.productFlavors = options.productFlavors;\n this.locales = options.locales;\n this.baseUrl = options.baseUrl;\n }\n\n public toCdnFile(): CdnFile {\n return {\n id: this.id,\n file: this.file,\n path: this.path,\n library: this.library,\n module: this.module,\n buildType: this.buildType,\n productFlavors: this.productFlavors,\n locales: this.locales.map(\n (locale: MetafileLocale): CdnFileLocale => ({\n locale: locale.locale,\n isBaseLocale: locale.isBaseLocale,\n uri: `${this.baseUrl}${locale.uri}`,\n }),\n ),\n };\n }\n}\n","import type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\n\nexport class MetafileLocale implements IMetafileFileLocale {\n public language: string;\n\n public region: string;\n\n public script: string;\n\n public isRtl: boolean;\n\n public name: string;\n\n public localizedName: string;\n\n public uri: string;\n\n public timestamp: number;\n\n protected baseLocale: string;\n\n constructor(options: IMetafileFileLocale, baseLocale: string) {\n this.language = options.language;\n this.region = options.region;\n this.script = options.script;\n this.isRtl = options.isRtl;\n this.name = options.name;\n this.localizedName = options.localizedName;\n this.uri = options.uri;\n this.timestamp = options.timestamp;\n this.baseLocale = baseLocale;\n }\n\n get locale(): string {\n if (this.language && this.region && this.script) {\n return `${this.language}_${this.region}#${this.script}`;\n }\n\n if (this.language && this.script) {\n return `${this.language}#${this.script}`;\n }\n\n if (this.language && this.region) {\n return `${this.language}_${this.region}`;\n }\n\n return this.language;\n }\n\n get isBaseLocale(): boolean {\n return this.locale === this.baseLocale;\n }\n\n public toCdnLocale(): CdnLocale {\n return {\n locale: this.locale,\n isBaseLocale: this.isBaseLocale,\n language: this.language,\n region: this.region,\n script: this.script,\n isRtl: this.isRtl,\n name: this.name,\n localizedName: this.localizedName,\n };\n }\n}\n","import { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { uniqBy } from '@/cdn/utils.js';\nimport type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { IMetafileFiles } from '@/interfaces/i-metafile-files.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { FilesMap } from '@/types/files-map.js';\nimport type { MetafileOptions } from '@/types/metafile-options.js';\n\nexport class MetafileData implements Omit<IMetafile, 'files' | 'baseLocale'> {\n public projectUrl: string;\n\n public baseLocale: CdnLocale;\n\n public locales: CdnLocale[];\n\n public timestamp: number;\n\n public files: MetafileFile[];\n\n public filesMap: FilesMap;\n\n constructor(options: MetafileOptions, params: MetafileParams) {\n this.projectUrl = options.projectUrl;\n this.timestamp = options.timestamp;\n this.files = MetafileData.filesFactory(options.files, options.baseLocale, params);\n this.filesMap = MetafileData.filesMapFactory(this.files);\n this.locales = MetafileData.localesFactory(this.files);\n this.baseLocale = this.locales.find((locale: CdnLocale) => locale.isBaseLocale) as CdnLocale;\n }\n\n public static createEmpty(params: MetafileParams): MetafileData {\n return new MetafileData(\n {\n projectUrl: '',\n baseLocale: '',\n timestamp: 0,\n files: {},\n },\n params,\n );\n }\n\n protected static filesFactory(\n files: IMetafileFiles,\n baseLocale: string,\n params: MetafileParams,\n ): MetafileFile[] {\n return Object.keys(files).reduce((acc: MetafileFile[], cur: string) => {\n if (typeof files[cur] !== 'undefined') {\n const locales: MetafileLocale[] = files[cur].locales.map(\n (locale: IMetafileFileLocale) => new MetafileLocale(locale, baseLocale),\n );\n\n acc.push(\n new MetafileFile({\n ...files[cur],\n id: cur,\n locales,\n baseUrl: params.baseUrl,\n }),\n );\n }\n\n return acc;\n }, []);\n }\n\n protected static filesMapFactory(files: MetafileFile[]): FilesMap {\n return files.reduce((acc: FilesMap, cur: MetafileFile) => {\n acc[cur.id] = cur;\n\n return acc;\n }, {});\n }\n\n protected static localesFactory(files: MetafileFile[]): CdnLocale[] {\n const locales: CdnLocale[] = files.reduce((acc: CdnLocale[], cur: MetafileFile) => {\n acc.push(...cur.locales.map((locale: MetafileLocale): CdnLocale => locale.toCdnLocale()));\n return acc;\n }, []);\n\n return uniqBy(locales, (cdnLocale: CdnLocale): string => cdnLocale.locale);\n }\n}\n","import type { IMetafileParams } from '@/interfaces/i-metafile-params.js';\n\nexport class MetafileParams implements IMetafileParams {\n protected options: IMetafileParams;\n\n constructor(metafileUrl: string) {\n this.options = MetafileParams.parseMetafileUrl(metafileUrl);\n }\n\n get url(): string {\n return this.options.url;\n }\n\n get baseUrl(): string {\n return this.options.baseUrl;\n }\n\n get cdnId(): string {\n return this.options.cdnId;\n }\n\n get jsonPath(): string {\n return this.options.jsonPath;\n }\n\n protected static parseMetafileUrl(metafileUrl: string): IMetafileParams {\n let url: URL;\n\n try {\n url = new URL(metafileUrl);\n } catch {\n throw new Error('Invalid param: \"options.metafile\" cannot be parsed as url.');\n }\n\n const matches: string[] | null = /^\\/(.*?)\\/(.*?)\\.(v2.json|js|ts)$/.exec(url.pathname);\n\n if (\n matches === null ||\n matches.length !== 4 ||\n typeof matches[1] === 'undefined' ||\n typeof matches[2] === 'undefined'\n ) {\n throw new Error('Invalid param: \"options.metafile\" contains invalid metafile url.');\n }\n\n const cdnId: string = matches[1];\n const tagId: string = matches[2];\n\n return {\n url: metafileUrl,\n baseUrl: url.origin,\n cdnId,\n jsonPath: `/${cdnId}/${tagId}.v2.json`,\n };\n }\n}\n","import { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\n\nexport class MetafileContext {\n public params: MetafileParams;\n\n public parsedData: IMetafile | null;\n\n public data: MetafileData;\n\n constructor(options: CdnClientOptions) {\n this.params = new MetafileParams(options.metafile);\n this.parsedData = null;\n this.data = MetafileData.createEmpty(this.params);\n }\n\n public setMetafile(metafile: IMetafile): void {\n this.parsedData = metafile;\n\n this.data = new MetafileData(metafile, this.params);\n }\n}\n","import type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\n\nexport class FetchHttpAdapter implements IHttpAdapter {\n protected baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async get(url: string): Promise<string | object> {\n const response: Response = await fetch(`${this.baseUrl}${url}`);\n const contentType: string | null = response.headers.get('content-type');\n const isJson: boolean =\n contentType === 'application/json5' || contentType === 'application/json';\n\n if (response.status >= 400) {\n throw new Error(`Request failed with status code ${response.status.toString()}`);\n }\n\n let result: string | object;\n\n if (isJson) {\n result = (await response.json()) as object;\n } else {\n result = await response.text();\n }\n\n return result;\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\n\nexport abstract class CdnBase {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n}\n","import { CdnBase } from '@/cdn/methods/cdn-base.js';\n\nexport class CdnCache extends CdnBase {\n public flush = (): void => {\n this.context.cache.flush();\n };\n}\n","import type { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { CdnBase } from '@/cdn/methods/cdn-base.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { CdnLocalesOptions } from '@/types/cdn-locales-options.js';\n\nexport class CdnMetafile extends CdnBase {\n get projectUrl(): string {\n return this.context.metafile.data.projectUrl;\n }\n\n get baseLocale(): CdnLocale {\n return this.context.metafile.data.baseLocale;\n }\n\n get url(): string {\n return this.context.metafile.params.url;\n }\n\n get files(): CdnFile[] {\n return this.context.metafile.data.files.map((file: MetafileFile): CdnFile => file.toCdnFile());\n }\n\n public locales = (options?: CdnLocalesOptions): CdnLocale[] => {\n const { excludeBaseLocale }: CdnLocalesOptions = options || {};\n const { locales }: MetafileData = this.context.metafile.data;\n\n return excludeBaseLocale\n ? locales.filter((cdnLocale: CdnLocale): boolean => !cdnLocale.isBaseLocale)\n : locales;\n };\n\n public refresh = async (): Promise<void> => {\n const response: IMetafile = await this.context.api.fetchMetafile();\n\n this.context.metafile.setMetafile(response);\n };\n\n public switch = async (options: CdnClientOptions): Promise<void> => {\n this.context.metafile.params = new MetafileParams(options.metafile);\n\n await this.refresh();\n };\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { LocalesMapData } from '@/types/locales-map-data.js';\nimport type { LocalesMapOptions } from '@/types/locales-map-options.js';\n\nexport class LocalesMap {\n public data: LocalesMapData;\n\n protected context: Context;\n\n constructor(options: LocalesMapOptions) {\n this.context = options.context;\n this.data = options.data || {};\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport { LocalesMap } from '@/cdn/request/locales-map.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class Request {\n public files: MetafileFile[];\n\n public localesMap: LocalesMap;\n\n public hasSingleFileResponse: boolean;\n\n public hasSingleLocaleResponse: boolean;\n\n protected context: Context;\n\n constructor(context: Context) {\n this.files = [];\n this.localesMap = new LocalesMap({ context });\n this.hasSingleFileResponse = false;\n this.hasSingleLocaleResponse = false;\n this.context = context;\n }\n\n public async execute(): Promise<CdnResponse> {\n const payload: [Promise<string | object>, ApiLocaleRequest][] = this.getPromises();\n const promises: Promise<string | object>[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[0],\n );\n const requests: ApiLocaleRequest[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[1],\n );\n const responses: (string | object)[] = await Promise.all(promises);\n\n return this.context.responseFactory.createCdnResponse({\n requests,\n responses,\n localesMap: this.localesMap,\n hasSingleFileResponse: this.hasSingleFileResponse,\n hasSingleLocaleResponse: this.hasSingleLocaleResponse,\n });\n }\n\n protected getPromises(): [Promise<string | object>, ApiLocaleRequest][] {\n return this.files.reduce(\n (acc: [Promise<string | object>, ApiLocaleRequest][], cur: MetafileFile) => {\n if (typeof this.localesMap.data?.[cur.id] !== 'undefined') {\n acc.push(\n ...this.localesMap.data[cur.id].map(\n (metafileLocale: MetafileLocale): [Promise<string | object>, ApiLocaleRequest] => {\n const request: ApiLocaleRequest = {\n metafileFile: cur,\n metafileLocale,\n };\n\n return [this.context.api.fetchLocale(request), request];\n },\n ),\n );\n }\n return acc;\n },\n [],\n );\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { LocalesMap } from '@/cdn/request/locales-map.js';\nimport { Request } from '@/cdn/request/request.js';\nimport { isArray, isPlainObject, isString, isUndefined } from '@/cdn/utils.js';\nimport type { IRequestBuilder } from '@/interfaces/i-request-builder.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\n\nexport class RequestBuilder implements IRequestBuilder {\n protected context: Context;\n\n protected request: Request;\n\n constructor(context: Context) {\n this.context = context;\n this.request = new Request(this.context);\n }\n\n public addFiles(files?: (CdnFile | string)[] | CdnFile | string): this {\n if (!(isPlainObject(files) || isString(files) || isUndefined(files) || isArray(files))) {\n throw new Error('Invalid param: \"request.files\" must be object, array, string or undefined.');\n }\n\n if (isArray(files)) {\n files.forEach((i: CdnFile | string): void => {\n if (!(isPlainObject(i) || isString(i))) {\n throw new Error('Invalid param: array \"request.files\" must contain objects or strings.');\n }\n });\n }\n\n if (isString(files)) {\n this.request.hasSingleFileResponse = true;\n\n const file: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files,\n );\n\n if (!(file instanceof MetafileFile)) {\n throw new Error(`File not found: \"${files}\".`);\n }\n\n this.request.files = [file];\n } else if (isUndefined(files)) {\n this.request.files = [...this.context.metafile.data.files];\n } else if (isArray(files)) {\n this.request.files = files.map((file: CdnFile | string): MetafileFile => {\n let metafileFile: MetafileFile;\n\n if (isString(file)) {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file}\".`);\n }\n\n metafileFile = foundFile;\n } else {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file.id}\".`);\n }\n\n metafileFile = foundFile;\n }\n\n return metafileFile;\n });\n } else if (isPlainObject(files)) {\n this.request.hasSingleFileResponse = true;\n\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${files.id}\".`);\n }\n\n this.request.files = [foundFile];\n }\n\n return this;\n }\n\n public addLocales(locales?: string[] | string, excludeBaseLocale?: boolean): this {\n if (!(isString(locales) || isUndefined(locales) || isArray(locales))) {\n throw new Error('Invalid param: \"request.locales\" must be array, string or undefined.');\n }\n\n if (isArray(locales)) {\n locales.forEach((i: MetafileFile | string): void => {\n if (!isString(i)) {\n throw new Error('Invalid param: array \"request.locales\" must contain strings.');\n }\n });\n }\n\n if (isString(locales)) {\n this.request.hasSingleLocaleResponse = true;\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => metafileLocale.locale === locales,\n );\n\n return acc;\n }, this.request.localesMap);\n } else if (isUndefined(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = excludeBaseLocale\n ? cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => !metafileLocale.isBaseLocale,\n )\n : cur.locales;\n\n return acc;\n }, this.request.localesMap);\n } else if (isArray(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter((metafileLocale: MetafileLocale) =>\n locales.includes(metafileLocale.locale),\n );\n\n return acc;\n }, this.request.localesMap);\n }\n\n return this;\n }\n\n public getCdnRequest(): Request {\n const result: Request = this.request;\n this.request = new Request(this.context);\n return result;\n }\n}\n","import { Context } from '@/cdn/context/context.js';\nimport { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { FetchHttpAdapter } from '@/cdn/http/fetch-http-adapter.js';\nimport { CdnCache } from '@/cdn/methods/cdn-cache.js';\nimport { CdnMetafile } from '@/cdn/methods/cdn-metafile.js';\nimport { RequestBuilder } from '@/cdn/request/request-builder.js';\nimport { isString } from '@/cdn/utils.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFetchOptions } from '@/types/cdn-fetch-options.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class CdnClient {\n public metafile: CdnMetafile;\n\n public cache: CdnCache;\n\n protected context: Context;\n\n public static version = '__CLIENT_VERSION__';\n\n protected constructor(options: CdnClientOptions) {\n const metafileContext: MetafileContext = new MetafileContext(options);\n const client: FetchHttpAdapter = new FetchHttpAdapter(metafileContext.params.baseUrl);\n\n this.context = new Context({ metafileContext, cdn: this, client });\n this.metafile = new CdnMetafile(this.context);\n this.cache = new CdnCache(this.context);\n }\n\n public fetch = async (options?: CdnFetchOptions): Promise<CdnResponse> => {\n const { files, locales, excludeBaseLocale }: CdnFetchOptions = options || {};\n const requestBuilder: RequestBuilder = new RequestBuilder(this.context)\n .addFiles(files)\n .addLocales(locales, excludeBaseLocale);\n\n return requestBuilder.getCdnRequest().execute();\n };\n\n public static async create(options: CdnClientOptions): Promise<CdnClient> {\n if (!options) {\n throw new Error('Invalid param: missing required \"options\" parameter.');\n }\n\n if (!isString(options.metafile)) {\n throw new Error('Invalid param: \"options.metafile\" must be string.');\n }\n\n const cdn: CdnClient = new CdnClient(options);\n\n await cdn.metafile.refresh();\n\n return cdn;\n }\n}\n"],"mappings":";;;;;AAIA,IAAa,MAAb,MAAiB;CACf;CAEA,YAAY,SAAkB;AAC5B,OAAK,UAAU;;CAGjB,MAAa,YAAY,SAAqD;AAC5E,MAAI,KAAK,QAAQ,MAAM,IAAI,QAAQ,CACjC,QAAO,IAAI,SAAS,YAAkB;AACpC,WAAQ,KAAK,QAAQ,MAAM,IAAI,QAAQ,CAAoB;IAC3D;AAGJ,SAAO,KAAK,QAAQ,OAAO,IAAI,QAAQ,eAAe,IAAI;;CAG5D,MAAa,gBAAoC;AAC/C,SAAQ,MAAM,KAAK,QAAQ,OAAO,IAAI,KAAK,QAAQ,SAAS,OAAO,SAAS;;;;;ACpBhF,IAAa,qBAAb,MAAqE;CACnE;CAEA,cAAc;AACZ,OAAK,sBAAM,IAAI,KAAK;;CAGtB,IAAW,KAAuB;AAChC,SAAO,KAAK,IAAI,IAAI,IAAI;;CAG1B,IAAW,KAAiB;AAC1B,SAAO,KAAK,IAAI,IAAI,IAAI;;CAG1B,IAAW,KAAQ,OAAgB;AACjC,OAAK,IAAI,IAAI,KAAK,MAAM;;CAG1B,QAAqB;AACnB,OAAK,sBAAM,IAAI,KAAK;;;;;ACtBxB,IAAa,YAAY,UAAoC,OAAO,UAAU;AAE9E,IAAa,eAAe,UAAuC,OAAO,UAAU;AAEpF,IAAa,WAAc,UAAiC,MAAM,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AAQ;GAAE;GAAiB,KAAK;GAAM;GAAQ,CAAC;AAClE,OAAK,WAAW,IAAI,YAAY,KAAK,QAAQ;AAC7C,OAAK,QAAQ,IAAI,SAAS,KAAK,QAAQ;;CAGzC,QAAe,OAAO,YAAoD;EACxE,MAAM,EAAE,OAAO,SAAS,sBAAuC,WAAW,EAAE;AAK5E,SAJuC,IAAI,eAAe,KAAK,QAAO,CACnE,SAAS,MAAK,CACd,WAAW,SAAS,kBAAkB,CAEnB,eAAe,CAAC,SAAS;;CAGjD,aAAoB,OAAO,SAA+C;AACxE,MAAI,CAAC,QACH,OAAM,IAAI,MAAM,yDAAuD;AAGzE,MAAI,CAAC,SAAS,QAAQ,SAAS,CAC7B,OAAM,IAAI,MAAM,sDAAoD;EAGtE,MAAM,MAAiB,IAAI,UAAU,QAAQ;AAE7C,QAAM,IAAI,SAAS,SAAS;AAE5B,SAAO"}
1
+ {"version":3,"file":"localazy-cdn-client.cjs","names":[],"sources":["../../src/cdn/api/api.ts","../../src/cdn/cache/memory-cache-adapter.ts","../../src/cdn/utils.ts","../../src/cdn/cache/locales-cache.ts","../../src/cdn/response/response-factory.ts","../../src/cdn/context/context.ts","../../src/cdn/metafile/metafile-file.ts","../../src/cdn/metafile/metafile-locale.ts","../../src/cdn/metafile/metafile-data.ts","../../src/cdn/metafile/metafile-params.ts","../../src/cdn/context/metafile-context.ts","../../src/cdn/http/fetch-http-adapter.ts","../../src/cdn/methods/cdn-base.ts","../../src/cdn/methods/cdn-cache.ts","../../src/cdn/methods/cdn-metafile.ts","../../src/cdn/request/locales-map.ts","../../src/cdn/request/request.ts","../../src/cdn/request/request-builder.ts","../../src/cdn/cdn-client.ts"],"sourcesContent":["import type { Context } from '@/cdn/context/context.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\n\nexport class Api {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public async fetchLocale(options: ApiLocaleRequest): Promise<object | string> {\n if (this.context.cache.has(options)) {\n return new Promise((resolve): void => {\n resolve(this.context.cache.get(options) as object | string);\n });\n }\n\n return this.context.client.get(options.metafileLocale.uri);\n }\n\n public async fetchMetafile(): Promise<IMetafile> {\n return (await this.context.client.get(this.context.metafile.params.jsonPath)) as IMetafile;\n }\n}\n","import type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\n\nexport class MemoryCacheAdapter<K, V> implements ICacheAdapter<K, V> {\n protected map: Map<K, V>;\n\n constructor() {\n this.map = new Map();\n }\n\n public get(key: K): V | undefined {\n return this.map.get(key);\n }\n\n public has(key: K): boolean {\n return this.map.has(key);\n }\n\n public set(key: K, value: V): void {\n this.map.set(key, value);\n }\n\n public flush(): void {\n this.map = new Map();\n }\n}\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isUndefined = (value: unknown): value is undefined => typeof value === 'undefined';\n\nexport const isArray = <T>(value: unknown): value is T[] => Array.isArray(value);\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n Object.prototype.toString.call(value) === '[object Object]';\n\nexport const uniq = <T>(array: T[]): T[] => [...new Set(array)];\n\nexport const uniqBy = <T>(array: T[], predicate: (item: T) => string): T[] => {\n const seen: Record<string, boolean> = {};\n\n return array.filter((item: T): boolean => {\n const key: string = predicate(item);\n\n if (!Object.hasOwn(seen, key)) {\n seen[key] = true;\n\n return true;\n }\n\n return false;\n });\n};\n","import { MemoryCacheAdapter } from '@/cdn/cache/memory-cache-adapter.js';\nimport type { Context } from '@/cdn/context/context.js';\nimport { uniq } from '@/cdn/utils.js';\nimport type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\nimport type { CacheGetLocalesRequest } from '@/types/cache-get-locales-request.js';\nimport type { CacheHasLocalesRequest } from '@/types/cache-has-locales-request.js';\nimport type { CacheKeyMetafileOptions } from '@/types/cache-key-metafile-options.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\n\nexport class LocalesCache {\n protected context: Context;\n\n protected cacheAdapter: ICacheAdapter<string, object | string>;\n\n constructor(context: Context) {\n this.context = context;\n this.cacheAdapter = new MemoryCacheAdapter();\n }\n\n public setIfMissed(options: CacheStoreLocalesRequest): void {\n const { metafileFile, metafileLocale, data }: CacheStoreLocalesRequest = options;\n\n const key: string = this.keyFromMetafile({\n metafileFile,\n metafileLocale,\n });\n\n if (!this.cacheAdapter.has(key)) {\n this.cacheAdapter.set(key, data);\n }\n }\n\n public has(options: CacheHasLocalesRequest): boolean {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.has(key);\n }\n\n public get(options: CacheGetLocalesRequest): object | string | undefined {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.get(key);\n }\n\n public flush(): void {\n this.cacheAdapter.flush();\n }\n\n protected keyFromMetafile(options: CacheKeyMetafileOptions): string {\n const { metafileFile, metafileLocale }: CacheKeyMetafileOptions = options;\n const productFlavors: string = [...uniq(metafileFile.productFlavors)].sort().join('-');\n\n const indices: string[] = [\n this.context.metafile.params.cdnId,\n metafileFile.id,\n metafileFile.file,\n metafileFile.path,\n metafileFile.library,\n metafileFile.module,\n metafileFile.buildType,\n productFlavors,\n metafileLocale.locale,\n metafileLocale.timestamp.toString(),\n ];\n\n return indices.filter((key: string): boolean => key !== '').join('-');\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\nimport type { ResponseFactoryOptions } from '@/types/response-factory-options.js';\n\nexport class ResponseFactory {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public createCdnResponse(options: ResponseFactoryOptions): CdnResponse {\n const {\n requests,\n responses,\n hasSingleFileResponse,\n hasSingleLocaleResponse,\n }: ResponseFactoryOptions = options;\n\n if (responses.length === 0 || typeof responses[0] === 'undefined') {\n return {};\n }\n\n this.cacheResponses(requests, responses);\n\n return hasSingleFileResponse && hasSingleLocaleResponse\n ? responses[0]\n : ResponseFactory.transformResponses(options);\n }\n\n protected cacheResponses(requests: ApiLocaleRequest[], responses: (object | string)[]): void {\n responses.forEach((response: object | string, index: number): void => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n this.context.cache.setIfMissed({ metafileFile, metafileLocale, data: response });\n }\n }\n });\n }\n\n protected static transformResponses(options: ResponseFactoryOptions): CdnResponse {\n const { requests, responses, hasSingleFileResponse }: ResponseFactoryOptions = options;\n\n return responses.reduce((acc: CdnResponse, cur: object | string, index: number) => {\n if (typeof requests[index] !== 'undefined') {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n if (hasSingleFileResponse) {\n // @ts-expect-error fix output type\n acc[metafileLocale.locale] = cur;\n } else {\n // @ts-expect-error fix output type\n if (!acc[metafileFile.id]) {\n // @ts-expect-error fix output type\n acc[metafileFile.id] = {};\n }\n\n // @ts-expect-error fix output type\n acc[metafileFile.id][metafileLocale.locale] = cur;\n }\n }\n }\n\n return acc;\n }, {});\n }\n}\n","import { Api } from '@/cdn/api/api.js';\nimport { LocalesCache } from '@/cdn/cache/locales-cache.js';\nimport type { CdnClient } from '@/cdn/cdn-client.js';\nimport type { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { ResponseFactory } from '@/cdn/response/response-factory.js';\nimport type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\nimport type { ContextOptions } from '@/types/context-options.js';\n\nexport class Context {\n public metafile: MetafileContext;\n\n public cdn: CdnClient;\n\n public client: IHttpAdapter;\n\n public api: Api;\n\n public cache: LocalesCache;\n\n public responseFactory: ResponseFactory;\n\n constructor(options: ContextOptions) {\n this.metafile = options.metafileContext;\n this.cdn = options.cdn;\n this.client = options.client;\n this.api = new Api(this);\n this.cache = new LocalesCache(this);\n this.responseFactory = new ResponseFactory(this);\n }\n}\n","import type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { IMetafileFile } from '@/interfaces/i-metafile-file.js';\nimport type { CdnFileLocale } from '@/types/cdn-file-locale.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { MetafileFileOptions } from '@/types/metafile-file-options.js';\n\nexport class MetafileFile implements Omit<IMetafileFile, 'locales'> {\n public id: string;\n\n public file: string;\n\n public path: string;\n\n public library: string;\n\n public module: string;\n\n public buildType: string;\n\n public timestamp: number;\n\n public productFlavors: string[];\n\n public locales: MetafileLocale[];\n\n protected baseUrl: string;\n\n constructor(options: MetafileFileOptions) {\n this.id = options.id;\n this.file = options.file;\n this.path = options.path;\n this.library = options.library;\n this.module = options.module;\n this.buildType = options.buildType;\n this.timestamp = options.timestamp;\n this.productFlavors = options.productFlavors;\n this.locales = options.locales;\n this.baseUrl = options.baseUrl;\n }\n\n public toCdnFile(): CdnFile {\n return {\n id: this.id,\n file: this.file,\n path: this.path,\n library: this.library,\n module: this.module,\n buildType: this.buildType,\n productFlavors: this.productFlavors,\n locales: this.locales.map(\n (locale: MetafileLocale): CdnFileLocale => ({\n locale: locale.locale,\n isBaseLocale: locale.isBaseLocale,\n uri: `${this.baseUrl}${locale.uri}`,\n }),\n ),\n };\n }\n}\n","import type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\n\nexport class MetafileLocale implements IMetafileFileLocale {\n public language: string;\n\n public region: string;\n\n public script: string;\n\n public isRtl: boolean;\n\n public name: string;\n\n public localizedName: string;\n\n public uri: string;\n\n public timestamp: number;\n\n protected baseLocale: string;\n\n constructor(options: IMetafileFileLocale, baseLocale: string) {\n this.language = options.language;\n this.region = options.region;\n this.script = options.script;\n this.isRtl = options.isRtl;\n this.name = options.name;\n this.localizedName = options.localizedName;\n this.uri = options.uri;\n this.timestamp = options.timestamp;\n this.baseLocale = baseLocale;\n }\n\n get locale(): string {\n if (this.language && this.region && this.script) {\n return `${this.language}_${this.region}#${this.script}`;\n }\n\n if (this.language && this.script) {\n return `${this.language}#${this.script}`;\n }\n\n if (this.language && this.region) {\n return `${this.language}_${this.region}`;\n }\n\n return this.language;\n }\n\n get isBaseLocale(): boolean {\n return this.locale === this.baseLocale;\n }\n\n public toCdnLocale(): CdnLocale {\n return {\n locale: this.locale,\n isBaseLocale: this.isBaseLocale,\n language: this.language,\n region: this.region,\n script: this.script,\n isRtl: this.isRtl,\n name: this.name,\n localizedName: this.localizedName,\n };\n }\n}\n","import { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { uniqBy } from '@/cdn/utils.js';\nimport type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { IMetafileFiles } from '@/interfaces/i-metafile-files.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { FilesMap } from '@/types/files-map.js';\nimport type { MetafileOptions } from '@/types/metafile-options.js';\n\nexport class MetafileData implements Omit<IMetafile, 'files' | 'baseLocale'> {\n public projectUrl: string;\n\n public baseLocale: CdnLocale;\n\n public locales: CdnLocale[];\n\n public timestamp: number;\n\n public files: MetafileFile[];\n\n public filesMap: FilesMap;\n\n constructor(options: MetafileOptions, params: MetafileParams) {\n this.projectUrl = options.projectUrl;\n this.timestamp = options.timestamp;\n this.files = MetafileData.filesFactory(options.files, options.baseLocale, params);\n this.filesMap = MetafileData.filesMapFactory(this.files);\n this.locales = MetafileData.localesFactory(this.files);\n this.baseLocale = this.locales.find((locale: CdnLocale) => locale.isBaseLocale) as CdnLocale;\n }\n\n public static createEmpty(params: MetafileParams): MetafileData {\n return new MetafileData(\n {\n projectUrl: '',\n baseLocale: '',\n timestamp: 0,\n files: {},\n },\n params,\n );\n }\n\n protected static filesFactory(\n files: IMetafileFiles,\n baseLocale: string,\n params: MetafileParams,\n ): MetafileFile[] {\n return Object.keys(files).reduce((acc: MetafileFile[], cur: string) => {\n if (typeof files[cur] !== 'undefined') {\n const locales: MetafileLocale[] = files[cur].locales.map(\n (locale: IMetafileFileLocale) => new MetafileLocale(locale, baseLocale),\n );\n\n acc.push(\n new MetafileFile({\n ...files[cur],\n id: cur,\n locales,\n baseUrl: params.baseUrl,\n }),\n );\n }\n\n return acc;\n }, []);\n }\n\n protected static filesMapFactory(files: MetafileFile[]): FilesMap {\n return files.reduce((acc: FilesMap, cur: MetafileFile) => {\n acc[cur.id] = cur;\n\n return acc;\n }, {});\n }\n\n protected static localesFactory(files: MetafileFile[]): CdnLocale[] {\n const locales: CdnLocale[] = files.reduce((acc: CdnLocale[], cur: MetafileFile) => {\n acc.push(...cur.locales.map((locale: MetafileLocale): CdnLocale => locale.toCdnLocale()));\n return acc;\n }, []);\n\n return uniqBy(locales, (cdnLocale: CdnLocale): string => cdnLocale.locale);\n }\n}\n","import type { IMetafileParams } from '@/interfaces/i-metafile-params.js';\n\nexport class MetafileParams implements IMetafileParams {\n protected options: IMetafileParams;\n\n constructor(metafileUrl: string) {\n this.options = MetafileParams.parseMetafileUrl(metafileUrl);\n }\n\n get url(): string {\n return this.options.url;\n }\n\n get baseUrl(): string {\n return this.options.baseUrl;\n }\n\n get cdnId(): string {\n return this.options.cdnId;\n }\n\n get jsonPath(): string {\n return this.options.jsonPath;\n }\n\n protected static parseMetafileUrl(metafileUrl: string): IMetafileParams {\n let url: URL;\n\n try {\n url = new URL(metafileUrl);\n } catch {\n throw new Error('Invalid param: \"options.metafile\" cannot be parsed as url.');\n }\n\n const matches: string[] | null = /^\\/(.*?)\\/(.*?)\\.(v2.json|js|ts)$/.exec(url.pathname);\n\n if (\n matches === null ||\n matches.length !== 4 ||\n typeof matches[1] === 'undefined' ||\n typeof matches[2] === 'undefined'\n ) {\n throw new Error('Invalid param: \"options.metafile\" contains invalid metafile url.');\n }\n\n const cdnId: string = matches[1];\n const tagId: string = matches[2];\n\n return {\n url: metafileUrl,\n baseUrl: url.origin,\n cdnId,\n jsonPath: `/${cdnId}/${tagId}.v2.json`,\n };\n }\n}\n","import { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\n\nexport class MetafileContext {\n public params: MetafileParams;\n\n public parsedData: IMetafile | null;\n\n public data: MetafileData;\n\n constructor(options: CdnClientOptions) {\n this.params = new MetafileParams(options.metafile);\n this.parsedData = null;\n this.data = MetafileData.createEmpty(this.params);\n }\n\n public setMetafile(metafile: IMetafile): void {\n this.parsedData = metafile;\n\n this.data = new MetafileData(metafile, this.params);\n }\n}\n","import type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\n\nexport class FetchHttpAdapter implements IHttpAdapter {\n protected baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async get(url: string): Promise<string | object> {\n const response: Response = await fetch(`${this.baseUrl}${url}`);\n const contentType: string | null = response.headers.get('content-type');\n const isJson: boolean =\n contentType === 'application/json5' || contentType === 'application/json';\n\n if (response.status >= 400) {\n throw new Error(`Request failed with status code ${response.status.toString()}`);\n }\n\n let result: string | object;\n\n if (isJson) {\n result = (await response.json()) as object;\n } else {\n result = await response.text();\n }\n\n return result;\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\n\nexport abstract class CdnBase {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n}\n","import { CdnBase } from '@/cdn/methods/cdn-base.js';\n\nexport class CdnCache extends CdnBase {\n public flush = (): void => {\n this.context.cache.flush();\n };\n}\n","import type { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { CdnBase } from '@/cdn/methods/cdn-base.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { CdnLocalesOptions } from '@/types/cdn-locales-options.js';\n\nexport class CdnMetafile extends CdnBase {\n get projectUrl(): string {\n return this.context.metafile.data.projectUrl;\n }\n\n get baseLocale(): CdnLocale {\n return this.context.metafile.data.baseLocale;\n }\n\n get url(): string {\n return this.context.metafile.params.url;\n }\n\n get files(): CdnFile[] {\n return this.context.metafile.data.files.map((file: MetafileFile): CdnFile => file.toCdnFile());\n }\n\n public locales = (options?: CdnLocalesOptions): CdnLocale[] => {\n const { excludeBaseLocale }: CdnLocalesOptions = options || {};\n const { locales }: MetafileData = this.context.metafile.data;\n\n return excludeBaseLocale\n ? locales.filter((cdnLocale: CdnLocale): boolean => !cdnLocale.isBaseLocale)\n : locales;\n };\n\n public refresh = async (): Promise<void> => {\n const response: IMetafile = await this.context.api.fetchMetafile();\n\n this.context.metafile.setMetafile(response);\n };\n\n public switch = async (options: CdnClientOptions): Promise<void> => {\n this.context.metafile.params = new MetafileParams(options.metafile);\n\n await this.refresh();\n };\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { LocalesMapData } from '@/types/locales-map-data.js';\nimport type { LocalesMapOptions } from '@/types/locales-map-options.js';\n\nexport class LocalesMap {\n public data: LocalesMapData;\n\n protected context: Context;\n\n constructor(options: LocalesMapOptions) {\n this.context = options.context;\n this.data = options.data || {};\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport { LocalesMap } from '@/cdn/request/locales-map.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class Request {\n public files: MetafileFile[];\n\n public localesMap: LocalesMap;\n\n public hasSingleFileResponse: boolean;\n\n public hasSingleLocaleResponse: boolean;\n\n protected context: Context;\n\n constructor(context: Context) {\n this.files = [];\n this.localesMap = new LocalesMap({ context });\n this.hasSingleFileResponse = false;\n this.hasSingleLocaleResponse = false;\n this.context = context;\n }\n\n public async execute(): Promise<CdnResponse> {\n const payload: [Promise<string | object>, ApiLocaleRequest][] = this.getPromises();\n const promises: Promise<string | object>[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[0],\n );\n const requests: ApiLocaleRequest[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[1],\n );\n const responses: (string | object)[] = await Promise.all(promises);\n\n return this.context.responseFactory.createCdnResponse({\n requests,\n responses,\n localesMap: this.localesMap,\n hasSingleFileResponse: this.hasSingleFileResponse,\n hasSingleLocaleResponse: this.hasSingleLocaleResponse,\n });\n }\n\n protected getPromises(): [Promise<string | object>, ApiLocaleRequest][] {\n return this.files.reduce(\n (acc: [Promise<string | object>, ApiLocaleRequest][], cur: MetafileFile) => {\n if (typeof this.localesMap.data?.[cur.id] !== 'undefined') {\n acc.push(\n ...this.localesMap.data[cur.id].map(\n (metafileLocale: MetafileLocale): [Promise<string | object>, ApiLocaleRequest] => {\n const request: ApiLocaleRequest = {\n metafileFile: cur,\n metafileLocale,\n };\n\n return [this.context.api.fetchLocale(request), request];\n },\n ),\n );\n }\n return acc;\n },\n [],\n );\n }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { LocalesMap } from '@/cdn/request/locales-map.js';\nimport { Request } from '@/cdn/request/request.js';\nimport { isArray, isPlainObject, isString, isUndefined } from '@/cdn/utils.js';\nimport type { IRequestBuilder } from '@/interfaces/i-request-builder.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\n\nexport class RequestBuilder implements IRequestBuilder {\n protected context: Context;\n\n protected request: Request;\n\n constructor(context: Context) {\n this.context = context;\n this.request = new Request(this.context);\n }\n\n public addFiles(files?: (CdnFile | string)[] | CdnFile | string): this {\n if (!(isPlainObject(files) || isString(files) || isUndefined(files) || isArray(files))) {\n throw new Error('Invalid param: \"request.files\" must be object, array, string or undefined.');\n }\n\n if (isArray(files)) {\n files.forEach((i: CdnFile | string): void => {\n if (!(isPlainObject(i) || isString(i))) {\n throw new Error('Invalid param: array \"request.files\" must contain objects or strings.');\n }\n });\n }\n\n if (isString(files)) {\n this.request.hasSingleFileResponse = true;\n\n const file: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files,\n );\n\n if (!(file instanceof MetafileFile)) {\n throw new Error(`File not found: \"${files}\".`);\n }\n\n this.request.files = [file];\n } else if (isUndefined(files)) {\n this.request.files = [...this.context.metafile.data.files];\n } else if (isArray(files)) {\n this.request.files = files.map((file: CdnFile | string): MetafileFile => {\n let metafileFile: MetafileFile;\n\n if (isString(file)) {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file}\".`);\n }\n\n metafileFile = foundFile;\n } else {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file.id}\".`);\n }\n\n metafileFile = foundFile;\n }\n\n return metafileFile;\n });\n } else if (isPlainObject(files)) {\n this.request.hasSingleFileResponse = true;\n\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${files.id}\".`);\n }\n\n this.request.files = [foundFile];\n }\n\n return this;\n }\n\n public addLocales(locales?: string[] | string, excludeBaseLocale?: boolean): this {\n if (!(isString(locales) || isUndefined(locales) || isArray(locales))) {\n throw new Error('Invalid param: \"request.locales\" must be array, string or undefined.');\n }\n\n if (isArray(locales)) {\n locales.forEach((i: MetafileFile | string): void => {\n if (!isString(i)) {\n throw new Error('Invalid param: array \"request.locales\" must contain strings.');\n }\n });\n }\n\n if (isString(locales)) {\n this.request.hasSingleLocaleResponse = true;\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => metafileLocale.locale === locales,\n );\n\n return acc;\n }, this.request.localesMap);\n } else if (isUndefined(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = excludeBaseLocale\n ? cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => !metafileLocale.isBaseLocale,\n )\n : cur.locales;\n\n return acc;\n }, this.request.localesMap);\n } else if (isArray(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter((metafileLocale: MetafileLocale) =>\n locales.includes(metafileLocale.locale),\n );\n\n return acc;\n }, this.request.localesMap);\n }\n\n return this;\n }\n\n public getCdnRequest(): Request {\n const result: Request = this.request;\n this.request = new Request(this.context);\n return result;\n }\n}\n","import { Context } from '@/cdn/context/context.js';\nimport { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { FetchHttpAdapter } from '@/cdn/http/fetch-http-adapter.js';\nimport { CdnCache } from '@/cdn/methods/cdn-cache.js';\nimport { CdnMetafile } from '@/cdn/methods/cdn-metafile.js';\nimport { RequestBuilder } from '@/cdn/request/request-builder.js';\nimport { isString } from '@/cdn/utils.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFetchOptions } from '@/types/cdn-fetch-options.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class CdnClient {\n public metafile: CdnMetafile;\n\n public cache: CdnCache;\n\n protected context: Context;\n\n public static version = '__CLIENT_VERSION__';\n\n protected constructor(options: CdnClientOptions) {\n const metafileContext: MetafileContext = new MetafileContext(options);\n const client: FetchHttpAdapter = new FetchHttpAdapter(metafileContext.params.baseUrl);\n\n this.context = new Context({ metafileContext, cdn: this, client });\n this.metafile = new CdnMetafile(this.context);\n this.cache = new CdnCache(this.context);\n }\n\n public fetch = async (options?: CdnFetchOptions): Promise<CdnResponse> => {\n const { files, locales, excludeBaseLocale }: CdnFetchOptions = options || {};\n const requestBuilder: RequestBuilder = new RequestBuilder(this.context)\n .addFiles(files)\n .addLocales(locales, excludeBaseLocale);\n\n return requestBuilder.getCdnRequest().execute();\n };\n\n public static async create(options: CdnClientOptions): Promise<CdnClient> {\n if (!options) {\n throw new Error('Invalid param: missing required \"options\" parameter.');\n }\n\n if (!isString(options.metafile)) {\n throw new Error('Invalid param: \"options.metafile\" must be string.');\n }\n\n const cdn: CdnClient = new CdnClient(options);\n\n await cdn.metafile.refresh();\n\n return cdn;\n }\n}\n"],"mappings":";;;;;AAIA,IAAa,MAAb,MAAiB;CACf;CAEA,YAAY,SAAkB;EAC5B,KAAK,UAAU;CACjB;CAEA,MAAa,YAAY,SAAqD;EAC5E,IAAI,KAAK,QAAQ,MAAM,IAAI,OAAO,GAChC,OAAO,IAAI,SAAS,YAAkB;GACpC,QAAQ,KAAK,QAAQ,MAAM,IAAI,OAAO,CAAoB;EAC5D,CAAC;EAGH,OAAO,KAAK,QAAQ,OAAO,IAAI,QAAQ,eAAe,GAAG;CAC3D;CAEA,MAAa,gBAAoC;EAC/C,OAAQ,MAAM,KAAK,QAAQ,OAAO,IAAI,KAAK,QAAQ,SAAS,OAAO,QAAQ;CAC7E;AACF;;;ACtBA,IAAa,qBAAb,MAAqE;CACnE;CAEA,cAAc;EACZ,KAAK,sBAAM,IAAI,IAAI;CACrB;CAEA,IAAW,KAAuB;EAChC,OAAO,KAAK,IAAI,IAAI,GAAG;CACzB;CAEA,IAAW,KAAiB;EAC1B,OAAO,KAAK,IAAI,IAAI,GAAG;CACzB;CAEA,IAAW,KAAQ,OAAgB;EACjC,KAAK,I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y/cdn-client",
3
- "version": "1.5.14",
3
+ "version": "1.5.16",
4
4
  "description": "Node.js module that allows you to easily interact with the Localazy CDN.",
5
5
  "keywords": [
6
6
  "CDN",
@@ -53,22 +53,22 @@
53
53
  }
54
54
  },
55
55
  "devDependencies": {
56
- "@microsoft/api-extractor": "^7.58.2",
56
+ "@microsoft/api-extractor": "^7.58.7",
57
57
  "@rollup/plugin-terser": "^1.0.0",
58
- "@tsconfig/node22": "^22.0.5",
58
+ "@tsconfig/node24": "^24.0.4",
59
59
  "@types/isomorphic-fetch": "^0.0.39",
60
- "@types/node": "^24.12.0",
61
- "@vitest/coverage-v8": "^4.1.4",
62
- "@vitest/ui": "^4.1.4",
60
+ "@types/node": "^24.12.4",
61
+ "@vitest/coverage-v8": "^4.1.6",
62
+ "@vitest/ui": "^4.1.6",
63
63
  "fetch-mock": "^12.6.0",
64
64
  "isomorphic-fetch": "^3.0.0",
65
65
  "reexport": "^1.4.1",
66
- "typescript": "^6.0.2",
67
- "unplugin-dts": "^1.0.0-beta.6",
68
- "unplugin-replace": "^0.8.0",
69
- "vite": "^8.0.8",
66
+ "typescript": "^6.0.3",
67
+ "unplugin-dts": "^1.0.0",
68
+ "unplugin-replace": "^0.9.0",
69
+ "vite": "^8.0.13",
70
70
  "vite-bundle-visualizer": "^1.2.1",
71
- "vitest": "^4.1.4"
71
+ "vitest": "^4.1.6"
72
72
  },
73
73
  "engines": {
74
74
  "node": ">=20"