Files
youle_cocos/out/room-platform-refactor/extract-chat.mjs
T
joywayer 35216f75e7 feat: integrate room framework and isolated subgame bundles
Complete room UI and protocol integration, move game definitions and resources behind bundle entries, publish authoritative version XML, and document single-game builds. Include all current resource changes and experiment artifacts.
2026-09-09 03:13:18 +08:00

16 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import {readFileSync,writeFileSync,mkdirSync} from 'node:fs';
const base='G:/Works/YouleGamesCocosCreator/cocoscreator_projects/YouleNexus/assets/';
const path=base+'framework/presentation/room-chat-config.ts';
const source=readFileSync(path,'utf8');
const corpus=readFileSync(base+'framework/presentation/room-chat-banned-words.ts','utf8');
for(const [key,folder,constant] of [['Game_Surface_3','template','ROOM_CHAT_BANNED_WORDS'],['erqiwang','erqiwang','ERQIWANG_CHAT_BANNED_WORDS']]){
const begin=source.indexOf(key+':Object.freeze(')+key.length+1;
const end=source.indexOf('].map(phrase=>Object.freeze(phrase)))}),',begin)+'].map(phrase=>Object.freeze(phrase)))}),'.length-1;
if(begin<key.length+1||end<begin)throw Error('chat extraction failed');
const declaration=corpus.split(/\r?\n/).find(line=>line.startsWith('export const '+constant+':'));
if(!declaration)throw Error('missing corpus '+constant);
writeFileSync(base+'games/'+folder+'/room-chat-config.ts',"import type {RoomChatConfig} from '../../framework/presentation/room-chat-config.ts';\n"+declaration+'\n/** Copied from this game’s original configuration and banned-word source. */\nexport const roomChatConfig:RoomChatConfig='+source.slice(begin,end)+';\n');
}
writeFileSync(path,source.replace(/^import \{ROOM_CHAT_BANNED_WORDS[^\n]*\r?\n/m,'').replace(/\/\/ Authoritative migration[\s\S]*?(?=\/\*\* Incoming send_text)/,''));
mkdirSync(base+'app/composition',{recursive:true});