Support non-full builds in testclient

Non-Preact testclients don't deal well with non-full builds anymore,
now that battledata includes data/text.js. This fixes it so that
they're usable (although no longer being able to edit battle-dex etc
without an initial full build still sucks, it's unavoidable).
This commit is contained in:
Guangcong Luo
2025-04-22 09:27:22 -07:00
parent e68993813d
commit 94a1876f61
3 changed files with 22 additions and 18 deletions

View File

@@ -107,20 +107,24 @@ compiledFiles += compiler.compileToDir(`replay.pokemonshowdown.com/src`, `replay
compiledFiles += compiler.compileToDir(`teams.pokemonshowdown.com/src`, `teams.pokemonshowdown.com/js`, compileOpts);
compiledFiles += compiler.compileToFile(
[
'play.pokemonshowdown.com/src/battle-dex.ts',
'play.pokemonshowdown.com/src/battle-dex-data.ts',
'play.pokemonshowdown.com/src/battle-log.ts',
'play.pokemonshowdown.com/src/battle-log-misc.js',
'caches/pokemon-showdown/server/chat-formatter.ts',
'play.pokemonshowdown.com/data/text.js',
'play.pokemonshowdown.com/data/text-afd.js',
'play.pokemonshowdown.com/src/battle-text-parser.ts',
],
'play.pokemonshowdown.com/js/battledata.js',
compileOpts
);
try {
fs.statSync('play.pokemonshowdown.com/data/text.js');
// text.js exists, we can compile battledata
compiledFiles += compiler.compileToFile(
[
'play.pokemonshowdown.com/src/battle-dex.ts',
'play.pokemonshowdown.com/src/battle-dex-data.ts',
'play.pokemonshowdown.com/src/battle-log.ts',
'play.pokemonshowdown.com/src/battle-log-misc.js',
'caches/pokemon-showdown/server/chat-formatter.ts',
'play.pokemonshowdown.com/data/text.js',
'play.pokemonshowdown.com/data/text-afd.js',
'play.pokemonshowdown.com/src/battle-text-parser.ts',
],
'play.pokemonshowdown.com/js/battledata.js',
compileOpts
);
} catch {}
if (!compileOpts.ignore) {
compiledFiles += compiler.compileToFile(

View File

@@ -16,7 +16,7 @@
<script>
function loadRemoteData(src) {
var scriptEl = document.createElement('script');
scriptEl.src = src.replace(/.*\/data\//g, 'https://play.pokemonshowdown.com/data/');
scriptEl.src = src.replace(/.*\/(data|js)\//g, 'https://play.pokemonshowdown.com/$1/');
document.head.appendChild(scriptEl);
}
Config.testclient = true;
@@ -86,12 +86,12 @@
<!-- fallback for if you've never done a full build -->
<script src="js/server/chat-formatter.js" onerror="loadRemoteData(this.src)"></script>
<script src="js/battledata.js" onerror="alert('You must build the client with `node build` before using testclient.html')"></script>
<script src="js/battledata.js" onerror="loadRemoteData(this.src)"></script>
<script src="data/text.js" onerror="loadRemoteData(this.src)"></script>
<script src="data/pokedex-mini.js" onerror="loadRemoteData(this.src)"></script>
<script src="data/pokedex-mini-bw.js" onerror="loadRemoteData(this.src)"></script>
<script src="data/typechart.js" onerror="loadRemoteData(this.src)"></script>
<script src="js/battle.js"></script>
<script src="js/battle.js" onerror="alert('You must build the client with `node build` before using testclient.html')"></script>
<script src="js/lib/sockjs-1.4.0-nwjsfix.min.js"></script>
<script src="js/lib/color-thief.min.js"></script>

View File

@@ -143,7 +143,7 @@
<script src="../play.pokemonshowdown.com/js/lib/jquery-1.11.0.min.js"></script>
<script src="../play.pokemonshowdown.com/js/lib/html-sanitizer-minified.js"></script>
<script src="../play.pokemonshowdown.com/js/battle-sound.js"></script>
<script src="../play.pokemonshowdown.com/js/battledata.js"></script>
<script src="../play.pokemonshowdown.com/js/battledata.js" onerror="loadRemoteData(this.src)"></script>
<script src="../play.pokemonshowdown.com/data/pokedex-mini.js" onerror="loadRemoteData(this.src)"></script>
<script src="../play.pokemonshowdown.com/data/pokedex-mini-bw.js" onerror="loadRemoteData(this.src)"></script>
<script src="../play.pokemonshowdown.com/data/graphics.js" onerror="loadRemoteData(this.src)"></script>