Skip to main content

CachedAssetsManager

class CachedAssetsManager

constructor

new CachedAssetsManager(enka)
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
enkaEnkaClient

Properties

enka

The client that instantiated this

Type: EnkaClient


defaultCacheDirectoryPath

Default path of genshin cache data directory

Type: string


_contentsSrc

List of the names of the files this library uses

Type: string[]


_langs

List of supported languages

Type: string[]


cacheDirectoryPath

Path of directory where genshin cache data is stored

Type: string


Methods

cacheDirectorySetup

async

Create the necessary folders and files, and if the directory cacheDirectoryPath did not exist, move the cache files from the default path.

Returns: Promise<void>


fetchLanguageData

async

Obtains a text map for a specific language.

Returns: Promise<{[key: string]: string}>

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
langLanguageCode

checkForUpdates

async

Returns: Promise<boolean>

  • Whether the game data update is available or not.
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
useRawGenshinData✔️falseWhether to fetch from gitlab repo (https://gitlab.com/Dimbreath/AnimeGameData) instead of downloading cache.zip

fetchAllContents

async

Returns: Promise<void>

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
options.useRawGenshinData{useRawGenshinData?: boolean, ghproxy?: boolean}Whether to fetch from gitlab repo (https://gitlab.com/Dimbreath/AnimeGameData) instead of downloading cache.zip
options.ghproxyWhether to use ghproxy.com

hasAllContents

Returns: boolean

  • whether all genshin cache data files exist.

updateContents

async

Returns: Promise<void>

  • true if there were any updates, false if there were no updates.
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
options.useRawGenshinData{useRawGenshinData?: boolean, ghproxy?: boolean, onUpdateStart?: () => Promise<void>, onUpdateEnd?: () => Promise<void>}✔️{}Whether to fetch from gitlab repo (https://gitlab.com/Dimbreath/AnimeGameData) instead of downloading cache.zip
options.ghproxyWhether to use ghproxy.com

activateAutoCacheUpdater

Returns: void

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
options.useRawGenshinData{useRawGenshinData?: boolean, instant?: boolean, ghproxy?: boolean, timeout?: number, onUpdateStart?: () => Promise<void>, onUpdateEnd?: () => Promise<void>, onError?: (error: Error) => Promise<void>}✔️{}Whether to fetch from gitlab repo (https://gitlab.com/Dimbreath/AnimeGameData) instead of downloading cache.zip
options.ghproxyWhether to use ghproxy.com
options.timeoutin milliseconds

deactivateAutoCacheUpdater

Disables the updater activated by activateAutoCacheUpdater

Returns: void


getLanguageDataPath

Returns: string

  • text map file path for a specific language
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
langLanguageCode
directorystring✔️

getJSONDataPath

Returns: string

  • excel bin file path
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
namestringwithout extensions (.json)

getGenshinCacheData

Returns: JsonReader

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
namestringwithout extensions (.json)

getLanguageData

Returns: {[key: string]: string}

  • text map for a specific language
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
langLanguageCode
directorystring✔️

getObjectKeysManager

Returns: ObjectKeysManager

  • ObjectKeysManager of this

refreshAllData

Clean memory of cache data.
Then reload data that was loaded before the clean if reload is true.
If reload is false, load each file as needed.

Returns: void

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
reload✔️false

removeUnusedTextData

Remove all unused text map entries

Returns: {langMap: LanguageMap, voiceLangMap: LanguageMap}

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
data{[s: string]: JsonArray}
langsDataLanguageMap
showLog✔️true

_downloadCacheZip

async

Download the zip file, which contains genshin cache data, from https://raw.githubusercontent.com/yuko1101/enka-network-api/main/cache.zip

Returns: Promise<void>

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
options.ghproxy{ghproxy?: boolean}✔️{}Whether to use ghproxy.com

_validateCache

Returns: boolean

  • whether the cache is valid or not
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
showLog✔️true