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): toast notifications + real Content Browser (UE5 alignment B5)
esenginef4e5cb5f7088
diff --git a/desktop/src/App.tsx b/desktop/src/App.tsxindex a204228f8..84c2c1f83 100644--- a/desktop/src/App.tsx+++ b/desktop/src/App.tsx@@ -8,6 +8,7 @@ import { SceneCommands } from '@/engine/SceneCommands';import { EngineHost } from '@/engine/EngineHost';import { ProjectStore } from '@/project/ProjectStore';import { Launcher } from '@/launcher/Launcher';+import { Toaster } from '@/components/Toaster';import { useEditorStore } from '@/store/editorStore';// The editor shell: fixed menu + toolbar on top, dockable workspace in the@@ -86,6 +87,7 @@ export function App() {<DockLayout /></main><StatusBar />+ <Toaster /></div>);}diff --git a/desktop/src/components/Toaster.tsx b/desktop/src/components/Toaster.tsxnew file mode 100644index 000000000..6afc1c97a--- /dev/null+++ b/desktop/src/components/Toaster.tsx@@ -0,0 +1,26 @@+import { useSyncExternalStore } from 'react';+import { X } from 'lucide-react';+import { Toasts } from '@/store/Toasts';++// Transient action feedback, stacked bottom-right over the editor shell.+export function Toaster() {+ const toasts = useSyncExternalStore(Toasts.subscribe, Toasts.getSnapshot);+ if (toasts.length === 0) return null;+ return (+ <div className="toaster">+ {toasts.map((t) => (+ <div key={t.id} className={`toast toast--${t.kind}`} role="status">+ <span className="toast__msg">{t.message}</span>+ <button+ type="button"+ className="toast__close"+ aria-label="Dismiss"+ onClick={() => Toasts.dismiss(t.id)}+ >+ <X size={12} strokeWidth={2.2} />+ </button>+ </div>+ ))}+ </div>+ );+}diff --git a/desktop/src/components/icons.tsx b/desktop/src/components/icons.tsxindex af526216a..89eb631e2 100644--- a/desktop/src/components/icons.tsx+++ b/desktop/src/components/icons.tsx@@ -15,6 +15,7 @@ import {Component,Blend,FileCode2,+ File,type LucideIcon,} from 'lucide-react';import type { NodeKind, AssetType } from '@/types';@@ -48,6 +49,7 @@ const ASSET_ICON: Record<AssetType, { icon: LucideIcon; tint: string }> = {prefab: { icon: Component, tint: '#ffb454' },material: { icon: Blend, tint: '#ff9d6f' },script: { icon: FileCode2, tint: '#9fb2d6' },+ file: { icon: File, tint: 'var(--text-dim)' },};export function AssetIcon({ type, size = 22 }: { type: AssetType; size?: number }) {diff --git a/desktop/src/layout/MenuBar.tsx b/desktop/src/layout/MenuBar.tsxindex 221dfe3d2..7a349193b 100644--- a/desktop/src/layout/MenuBar.tsx+++ b/desktop/src/layout/MenuBar.tsx@@ -7,6 +7,7 @@ import { useEditorStore } from '@/store/editorStore';import { EditorHistory } from '@/engine/EditorHistory';import { SceneCommands } from '@/engine/SceneCommands';import { ProjectStore } from '@/project/ProjectStore';+import { Toasts } from '@/store/Toasts';import { MenuItems, type MenuItem } from '@/components/Menu';const LAYOUT_KEY = 'estella.editor.layout.v1';@@ -116,8 +117,20 @@ export function MenuBar() {{title: 'Build',items: [- { label: 'Build Project Scripts', onClick: () => void window.estella?.project?.buildScripts?.().catch(() => {}), disabled: !project },- { label: 'Extract Component Schemas', onClick: () => void window.estella?.project?.extractSchemas?.().catch(() => {}), disabled: !project },+ {+ label: 'Build Project Scripts',+ onClick: () => void window.estella?.project?.buildScripts?.()+ .then(() => Toasts.push('Built project scripts', 'success'))+ .catch(() => Toasts.push('Build failed', 'error')),+ disabled: !project,+ },+ {+ label: 'Extract Component Schemas',+ onClick: () => void window.estella?.project?.extractSchemas?.()+ .then(() => Toasts.push('Extracted component schemas', 'success'))+ .catch(() => Toasts.push('Extract failed', 'error')),+ disabled: !project,+ },],},{diff --git a/desktop/src/layout/Toolbar.tsx b/desktop/src/layout/Toolbar.tsxindex 55af50c1c..dc3affd2a 100644--- a/desktop/src/layout/Toolbar.tsx+++ b/desktop/src/layout/Toolbar.tsx@@ -20,6 +20,7 @@ import {import { useEditorStore } from '@/store/editorStore';import { EditorHistory } from '@/engine/EditorHistory';import { ProjectStore } from '@/project/ProjectStore';+import { Toasts } from '@/store/Toasts';import type { ToolMode } from '@/types';interface ToolDef {@@ -161,7 +162,11 @@ export function Toolbar() {type="button"className="chip chip--accent"title="Build project scripts"- onClick={() => void window.estella?.project?.buildScripts?.().catch(() => {})}+ onClick={() =>+ void window.estella?.project?.buildScripts?.()+ .then(() => Toasts.push('Built project scripts', 'success'))+ .catch(() => Toasts.push('Build failed', 'error'))+ }><Hammer size={13} strokeWidth={1.85} /><span>Build</span>diff --git a/desktop/src/panels/ContentBrowser.tsx b/desktop/src/panels/ContentBrowser.tsxindex 31c76c79c..5a22ff51f 100644--- a/desktop/src/panels/ContentBrowser.tsx+++ b/desktop/src/panels/ContentBrowser.tsx@@ -1,25 +1,148 @@-import { useState } from 'react';-import { ChevronRight, Search, Plus, LayoutGrid, Import } from 'lucide-react';-import { MOCK_ASSETS } from '@/mock/sceneData';+import { useEffect, useMemo, useState, useSyncExternalStore } from 'react';+import { ChevronRight, Search, Plus, LayoutGrid, Import, FolderOpen } from 'lucide-react';import { AssetIcon } from '@/components/icons';+import { ContextMenu, type MenuItem } from '@/components/Menu';+import { ProjectStore } from '@/project/ProjectStore';+import { Toasts } from '@/store/Toasts';+import type { DirEntry } from '@/project/format';+import type { AssetType } from '@/types';-const FOLDERS = ['Content', 'scenes', 'sprites', 'audio', 'scripts', 'prefabs'];+const IMAGE_RE = /\.(png|jpe?g|webp|gif)$/i;++// Lazily read a project-relative directory (or [] when null / no project / error).+function useDir(relPath: string | null): DirEntry[] {+ const [entries, setEntries] = useState<DirEntry[]>([]);+ useEffect(() => {+ if (relPath == null || !window.estella?.fs) {+ setEntries([]);+ return;+ }+ let alive = true;+ window.estella.fs+ .readDir(relPath)+ .then((e) => alive && setEntries(e))+ .catch(() => alive && setEntries([]));+ return () => {+ alive = false;+ };+ }, [relPath]);+ return entries;+}++const join = (dir: string, name: string) => (dir ? `${dir}/${name}` : name);++// Asset type label from the file extension (drives the icon + tile caption).+function assetType(name: string): AssetType {+ const ext = name.split('.').pop()?.toLowerCase() ?? '';+ if (IMAGE_RE.test(name)) return ext === 'png' || ext === 'webp' ? 'texture' : 'sprite';+ if (ext === 'esscene') return 'scene';+ if (ext === 'ogg' || ext === 'mp3' || ext === 'wav') return 'audio';+ if (ext === 'ts' || ext === 'js') return 'script';+ if (ext === 'atlas' || ext === 'skel') return 'spine';+ if (ext === 'esprefab') return 'prefab';+ if (ext === 'esmat') return 'material';+ return 'file';+}++function FolderNode({+ path,+ name,+ depth,+ cwd,+ onSelect,+}: {+ path: string;+ name: string;+ depth: number;+ cwd: string;+ onSelect: (p: string) => void;+}) {+ const [open, setOpen] = useState(depth === 0);+ const children = useDir(open ? path : null);+ const subdirs = children.filter((e) => e.isDir);++ return (+ <>+ <div+ className={`content__folder${cwd === path ? ' is-active' : ''}`}+ style={{ paddingLeft: depth * 14 + 6 }}+ onClick={() => onSelect(path)}+ >+ <button+ type="button"+ className={`content__folder-twist${open ? ' is-open' : ''}`}+ onClick={(e) => {+ e.stopPropagation();+ setOpen((o) => !o);+ }}+ >+ <ChevronRight size={12} strokeWidth={2} />+ </button>+ <AssetIcon type="folder" size={14} />+ <span>{name}</span>+ </div>+ {open && subdirs.map((d) => (+ <FolderNode key={d.name} path={join(path, d.name)} name={d.name} depth={depth + 1} cwd={cwd} onSelect={onSelect} />+ ))}+ </>+ );+}export function ContentBrowser() {- const [active, setActive] = useState('Content');+ const project = useSyncExternalStore(ProjectStore.subscribe, ProjectStore.getSnapshot);+ const [cwd, setCwd] = useState('');+ const [query, setQuery] = useState('');+ const [ctx, setCtx] = useState<{ x: number; y: number; path: string } | null>(null);++ const entries = useDir(project ? cwd : null);+ const q = query.trim().toLowerCase();+ const items = useMemo(() => {+ const list = q ? entries.filter((e) => e.name.toLowerCase().includes(q)) : entries;+ // Folders first, then files; both alphabetical.+ return [...list].sort((a, b) => (a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1));+ }, [entries, q]);++ const ctxItems: MenuItem[] = ctx+ ? [+ {+ label: 'Copy Path',+ onClick: () => {+ void navigator.clipboard?.writeText(ctx.path);+ Toasts.push('Copied path', 'info', 1600);+ },+ },+ ]+ : [];++ if (!project) {+ return (+ <div className="panel content">+ <div className="empty">+ <FolderOpen size={24} strokeWidth={1.4} />+ <p>Open a project to browse its assets.</p>+ </div>+ </div>+ );+ }return (<div className="panel content"><div className="panel__toolbar">- <button type="button" className="btn-soft">+ <button type="button" className="btn-soft" disabled title="Import (coming soon)"><Import size={13} strokeWidth={1.85} /> Import</button>- <button type="button" className="btn-soft">+ <button type="button" className="btn-soft" disabled title="Add (coming soon)"><Plus size={13} strokeWidth={1.85} /> Add</button><div className="searchbox searchbox--grow"><Search size={13} strokeWidth={1.85} />- <input className="searchbox__input" placeholder="Search assets" spellCheck={false} />+ <input+ className="searchbox__input"+ placeholder="Search assets"+ spellCheck={false}+ value={query}+ onChange={(e) => setQuery(e.target.value)}+ /></div><button type="button" className="iconbtn" title="View options"><LayoutGrid size={15} strokeWidth={1.85} />@@ -27,42 +150,44 @@ export function ContentBrowser() {</div><div className="content__split">- {/* Source tree */}<div className="content__tree">- {FOLDERS.map((f, i) => (- <div- key={f}- className={`content__folder${active === f ? ' is-active' : ''}`}- style={{ paddingLeft: (i === 0 ? 0 : 14) + 8 }}- onClick={() => setActive(f)}- >- <ChevronRight- size={12}- strokeWidth={2}- className={`content__folder-twist${i === 0 ? ' is-open' : ''}`}- style={{ opacity: i === 0 ? 1 : 0 }}- />- <AssetIcon type="folder" size={14} />- <span>{f}</span>- </div>- ))}+ <FolderNode path="" name={project.name} depth={0} cwd={cwd} onSelect={setCwd} /></div>- {/* Asset grid */}<div className="content__grid">- {MOCK_ASSETS.map((a) => (- <button key={a.id} type="button" className="tile">- <span className="tile__thumb">- <AssetIcon type={a.type} />- </span>- <span className="tile__name">{a.name}</span>- <span className="tile__type">{a.type}</span>- </button>- ))}+ {items.map((e) => {+ const path = join(cwd, e.name);+ const type = e.isDir ? 'folder' : assetType(e.name);+ return (+ <button+ key={e.name}+ type="button"+ className="tile"+ onDoubleClick={() => e.isDir && setCwd(path)}+ onContextMenu={(ev) => {+ ev.preventDefault();+ setCtx({ x: ev.clientX, y: ev.clientY, path });+ }}+ >+ <span className="tile__thumb">+ {!e.isDir && IMAGE_RE.test(e.name) ? (+ <img className="tile__img" src={`estella://project/${path}`} alt="" draggable={false} />+ ) : (+ <AssetIcon type={type} />+ )}+ </span>+ <span className="tile__name">{e.name}</span>+ <span className="tile__type">{type}</span>+ </button>+ );+ })}+ {items.length === 0 && <p className="inspector-note">{q ? 'No assets match.' : 'Empty folder.'}</p>}</div></div>- <div className="content__path mono">/Content · 14 items</div>+ <div className="content__path mono">/{cwd} · {items.length} items</div>++ {ctx && <ContextMenu x={ctx.x} y={ctx.y} items={ctxItems} onClose={() => setCtx(null)} />}</div>);}diff --git a/desktop/src/project/ProjectStore.ts b/desktop/src/project/ProjectStore.tsindex 5b5282223..f029fbda6 100644--- a/desktop/src/project/ProjectStore.ts+++ b/desktop/src/project/ProjectStore.ts@@ -2,6 +2,7 @@ import { resetWorldTo, getComponent, Assets } from 'esengine';import type { SceneData } from 'esengine';import { EngineHost } from '@/engine/EngineHost';import { SceneModel } from '@/engine/SceneModel';+import { Toasts } from '@/store/Toasts';import { resolveLayout, type OpenedProject, type ProjectLayout, type WorkspaceState } from './format';/**@@ -261,6 +262,7 @@ class ProjectStoreImpl {if (!st || !st.currentScene) throw new Error('no scene to save');await this.writeScene(st.currentScene, this.serializeCurrent());await this.persistLastScene(st.currentScene);+ Toasts.push(`Saved ${st.currentScene.split('/').pop()}`, 'success');}/** Write the current world to a project-relative path (explicit, no lossy guard). */@@ -268,6 +270,7 @@ class ProjectStoreImpl {if (!this.state) throw new Error('no project open');await this.writeScene(relPath, this.serializeCurrent());await this.persistLastScene(relPath);+ Toasts.push(`Saved ${relPath.split('/').pop()}`, 'success');}/** Prompt for a destination (Save-As) and write there. Returns the path or null. */diff --git a/desktop/src/store/Toasts.ts b/desktop/src/store/Toasts.tsnew file mode 100644index 000000000..116f0b2a7--- /dev/null+++ b/desktop/src/store/Toasts.ts@@ -0,0 +1,47 @@+/**+ * @file Toasts.ts+ * @brief Transient action feedback (save / build / errors). A tiny external+ * store (same subscribe/getSnapshot shape as EngineHost / ProjectStore)+ * so any module — React component or plain class — can post a toast.+ */+export type ToastKind = 'info' | 'success' | 'warn' | 'error';++export interface Toast {+ id: number;+ kind: ToastKind;+ message: string;+}++class ToastsImpl {+ private list: Toast[] = [];+ private readonly listeners = new Set<() => void>();+ private seq = 0;++ subscribe = (fn: () => void): (() => void) => {+ this.listeners.add(fn);+ return () => this.listeners.delete(fn);+ };+ getSnapshot = (): Toast[] => this.list;++ /** Post a toast; it auto-dismisses after `ttl` ms (0 = sticky until clicked). */+ push(message: string, kind: ToastKind = 'info', ttl = 3200): number {+ const id = ++this.seq;+ this.list = [...this.list, { id, kind, message }];+ this.emit();+ if (ttl > 0) setTimeout(() => this.dismiss(id), ttl);+ return id;+ }+ dismiss(id: number): void {+ const next = this.list.filter((t) => t.id !== id);+ if (next.length !== this.list.length) {+ this.list = next;+ this.emit();+ }+ }++ private emit() {+ for (const l of this.listeners) l();+ }+}++export const Toasts = new ToastsImpl();diff --git a/desktop/src/theme/app.css b/desktop/src/theme/app.cssindex 59515c260..94aedfaef 100644--- a/desktop/src/theme/app.css+++ b/desktop/src/theme/app.css@@ -359,10 +359,14 @@border: 1px solid var(--line);border-radius: var(--r-sm);}-.btn-soft:hover {+.btn-soft:hover:not(:disabled) {border-color: var(--line-strong);color: var(--text-hi);}+.btn-soft:disabled {+ opacity: 0.4;+ cursor: default;+}.empty {flex: 1;@@ -1195,6 +1199,12 @@background: var(--void);border: 1px solid var(--line);border-radius: var(--r-sm);+ overflow: hidden;+}+.tile__img {+ width: 100%;+ height: 100%;+ object-fit: contain;}.tile__name {font-size: var(--fs-xs);@@ -1293,3 +1303,68 @@.logline--success .logline__msg {color: var(--run);}++/* ----------------------------------------------------------------- toasts --- */+.toaster {+ position: fixed;+ right: 14px;+ bottom: 32px;+ z-index: 2000;+ display: flex;+ flex-direction: column;+ gap: 8px;+ align-items: flex-end;+ pointer-events: none;+}+.toast {+ display: flex;+ align-items: center;+ gap: 10px;+ min-width: 200px;+ max-width: 360px;+ padding: 8px 10px 8px 12px;+ background: var(--raised);+ border: 1px solid var(--line-strong);+ border-left: 2px solid var(--star);+ border-radius: var(--r-sm);+ box-shadow: var(--shadow-pop);+ color: var(--text-hi);+ font-size: var(--fs-sm);+ pointer-events: auto;+ animation: toast-in 0.16s ease-out;+}+.toast--success {+ border-left-color: var(--run);+}+.toast--warn {+ border-left-color: var(--warn);+}+.toast--error {+ border-left-color: var(--error);+}+.toast__msg {+ flex: 1;+}+.toast__close {+ flex-shrink: 0;+ display: grid;+ place-items: center;+ width: 18px;+ height: 18px;+ border-radius: var(--r-xs);+ color: var(--text-faint);+}+.toast__close:hover {+ color: var(--text-hi);+ background: var(--hover);+}+@keyframes toast-in {+ from {+ opacity: 0;+ transform: translateY(6px);+ }+ to {+ opacity: 1;+ transform: translateY(0);+ }+}diff --git a/desktop/src/types.ts b/desktop/src/types.tsindex 049e437d9..d5c734b08 100644--- a/desktop/src/types.ts+++ b/desktop/src/types.ts@@ -65,7 +65,8 @@ export type AssetType =| 'audio'| 'prefab'| 'material'- | 'script';+ | 'script'+ | 'file';export interface AssetItem {id: string;