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): drop-target affordances, loading skeletons, accent demotion
yhh000487afc21f
diff --git a/desktop/src/launcher/Launcher.tsx b/desktop/src/launcher/Launcher.tsxindex da6f804ea..ad5544fb1 100644--- a/desktop/src/launcher/Launcher.tsx+++ b/desktop/src/launcher/Launcher.tsx@@ -65,15 +65,21 @@ function RecentView({onOpenFolder: () => void;}) {const [recents, setRecents] = useState<RecentEntry[]>([]);+ const [loading, setLoading] = useState(true);const [layout, setLayout] = useState<Layout>('grid');const [query, setQuery] = useState('');useEffect(() => {let live = true;- void window.estella?.recents- ?.list()+ const req = window.estella?.recents?.list();+ if (!req) {+ setLoading(false);+ return;+ }+ req.then((r) => { if (live) setRecents(r); })- .catch(() => {});+ .catch(() => {})+ .finally(() => { if (live) setLoading(false); });return () => {live = false;};@@ -116,7 +122,20 @@ function RecentView({</div></header>- {recents.length === 0 ? (+ {loading ? (+ // Recents arrive async — skeleton cards instead of flashing the empty state.+ <div className="proj-grid" aria-hidden="true">+ {Array.from({ length: 4 }, (_, i) => (+ <div key={i} className="proj-card is-skel">+ <div className="proj-card__thumb skel" />+ <div className="proj-card__body">+ <span className="skel" />+ <span className="skel" />+ </div>+ </div>+ ))}+ </div>+ ) : recents.length === 0 ? (<div className="lc-empty"><p>No recent projects yet.</p><button type="button" className="lc-btn lc-btn--primary" onClick={onOpenFolder}>diff --git a/desktop/src/panels/ContentBrowser.tsx b/desktop/src/panels/ContentBrowser.tsxindex cad8f79b5..3f3ef1f0a 100644--- a/desktop/src/panels/ContentBrowser.tsx+++ b/desktop/src/panels/ContentBrowser.tsx@@ -34,24 +34,31 @@ const errMsg = (e: unknown) => (e instanceof Error ? e.message : String(e));// Lazily read a project-relative directory (or [] when null / no project / error),// re-reading whenever the path changes or an fs mutation bumps fsRefresh.-function useDir(relPath: string | null): DirEntry[] {- const [entries, setEntries] = useState<DirEntry[]>([]);+// `loading` flips in-render on a path change (so the empty state never paints+// before the read lands); fs-version bumps refresh silently over stale rows.+function useDir(relPath: string | null): { entries: DirEntry[]; loading: boolean } {+ const [state, setState] = useState<{ path: string | null; entries: DirEntry[]; loading: boolean }>({+ path: relPath,+ entries: [],+ loading: relPath != null,+ });const version = useSyncExternalStore(fsRefresh.subscribe, fsRefresh.get);+ if (state.path !== relPath) setState({ path: relPath, entries: [], loading: relPath != null });useEffect(() => {if (relPath == null || !window.estella?.fs) {- setEntries([]);+ setState((s) => (s.entries.length || s.loading ? { path: relPath, entries: [], loading: false } : s));return;}let alive = true;window.estella.fs.readDir(relPath)- .then((e) => alive && setEntries(e))- .catch(() => alive && setEntries([]));+ .then((e) => alive && setState({ path: relPath, entries: e, loading: false }))+ .catch(() => alive && setState({ path: relPath, entries: [], loading: false }));return () => {alive = false;};}, [relPath, version]);- return entries;+ return state;}// Inline name editor for a tile / list row (UE5 rename + new-folder flow): commits@@ -206,22 +213,26 @@ function FolderNode({cwd,onSelect,folderDrop,+ dropPath,}: {path: string;name: string;depth: number;cwd: string;onSelect: (p: string) => void;- folderDrop?: (folderPath: string) => Pick<React.HTMLAttributes<HTMLDivElement>, 'onDragOver' | 'onDrop'>;+ folderDrop?: (+ folderPath: string,+ ) => Pick<React.HTMLAttributes<HTMLDivElement>, 'onDragEnter' | 'onDragOver' | 'onDragLeave' | 'onDrop'>;+ dropPath?: string | null;}) {const [open, setOpen] = useState(depth === 0);- const children = useDir(open ? path : null);+ const children = useDir(open ? path : null).entries;const subdirs = children.filter((e) => e.isDir);return (<><div- className={`tr${cwd === path ? ' sel' : ''}${open ? ' open' : ''}`}+ className={`tr${cwd === path ? ' sel' : ''}${open ? ' open' : ''}${dropPath === path ? ' is-drop' : ''}`}style={{ paddingLeft: depth * 12 + 6 }}title={name}onClick={() => onSelect(path)}@@ -242,7 +253,7 @@ function FolderNode({<span className="tn">{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} folderDrop={folderDrop} />+ <FolderNode key={d.name} path={join(path, d.name)} name={d.name} depth={depth + 1} cwd={cwd} onSelect={onSelect} folderDrop={folderDrop} dropPath={dropPath} />))}</>);@@ -293,7 +304,7 @@ export function ContentBrowser() {[go],);- const entries = useDir(project ? cwd : null);+ const { entries, loading: dirLoading } = useDir(project ? cwd : null);const q = query.trim();// Search supports `type:`/`t:` tokens + free text; the type chips add to the// token constraint; sort is folders-first, then by name or type.@@ -303,33 +314,40 @@ export function ContentBrowser() {// main-side and refreshed on fs mutations (same signal useDir rides).const searching = q.length > 0;const fsVersion = useSyncExternalStore(fsRefresh.subscribe, fsRefresh.get);- const [allFiles, setAllFiles] = useState<string[]>([]);+ // Keyed like useDir: entering search / changing folders flips `loading`+ // in-render (skeletons, not a false "No assets match."); version bumps+ // re-scan silently over the stale list.+ const scanKey = project && searching ? cwd : null;+ const [scan, setScan] = useState<{ key: string | null; files: string[]; loading: boolean }>({+ key: scanKey,+ files: [],+ loading: scanKey != null,+ });+ if (scan.key !== scanKey) setScan({ key: scanKey, files: [], loading: scanKey != null });useEffect(() => {- if (!project || !searching) {- setAllFiles([]);- return;- }+ if (scanKey == null) return;let alive = true;window.estella.fs- .listFiles(cwd)- .then((f) => alive && setAllFiles(f))- .catch(() => alive && setAllFiles([]));+ .listFiles(scanKey)+ .then((f) => alive && setScan({ key: scanKey, files: f, loading: false }))+ .catch(() => alive && setScan({ key: scanKey, files: [], loading: false }));return () => {alive = false;};- }, [project, cwd, searching, fsVersion]);+ }, [scanKey, fsVersion]);const rows = useMemo<Row[]>(() =>searching- ? allFiles.map((p) => ({ path: p, name: p.split('/').pop() ?? p, isDir: false }))+ ? scan.files.map((p) => ({ path: p, name: p.split('/').pop() ?? p, isDir: false })): entries.map((e) => ({ path: join(cwd, e.name), name: e.name, isDir: e.isDir })),- [searching, allFiles, entries, cwd],+ [searching, scan.files, entries, cwd],);const items = useMemo(() => filterAndSortAssets(rows, parsed, filters as ReadonlySet<string>, sort, assetType),[rows, parsed, filters, sort],);+ const listLoading = searching ? scan.loading : dirLoading;useEffect(() => {if (!pendingReveal || !items.some((it) => it.path === pendingReveal)) return;@@ -488,13 +506,41 @@ export function ContentBrowser() {!e.dataTransfer.types.includes('application/x-estella-asset') &&Array.from(e.dataTransfer.types).includes('Files');+ // Drop affordances. dragenter/dragleave also fire when crossing child elements,+ // so both the body and each folder target keep an enter-depth counter — the+ // highlight clears only when the count returns to zero (a real exit), never on+ // a child-to-child transition.+ const [fileDrop, setFileDrop] = useState(false);+ const fileDragDepth = useRef(0);+ const [dropFolder, setDropFolder] = useState<string | null>(null);+ const folderDragDepth = useRef(new Map<string, number>());+ const clearDropState = () => {+ fileDragDepth.current = 0;+ setFileDrop(false);+ folderDragDepth.current.clear();+ setDropFolder(null);+ };++ const onBodyDragEnter = (e: React.DragEvent) => {+ if (!isOsFileDrag(e)) return;+ fileDragDepth.current++;+ setFileDrop(true);+ };+const onBodyDragOver = (e: React.DragEvent) => {if (!isOsFileDrag(e)) return;e.preventDefault();e.dataTransfer.dropEffect = 'copy';};+ const onBodyDragLeave = (e: React.DragEvent) => {+ if (!isOsFileDrag(e)) return;+ fileDragDepth.current = Math.max(0, fileDragDepth.current - 1);+ if (fileDragDepth.current === 0) setFileDrop(false);+ };+const onBodyDrop = (e: React.DragEvent) => {+ clearDropState();if (!isOsFileDrag(e)) return;e.preventDefault();const sources = Array.from(e.dataTransfer.files)@@ -524,14 +570,32 @@ export function ContentBrowser() {}};- // Drop-target props for a folder (tile or tree node): accept internal asset drags.+ // Drop-target props for a folder (tile, list row or tree node): accept internal+ // asset drags + highlight the hovered target. The clear on leave is conditional+ // because moving between targets fires the new target's dragenter first.const folderDrop = (folderPath: string) => ({+ onDragEnter: (e: React.DragEvent) => {+ if (!e.dataTransfer.types.includes('application/x-estella-asset')) return;+ folderDragDepth.current.set(folderPath, (folderDragDepth.current.get(folderPath) ?? 0) + 1);+ setDropFolder(folderPath);+ },onDragOver: (e: React.DragEvent) => {if (!e.dataTransfer.types.includes('application/x-estella-asset')) return;e.preventDefault();e.dataTransfer.dropEffect = 'move';},+ onDragLeave: (e: React.DragEvent) => {+ if (!e.dataTransfer.types.includes('application/x-estella-asset')) return;+ const depth = (folderDragDepth.current.get(folderPath) ?? 0) - 1;+ if (depth <= 0) {+ folderDragDepth.current.delete(folderPath);+ setDropFolder((cur) => (cur === folderPath ? null : cur));+ } else {+ folderDragDepth.current.set(folderPath, depth);+ }+ },onDrop: (e: React.DragEvent) => {+ clearDropState();const src = e.dataTransfer.getData('application/x-estella-asset');if (!src) return;e.preventDefault();@@ -561,6 +625,9 @@ export function ContentBrowser() {ev.dataTransfer.setData('application/x-estella-asset', path);ev.dataTransfer.setData('text/plain', path);},+ // A cancelled drag (Escape / dropped outside a target) fires no drop —+ // make sure no folder keeps its highlight.+ onDragEnd: clearDropState,onClick: () => selectAsset(path),onDoubleClick: () => onOpen(path, e.isDir, e.name),// Suppress the hover card while any inline rename is active.@@ -650,7 +717,7 @@ export function ContentBrowser() {</div><div className="cb-src-body"><div className="cb-sec">Folders</div>- <FolderNode path="" name={project.name} depth={0} cwd={cwd} onSelect={go} folderDrop={folderDrop} />+ <FolderNode path="" name={project.name} depth={0} cwd={cwd} onSelect={go} folderDrop={folderDrop} dropPath={dropFolder} /></div></div>@@ -747,11 +814,13 @@ export function ContentBrowser() {</div><div- className={`cb-scroll${view === 'list' ? ' list' : ''}`}+ className={`cb-scroll${view === 'list' ? ' list' : ''}${fileDrop ? ' is-file-drop' : ''}`}onClick={(e) => {if (e.target === e.currentTarget) selectAsset(null);}}+ onDragEnter={onBodyDragEnter}onDragOver={onBodyDragOver}+ onDragLeave={onBodyDragLeave}onDrop={onBodyDrop}onContextMenu={(e) => {// Items stopPropagation, so reaching here = a right-click on empty space.@@ -762,7 +831,16 @@ export function ContentBrowser() {>{view === 'grid' ? (<div className="cb-grid" style={{ ['--tile' as string]: `${tileSize}px` } as React.CSSProperties}>- {items.map((it) => {+ {listLoading &&+ Array.from({ length: 8 }, (_, i) => (+ <div key={i} className="asset is-skel" aria-hidden="true">+ <div className="th skel" />+ <div className="nm">+ <span className="skel" />+ </div>+ </div>+ ))}+ {!listLoading && items.map((it) => {const path = it.path;const type: AssetType = it.isDir ? 'folder' : assetType(it.name);const isImg = !it.isDir && IMAGE_RE.test(it.name);@@ -770,7 +848,7 @@ export function ContentBrowser() {<divkey={path}data-path={path}- className={`asset${it.isDir ? ' folder' : ''}${selected === path ? ' sel' : ''}`}+ className={`asset${it.isDir ? ' folder' : ''}${selected === path ? ' sel' : ''}${it.isDir && dropFolder === path ? ' is-drop' : ''}`}// Files drag onto inspector asset fields / the viewport (assign / instantiate);// folders are drop targets that move the dragged asset into them.{...bindItem(path, it)}@@ -801,7 +879,7 @@ export function ContentBrowser() {</div>);})}- {items.length === 0 && (+ {!listLoading && items.length === 0 && (<div className="cb-empty" style={{ gridColumn: '1 / -1' }}>{q ? 'No assets match.' : 'Empty folder.'}</div>@@ -813,14 +891,25 @@ export function ContentBrowser() {<span>Name</span><span>Type</span></div>- {items.map((it) => {+ {listLoading &&+ Array.from({ length: 8 }, (_, i) => (+ <div key={i} className="lr is-skel" aria-hidden="true">+ <span className="ln">+ <span className="skel" />+ </span>+ <span className="c">+ <span className="skel" />+ </span>+ </div>+ ))}+ {!listLoading && items.map((it) => {const path = it.path;const type: AssetType = it.isDir ? 'folder' : assetType(it.name);return (<divkey={path}data-path={path}- className={`lr${selected === path ? ' sel' : ''}`}+ className={`lr${selected === path ? ' sel' : ''}${it.isDir && dropFolder === path ? ' is-drop' : ''}`}{...bindItem(path, it)}{...(it.isDir ? folderDrop(path) : null)}>@@ -840,7 +929,9 @@ export function ContentBrowser() {</div>);})}- {items.length === 0 && <div className="cb-empty">{q ? 'No assets match.' : 'Empty folder.'}</div>}+ {!listLoading && items.length === 0 && (+ <div className="cb-empty">{q ? 'No assets match.' : 'Empty folder.'}</div>+ )}</div>)}</div>diff --git a/desktop/src/theme/content.css b/desktop/src/theme/content.cssindex 8a51f4d2d..e1e1f55f9 100644--- a/desktop/src/theme/content.css+++ b/desktop/src/theme/content.css@@ -43,8 +43,9 @@.crumbs .cr.cur { color: var(--text); font-weight: 600; }.crumbs .sep { color: var(--text-mute); }.cb-search { width: 200px; height: 26px; flex-shrink: 0; }-.cb-add { height: 26px; display: inline-flex; align-items: center; gap: 5px; padding: 0 10px; background: var(--acc); color: var(--on-accent); font-weight: 600; font-size: var(--fs-xs); border-radius: var(--r-sm); transition: background var(--t-fast); flex-shrink: 0; }-.cb-add:hover { background: var(--acc-hi); }+/* Demoted from a filled-accent button — Play keeps the primary-action weight. */+.cb-add { height: 26px; display: inline-flex; align-items: center; gap: 5px; padding: 0 10px; background: var(--srf-3); color: var(--star-hi); border: 1px solid var(--star-line); font-weight: 600; font-size: var(--fs-xs); border-radius: var(--r-sm); transition: background var(--t-fast); flex-shrink: 0; }+.cb-add:hover { background: var(--star-dim); }.cb-add:disabled { opacity: 0.45; }.cb-ghost { width: 26px; height: 26px; display: grid; place-items: center; color: var(--text-dim); background: var(--srf-3); border: 1px solid var(--border-line); border-radius: var(--r-sm); flex-shrink: 0; transition: color var(--t-fast), background var(--t-fast); }.cb-ghost:hover { color: var(--text); background: var(--srf-4); }@@ -92,6 +93,27 @@.cb-empty { padding: 50px; text-align: center; color: var(--text-mute); }.cb-empty .ei { width: 44px; height: 44px; margin: 0 auto 10px; display: grid; place-items: center; border: 1px dashed var(--border-line); border-radius: var(--r-lg); }+/* ── Drag & drop affordances ── the outliner's drop language (accent-soft fill ++ 1px accent ring) on every folder drop target; a soft inset ring on the scroll+ body while an OS-file drag hovers the panel. */+.tr.is-drop,+.lr.is-drop { background: var(--acc-soft); box-shadow: inset 0 0 0 1px var(--acc); }+.asset.is-drop { outline: 1px solid var(--acc); background: var(--acc-soft); }+.cb-scroll.is-file-drop { box-shadow: inset 0 0 0 2px var(--acc-soft); }++/* ── Loading skeletons ── placeholder tiles / rows while a folder read or search+ scan is in flight (shimmer = shared .skel primitive, controls.css). */+.asset.is-skel { pointer-events: none; }+.asset.is-skel .th { background: var(--srf-3); }+.asset.is-skel .nm { border-top-color: transparent; }+.asset.is-skel .nm .skel { display: block; height: 9px; width: 70%; }+.asset.is-skel:nth-child(2n) .nm .skel { width: 52%; }+.lr.is-skel { pointer-events: none; }+.lr.is-skel .skel { display: block; height: 9px; }+.lr.is-skel .ln .skel { width: 56%; max-width: 220px; }+.lr.is-skel:nth-child(2n) .ln .skel { width: 38%; }+.lr.is-skel .c .skel { width: 36px; }+/* ── Detail (right) ── */.cb-detail { width: 232px; flex-shrink: 0; border-left: 1px solid var(--border); }.cb-detail-body { flex: 1; overflow-y: auto; }diff --git a/desktop/src/theme/controls.css b/desktop/src/theme/controls.cssindex f107facf2..4ebf493a6 100644--- a/desktop/src/theme/controls.css+++ b/desktop/src/theme/controls.css@@ -55,3 +55,24 @@/* — Unsaved-changes dot (components/DirtyDot.tsx) — */.dirty-dot { color: var(--sel); font-size: 0.7em; line-height: 1; }++/* — Skeleton shimmer (loading placeholders: Content Browser listing, launcher+ recents). Size it at the usage site; the global reduced-motion kill-switch+ (global.css) already stops the sweep. — */+.skel {+ background: var(--srf-3);+ border-radius: var(--r-sm);+ overflow: hidden;+ position: relative;+}+.skel::after {+ content: '';+ position: absolute;+ inset: 0;+ transform: translateX(-100%);+ background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent);+ animation: skel-sweep 1.2s ease infinite;+}+@keyframes skel-sweep {+ to { transform: translateX(100%); }+}diff --git a/desktop/src/theme/inspector.css b/desktop/src/theme/inspector.cssindex ed1854157..12ce606d9 100644--- a/desktop/src/theme/inspector.css+++ b/desktop/src/theme/inspector.css@@ -30,10 +30,13 @@.insp { display: flex; flex-direction: column; height: 100%; min-height: 0; }.insp-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--border); flex-shrink: 0; }.insp-head .search { height: 26px; }+/* Outlined, not filled — the accent fill is reserved for Play (one primary+ action per screen); +Add stays prominent through the accent stroke/text. */.insp-add { height: 26px; display: inline-flex; align-items: center; gap: 5px; padding: 0 10px;- background: var(--acc); color: var(--on-accent); font-weight: 600; font-size: var(--fs-xs); border-radius: var(--r-sm);+ background: transparent; color: var(--star-hi); border: 1px solid var(--star-line);+ font-weight: 600; font-size: var(--fs-xs); border-radius: var(--r-sm);transition: background var(--t-fast); white-space: nowrap; }-.insp-add:hover { background: var(--acc-hi); }+.insp-add:hover { background: var(--star-dim); }.filt-btn { width: 28px; height: 26px; display: grid; place-items: center; color: var(--text-mute); border: 1px solid var(--border-line); border-radius: var(--r-sm); flex-shrink: 0; transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast); }.filt-btn:hover { color: var(--text); background: var(--srf-4); }.filt-btn.on { color: var(--warn); border-color: rgba(211,162,60,0.4); background: rgba(211,162,60,0.12); }diff --git a/desktop/src/theme/launcher.css b/desktop/src/theme/launcher.cssindex 2270a186c..256913117 100644--- a/desktop/src/theme/launcher.css+++ b/desktop/src/theme/launcher.css@@ -355,6 +355,26 @@.proj-card:focus-within .proj-card__remove { opacity: 1; }.proj-card__remove:hover { color: var(--error); border-color: var(--error); }+/* Loading skeleton cards — shown while recents load, so the empty state never+ flashes (shimmer = shared .skel primitive, controls.css). */+.proj-card.is-skel {+ pointer-events: none;+ cursor: default;+}+.proj-card.is-skel .proj-card__thumb {+ background: var(--srf-3);+ background-image: none;+}+.proj-card.is-skel .proj-card__body .skel {+ display: block;+ height: 10px;+ width: 62%;+}+.proj-card.is-skel .proj-card__body .skel + .skel {+ height: 8px;+ width: 40%;+}+/* ----------------------------------------------------------- list view --- */.proj-list {overflow-y: auto;