feat: integrate login flow, lobby UI and bitmap font resources

This commit is contained in:
2026-09-06 13:46:57 +08:00
parent e1bcfd91ec
commit 842c68ef55
141 changed files with 11279 additions and 1717 deletions
@@ -6,8 +6,9 @@ import ts from 'typescript';
import { ConfigFetchError, ConfigParseError } from '../../YouleNexus/assets/framework/config/remote-config.ts';
// 在引擎资源边界验证错误、JSON 解析和缓存释放,不以 HTTP 模拟项目资源。
function fixture(debug: boolean, text: string, error?: Error) {
function fixture(debug: boolean, text: string, error?: Error, debugIO = false) {
const calls: string[] = [];
const logs: unknown[][] = [];
const exports: any = {};
class TextAsset {}
const resources = {
@@ -19,15 +20,25 @@ function fixture(debug: boolean, text: string, error?: Error) {
const source = readFileSync(new URL('../../YouleNexus/assets/scripts/platform-login/local-config-fetcher.ts', import.meta.url), 'utf8');
runInNewContext(ts.transpileModule(source, {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText, { exports, require(name: string) {
}).outputText, { exports, console: {log: (...args:unknown[])=>logs.push(args)}, require(name: string) {
if (name === 'cc') return { resources, TextAsset };
if (name === 'cc/env') return { DEBUG: debug };
if (name.endsWith('/profiles.ts')) return { STARTUP_CONFIG: { debugIO } };
if (name.endsWith('/remote-config.ts')) return { ConfigFetchError, ConfigParseError };
throw Error(`Unexpected import: ${name}`);
} });
return { fetcher: new exports.CocosLocalConfigFetcher(), calls };
return { fetcher: new exports.CocosLocalConfigFetcher(), calls, logs };
}
test('config logging emits the parsed object and is silent when disabled', async () => {
for(const enabled of [false,true]){
const f=fixture(true,'{"showVisitor":1}',undefined,enabled);
const data=await f.fetcher.fetch('dev-config/test');
assert.deepEqual(f.logs,enabled?[['[Config LOCAL]','dev-config/test.txt',data]]:[]);
if(enabled)assert.equal(typeof f.logs[0][2],'object');
}
});
test('project txt parses JSON and releases the asset after every load', async () => {
const f = fixture(true, '{"showVisitor":1}');
assert.equal((await f.fetcher.fetch('dev-config/test')).showVisitor, 1);
@@ -25,11 +25,11 @@ test('resolveGameServer:空 gameconfig 使用配置源,非空值使用解码
});
test('one frozen source defines the complete default startup configuration', () => {
assert.deepEqual(STARTUP_CONFIG, { mode: 'debug', configSource: 'remote', localConfigResource: 'dev-config/update_jsonv2', gameserver: 'https://tsgames.daoqi88.cn/config_test/update_jsonv2.txt', useLocalServer: true, localServers: ['ws://127.0.0.1:3088'] });
assert.deepEqual(STARTUP_CONFIG, { debugIO: true, mode: 'debug', configSource: 'remote', localConfigResource: 'dev-config/update_jsonv2', gameserver: 'https://tsgames.daoqi88.cn/config_test/update_jsonv2.txt', useLocalServer: true, localServers: ['ws://127.0.0.1:3088'] });
assert.ok(Object.isFrozen(STARTUP_CONFIG)); assert.ok(Object.isFrozen(STARTUP_CONFIG.localServers));
});
test('source validation rejects malformed configuration without defaults', () => {
for (const patch of [{mode:'other'}, {useLocalServer:undefined}, {gameserver:'ws://host'}, {gameserver:''}, {localServers:[]}, {localServers:['ws://example.com:3088']}, {localServers:['ws://user:pass@localhost']}, {localServers:['ws://localhost/#fragment']}, {localServers:['ws://127.999.0.1']}, {localServers:['not-a-url']}]) {
for (const patch of [{debugIO:undefined}, {debugIO:'true'}, {mode:'other'}, {useLocalServer:undefined}, {gameserver:'ws://host'}, {gameserver:''}, {localServers:[]}, {localServers:['ws://example.com:3088']}, {localServers:['ws://user:pass@localhost']}, {localServers:['ws://localhost/#fragment']}, {localServers:['ws://127.999.0.1']}, {localServers:['not-a-url']}]) {
assert.throws(() => validateStartupConfig({...STARTUP_CONFIG,...patch} as any), /startup config/i);
}
for (const url of ['ws://127.4.3.2:3088','wss://localhost:3088','ws://[::1]:3088']) assert.deepEqual(validateStartupConfig({...STARTUP_CONFIG,localServers:[url]}).localServers,[url]);