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: improve Help menu and update experience
esengined57b0ac50977
diff --git a/desktop/src/main.ts b/desktop/src/main.tsindex a06a215c5..c5f845898 100644--- a/desktop/src/main.ts+++ b/desktop/src/main.ts@@ -4,14 +4,13 @@*/import '@esengine/editor/styles';-import { createEditor, ProjectLauncher, setPlatformAdapter, setEditorContext, loadProjectConfig, type Editor } from '@esengine/editor';+import { createEditor, ProjectLauncher, setPlatformAdapter, setEditorContext, loadProjectConfig, showToast, dismissToast, showProgressToast, updateToast, type Editor } from '@esengine/editor';import { TauriPlatformAdapter } from './TauriPlatformAdapter';import { nativeFS, nativeShell } from './native-fs';import { invoke } from '@tauri-apps/api/core';import { getVersion } from '@tauri-apps/api/app';import { check } from '@tauri-apps/plugin-updater';import { relaunch } from '@tauri-apps/plugin-process';-import { ask } from '@tauri-apps/plugin-dialog';import type { App, ESEngineModule } from 'esengine';let currentLauncher: ProjectLauncher | null = null;@@ -110,21 +109,51 @@ function loadUmdModule(url: string, globalName: string): Promise<any> {});}-async function checkForUpdate(): Promise<void> {+async function checkForUpdate(manual = false): Promise<void> {+ let tid: string | undefined;+ if (manual) {+ tid = showProgressToast('Checking for updates...');+ }+try {const update = await check();- if (!update) return;-- const yes = await ask(- `New version ${update.version} is available. Update now?`,- { title: 'Update Available', kind: 'info', okLabel: 'Update', cancelLabel: 'Later' }- );- if (!yes) return;-- await update.downloadAndInstall();- await relaunch();+ if (!update) {+ if (tid) {+ updateToast(tid, { type: 'success', title: 'You\'re up to date', message: 'No updates available.' });+ setTimeout(() => dismissToast(tid!), 3000);+ }+ return;+ }++ if (tid) dismissToast(tid);++ showToast({+ type: 'info',+ title: 'Update Available',+ message: `New version ${update.version} is ready to install.`,+ duration: 0,+ actions: [{+ label: 'Update',+ primary: true,+ onClick: async () => {+ const dlTid = showProgressToast('Downloading update...');+ try {+ await update.downloadAndInstall();+ updateToast(dlTid, { type: 'success', title: 'Update complete', message: 'Restarting...' });+ setTimeout(() => relaunch(), 1000);+ } catch (e) {+ updateToast(dlTid, { type: 'error', title: 'Update failed', message: String(e) });+ }+ },+ }],+ });} catch (e) {- console.warn('Update check failed:', e);+ if (tid) {+ updateToast(tid, { type: 'error', title: 'Update check failed', message: String(e) });+ setTimeout(() => dismissToast(tid!), 5000);+ } else {+ console.warn('Update check failed:', e);+ }}}@@ -137,6 +166,7 @@ async function init(): Promise<void> {shell: nativeShell,esbuildWasmURL: '/esbuild.wasm',version,+ onCheckUpdate: () => checkForUpdate(true),});const container = document.getElementById('editor-root');diff --git a/desktop/src/native-fs.ts b/desktop/src/native-fs.tsindex 7240c5024..19b213956 100644--- a/desktop/src/native-fs.ts+++ b/desktop/src/native-fs.ts@@ -19,6 +19,7 @@ import {import { invoke, convertFileSrc } from '@tauri-apps/api/core';import { listen, type UnlistenFn } from '@tauri-apps/api/event';import { resourceDir } from '@tauri-apps/api/path';+import { open as shellOpen } from '@tauri-apps/plugin-shell';import type { NativeShell } from '@esengine/editor';export interface DirectoryEntry {@@ -359,6 +360,10 @@ export const nativeShell: NativeShell = {});},+ async openUrl(url: string): Promise<void> {+ await shellOpen(url);+ },+async openInEditor(projectPath: string, filePath: string): Promise<void> {await invoke('execute_command', {cmd: 'open',diff --git a/editor/src/Editor.ts b/editor/src/Editor.tsindex d7032d406..de22a7e9a 100644--- a/editor/src/Editor.ts+++ b/editor/src/Editor.ts@@ -320,6 +320,7 @@ export class Editor {}showAboutDialog(): void {+ const hasUpdater = !!getEditorContext().onCheckUpdate;const overlay = document.createElement('div');overlay.className = 'es-dialog-overlay';overlay.innerHTML = `@@ -336,7 +337,8 @@ export class Editor {A lightweight 2D game engine<br>for web and mini-programs.</p></div>- <div class="es-dialog-footer" style="justify-content: center;">+ <div class="es-dialog-footer" style="justify-content: center; gap: 8px;">+ ${hasUpdater ? '<button class="es-dialog-btn" id="about-check-update">Check for Updates</button>' : ''}<button class="es-dialog-btn es-dialog-btn-primary">OK</button></div></div>@@ -344,7 +346,11 @@ export class Editor {const close = () => overlay.remove();overlay.querySelector('.es-dialog-close')?.addEventListener('click', close);- overlay.querySelector('.es-dialog-btn')?.addEventListener('click', close);+ overlay.querySelector('.es-dialog-btn-primary')?.addEventListener('click', close);+ overlay.querySelector('#about-check-update')?.addEventListener('click', () => {+ close();+ getEditorContext().onCheckUpdate?.();+ });overlay.addEventListener('click', (e) => {if (e.target === overlay) close();});diff --git a/editor/src/context/EditorContext.ts b/editor/src/context/EditorContext.tsindex faf81d88d..df2d7dfe9 100644--- a/editor/src/context/EditorContext.ts+++ b/editor/src/context/EditorContext.ts@@ -3,6 +3,7 @@ import type { Editor } from '../Editor';export interface NativeShell {openFile(path: string): Promise<void>;+ openUrl(url: string): Promise<void>;openInEditor(projectPath: string, filePath: string): Promise<void>;execute(cmd: string,@@ -18,6 +19,7 @@ export interface EditorContextConfig {shell?: NativeShell;esbuildWasmURL?: string;version?: string;+ onCheckUpdate?: () => void;}let ctx: EditorContextConfig = {};diff --git a/editor/src/menus/builtinMenus.ts b/editor/src/menus/builtinMenus.tsindex 206fbe199..04f4e57c9 100644--- a/editor/src/menus/builtinMenus.ts+++ b/editor/src/menus/builtinMenus.ts@@ -1,5 +1,6 @@import { registerMenu, registerMenuItem } from './MenuRegistry';import type { Editor } from '../Editor';+import { getEditorContext } from '../context/EditorContext';export function registerBuiltinMenus(editor: Editor): void {registerMenu({ id: 'file', label: 'File', order: 0 });@@ -95,7 +96,14 @@ export function registerBuiltinMenus(editor: Editor): void {registerMenuItem({id: 'help.docs', menu: 'help', label: 'Documentation', order: 0,- action: () => window.open('https://esengine.github.io/microes/', '_blank'),+ action: () => {+ const shell = getEditorContext().shell;+ if (shell) {+ shell.openUrl('https://esengine.github.io/microes/');+ } else {+ window.open('https://esengine.github.io/microes/', '_blank');+ }+ },});registerMenuItem({id: 'help.about', menu: 'help', label: 'About ESEngine', order: 1, separator: true,