feat(config): unify startup mode and server selection

This commit is contained in:
2026-09-05 22:52:14 +08:00
parent 239af0aa39
commit facceeae9b
26 changed files with 204 additions and 240 deletions
@@ -1,3 +1,4 @@
import { STARTUP_CONFIG } from '../../YouleNexus/assets/framework/config/profiles.ts';
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { resolveBootstrap } from '../../YouleNexus/assets/framework/config/bootstrap.ts';
@@ -8,9 +9,19 @@ test('resolveBootstrap:显式 hostKind 透传严格 RuntimeConfig,并保留
async fetch() { return { player_server_tcp: '5.5.5.5:5000' }; },
};
const result = await resolveBootstrap({
mode: 'debug', hostKind: 'h5', win: {}, search: '?profile=local', fetcher,
hostKind: 'h5', win: {}, search: '', fetcher,
});
assert.equal(result.source, 'remote');
assert.equal(result.profile.name, 'local');
assert.deepEqual(result.servers, ['ws://127.0.0.1:3088']);
});
test('facade forwards the entire injected source and derives its compatibility label', async () => {
for (const useLocalServer of [true,false]) {
const startupConfig={...STARTUP_CONFIG,mode:'release' as const,useLocalServer,gameserver:'https://fixture.example/config.txt'};
const result=await resolveBootstrap({startupConfig,isNative:false,win:{},search:'?mode=debug&profile=unknown&profile=local',fetcher:{async fetch(url){assert.equal(url,startupConfig.gameserver);return {player_server_tcp:'remote.example:3088'};}}});
assert.deepEqual(result.startupConfig,startupConfig); assert.equal(result.mode,'release');
assert.equal(result.profile.name,useLocalServer?'local':'prod');
assert.deepEqual(result.servers,useLocalServer?STARTUP_CONFIG.localServers:['ws://remote.example:3088']);
}
});