feat: add launcher protocol data archive

- Add protocol data for multiple locales and versions
- Implement protocol archiving in archive command
- Update Api types and default settings for protocol support
This commit is contained in:
daydreamer-json
2026-03-12 16:14:29 +09:00
parent 6d0f2e3894
commit b1ed9573e5
62 changed files with 1045 additions and 1 deletions

View File

@@ -531,6 +531,7 @@ async function fetchAndSaveLatestLauncher(launcherTargets: LauncherTarget[]) {
async function fetchAndSaveLatestWebApis(gameTargets: GameTarget[]) {
logger.debug('Fetching latestWebApis ...');
const langs = apiUtils.akEndfield.defaultSettings.launcherWebLang;
const langsCN = apiUtils.akEndfield.defaultSettings.launcherWebLangCN;
const apis = [
{ name: 'sidebar', method: apiUtils.akEndfield.launcherWeb.sidebar, dir: 'sidebar' },
{ name: 'singleEnt', method: apiUtils.akEndfield.launcherWeb.singleEnt, dir: 'single_ent' },
@@ -540,7 +541,7 @@ async function fetchAndSaveLatestWebApis(gameTargets: GameTarget[]) {
] as const;
for (const target of gameTargets) {
for (const lang of langs) {
for (const lang of target.region === 'cn' ? langsCN : langs) {
for (const api of apis) {
networkQueue.add(async () => {
const rsp = await api.method(target.appCode, target.channel, target.subChannel, lang, target.region);
@@ -569,6 +570,50 @@ async function fetchAndSaveLatestWebApis(gameTargets: GameTarget[]) {
await networkQueue.onIdle();
}
async function fetchAndSaveLauncherProtocol(gameTargets: GameTarget[]) {
logger.debug('Fetching launcherProtocol ...');
const langs = apiUtils.akEndfield.defaultSettings.launcherWebLang;
const langsCN = apiUtils.akEndfield.defaultSettings.launcherWebLangCN;
const filterChannel = [
appConfig.network.api.akEndfield.subChannel.cnWinRel,
appConfig.network.api.akEndfield.subChannel.osWinRel,
appConfig.network.api.akEndfield.subChannel.osWinRelEpic,
];
for (const target of gameTargets.filter((e) => filterChannel.includes(e.launcherSubChannel))) {
for (const lang of target.region === 'cn' ? langsCN : langs) {
networkQueue.add(async () => {
const rsp = await apiUtils.akEndfield.launcher.protocol(
target.launcherAppCode,
target.channel,
target.subChannel,
lang,
target.region,
'',
);
if (!rsp) return;
logger.trace(`Found protocol: ${rsp.dataVersion}, ${target.region.toUpperCase()}, ${target.name}, ${lang}`);
const prettyRsp = {
req: {
appCode: target.launcherAppCode,
channel: target.channel,
subChannel: target.subChannel,
language: lang,
dataVersion: '',
},
rsp,
};
await saveResultWithHistory(
['akEndfield', 'launcher', 'protocol', String(target.subChannel), lang],
null,
prettyRsp,
{ ignoreRules: diffIgnoreRules },
);
});
}
}
await networkQueue.onIdle();
}
async function mainCmdHandler() {
const cfg = appConfig.network.api.akEndfield;
const gameTargets: GameTarget[] = [
@@ -638,6 +683,7 @@ async function mainCmdHandler() {
await fetchAndSaveLatestGamePatches(gameTargets);
await fetchAndSaveLatestGameResources(gameTargets);
await fetchAndSaveLatestWebApis(gameTargets);
await fetchAndSaveLauncherProtocol(gameTargets);
await fetchAndSaveLatestLauncher(launcherTargets);
await fetchAndSaveAllGameResRawData(gameTargets);

View File

@@ -1,3 +1,9 @@
type LauncherProtocol = {
dataVersion: string;
protocol: {
version: string;
};
};
type LauncherLatestGame = {
action: number;
version: string; // x.y.z
@@ -549,6 +555,7 @@ type GameHubGiftCodeRedeem = {
};
export type {
LauncherProtocol,
LauncherLatestGame,
LauncherLatestGameResources,
LauncherLatestLauncher,

View File

@@ -24,4 +24,5 @@ export default {
'zh-cn',
'zh-tw',
] as const,
launcherWebLangCN: ['zh-cn'] as const,
};

View File

@@ -7,6 +7,39 @@ import defaultSettings from './defaultSettings.js';
import launcherWeb from './launcherWeb.js';
export default {
protocol: async (
appCode: string,
channel: number,
subChannel: number,
language: (typeof defaultSettings.launcherWebLang)[number],
region: 'os' | 'cn',
dataVersion: string = '',
): Promise<TypesApiAkEndfield.LauncherProtocol> => {
const apiBase =
region === 'cn'
? appConfig.network.api.akEndfield.base.launcherCN
: appConfig.network.api.akEndfield.base.launcher;
const rsp = await ky
.post(`https://${apiBase}/proxy/batch_proxy`, {
...defaultSettings.ky,
json: {
proxy_reqs: [
{
kind: 'get_protocol',
get_protocol_req: {
appcode: appCode,
channel: String(channel),
sub_channel: String(subChannel),
language,
dataVersion,
},
},
],
},
})
.json();
return (rsp as any).proxy_rsps[0].get_protocol as TypesApiAkEndfield.LauncherProtocol;
},
latestGame: async (
appCode: string,
launcherAppCode: string,