perf: preload tavern canvas tiles on the main domain (0.69.0)

- the LPC scene images only started downloading after the Scene2D chunk loaded
  and TavernGame mounted, extending the 'loading tavern…' flash
- preload them in main.jsx (gated to the main domain via App===Scene2DApp, so
  docs/pm don't fetch them) — they now download in parallel with the JS chunk
- verified live: images requested at 1461ms vs Scene2D chunk at 1467ms (before,
  in parallel), canvas renders correctly
This commit is contained in:
artheru 2026-06-10 09:25:33 +08:00
parent 910b536dd9
commit 344a3f7bb2
4 changed files with 12 additions and 3 deletions

View File

@ -4,7 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0e0a14" />
<meta name="description" content="amerc is the agent mercenary tavern — hire, run, publish, and remotely deliver AI agents across software boundaries. No infrastructure, just skills." />
<meta name="version" content="0.68.0-trim" />
<meta name="version" content="0.69.0-preload" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<link rel="icon" href="/app-192.png" type="image/png" sizes="192x192" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />

View File

@ -1,6 +1,6 @@
{
"name": "amerc-site",
"version": "0.68.0-trim",
"version": "0.69.0-preload",
"private": true,
"type": "module",
"scripts": {

View File

@ -7,7 +7,7 @@ import Account from './Account.jsx';
import TavernGame from './TavernGame.jsx';
import { api } from './api.js';
const RELEASE = '0.68.0-trim';
const RELEASE = '0.69.0-preload';
const NAV = [
{ id: 'home', label: 'Tavern' },

View File

@ -12,6 +12,15 @@ let App = Scene2DApp;
if (host.startsWith('docs.')) App = DocsApp;
else if (host.startsWith('pm.')) App = PmApp;
// Preload the tavern's canvas tiles on the main domain so the scene paints as
// soon as the app mounts they download in parallel with the JS chunk instead
// of only after TavernGame runs. Not needed on docs/pm.
if (App === Scene2DApp) {
for (const n of ['inside', 'castlefloors', 'victoria', 'barrel', 'princess', 'soldier', 'soldier_altcolor']) {
const im = new Image(); im.src = `/scene2d/lpc/${n}.png`;
}
}
// Catch render errors so a single bad component can't blank the whole app.
class ErrorBoundary extends React.Component {
constructor(props) { super(props); this.state = { error: null }; }