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
feat(editor): custom components/systems run in Play via import-map realm (IM1/IM2)
esenginea41de0c979be
diff --git a/desktop/electron/buildPlayRealm.ts b/desktop/electron/buildPlayRealm.tsnew file mode 100644index 000000000..9da74662b--- /dev/null+++ b/desktop/electron/buildPlayRealm.ts@@ -0,0 +1,124 @@+/**+ * @file Play-realm host assembly (REARCH_EDITOR_REALM import-map phase). Stages a+ * self-contained realm under the project's `.esengine/play/` so the editor+ * can run it from `estella://project/.esengine/play/play.html` (everything+ * same-origin estella://):+ * - host.js esbuild of src/playHost.ts, esengine EXTERNAL+ * - sdk/ a copy of the SDK dist (the import-map target)+ * - wasm/ a copy of the engine runtime (glue + binary + side modules)+ * - play.html the host page: import map (esengine → ./sdk) + host.js+ * The project bundle (`.esengine/cache/scripts.mjs`, esengine external —+ * built separately by buildProjectScripts) resolves esengine through the+ * SAME import map, so its defineComponent/defineSystem register into the+ * instance the host's createWebApp uses (custom components+systems run).+ *+ * Pure Node (esbuild + fs); IPC wiring in main.ts.+ */+import { build } from 'esbuild';+import { cp, mkdir, rm, writeFile, readFile, stat } from 'node:fs/promises';+import { existsSync } from 'node:fs';+import { createHash } from 'node:crypto';+import path from 'node:path';++const PLAY_DIR = '.esengine/play';++// Subpath exports can't be a single `esengine/` → `./sdk/` mapping (import maps+// don't append /index.js for directories), so list the real files (mirrors+// sdk/package.json `exports`).+const IMPORT_MAP = {+ imports: {+ esengine: './sdk/index.js',+ 'esengine/spine': './sdk/spine/index.js',+ 'esengine/physics': './sdk/physics/index.js',+ 'esengine/wasm': './sdk/wasm.js',+ 'esengine/factory': './sdk/webAppFactory.js',+ },+};++// The inline import map is an inline <script>, so CSP must allow it — by HASH+// (not 'unsafe-inline', which would permit any inline script). 'unsafe-eval' is+// for the emscripten glue; everything else is same-origin estella://.+const IMPORT_MAP_JSON = JSON.stringify(IMPORT_MAP);+const IMPORT_MAP_HASH = `sha256-${createHash('sha256').update(IMPORT_MAP_JSON).digest('base64')}`;++const PLAY_HTML = `<!doctype html>+<html>+ <head>+ <meta charset="UTF-8" />+ <meta+ http-equiv="Content-Security-Policy"+ content="default-src 'self' estella:; script-src 'self' 'unsafe-eval' '${IMPORT_MAP_HASH}' estella:; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: estella:; font-src 'self' data: estella:; connect-src 'self' data: blob: estella:; worker-src 'self' blob:;"+ />+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />+ <title>Estella Play</title>+ <script type="importmap">${IMPORT_MAP_JSON}</script>+ <style>+ * { margin: 0; padding: 0; box-sizing: border-box; }+ html, body { width: 100%; height: 100%; overflow: hidden; background: #0e121b; }+ #canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }+ </style>+ </head>+ <body>+ <canvas id="canvas"></canvas>+ <script type="module" src="./host.js"></script>+ </body>+</html>+`;++export interface PlayRealmResult {+ ok: boolean;+ /** Project-relative path to the host page → `estella://project/<hostPath>`. */+ hostPath: string;+ errors: string[];+}++/** Copy `src`→`dst` only when `marker`'s mtime changed since the last copy. */+async function syncDir(src: string, dst: string, marker: string, stampFile: string): Promise<void> {+ if (!existsSync(src)) return;+ const sig = String((await stat(marker)).mtimeMs);+ if (existsSync(dst) && existsSync(stampFile) && (await readFile(stampFile, 'utf8')) === sig) return;+ await rm(dst, { recursive: true, force: true });+ await cp(src, dst, { recursive: true });+ await writeFile(stampFile, sig);+}++export async function buildPlayRealm(opts: {+ root: string;+ playHostEntry: string;+ sdkDistDir: string;+ wasmDir: string;+}): Promise<PlayRealmResult> {+ const out = path.join(opts.root, PLAY_DIR);+ const errors: string[] = [];+ await mkdir(out, { recursive: true });++ // 1. Host module — esengine EXTERNAL (resolved by the realm's import map).+ try {+ const res = await build({+ entryPoints: [opts.playHostEntry],+ bundle: true,+ format: 'esm',+ platform: 'browser',+ target: 'es2020',+ external: ['esengine', 'esengine/*'],+ outfile: path.join(out, 'host.js'),+ sourcemap: false,+ write: true,+ logLevel: 'silent',+ });+ errors.push(...res.errors.map((e) => e.text));+ } catch (err) {+ const e = err as { errors?: { text: string }[]; message?: string };+ errors.push(...(e.errors?.map((x) => x.text) ?? [String(e.message ?? err)]));+ return { ok: false, hostPath: '', errors };+ }++ // 2. SDK + wasm copies (hash-gated on a marker file's mtime).+ await syncDir(opts.sdkDistDir, path.join(out, 'sdk'), path.join(opts.sdkDistDir, 'index.js'), path.join(out, '.sdk-stamp'));+ await syncDir(opts.wasmDir, path.join(out, 'wasm'), path.join(opts.wasmDir, 'esengine.js'), path.join(out, '.wasm-stamp'));++ // 3. Host page.+ await writeFile(path.join(out, 'play.html'), PLAY_HTML);++ return { ok: errors.length === 0, hostPath: `${PLAY_DIR}/play.html`, errors };+}diff --git a/desktop/electron/main.ts b/desktop/electron/main.tsindex f942fd99e..1a6454bc3 100644--- a/desktop/electron/main.ts+++ b/desktop/electron/main.ts@@ -25,6 +25,7 @@ import { cookAssets } from './cookAssets';import { startProjectWatch, stopProjectWatch } from './projectWatcher';import { importAssets, IMPORT_EXTENSIONS } from './importAssets';import { exportGame } from './exportGame';+import { buildPlayRealm } from './buildPlayRealm';import { resolveScripts } from '../src/project/format';import type { WorkspaceState } from '../src/project/format';@@ -58,6 +59,13 @@ const ASSET_MIME: Record<string, string> = {json: 'application/json',esscene: 'application/json',fnt: 'text/plain',+ // The play realm is served from estella:// too (host page + SDK + bundle + wasm),+ // so estella must hand back script/document/wasm types, not just asset types.+ html: 'text/html',+ js: 'text/javascript',+ mjs: 'text/javascript',+ wasm: 'application/wasm',+ css: 'text/css',};// MIME for serving the built renderer over app:// (wasm MUST be application/wasm@@ -281,6 +289,28 @@ ipcMain.handle(},);+// Stage the isolated play realm under the project's .esengine/play/ (host + SDK ++// wasm + import map) and build the project's script bundle, so the editor can run+// it from estella://project/.esengine/play/play.html with custom components/systems.+ipcMain.handle('project:preparePlayRealm', async () => {+ const root = requireRoot();+ const manifest = await readManifest(root);+ const { main } = resolveScripts(manifest);+ // Best-effort: a project with no scripts entry just runs builtin-only.+ try {+ await buildProjectScripts(root, { entry: main });+ } catch {+ /* no bundle — builtin components/systems only */+ }+ const publicWasm = path.join(VITE_PUBLIC, 'wasm');+ return buildPlayRealm({+ root,+ playHostEntry: path.join(process.env.APP_ROOT!, 'src', 'playHost.ts'),+ sdkDistDir: path.join(process.env.APP_ROOT!, 'node_modules', 'esengine', 'dist'),+ wasmDir: existsSync(publicWasm) ? publicWasm : path.join(RENDERER_DIST, 'wasm'),+ });+});+ipcMain.handle('recents:list', () => listRecents());ipcMain.handle('recents:add', (_e, root: string, name: string) => addRecent(root, name));diff --git a/desktop/electron/preload.ts b/desktop/electron/preload.tsindex 92adbfd8e..e6236864c 100644--- a/desktop/electron/preload.ts+++ b/desktop/electron/preload.ts@@ -5,6 +5,7 @@ import type { ExtractSchemasResult } from './extractSchemas';import type { ScanAssetsResult } from './assetDb';import type { CookResult } from './cookAssets';import type { ExportGameResult } from './exportGame';+import type { PlayRealmResult } from './buildPlayRealm';// The privileged bridge the renderer is allowed to touch. Keep this surface small// and explicit — anything the editor needs from the OS or Node goes through here.@@ -40,6 +41,9 @@ const api = {/** Export a runnable web build (play==ship) → self-contained `outDir` (default dist-game/). */exportGame: (opts?: { outDir?: string; minify?: boolean; sourcemap?: boolean }): Promise<ExportGameResult> =>ipcRenderer.invoke('project:exportGame', opts),+ /** Stage the isolated play realm (host + SDK + wasm + project bundle) under+ * `.esengine/play/`; returns the project-relative host page path. */+ preparePlayRealm: (): Promise<PlayRealmResult> => ipcRenderer.invoke('project:preparePlayRealm'),/** Show a file picker and import the chosen files into `destDir` (writes .meta);* null if cancelled. */importAssets: (destDir: string): Promise<{ imported: string[]; skipped: string[] } | null> =>diff --git a/desktop/package.json b/desktop/package.jsonindex f8fc91269..c8df125ad 100644--- a/desktop/package.json+++ b/desktop/package.json@@ -14,7 +14,6 @@"test:watch": "vitest","verify:render": "vite build && electron scripts/headless-verify.mjs","verify:smoke": "vite build && electron scripts/headless-smoke.mjs",- "play:verify": "vite build && electron scripts/play-realm-verify.mjs","mcp": "electron electron/mcp/server.mjs","mcp:smoke": "vite build && node electron/mcp/smoke.mjs"},diff --git a/desktop/play.html b/desktop/play.htmldeleted file mode 100644index 93601b57d..000000000--- a/desktop/play.html+++ /dev/null@@ -1,23 +0,0 @@-<!doctype html>-<html lang="en">- <head>- <meta charset="UTF-8" />- <!-- Same CSP as the editor shell: 'unsafe-eval' for the emscripten glue, and- estella: in img/connect so the realm can fetch project assets. -->- <meta- http-equiv="Content-Security-Policy"- content="default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: estella:; font-src 'self' data:; connect-src 'self' ws: estella:; worker-src 'self' blob:;"- />- <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />- <title>Estella Play</title>- <style>- * { margin: 0; padding: 0; box-sizing: border-box; }- html, body { width: 100%; height: 100%; overflow: hidden; background: #0e121b; }- #canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }- </style>- </head>- <body>- <canvas id="canvas"></canvas>- <script type="module" src="/src/play.ts"></script>- </body>-</html>diff --git a/desktop/scripts/play-realm-verify.mjs b/desktop/scripts/play-realm-verify.mjsdeleted file mode 100644index 8dcfcdcd6..000000000--- a/desktop/scripts/play-realm-verify.mjs+++ /dev/null@@ -1,104 +0,0 @@-/**- * @file Play-realm verification runner (REARCH_EDITOR_REALM Phase R1).- *- * Proves the isolated play realm boots the SHIPPING runtime against a posted- * scene snapshot + a fetched asset manifest — the play==ship path, in isolation- * from the editor. Static-serves dist/ over loopback http, opens a show:false- * window on play.html, posts an `estella:play:init` with a real scene snapshot +- * uuid→url manifest, and waits for the realm's `estella:play:ready` handshake- * (reaching ready means createWebApp + initRuntime + asset fetch + app.run all- * succeeded). A capturePage spread check is reported as bonus evidence.- *- * Runs by Electron (real WebGL2). `pnpm --filter ./desktop play:verify`.- */-import { app, BrowserWindow } from 'electron';-import http from 'node:http';-import { readFile } from 'node:fs/promises';-import path from 'node:path';-import { fileURLToPath } from 'node:url';--const DIST = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'dist');-const SCENE = process.env.ESTELLA_VERIFY_SCENE ?? '/scenes/sprite-rendering.esscene';-const MANIFEST = process.env.ESTELLA_VERIFY_MANIFEST ?? '/scenes/sprite-rendering.textures.json';-const W = 640;-const H = 480;--app.commandLine.appendSwitch('enable-unsafe-swiftshader');-process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true';--const MIME = {- '.html': 'text/html', '.js': 'text/javascript', '.mjs': 'text/javascript',- '.css': 'text/css', '.json': 'application/json', '.esscene': 'application/json',- '.wasm': 'application/wasm', '.png': 'image/png', '.jpg': 'image/jpeg',- '.webp': 'image/webp', '.woff': 'font/woff', '.woff2': 'font/woff2', '.svg': 'image/svg+xml',-};--function serveDist() {- const server = http.createServer(async (req, res) => {- try {- const rel = decodeURIComponent(new URL(req.url, 'http://x').pathname).replace(/^\/+/, '') || 'index.html';- const abs = path.join(DIST, rel);- if (!abs.startsWith(DIST)) return void res.writeHead(403).end();- const bytes = await readFile(abs);- res.writeHead(200, { 'content-type': MIME[path.extname(abs).toLowerCase()] ?? 'application/octet-stream' });- res.end(bytes);- } catch {- res.writeHead(404).end('not found');- }- });- return new Promise((resolve) => server.listen(0, '127.0.0.1', () => resolve(server)));-}--function finish(result, server) {- const ok = result.ok && result.handshake === 'estella:play:ready';- console.log(`\n[play:verify] ${ok ? 'PASS' : 'FAIL'} — ${SCENE}`);- console.log('DRIVE_RESULT ' + JSON.stringify(result));- process.exitCode = ok ? 0 : 1;- try { server?.close(); } catch { /* ignore */ }- app.quit();-}--app.whenReady().then(async () => {- let server;- try {- server = await serveDist();- const base = `http://127.0.0.1:${server.address().port}`;- const sceneData = JSON.parse(await readFile(path.join(DIST, SCENE.replace(/^\//, '')), 'utf8'));- const assetManifest = JSON.parse(await readFile(path.join(DIST, MANIFEST.replace(/^\//, '')), 'utf8'));-- const win = new BrowserWindow({ show: false, width: W, height: H, webPreferences: { offscreen: false } });- win.webContents.on('console-message', (...a) => {- const m = a.map((x) => (x && typeof x === 'object' ? x.message ?? '' : String(x))).join(' ');- if (/error|fail|exception|webgl/i.test(m) && !/unwind/i.test(m)) console.log('[realm]', m.slice(0, 240));- });- await win.loadURL(`${base}/play.html`);- const exec = (code) => win.webContents.executeJavaScript(code, true);-- // Record the realm's outbound handshake, then post the scene snapshot in.- await exec(`window.__msgs=[];addEventListener('message',e=>{if(e.data&&String(e.data.type||'').startsWith('estella:play:'))window.__msgs.push(e.data)});true`);- await exec(`window.postMessage(${JSON.stringify({ type: 'estella:play:init', sceneData, assetManifest })},'*');true`);-- const msg = await exec(`(async()=>{for(let i=0;i<400;i++){const m=(window.__msgs||[]).find(x=>x.type==='estella:play:ready'||x.type==='estella:play:error');if(m)return m;await new Promise(r=>setTimeout(r,50));}return{type:'timeout'};})()`);-- let capture = null;- try {- const img = await win.capturePage();- const b = img.toBitmap(); // BGRA- const min = [255, 255, 255], max = [0, 0, 0];- let nonZero = 0;- for (let i = 0; i < b.length; i += 4) {- for (let k = 0; k < 3; k++) { const v = b[i + k]; if (v < min[k]) min[k] = v; if (v > max[k]) max[k] = v; }- if (b[i] | b[i + 1] | b[i + 2]) nonZero++;- }- capture = { spread: (max[0] - min[0]) + (max[1] - min[1]) + (max[2] - min[2]), nonZeroPixels: nonZero };- } catch (e) {- capture = { error: String(e) };- }-- finish({ ok: true, handshake: msg.type, detail: msg, capture }, server);- } catch (e) {- finish({ ok: false, error: String((e && e.stack) || e) }, server);- }-});--setTimeout(() => finish({ ok: false, error: 'timeout' }), 45000);diff --git a/desktop/src/App.tsx b/desktop/src/App.tsxindex 8df9a7977..4dfba7e45 100644--- a/desktop/src/App.tsx+++ b/desktop/src/App.tsx@@ -60,7 +60,7 @@ export function App() {return;}dockApi.openGame();- PlayRealm.start(payload);+ void PlayRealm.start(payload);} else {PlayRealm.stop();dockApi.closeGame();diff --git a/desktop/src/engine/PlayRealm.ts b/desktop/src/engine/PlayRealm.tsindex d238004b5..2a8acc6fd 100644--- a/desktop/src/engine/PlayRealm.ts+++ b/desktop/src/engine/PlayRealm.ts@@ -54,11 +54,27 @@ class PlayRealmImpl {this.iframe?.parentElement?.removeChild(this.iframe);}- /** Boot a fresh realm and play `payload` (init is posted on the realm's hello). */- start(payload: PlayPayload): void {+ /**+ * Boot a fresh realm and play `payload`. Stages the realm under the project's+ * `.esengine/play/` (host + SDK + wasm + project bundle) and loads it from the+ * project's `estella://` origin, so the host + the project bundle share one+ * esengine instance (custom components/systems run) and all assets are+ * same-origin. Init is posted on the realm's `hello`.+ */+ async start(payload: PlayPayload): Promise<void> {this.payload = payload;this.set({ playing: true, ready: false, error: null });- this.ensureIframe().src = `/play.html?n=${++this.epoch}`;+ const frame = this.ensureIframe();+ try {+ const realm = await window.estella.project.preparePlayRealm();+ if (!realm.ok) {+ this.set({ error: realm.errors[0] ?? 'failed to prepare play realm' });+ return;+ }+ frame.src = `estella://project/${realm.hostPath}?n=${++this.epoch}`;+ } catch (err) {+ this.set({ error: err instanceof Error ? err.message : String(err) });+ }}/** Tear the realm down (releases its wasm + GL by navigating to a blank page). */diff --git a/desktop/src/play.ts b/desktop/src/playHost.tssimilarity index 54%rename from desktop/src/play.tsrename to desktop/src/playHost.tsindex e062bd522..b83b12f52 100644--- a/desktop/src/play.ts+++ b/desktop/src/playHost.ts@@ -1,13 +1,16 @@/**- * @file play.ts — the isolated play-realm host page (REARCH_EDITOR_REALM Phase R).+ * @file playHost.ts — the isolated play realm's host module (REARCH_EDITOR_REALM+ * import-map phase). Unlike the R1 Vite `play.ts` (which bundles its own+ * esengine), this is esbuilt with **esengine EXTERNAL** and runs from the+ * project's `estella://` origin under `.esengine/play/host.js`. A+ * `<script type=importmap>` in play.html maps `esengine` → `./sdk/index.js`,+ * so THIS host AND the project bundle (`../cache/scripts.mjs`, also external+ * esengine) resolve to the SAME esengine instance — the bundle's+ * defineComponent/defineSystem register into the registry createWebApp uses,+ * so custom components + systems actually run (play == ship).*- * Runs inside the editor's "Game" iframe as a SEPARATE realm (its own wasm + GL +- * World). It boots the SHIPPING runtime (createWebApp → initPlayRealmRuntime) and- * runs the scene SNAPSHOT the editor posts in — so what you play is what you ship.- * Control + handshake go over postMessage; the realm never touches `window.estella`.- *- * Builtin components/systems run as-is. Project-defined components/systems (a- * bundle with esengine external + an import map) are a layered follow-up.+ * Everything is same-origin estella:// (host, sdk, bundle, wasm, assets),+ * sidestepping the custom-scheme cross-fetch ban.*/import { createWebApp, setEditorMode, setPlayMode, initPlayRealmRuntime } from 'esengine';import type { App, ESEngineModule, SceneData } from 'esengine';@@ -19,6 +22,8 @@ interface InitMessage {}const canvas = document.getElementById('canvas') as HTMLCanvasElement;+const wasmBase = new URL('./wasm/', import.meta.url).href; // sibling of host.js+const bundleUrl = new URL('../cache/scripts.mjs', import.meta.url).href; // project bundlefunction resize(): void {const dpr = window.devicePixelRatio || 1;@@ -30,23 +35,27 @@ resize();let app: App | null = null;let booted = false;--function post(message: Record<string, unknown>): void {- parent.postMessage(message, '*');-}+const post = (m: Record<string, unknown>) => parent.postMessage(m, '*');async function boot(msg: InitMessage): Promise<void> {if (booted) return;booted = true;try {- // Glue + binary load from this realm's origin (dev http / packaged app://).- const glueUrl = `${location.origin}/wasm/esengine.js`;- const { default: createModule } = (await import(/* @vite-ignore */ glueUrl)) as {+ // Register the project's own components/systems FIRST (side-effect import; its+ // `import 'esengine'` resolves through the import map to the shared instance).+ // Absent (a project with no scripts) → builtin-only, which is fine.+ try {+ await import(/* @vite-ignore */ bundleUrl);+ } catch {+ /* no project bundle — builtin components/systems only */+ }++ const { default: createModule } = (await import(/* @vite-ignore */ `${wasmBase}esengine.js`)) as {default: (options?: Record<string, unknown>) => Promise<ESEngineModule>;};const module = await createModule({canvas,- locateFile: (p: string) => `/wasm/${p}`,+ locateFile: (p: string) => `${wasmBase}${p}`,print: (t: string) => console.log('[wasm]', t),printErr: (t: string) => console.warn('[wasm]', t),});@@ -59,19 +68,13 @@ async function boot(msg: InitMessage): Promise<void> {premultipliedAlpha: false,}) as WebGL2RenderingContext | null;if (!gl) throw new Error('WebGL2 is not available in this realm.');- const glHandle = module.GL.registerContext(gl, {- majorVersion: 2,- minorVersion: 0,- enableExtensionsByDefault: true,- });+ const glHandle = module.GL.registerContext(gl, { majorVersion: 2, minorVersion: 0, enableExtensionsByDefault: true });app = createWebApp(module, {glContextHandle: glHandle,getViewportSize: () => ({ width: canvas.width, height: canvas.height }),- wasmBaseUrl: '/wasm',+ wasmBaseUrl: wasmBase,});-- // Real shipping mode — NOT editor mode. Gameplay systems run.setEditorMode(false);setPlayMode(true);@@ -84,7 +87,6 @@ async function boot(msg: InitMessage): Promise<void> {});post({ type: 'estella:play:ready' });} catch (err) {- // Emscripten throws 'unwind' when its main loop takes over — that's success.const message = err instanceof Error ? err.message : String(err);if (err === 'unwind' || message.includes('unwind')) {post({ type: 'estella:play:ready' });@@ -98,16 +100,8 @@ async function boot(msg: InitMessage): Promise<void> {window.addEventListener('message', (e: MessageEvent) => {const data = e.data as { type?: string; paused?: boolean } | null;if (!data || typeof data !== 'object') return;- switch (data.type) {- case 'estella:play:init':- void boot(e.data as InitMessage);- break;- case 'estella:play:setPaused':- app?.setPaused(!!data.paused);- break;- // 'dispose' = the editor removes the iframe; the whole realm is torn down.- }+ if (data.type === 'estella:play:init') void boot(e.data as InitMessage);+ else if (data.type === 'estella:play:setPaused') app?.setPaused(!!data.paused);});-// Tell the editor the realm is mounted and ready to receive the scene snapshot.post({ type: 'estella:play:hello' });diff --git a/desktop/src/project/ProjectStore.ts b/desktop/src/project/ProjectStore.tsindex 93f70ce21..e62ecb475 100644--- a/desktop/src/project/ProjectStore.ts+++ b/desktop/src/project/ProjectStore.ts@@ -394,15 +394,10 @@ class ProjectStoreImpl {playPayload(): { sceneData: SceneData; assetManifest: Record<string, string> } | null {const sceneData = SceneModel.serialize();if (!sceneData) return null;- // The realm is same-origin with the editor (relative iframe src). A custom- // scheme (app://) can't cross-fetch another (estella://), so under app://- // (packaged) serve assets through the app:// project route; in dev (http- // origin) estella:// is reachable (http may make CORS requests).- const base = location.origin.startsWith('app:')- ? `${location.origin}/__project__/`- : 'estella://project/';+ // The realm runs from the project's estella:// origin, so assets are+ // same-origin estella:// — no cross-scheme dance needed.const assetManifest: Record<string, string> = {};- for (const [uuid, path] of this.uuidToPath) assetManifest[uuid] = base + path;+ for (const [uuid, path] of this.uuidToPath) assetManifest[uuid] = `estella://project/${path}`;return { sceneData, assetManifest };}diff --git a/desktop/vite.config.ts b/desktop/vite.config.tsindex 033316b5c..f34fe2da0 100644--- a/desktop/vite.config.ts+++ b/desktop/vite.config.ts@@ -14,13 +14,13 @@ export default defineConfig({},build: {rollupOptions: {- // Renderer entries: the editor shell (index), the headless render host- // (headless, for automation/verification), and the isolated play realm- // host (play, REARCH_EDITOR_REALM Phase R).+ // Renderer entries: the editor shell (index) + the headless render host+ // (headless, for automation/verification). The play realm is NOT a Vite+ // entry — it's esbuilt (esengine external) into the project's .esengine/play/+ // and served from estella:// (see electron/buildPlayRealm.ts).input: {index: fileURLToPath(new URL('./index.html', import.meta.url)),headless: fileURLToPath(new URL('./headless.html', import.meta.url)),- play: fileURLToPath(new URL('./play.html', import.meta.url)),},},},