feat: dlcs

This commit is contained in:
TrèsAbhi committed 2026-04-20 20:51:57 -05:00
1 parent 4067357b54
commit 13311245a5
1 file changed
+6 -17
+6 -17
View File
@@ -186,7 +186,7 @@ export class ServerAPI extends AbstractAPI {
return strings; return strings;
} }
// @Cache() @Cache()
async gameStrings(locale: string) { async gameStrings(locale: string) {
const group = this.metadata.group("ClientConfigsEntity"); const group = this.metadata.group("ClientConfigsEntity");
@@ -198,20 +198,17 @@ export class ServerAPI extends AbstractAPI {
const clientConfig = this.metadata.item(group[0].id); const clientConfig = this.metadata.item(group[0].id);
const localizationResources = clientConfig.LocalizationResources(); const localizationResources = clientConfig.LocalizationResources();
const strings: Record<string, string> = {};
if (localizationResources.remote_storages.length !== 1) { for (const remoteStorageSettings of localizationResources.remote_storages) {
throw new RangeError(
`Don't know how to handle ${group.length} remote_storages`,
);
}
const remoteStorageName = localizationResources.remote_storages[0];
let remoteStorage: RemoteStorageComponent | undefined = undefined; let remoteStorage: RemoteStorageComponent | undefined = undefined;
for (const remoteUrl of remoteStorageName.remote_urls) { for (const remoteUrl of remoteStorageSettings.remote_urls) {
const item = this.metadata.item(remoteUrl); const item = this.metadata.item(remoteUrl);
const candidate = item.RemoteStorage(); const candidate = item.RemoteStorage();
console.log(remoteUrl, candidate);
if ( if (
remoteStorage === undefined || remoteStorage === undefined ||
candidate.download_speed_weight > remoteStorage.download_speed_weight candidate.download_speed_weight > remoteStorage.download_speed_weight
@@ -224,10 +221,7 @@ export class ServerAPI extends AbstractAPI {
throw new Error("No suitable production remote storage found"); throw new Error("No suitable production remote storage found");
} }
const strings: Record<string, string> = {};
const configPath = `${remoteStorage.url}${remoteStorage.relative_path}/config.yaml`; const configPath = `${remoteStorage.url}${remoteStorage.relative_path}/config.yaml`;
try {
const config = await fetch(configPath) const config = await fetch(configPath)
.then((response) => response.text()) .then((response) => response.text())
.then((text) => parse(text) as LocalizationConfig); .then((text) => parse(text) as LocalizationConfig);
@@ -245,11 +239,6 @@ export class ServerAPI extends AbstractAPI {
Object.assign(strings, namespaceStrings); Object.assign(strings, namespaceStrings);
} }
} catch (error) {
console.warn(
`Failed to fetch config from ${configPath}. Returning empty strings. This will throw an error in production. Error:`,
error,
);
} }
return strings; return strings;