CachedAssetsManager
class CachedAssetsManager
constructor
new CachedAssetsManager(enka)
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
enka | EnkaClient |
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
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
Obtains a text map for a specific language.
Returns: Promise<{[key: string]: string}>
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
lang | LanguageCode |
checkForUpdates
Returns: Promise<boolean>
- Whether the game data update is available or not.
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
useRawGenshinData | ✔️ | false | Whether to fetch from gitlab repo (https://gitlab.com/Dimbreath/AnimeGameData) instead of downloading cache.zip |
fetchAllContents
Returns: Promise<void>
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
options.useRawGenshinData | {useRawGenshinData?: boolean, ghproxy?: boolean} | Whether to fetch from gitlab repo (https://gitlab.com/Dimbreath/AnimeGameData) instead of downloading cache.zip | ||
options.ghproxy | Whether to use ghproxy.com |
hasAllContents
Returns: boolean
- whether all genshin cache data files exist.
updateContents
Returns: Promise<void>
- true if there were any updates, false if there were no updates.
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
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.ghproxy | Whether to use ghproxy.com |
activateAutoCacheUpdater
Returns: void
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
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.ghproxy | Whether to use ghproxy.com | |||
options.timeout | in milliseconds |
deactivateAutoCacheUpdater
Disables the updater activated by activateAutoCacheUpdater
Returns: void
getLanguageDataPath
Returns: string
- text map file path for a specific language
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
lang | LanguageCode | |||
directory | string | ✔️ |
getJSONDataPath
Returns: string
- excel bin file path
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
name | string | without extensions (.json) |
getGenshinCacheData
Returns: JsonReader
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
name | string | without extensions (.json) |
getLanguageData
Returns: {[key: string]: string}
- text map for a specific language
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
lang | LanguageCode | |||
directory | string | ✔️ |
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
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
reload | ✔️ | false |
removeUnusedTextData
Remove all unused text map entries
Returns: {langMap: LanguageMap, voiceLangMap: LanguageMap}
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
data | {[s: string]: JsonArray} | |||
langsData | LanguageMap | |||
showLog | ✔️ | true |
_downloadCacheZip
Download the zip file, which contains genshin cache data, from https://raw.githubusercontent.com/yuko1101/enka-network-api/main/cache.zip
Returns: Promise<void>
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
options.ghproxy | {ghproxy?: boolean} | ✔️ | {} | Whether to use ghproxy.com |
_validateCache
Returns: boolean
- whether the cache is valid or not
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
showLog | ✔️ | true |