CachedAssetsManager
class CachedAssetsManager
constructor
new CachedAssetsManager(client)
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
client | StarRail |
Properties
client
The client that instantiated this
Type: StarRail
defaultCacheDirectoryPath
Default path of StarRail 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 StarRail 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, and if store
is true, stores the data as a json file.
Returns: Promise<{[key: string]: string}>
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
lang | LanguageCode | |||
store | ✔️ | true |
checkForUpdates
Returns: Promise<boolean>
- Whether the game data update is available or not.
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
useRawStarRailData | ✔️ | false | Whether to fetch from github repo (https://github.com/Dimbreath/StarRailData) instead of downloading cache.zip |
fetchAllContents
Returns: Promise<void>
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
options.useRawStarRailData | {useRawStarRailData?: boolean, ghproxy?: boolean} | Whether to fetch from github repo (https://github.com/Dimbreath/StarRailData) instead of downloading cache.zip | ||
options.ghproxy | Whether to use ghproxy.com |
hasAllContents
Returns: boolean
- whether all StarRail 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.useRawStarRailData | {useRawStarRailData?: boolean, ghproxy?: boolean, onUpdateStart?: () => Promise<void>, onUpdateEnd?: () => Promise<void>} | ✔️ | {} | Whether to fetch from github repo (https://github.com/Dimbreath/StarRailData) instead of downloading cache.zip |
options.ghproxy | Whether to use ghproxy.com |
activateAutoCacheUpdater
Returns: void
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
options.useRawStarRailData | {useRawStarRailData?: boolean, instant?: boolean, ghproxy?: boolean, timeout?: number, onUpdateStart?: () => Promise<void>, onUpdateEnd?: () => Promise<void>, onError?: (error: Error) => Promise<void>} | ✔️ | {} | Whether to fetch from github repo (https://github.com/Dimbreath/StarRailData) 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 |
getJSONDataPath
Returns: string
- excel bin file path
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
name | string | without extensions (.json) |
getStarRailCacheData
Returns: {[key: string]: JsonObject}
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 |
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: LanguageMap
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
data | {[s: string]: {[s: string]: JsonObject}} | |||
langsData | LanguageMap | |||
showLog | ✔️ | true |
_downloadCacheZip
Download the zip file, which contains StarRail cache data, from https://raw.githubusercontent.com/yuko1101/starrail.js/main/cache.zip
Returns: Promise<void>
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
options.ghproxy | {ghproxy?: boolean} | ✔️ | {} | Whether to use ghproxy.com |