UNPKG

genshin-manager

Version:

<div align="center"> <p> <a href="https://www.npmjs.com/package/genshin-manager"><img src="https://img.shields.io/npm/v/genshin-manager.svg?maxAge=3600" alt="npm version" /></a> <a href="https://www.npmjs.com/package/genshin-manager"><img src="https:

157 lines (156 loc) 5.59 kB
import EventEmitter from 'events'; import { ClientOption, ExcelBinOutputs, TextMapLanguage } from '../types'; import { JsonObject } from '../utils/JsonParser'; import { EventMap, PromiseEventEmitter } from '../utils/PromiseEventEmitter'; interface AssetCacheManagerEventMap { BEGIN_UPDATE_CACHE: [version: string]; END_UPDATE_CACHE: [version: string]; BEGIN_UPDATE_ASSETS: [version: string]; END_UPDATE_ASSETS: [version: string]; } /** * Class for managing cached assets * @abstract */ export declare abstract class AssetCacheManager<T extends EventMap<T>, E extends keyof T> extends PromiseEventEmitter<T, E> { /** * Cached text map * @deprecated This property is deprecated because it is used to pass data to each class * @key Text hash * @value Text */ static readonly _cachedTextMap: Map<string, string>; /** * Asset event emitter * @deprecated This property is deprecated because it is used to pass data to each class */ protected static readonly _assetEventEmitter: EventEmitter<AssetCacheManagerEventMap>; private static readonly GIT_REMOTE_API_URL; private static readonly GIT_REMOTE_RAW_BASE_URL; /** * Cached text map * @key ExcelBinOutput name * @value Cached excel bin output */ private static readonly cachedExcelBinOutput; private static option; private static nowCommitId; private static commitFilePath; private static excelBinOutputFolderPath; private static textMapFolderPath; private static textHashes; private static useExcelBinOutputKeys; /** * Create a AssetCacheManager * @param option Client option */ constructor(option: ClientOption); /** * Assets game version text * @returns Assets game version text or undefined */ protected static get gameVersion(): string | undefined; /** * Create ExcelBinOutput Keys to cache * @returns All ExcelBinOutput Keys */ private static get excelBinOutputAllKeys(); /** * Add ExcelBinOutput Key from Class Prototype to AssetCacheManager * @deprecated This method is deprecated because it is used to pass data to each class * @param classPrototype Class Prototype */ static _addExcelBinOutputKeyFromClassPrototype(classPrototype: unknown): void; /** * Get Json from cached excel bin output * @deprecated This method is deprecated because it is used to pass data to each class * @param key ExcelBinOutput name * @param id ID of character, etc * @returns Json */ static _getJsonFromCachedExcelBinOutput(key: keyof typeof ExcelBinOutputs, id: string | number): JsonObject; /** * Get cached excel bin output by name * @deprecated This method is deprecated because it is used to pass data to each class * @param key ExcelBinOutput name * @returns Cached excel bin output */ static _getCachedExcelBinOutputByName(key: keyof typeof ExcelBinOutputs): { [key in string]: JsonObject; }; /** * Check if cached excel bin output exists by name * @deprecated This method is deprecated because it is used to pass data to each class * @param key ExcelBinOutput name * @returns Cached excel bin output exists */ static _hasCachedExcelBinOutputByName(key: keyof typeof ExcelBinOutputs): boolean; /** * Check if cached excel bin output exists by ID * @deprecated This method is deprecated because it is used to pass data to each class * @param key ExcelBinOutput name * @param id ID of character, etc * @returns Cached excel bin output exists */ static _hasCachedExcelBinOutputById(key: keyof typeof ExcelBinOutputs, id: string | number): boolean; /** * Search ID in CachedExcelBinOutput by text * @deprecated This method is deprecated because it is used to pass data to each class * @param key ExcelBinOutput name * @param text Text * @returns IDs */ static _searchIdInExcelBinOutByText(key: keyof typeof ExcelBinOutputs, text: string): string[]; /** * Set excel bin output to cache * @param keys ExcelBinOutput names * @returns Returns true if an error occurs */ protected static setExcelBinOutputToCache(keys: Set<keyof typeof ExcelBinOutputs>): Promise<boolean>; /** * Change cached languages * @param language Country code * @returns Returns true if an error occurs */ protected static setTextMapToCache(language: keyof typeof TextMapLanguage): Promise<boolean>; /** * Update cache * @example * ```ts * await Client.updateCache() * ``` */ protected static updateCache(): Promise<void>; /** * Check gitlab for new commits * @returns New assets version text or undefined */ private static checkGitUpdate; /** * Create TextHashes to cache */ private static createTextHashes; /** * Re download text map * @param language Country code */ private static reDownloadTextMap; /** * Re download all excel bin output */ private static reDownloadAllExcelBinOutput; /** * Fetch asset folder from gitlab * @param folderPath Folder path * @param files File names * @param isRetry Is Retry */ private static fetchAssetFolder; /** * Download json file from URL and write to downloadFilePath * @param url URL * @param downloadFilePath Download file path */ private static downloadJsonFile; } export {};