Optimize initial loading performance
This commit is contained in:
@@ -56,6 +56,11 @@ export const portraitAssets: Record<string, string> = Object.fromEntries(
|
||||
Object.entries(portraitModules).map(([path, url]) => [fileSlugFromPath(path), url])
|
||||
);
|
||||
|
||||
export type PortraitAssetEntry = {
|
||||
textureKey: string;
|
||||
url: string;
|
||||
};
|
||||
|
||||
export function portraitSlugForKey(key: string) {
|
||||
return legacyPortraitSlugs[key] ?? camelToKebab(key);
|
||||
}
|
||||
@@ -65,6 +70,18 @@ export function portraitTextureKey(key: string) {
|
||||
return portraitAssets[slug] ? `portrait-${slug}` : undefined;
|
||||
}
|
||||
|
||||
export function portraitAssetEntriesForKey(key: string): PortraitAssetEntry[] {
|
||||
const slug = portraitSlugForKey(key);
|
||||
const prefix = `${slug}-`;
|
||||
return Object.keys(portraitAssets)
|
||||
.filter((candidate) => candidate === slug || candidate.startsWith(prefix))
|
||||
.sort()
|
||||
.map((candidate) => ({
|
||||
textureKey: `portrait-${candidate}`,
|
||||
url: portraitAssets[candidate]
|
||||
}));
|
||||
}
|
||||
|
||||
export function portraitTextureKeysForKey(key: string) {
|
||||
const slug = portraitSlugForKey(key);
|
||||
const prefix = `${slug}-`;
|
||||
|
||||
Reference in New Issue
Block a user