A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
// Static config for the hot-update center: the delivery endpoint, the DLC pack
// refs, and the palette. Kept data-only so the systems read as pure wiring.
import type { Color } from 'esengine';
/** The `pack` group (see `.esengine/asset-groups.json`), pulled on demand by the
* "Download pack" button. Delivered as a SUBPACKAGE — it ships inside the
* package and the vendor fetches it on the first `loadGroup` (WeChat 分包) —
* unlike `cdn`, which is remote so a hot update can replace it after ship. */
export const PACK_GROUP = 'pack';
/** The pack's textures, by ordinary project-relative path (the ref a game
* actually writes — the loader resolves it to wherever the `pack` group's
* delivery staged it). The order here is the on-screen tile order. */
export const PACK_TILES: readonly string[] = [
'assets/pack/tile0.png',
'assets/pack/tile1.png',
'assets/pack/tile2.png',
'assets/pack/tile3.png',
'assets/pack/tile4.png',
'assets/pack/tile5.png',
];
/**
* Where "Check for update" looks: `window.__estellaHotUpdate` (a real CDN), else the
* checked-in `updates/` channel, which editor Play serves from the project root. A
* cooked build carries those files as data but not at that URL, so it reports
* "已是最新版本" — see the README.
*/
export interface HotUpdateEndpoint {
manifestUrl: string;
remoteRoot: string;
}
export function hotUpdateEndpoint(): HotUpdateEndpoint {
const w = globalThis as unknown as {
__estellaHotUpdate?: Partial<HotUpdateEndpoint>;
location?: { origin?: string };
};
const cfg = w.__estellaHotUpdate ?? {};
// checkForUpdate/applyUpdate fetch through the raw backend (no asset-base
// prefixing), so the manifest + its assets must be addressed absolutely. The
// page origin IS the project root in editor Play (estella://project) and the
// deploy root in a shipped build, so both realms resolve correctly from it.
const origin = w.location?.origin ?? '';
return {
manifestUrl: cfg.manifestUrl ?? `${origin}/updates/v2-manifest.json`,
remoteRoot: cfg.remoteRoot ?? origin,
};
}
/**
* True when booted headless for the render verify (`index.html?headless=1`). In
* that mode the verify harness drives `checkForUpdate`/`applyUpdate` directly on
* the Assets resource, so we must NOT auto-check — two drivers would race the one
* staged pending-update. Button-driven flows are always safe (never auto-fired).
*/
export function isHeadless(): boolean {
const loc = (globalThis as unknown as { location?: { search?: string } }).location;
return typeof loc?.search === 'string' && /(?:\?|&)headless\b/.test(loc.search);
}
// ── Palette (0..1 linear-ish sRGB triples the UI authors in) ────────────────
export const COLORS = {
card: { r: 0.11, g: 0.12, b: 0.15, a: 0.96 } as Color,
cardSoft: { r: 0.11, g: 0.12, b: 0.15, a: 0.90 } as Color,
track: { r: 0.24, g: 0.26, b: 0.31, a: 1 } as Color,
accent: { r: 0.29, g: 0.56, b: 0.95, a: 1 } as Color,
accentHover: { r: 0.36, g: 0.62, b: 0.98, a: 1 } as Color,
accentPressed: { r: 0.22, g: 0.46, b: 0.82, a: 1 } as Color,
control: { r: 0.22, g: 0.24, b: 0.29, a: 1 } as Color,
controlHover: { r: 0.28, g: 0.30, b: 0.36, a: 1 } as Color,
controlPressed: { r: 0.18, g: 0.20, b: 0.24, a: 1 } as Color,
ok: { r: 0.29, g: 0.80, b: 0.52, a: 1 } as Color,
warn: { r: 0.96, g: 0.62, b: 0.30, a: 1 } as Color,
text: { r: 0.93, g: 0.95, b: 0.98, a: 1 } as Color,
muted: { r: 0.60, g: 0.64, b: 0.72, a: 1 } as Color,
tileEmpty: { r: 0.20, g: 0.22, b: 0.27, a: 1 } as Color,
} as const;