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 editor UI and add build scripts
esengine6bb66b96c72c
diff --git a/desktop/public/sdk/cjs/esengine.js b/desktop/public/sdk/cjs/esengine.jsindex 14bd5d472..9659f91db 100644--- a/desktop/public/sdk/cjs/esengine.js+++ b/desktop/public/sdk/cjs/esengine.js@@ -1,5 +1,148 @@'use strict';+/**+ * @file base.ts+ * @brief Base platform adapter - no platform-specific code+ */+// =============================================================================+// Platform Instance (set by entry point)+// =============================================================================+let currentPlatform = null;+/**+ * Set the platform adapter (called by entry point)+ */+function setPlatform(adapter) {+ currentPlatform = adapter;+ console.log(`[ESEngine] Platform: ${adapter.name}`);+}+/**+ * Get the current platform adapter+ * @throws Error if platform not initialized+ */+function getPlatform() {+ if (!currentPlatform) {+ throw new Error('[ESEngine] Platform not initialized. ' ++ 'Import from "esengine" (web) or "esengine/wechat" (WeChat) instead of direct imports.');+ }+ return currentPlatform;+}+/**+ * Check if platform is initialized+ */+function isPlatformInitialized() {+ return currentPlatform !== null;+}+/**+ * Get platform type+ */+function getPlatformType() {+ return currentPlatform?.name ?? null;+}+/**+ * Check if running on WeChat+ */+function isWeChat() {+ return currentPlatform?.name === 'wechat';+}+/**+ * Check if running on Web+ */+function isWeb() {+ return currentPlatform?.name === 'web';+}+// =============================================================================+// Convenience Functions+// =============================================================================+async function platformFetch(url, options) {+ return getPlatform().fetch(url, options);+}+async function platformReadFile(path) {+ return getPlatform().readFile(path);+}+async function platformReadTextFile(path) {+ return getPlatform().readTextFile(path);+}+async function platformFileExists(path) {+ return getPlatform().fileExists(path);+}+async function platformInstantiateWasm(pathOrBuffer, imports) {+ return getPlatform().instantiateWasm(pathOrBuffer, imports);+}++/**+ * @file web.ts+ * @brief Web platform adapter implementation+ */+// =============================================================================+// Web Platform Adapter+// =============================================================================+class WebPlatformAdapter {+ constructor() {+ this.name = 'web';+ }+ async fetch(url, options) {+ const response = await globalThis.fetch(url, {+ method: options?.method ?? 'GET',+ headers: options?.headers,+ body: options?.body,+ });+ const headers = {};+ response.headers.forEach((value, key) => {+ headers[key] = value;+ });+ return {+ ok: response.ok,+ status: response.status,+ statusText: response.statusText,+ headers,+ json: () => response.json(),+ text: () => response.text(),+ arrayBuffer: () => response.arrayBuffer(),+ };+ }+ async readFile(path) {+ const response = await this.fetch(path);+ if (!response.ok) {+ throw new Error(`Failed to read file: ${path} (${response.status})`);+ }+ return response.arrayBuffer();+ }+ async readTextFile(path) {+ const response = await this.fetch(path);+ if (!response.ok) {+ throw new Error(`Failed to read file: ${path} (${response.status})`);+ }+ return response.text();+ }+ async fileExists(path) {+ try {+ const response = await globalThis.fetch(path, { method: 'HEAD' });+ return response.ok;+ }+ catch {+ return false;+ }+ }+ async instantiateWasm(pathOrBuffer, imports) {+ let buffer;+ if (typeof pathOrBuffer === 'string') {+ buffer = await this.readFile(pathOrBuffer);+ }+ else {+ buffer = pathOrBuffer;+ }+ const result = await WebAssembly.instantiate(buffer, imports);+ return {+ instance: result.instance,+ module: result.module,+ };+ }+}+// =============================================================================+// Export Singleton+// =============================================================================+const webAdapter = new WebPlatformAdapter();+/*** @file types.ts* @brief Core type definitions for ESEngine SDK@@ -1148,7 +1291,12 @@ function createWebApp(module, options) {const app = App.new();const cppRegistry = new module.Registry();app.connectCpp(cppRegistry, module);- module.initRenderer();+ if (options?.glContextHandle) {+ module.initRendererWithContext(options.glContextHandle);+ }+ else {+ module.initRenderer();+ }const getViewportSize = options?.getViewportSize ?? (() => ({width: window.innerWidth * (window.devicePixelRatio || 1),height: window.innerHeight * (window.devicePixelRatio || 1)@@ -1485,7 +1633,7 @@ class PreviewPlugin {if (!this.app_)return;try {- const response = await fetch(this.sceneUrl_);+ const response = await platformFetch(this.sceneUrl_);if (!response.ok) {throw new Error(`Failed to fetch scene: ${response.status}`);}@@ -1537,6 +1685,13 @@ class PreviewPlugin {}}+/**+ * @file index.ts+ * @brief ESEngine SDK - Web entry point (auto-initializes Web platform)+ */+// Initialize Web platform+setPlatform(webAdapter);+exports.App = App;exports.AssetPlugin = AssetPlugin;exports.AssetServer = AssetServer;@@ -1575,9 +1730,19 @@ exports.defineComponent = defineComponent;exports.defineResource = defineResource;exports.defineSystem = defineSystem;exports.defineTag = defineTag;+exports.getPlatform = getPlatform;+exports.getPlatformType = getPlatformType;exports.isBuiltinComponent = isBuiltinComponent;+exports.isPlatformInitialized = isPlatformInitialized;+exports.isWeChat = isWeChat;+exports.isWeb = isWeb;exports.loadSceneData = loadSceneData;exports.loadSceneWithAssets = loadSceneWithAssets;+exports.platformFetch = platformFetch;+exports.platformFileExists = platformFileExists;+exports.platformInstantiateWasm = platformInstantiateWasm;+exports.platformReadFile = platformReadFile;+exports.platformReadTextFile = platformReadTextFile;exports.quat = quat;exports.textPlugin = textPlugin;exports.vec2 = vec2;diff --git a/desktop/public/sdk/esm/esengine.js b/desktop/public/sdk/esm/esengine.jsindex 6834ec4f7..b435b47ed 100644--- a/desktop/public/sdk/esm/esengine.js+++ b/desktop/public/sdk/esm/esengine.js@@ -1,3 +1,146 @@+/**+ * @file base.ts+ * @brief Base platform adapter - no platform-specific code+ */+// =============================================================================+// Platform Instance (set by entry point)+// =============================================================================+let currentPlatform = null;+/**+ * Set the platform adapter (called by entry point)+ */+function setPlatform(adapter) {+ currentPlatform = adapter;+ console.log(`[ESEngine] Platform: ${adapter.name}`);+}+/**+ * Get the current platform adapter+ * @throws Error if platform not initialized+ */+function getPlatform() {+ if (!currentPlatform) {+ throw new Error('[ESEngine] Platform not initialized. ' ++ 'Import from "esengine" (web) or "esengine/wechat" (WeChat) instead of direct imports.');+ }+ return currentPlatform;+}+/**+ * Check if platform is initialized+ */+function isPlatformInitialized() {+ return currentPlatform !== null;+}+/**+ * Get platform type+ */+function getPlatformType() {+ return currentPlatform?.name ?? null;+}+/**+ * Check if running on WeChat+ */+function isWeChat() {+ return currentPlatform?.name === 'wechat';+}+/**+ * Check if running on Web+ */+function isWeb() {+ return currentPlatform?.name === 'web';+}+// =============================================================================+// Convenience Functions+// =============================================================================+async function platformFetch(url, options) {+ return getPlatform().fetch(url, options);+}+async function platformReadFile(path) {+ return getPlatform().readFile(path);+}+async function platformReadTextFile(path) {+ return getPlatform().readTextFile(path);+}+async function platformFileExists(path) {+ return getPlatform().fileExists(path);+}+async function platformInstantiateWasm(pathOrBuffer, imports) {+ return getPlatform().instantiateWasm(pathOrBuffer, imports);+}++/**+ * @file web.ts+ * @brief Web platform adapter implementation+ */+// =============================================================================+// Web Platform Adapter+// =============================================================================+class WebPlatformAdapter {+ constructor() {+ this.name = 'web';+ }+ async fetch(url, options) {+ const response = await globalThis.fetch(url, {+ method: options?.method ?? 'GET',+ headers: options?.headers,+ body: options?.body,+ });+ const headers = {};+ response.headers.forEach((value, key) => {+ headers[key] = value;+ });+ return {+ ok: response.ok,+ status: response.status,+ statusText: response.statusText,+ headers,+ json: () => response.json(),+ text: () => response.text(),+ arrayBuffer: () => response.arrayBuffer(),+ };+ }+ async readFile(path) {+ const response = await this.fetch(path);+ if (!response.ok) {+ throw new Error(`Failed to read file: ${path} (${response.status})`);+ }+ return response.arrayBuffer();+ }+ async readTextFile(path) {+ const response = await this.fetch(path);+ if (!response.ok) {+ throw new Error(`Failed to read file: ${path} (${response.status})`);+ }+ return response.text();+ }+ async fileExists(path) {+ try {+ const response = await globalThis.fetch(path, { method: 'HEAD' });+ return response.ok;+ }+ catch {+ return false;+ }+ }+ async instantiateWasm(pathOrBuffer, imports) {+ let buffer;+ if (typeof pathOrBuffer === 'string') {+ buffer = await this.readFile(pathOrBuffer);+ }+ else {+ buffer = pathOrBuffer;+ }+ const result = await WebAssembly.instantiate(buffer, imports);+ return {+ instance: result.instance,+ module: result.module,+ };+ }+}+// =============================================================================+// Export Singleton+// =============================================================================+const webAdapter = new WebPlatformAdapter();+/*** @file types.ts* @brief Core type definitions for ESEngine SDK@@ -1146,7 +1289,12 @@ function createWebApp(module, options) {const app = App.new();const cppRegistry = new module.Registry();app.connectCpp(cppRegistry, module);- module.initRenderer();+ if (options?.glContextHandle) {+ module.initRendererWithContext(options.glContextHandle);+ }+ else {+ module.initRenderer();+ }const getViewportSize = options?.getViewportSize ?? (() => ({width: window.innerWidth * (window.devicePixelRatio || 1),height: window.innerHeight * (window.devicePixelRatio || 1)@@ -1483,7 +1631,7 @@ class PreviewPlugin {if (!this.app_)return;try {- const response = await fetch(this.sceneUrl_);+ const response = await platformFetch(this.sceneUrl_);if (!response.ok) {throw new Error(`Failed to fetch scene: ${response.status}`);}@@ -1535,4 +1683,11 @@ class PreviewPlugin {}}-export { App, AssetPlugin, AssetServer, Assets, Camera, Canvas, Children, Commands, CommandsInstance, EntityCommands, INVALID_ENTITY, INVALID_TEXTURE, Input, LocalTransform, Mut, Parent, PreviewPlugin, Query, QueryInstance, Res, ResMut, Schedule, Sprite, SystemRunner, Text, TextAlign, TextOverflow, TextPlugin, TextRenderer, TextVerticalAlign, Time, UIRect, Velocity, World, WorldTransform, assetPlugin, color, createWebApp, defineComponent, defineResource, defineSystem, defineTag, isBuiltinComponent, loadSceneData, loadSceneWithAssets, quat, textPlugin, vec2, vec3, vec4 };+/**+ * @file index.ts+ * @brief ESEngine SDK - Web entry point (auto-initializes Web platform)+ */+// Initialize Web platform+setPlatform(webAdapter);++export { App, AssetPlugin, AssetServer, Assets, Camera, Canvas, Children, Commands, CommandsInstance, EntityCommands, INVALID_ENTITY, INVALID_TEXTURE, Input, LocalTransform, Mut, Parent, PreviewPlugin, Query, QueryInstance, Res, ResMut, Schedule, Sprite, SystemRunner, Text, TextAlign, TextOverflow, TextPlugin, TextRenderer, TextVerticalAlign, Time, UIRect, Velocity, World, WorldTransform, assetPlugin, color, createWebApp, defineComponent, defineResource, defineSystem, defineTag, getPlatform, getPlatformType, isBuiltinComponent, isPlatformInitialized, isWeChat, isWeb, loadSceneData, loadSceneWithAssets, platformFetch, platformFileExists, platformInstantiateWasm, platformReadFile, platformReadTextFile, quat, textPlugin, vec2, vec3, vec4 };diff --git a/desktop/public/sdk/iife/esengine.js b/desktop/public/sdk/iife/esengine.jsindex d505bff3d..28f225a15 100644--- a/desktop/public/sdk/iife/esengine.js+++ b/desktop/public/sdk/iife/esengine.js@@ -1,6 +1,149 @@var ES = (function (exports) {'use strict';+ /**+ * @file base.ts+ * @brief Base platform adapter - no platform-specific code+ */+ // =============================================================================+ // Platform Instance (set by entry point)+ // =============================================================================+ let currentPlatform = null;+ /**+ * Set the platform adapter (called by entry point)+ */+ function setPlatform(adapter) {+ currentPlatform = adapter;+ console.log(`[ESEngine] Platform: ${adapter.name}`);+ }+ /**+ * Get the current platform adapter+ * @throws Error if platform not initialized+ */+ function getPlatform() {+ if (!currentPlatform) {+ throw new Error('[ESEngine] Platform not initialized. ' ++ 'Import from "esengine" (web) or "esengine/wechat" (WeChat) instead of direct imports.');+ }+ return currentPlatform;+ }+ /**+ * Check if platform is initialized+ */+ function isPlatformInitialized() {+ return currentPlatform !== null;+ }+ /**+ * Get platform type+ */+ function getPlatformType() {+ return currentPlatform?.name ?? null;+ }+ /**+ * Check if running on WeChat+ */+ function isWeChat() {+ return currentPlatform?.name === 'wechat';+ }+ /**+ * Check if running on Web+ */+ function isWeb() {+ return currentPlatform?.name === 'web';+ }+ // =============================================================================+ // Convenience Functions+ // =============================================================================+ async function platformFetch(url, options) {+ return getPlatform().fetch(url, options);+ }+ async function platformReadFile(path) {+ return getPlatform().readFile(path);+ }+ async function platformReadTextFile(path) {+ return getPlatform().readTextFile(path);+ }+ async function platformFileExists(path) {+ return getPlatform().fileExists(path);+ }+ async function platformInstantiateWasm(pathOrBuffer, imports) {+ return getPlatform().instantiateWasm(pathOrBuffer, imports);+ }++ /**+ * @file web.ts+ * @brief Web platform adapter implementation+ */+ // =============================================================================+ // Web Platform Adapter+ // =============================================================================+ class WebPlatformAdapter {+ constructor() {+ this.name = 'web';+ }+ async fetch(url, options) {+ const response = await globalThis.fetch(url, {+ method: options?.method ?? 'GET',+ headers: options?.headers,+ body: options?.body,+ });+ const headers = {};+ response.headers.forEach((value, key) => {+ headers[key] = value;+ });+ return {+ ok: response.ok,+ status: response.status,+ statusText: response.statusText,+ headers,+ json: () => response.json(),+ text: () => response.text(),+ arrayBuffer: () => response.arrayBuffer(),+ };+ }+ async readFile(path) {+ const response = await this.fetch(path);+ if (!response.ok) {+ throw new Error(`Failed to read file: ${path} (${response.status})`);+ }+ return response.arrayBuffer();+ }+ async readTextFile(path) {+ const response = await this.fetch(path);+ if (!response.ok) {+ throw new Error(`Failed to read file: ${path} (${response.status})`);+ }+ return response.text();+ }+ async fileExists(path) {+ try {+ const response = await globalThis.fetch(path, { method: 'HEAD' });+ return response.ok;+ }+ catch {+ return false;+ }+ }+ async instantiateWasm(pathOrBuffer, imports) {+ let buffer;+ if (typeof pathOrBuffer === 'string') {+ buffer = await this.readFile(pathOrBuffer);+ }+ else {+ buffer = pathOrBuffer;+ }+ const result = await WebAssembly.instantiate(buffer, imports);+ return {+ instance: result.instance,+ module: result.module,+ };+ }+ }+ // =============================================================================+ // Export Singleton+ // =============================================================================+ const webAdapter = new WebPlatformAdapter();+/*** @file types.ts* @brief Core type definitions for ESEngine SDK@@ -1149,7 +1292,12 @@ var ES = (function (exports) {const app = App.new();const cppRegistry = new module.Registry();app.connectCpp(cppRegistry, module);- module.initRenderer();+ if (options?.glContextHandle) {+ module.initRendererWithContext(options.glContextHandle);+ }+ else {+ module.initRenderer();+ }const getViewportSize = options?.getViewportSize ?? (() => ({width: window.innerWidth * (window.devicePixelRatio || 1),height: window.innerHeight * (window.devicePixelRatio || 1)@@ -1486,7 +1634,7 @@ var ES = (function (exports) {if (!this.app_)return;try {- const response = await fetch(this.sceneUrl_);+ const response = await platformFetch(this.sceneUrl_);if (!response.ok) {throw new Error(`Failed to fetch scene: ${response.status}`);}@@ -1538,6 +1686,13 @@ var ES = (function (exports) {}}+ /**+ * @file index.ts+ * @brief ESEngine SDK - Web entry point (auto-initializes Web platform)+ */+ // Initialize Web platform+ setPlatform(webAdapter);+exports.App = App;exports.AssetPlugin = AssetPlugin;exports.AssetServer = AssetServer;@@ -1576,9 +1731,19 @@ var ES = (function (exports) {exports.defineResource = defineResource;exports.defineSystem = defineSystem;exports.defineTag = defineTag;+ exports.getPlatform = getPlatform;+ exports.getPlatformType = getPlatformType;exports.isBuiltinComponent = isBuiltinComponent;+ exports.isPlatformInitialized = isPlatformInitialized;+ exports.isWeChat = isWeChat;+ exports.isWeb = isWeb;exports.loadSceneData = loadSceneData;exports.loadSceneWithAssets = loadSceneWithAssets;+ exports.platformFetch = platformFetch;+ exports.platformFileExists = platformFileExists;+ exports.platformInstantiateWasm = platformInstantiateWasm;+ exports.platformReadFile = platformReadFile;+ exports.platformReadTextFile = platformReadTextFile;exports.quat = quat;exports.textPlugin = textPlugin;exports.vec2 = vec2;diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.tomlindex e62aa6bf4..62bc24c34 100644--- a/desktop/src-tauri/Cargo.toml+++ b/desktop/src-tauri/Cargo.toml@@ -19,6 +19,7 @@ tauri-plugin-fs = "2"tauri-plugin-shell = "2"serde = { version = "1", features = ["derive"] }serde_json = "1"+tokio = { version = "1", features = ["process", "io-util", "macros"] }tiny_http = "0.12"open = "5"urlencoding = "2"diff --git a/desktop/src-tauri/tauri.conf.json b/desktop/src-tauri/tauri.conf.jsonindex a153664e3..dde01887a 100644--- a/desktop/src-tauri/tauri.conf.json+++ b/desktop/src-tauri/tauri.conf.json@@ -32,6 +32,9 @@"plugins": {"fs": {"requireLiteralLeadingDot": false+ },+ "shell": {+ "open": true}},"bundle": {diff --git a/editor/src/Editor.ts b/editor/src/Editor.tsindex a260b5cad..8dcde626f 100644--- a/editor/src/Editor.ts+++ b/editor/src/Editor.ts@@ -327,23 +327,35 @@ export class Editor {</div><div class="es-editor-statusbar"><div class="es-statusbar-left">- <button class="es-btn-dropdown es-active" data-action="toggle-assets">+ <button class="es-statusbar-btn es-statusbar-btn-primary es-active" data-action="toggle-assets">${icons.folder(12)}- <span>Assets</span>+ <span>Content Browser</span>${icons.chevronDown(10)}</button>- <button class="es-btn-tab" data-action="toggle-output">+ <button class="es-statusbar-btn" data-action="toggle-output">${icons.list(12)}<span>Output</span></button>+ <div class="es-statusbar-divider"></div>+ <span class="es-cmd-prompt">></span>+ <input type="text" class="es-cmd-input" placeholder="pnpm install, npm run build..." /></div><div class="es-statusbar-right">+ <button class="es-statusbar-btn" data-action="undo" title="Undo">+ <span>Undo</span>+ </button><div class="es-statusbar-icons">- <button title="Grid">${icons.hash(12)}</button>+ <button title="Notifications">${icons.list(12)}</button>+ <button title="Extensions">${icons.grid(12)}</button>+ <button title="Settings">${icons.settings(12)}</button></div><span class="es-status-indicator es-status-saved">${icons.check(12)}- <span>Saved</span>+ <span>All Saved</span>+ </span>+ <div class="es-statusbar-divider"></div>+ <span class="es-status-indicator">+ <span>Version Control</span></span></div></div>@@ -629,8 +641,92 @@ export class Editor {this.toggleAssetsPanel();} else if (action === 'toggle-output') {this.toggleOutputPanel();+ } else if (action === 'undo') {+ this.store_.undo();}});++ const cmdInput = statusbar.querySelector('.es-cmd-input') as HTMLInputElement;++ cmdInput?.addEventListener('keydown', (e) => {+ if (e.key === 'Enter') {+ const command = cmdInput.value.trim();+ if (command) {+ this.executeShellCommand(command);+ cmdInput.value = '';+ }+ }+ });+ }++ private async executeShellCommand(fullCommand: string): Promise<void> {+ if (!this.projectPath_) {+ this.appendOutput('Error: No project loaded\n', 'error');+ return;+ }++ const shell = (window as any).__esengine_shell;+ if (!shell) {+ this.appendOutput('Error: Shell not available\n', 'error');+ return;+ }++ const projectDir = this.projectPath_.replace(/[/\\][^/\\]+$/, '');++ this.outputPanelVisible_ = true;+ this.assetsPanelVisible_ = false;+ this.updateBottomPanelVisibility();++ const parts = fullCommand.split(/\s+/);+ const cmd = parts[0];+ const args = parts.slice(1);++ this.appendOutput(`> ${fullCommand}\n`, 'command');++ try {+ const result = await shell.execute(cmd, args, projectDir, (stream: string, data: string) => {+ this.appendOutput(data + '\n', stream === 'stderr' ? 'stderr' : 'stdout');+ });++ if (result.code !== 0) {+ this.appendOutput(`Process exited with code ${result.code}\n`, 'error');+ } else {+ this.appendOutput(`Done.\n`, 'success');+ }+ } catch (err) {+ this.appendOutput(`Error: ${err}\n`, 'error');+ }+ }++ private appendOutput(text: string, type: 'command' | 'stdout' | 'stderr' | 'error' | 'success'): void {+ const outputContent = this.container_.querySelector('.es-output-content');+ if (!outputContent) return;++ const empty = outputContent.querySelector('.es-output-empty');+ if (empty) empty.remove();++ const line = document.createElement('div');+ line.className = `es-output-line es-output-${type}`;+ line.textContent = text;+ outputContent.appendChild(line);+ outputContent.scrollTop = outputContent.scrollHeight;+ }++ private updateBottomPanelVisibility(): void {+ const assetsBtn = this.container_.querySelector('[data-action="toggle-assets"]');+ const outputBtn = this.container_.querySelector('[data-action="toggle-output"]');+ const contentBrowser = this.container_.querySelector('.es-content-browser-container') as HTMLElement;+ const outputPanel = this.container_.querySelector('.es-output-container') as HTMLElement;+ const bottomPanel = this.container_.querySelector('.es-editor-bottom') as HTMLElement;++ assetsBtn?.classList.toggle('es-active', this.assetsPanelVisible_);+ outputBtn?.classList.toggle('es-active', this.outputPanelVisible_);++ if (contentBrowser) contentBrowser.style.display = this.assetsPanelVisible_ ? '' : 'none';+ if (outputPanel) outputPanel.style.display = this.outputPanelVisible_ ? '' : 'none';+ if (bottomPanel) bottomPanel.style.display = (this.assetsPanelVisible_ || this.outputPanelVisible_) ? '' : 'none';++ requestAnimationFrame(() => this.sceneViewPanel_?.resize());}private toggleAssetsPanel(): void {diff --git a/editor/src/panels/ContentBrowserPanel.ts b/editor/src/panels/ContentBrowserPanel.tsindex 3f66e4ea3..eb91042b3 100644--- a/editor/src/panels/ContentBrowserPanel.ts+++ b/editor/src/panels/ContentBrowserPanel.ts@@ -5,6 +5,7 @@import type { EditorStore, AssetType } from '../store/EditorStore';import { icons } from '../utils/icons';+import { showContextMenu } from '../ui/ContextMenu';// =============================================================================// Types@@ -28,6 +29,7 @@ interface NativeFS {callback: (event: FileChangeEvent) => void,options?: { recursive?: boolean }): Promise<() => void>;+ openFolder(path: string): Promise<boolean>;}interface FolderNode {@@ -405,6 +407,97 @@ export class ContentBrowserPanel {refreshBtn?.addEventListener('click', () => {this.refresh();});++ this.gridContainer_?.addEventListener('contextmenu', (e) => {+ e.preventDefault();+ const target = e.target as HTMLElement;+ const item = target.closest('.es-asset-item') as HTMLElement;++ if (item) {+ const path = item.dataset.path;+ const type = item.dataset.type;+ if (path) {+ this.showAssetContextMenu(e, path, type as AssetItem['type']);+ }+ } else {+ this.showFolderContextMenu(e, this.currentPath_);+ }+ });++ this.treeContainer_?.addEventListener('contextmenu', (e) => {+ e.preventDefault();+ const target = e.target as HTMLElement;+ const item = target.closest('.es-folder-item') as HTMLElement;+ const path = item?.dataset.path ?? this.currentPath_;+ if (path) {+ this.showFolderContextMenu(e, path);+ }+ });+ }++ private showAssetContextMenu(e: MouseEvent, path: string, type: AssetItem['type']): void {+ const fs = getNativeFS();+ const parentPath = getParentPath(path);++ showContextMenu({+ x: e.clientX,+ y: e.clientY,+ items: [+ {+ label: 'Show in Folder',+ icon: icons.folderOpen(14),+ onClick: () => {+ fs?.openFolder(parentPath);+ },+ },+ {+ label: 'Copy Path',+ icon: icons.copy(14),+ onClick: () => {+ navigator.clipboard.writeText(path);+ },+ },+ { separator: true, label: '' },+ {+ label: 'Delete',+ icon: icons.trash(14),+ disabled: true,+ },+ ],+ });+ }++ private showFolderContextMenu(e: MouseEvent, path: string): void {+ const fs = getNativeFS();++ showContextMenu({+ x: e.clientX,+ y: e.clientY,+ items: [+ {+ label: 'Show in Folder',+ icon: icons.folderOpen(14),+ onClick: () => {+ fs?.openFolder(path);+ },+ },+ {+ label: 'Copy Path',+ icon: icons.copy(14),+ onClick: () => {+ navigator.clipboard.writeText(path);+ },+ },+ { separator: true, label: '' },+ {+ label: 'Refresh',+ icon: icons.refresh(14),+ onClick: () => {+ this.refresh();+ },+ },+ ],+ });}private selectAsset(path: string): void {diff --git a/editor/src/styles/editor.css b/editor/src/styles/editor.cssindex 4b09b889e..e55c807c8 100644--- a/editor/src/styles/editor.css+++ b/editor/src/styles/editor.css@@ -3083,3 +3083,128 @@ svg {background: #3d9ee0;border-color: #3d9ee0;}++/* =============================================================================+ * Statusbar Command Input+ * ============================================================================= */++.es-statusbar-divider {+ width: 1px;+ height: 14px;+ background: var(--es-border);+ margin: 0 6px;+}++.es-statusbar-btn {+ display: flex;+ align-items: center;+ gap: 4px;+ height: 20px;+ padding: 0 8px;+ background: transparent;+ border: none;+ border-radius: 3px;+ color: var(--es-text-secondary);+ font-size: 11px;+ cursor: pointer;+ white-space: nowrap;+}++.es-statusbar-btn:hover {+ background: var(--es-bg-hover);+ color: var(--es-text-primary);+}++.es-statusbar-btn svg {+ stroke: var(--es-text-secondary);+}++.es-statusbar-btn:hover svg {+ stroke: var(--es-text-primary);+}++.es-statusbar-btn-primary {+ background: var(--es-bg-tertiary);+ border: 1px solid var(--es-border);+ color: var(--es-text-primary);+}++.es-statusbar-btn-primary:hover {+ background: var(--es-bg-hover);+ border-color: var(--es-text-secondary);+}++.es-statusbar-btn-primary svg {+ stroke: var(--es-text-primary);+}++.es-statusbar-btn.es-active {+ color: var(--es-text-primary);+}++.es-statusbar-btn.es-active svg {+ stroke: var(--es-text-primary);+}++.es-cmd-prompt {+ color: var(--es-text-secondary);+ font-size: 12px;+ font-weight: 500;+ margin: 0 4px;+}++.es-cmd-input {+ flex: 1;+ min-width: 150px;+ max-width: 300px;+ height: 20px;+ padding: 0 8px;+ background: var(--es-bg-primary);+ border: 1px solid var(--es-border);+ border-radius: 3px;+ color: var(--es-text-primary);+ font-size: 11px;+ outline: none;+}++.es-cmd-input::placeholder {+ color: var(--es-text-secondary);+}++.es-cmd-input:focus {+ border-color: var(--es-accent);+}++/* =============================================================================+ * Output Panel Lines+ * ============================================================================= */++.es-output-line {+ font-family: 'Consolas', 'Monaco', monospace;+ font-size: 12px;+ line-height: 1.5;+ white-space: pre-wrap;+ word-break: break-all;+}++.es-output-command {+ color: var(--es-accent);+ font-weight: 500;+ margin-top: 8px;+}++.es-output-stdout {+ color: var(--es-text-primary);+}++.es-output-stderr {+ color: #e5c07b;+}++.es-output-error {+ color: var(--es-danger);+}++.es-output-success {+ color: var(--es-success);+}diff --git a/editor/src/ui/ContextMenu.ts b/editor/src/ui/ContextMenu.tsnew file mode 100644index 000000000..10ef07b8c--- /dev/null+++ b/editor/src/ui/ContextMenu.ts@@ -0,0 +1,141 @@+/**+ * @file ContextMenu.ts+ * @brief Context menu component for right-click actions+ */++import { icons } from '../utils/icons';++// =============================================================================+// Types+// =============================================================================++export interface ContextMenuItem {+ label: string;+ icon?: string;+ shortcut?: string;+ disabled?: boolean;+ separator?: boolean;+ onClick?: () => void;+}++export interface ContextMenuOptions {+ items: ContextMenuItem[];+ x: number;+ y: number;+}++// =============================================================================+// ContextMenu+// =============================================================================++class ContextMenuManager {+ private menu_: HTMLElement | null = null;+ private closeHandler_: ((e: MouseEvent) => void) | null = null;+ private keyHandler_: ((e: KeyboardEvent) => void) | null = null;++ show(options: ContextMenuOptions): void {+ this.hide();++ this.menu_ = document.createElement('div');+ this.menu_.className = 'es-context-menu';++ const itemsHtml = options.items.map((item, index) => {+ if (item.separator) {+ return '<div class="es-context-menu-separator"></div>';+ }++ const disabledClass = item.disabled ? 'es-disabled' : '';+ const iconHtml = item.icon ? `<span class="es-context-menu-icon">${item.icon}</span>` : '';+ const shortcutHtml = item.shortcut ? `<span class="es-context-menu-shortcut">${item.shortcut}</span>` : '';++ return `+ <div class="es-context-menu-item ${disabledClass}" data-index="${index}">+ ${iconHtml}+ <span class="es-context-menu-label">${item.label}</span>+ ${shortcutHtml}+ </div>+ `;+ }).join('');++ this.menu_.innerHTML = itemsHtml;++ // Position menu+ document.body.appendChild(this.menu_);++ // Adjust position if menu goes off screen+ const rect = this.menu_.getBoundingClientRect();+ let x = options.x;+ let y = options.y;++ if (x + rect.width > window.innerWidth) {+ x = window.innerWidth - rect.width - 5;+ }+ if (y + rect.height > window.innerHeight) {+ y = window.innerHeight - rect.height - 5;+ }++ this.menu_.style.left = `${x}px`;+ this.menu_.style.top = `${y}px`;++ // Event handlers+ this.menu_.addEventListener('click', (e) => {+ const target = e.target as HTMLElement;+ const itemEl = target.closest('.es-context-menu-item') as HTMLElement;+ if (!itemEl || itemEl.classList.contains('es-disabled')) return;++ const index = parseInt(itemEl.dataset.index ?? '-1', 10);+ const item = options.items[index];+ if (item?.onClick) {+ item.onClick();+ }+ this.hide();+ });++ // Close on click outside+ this.closeHandler_ = (e: MouseEvent) => {+ if (!this.menu_?.contains(e.target as Node)) {+ this.hide();+ }+ };+ setTimeout(() => {+ document.addEventListener('mousedown', this.closeHandler_!);+ }, 0);++ // Close on Escape+ this.keyHandler_ = (e: KeyboardEvent) => {+ if (e.key === 'Escape') {+ this.hide();+ }+ };+ document.addEventListener('keydown', this.keyHandler_);+ }++ hide(): void {+ if (this.menu_) {+ this.menu_.remove();+ this.menu_ = null;+ }+ if (this.closeHandler_) {+ document.removeEventListener('mousedown', this.closeHandler_);+ this.closeHandler_ = null;+ }+ if (this.keyHandler_) {+ document.removeEventListener('keydown', this.keyHandler_);+ this.keyHandler_ = null;+ }+ }+}++// =============================================================================+// Singleton Export+// =============================================================================++export const contextMenu = new ContextMenuManager();++export function showContextMenu(options: ContextMenuOptions): void {+ contextMenu.show(options);+}++export function hideContextMenu(): void {+ contextMenu.hide();+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex b28f6e57a..d09a79c21 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -79,6 +79,9 @@ importers:'@rollup/plugin-typescript':specifier: ^11.1.5+ minigame-api-typings:+ specifier: ^3.8.16+ version: 3.8.16rimraf:specifier: ^5.0.5version: 5.0.10@@ -328,66 +331,79 @@ packages:resolution: {integrity: sha512-F8sWbhZ7tyuEfsmOxwc2giKDQzN3+kuBLPwwZGyVkLlKGdV1nvnNwYD0fKQ8+XS6hp9nY7B+ZeK01EBUE7aHaw==}cpu: [arm]os: [linux]+ libc: [glibc]'@rollup/[email protected]':resolution: {integrity: sha512-rGfNUfn0GIeXtBP1wL5MnzSj98+PZe/AXaGBCRmT0ts80lU5CATYGxXukeTX39XBKsxzFpEeK+Mrp9faXOlmrw==}cpu: [arm]os: [linux]+ libc: [musl]'@rollup/[email protected]':resolution: {integrity: sha512-MMtej3YHWeg/0klK2Qodf3yrNzz6CGjo2UntLvk2RSPlhzgLvYEB3frRvbEF2wRKh1Z2fDIg9KRPe1fawv7C+g==}cpu: [arm64]os: [linux]+ libc: [glibc]'@rollup/[email protected]':resolution: {integrity: sha512-1a/qhaaOXhqXGpMFMET9VqwZakkljWHLmZOX48R0I/YLbhdxr1m4gtG1Hq7++VhVUmf+L3sTAf9op4JlhQ5u1Q==}cpu: [arm64]os: [linux]+ libc: [musl]'@rollup/[email protected]':resolution: {integrity: sha512-QWO6RQTZ/cqYtJMtxhkRkidoNGXc7ERPbZN7dVW5SdURuLeVU7lwKMpo18XdcmpWYd0qsP1bwKPf7DNSUinhvA==}cpu: [loong64]os: [linux]+ libc: [glibc]'@rollup/[email protected]':resolution: {integrity: sha512-xpObYIf+8gprgWaPP32xiN5RVTi/s5FCR+XMXSKmhfoJjrpRAjCuuqQXyxUa/eJTdAE6eJ+KDKaoEqjZQxh3Gw==}cpu: [loong64]os: [linux]+ libc: [musl]'@rollup/[email protected]':resolution: {integrity: sha512-4BrCgrpZo4hvzMDKRqEaW1zeecScDCR+2nZ86ATLhAoJ5FQ+lbHVD3ttKe74/c7tNT9c6F2viwB3ufwp01Oh2w==}cpu: [ppc64]os: [linux]+ libc: [glibc]'@rollup/[email protected]':resolution: {integrity: sha512-NOlUuzesGauESAyEYFSe3QTUguL+lvrN1HtwEEsU2rOwdUDeTMJdO5dUYl/2hKf9jWydJrO9OL/XSSf65R5+Xw==}cpu: [ppc64]os: [linux]+ libc: [musl]'@rollup/[email protected]':resolution: {integrity: sha512-ptA88htVp0AwUUqhVghwDIKlvJMD/fmL/wrQj99PRHFRAG6Z5nbWoWG4o81Nt9FT+IuqUQi+L31ZKAFeJ5Is+A==}cpu: [riscv64]os: [linux]+ libc: [glibc]'@rollup/[email protected]':resolution: {integrity: sha512-S51t7aMMTNdmAMPpBg7OOsTdn4tySRQvklmL3RpDRyknk87+Sp3xaumlatU+ppQ+5raY7sSTcC2beGgvhENfuw==}cpu: [riscv64]os: [linux]+ libc: [musl]'@rollup/[email protected]':resolution: {integrity: sha512-Bl00OFnVFkL82FHbEqy3k5CUCKH6OEJL54KCyx2oqsmZnFTR8IoNqBF+mjQVcRCT5sB6yOvK8A37LNm/kPJiZg==}cpu: [s390x]os: [linux]+ libc: [glibc]'@rollup/[email protected]':resolution: {integrity: sha512-ABca4ceT4N+Tv/GtotnWAeXZUZuM/9AQyCyKYyKnpk4yoA7QIAuBt6Hkgpw8kActYlew2mvckXkvx0FfoInnLg==}cpu: [x64]os: [linux]+ libc: [glibc]'@rollup/[email protected]':resolution: {integrity: sha512-HFps0JeGtuOR2convgRRkHCekD7j+gdAuXM+/i6kGzQtFhlCtQkpwtNzkNj6QhCDp7DRJ7+qC/1Vg2jt5iSOFw==}cpu: [x64]os: [linux]+ libc: [musl]'@rollup/[email protected]':resolution: {integrity: sha512-H+hXEv9gdVQuDTgnqD+SQffoWoc0Of59AStSzTEj/feWTBAnSfSD3+Dql1ZruJQxmykT/JVY0dE8Ka7z0DH1hw==}@@ -445,30 +461,35 @@ packages:engines: {node: '>= 10'}cpu: [arm64]os: [linux]+ libc: [glibc]'@tauri-apps/[email protected]':resolution: {integrity: sha512-GUoPdVJmrJRIXFfW3Rkt+eGK9ygOdyISACZfC/bCSfOnGt8kNdQIQr5WRH9QUaTVFIwxMlQyV3m+yXYP+xhSVA==}engines: {node: '>= 10'}cpu: [arm64]os: [linux]+ libc: [musl]'@tauri-apps/[email protected]':resolution: {integrity: sha512-JO7s3TlSxshwsoKNCDkyvsx5gw2QAs/Y2GbR5UE2d5kkU138ATKoPOtxn8G1fFT1aDW4LH0rYAAfBpGkDyJJnw==}engines: {node: '>= 10'}cpu: [riscv64]os: [linux]+ libc: [glibc]'@tauri-apps/[email protected]':resolution: {integrity: sha512-Uvh4SUUp4A6DVRSMWjelww0GnZI3PlVy7VS+DRF5napKuIehVjGl9XD0uKoCoxwAQBLctvipyEK+pDXpJeoHng==}engines: {node: '>= 10'}cpu: [x64]os: [linux]+ libc: [glibc]'@tauri-apps/[email protected]':resolution: {integrity: sha512-AP0KRK6bJuTpQ8kMNWvhIpKUkQJfcPFeba7QshOQZjJ8wOS6emwTN4K5g/d3AbCMo0RRdnZWwu67MlmtJyxC1Q==}engines: {node: '>= 10'}cpu: [x64]os: [linux]+ libc: [musl]'@tauri-apps/[email protected]':resolution: {integrity: sha512-97DXVU3dJystrq7W41IX+82JEorLNY+3+ECYxvXWqkq7DBN6FsA08x/EFGE8N/b0LTOui9X2dvpGGoeZKKV08g==}@@ -616,6 +637,9 @@ packages:resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}+ resolution: {integrity: sha512-xSxV1onUDkwBRRqxAQgu+Xct1Ose74Ol2ESefE/hUpxH+7oY/eAFUvEaQB8hKL/2TZNx4RMIduEZv4Z5cAuvYg==}+resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==}engines: {node: '>=16 || 14 >=14.17'}@@ -1145,6 +1169,8 @@ snapshots:dependencies:'@jridgewell/sourcemap-codec': 1.5.5+ [email protected]: {}+dependencies:brace-expansion: 2.0.2diff --git a/scripts/build-web-single.sh b/scripts/build-web-single.shnew file mode 100755index 000000000..4ca6b849c--- /dev/null+++ b/scripts/build-web-single.sh@@ -0,0 +1,24 @@+#!/bin/bash+set -e++cd "$(dirname "$0")/.."++BUILD_DIR=build-web-single++mkdir -p "$BUILD_DIR"+cd "$BUILD_DIR"++emcmake cmake .. -DES_BUILD_WEB=ON -DES_BUILD_TESTS=OFF -DES_BUILD_SINGLE_FILE=ON -DCMAKE_BUILD_TYPE=Release+emmake make esengine_single -j$(sysctl -n hw.ncpu)++echo ""+echo "Single-file SDK built:"+ls -la sdk/esengine.single.js++echo ""+echo "Bundling playable HTML..."+node "$(dirname "$0")/../tools/bundle-playable.js" --wasm sdk/esengine.single.js --game "$(dirname "$0")/../sdk/examples/playground/build/playable/game.js" --output sdk/playable.html++echo ""+echo "Final output:"+ls -la sdk/playable.htmldiff --git a/scripts/build-web.sh b/scripts/build-web.shnew file mode 100755index 000000000..38cdf3d9a--- /dev/null+++ b/scripts/build-web.sh@@ -0,0 +1,23 @@+#!/bin/bash+set -e++cd "$(dirname "$0")/.."++BUILD_DIR=build-web++mkdir -p "$BUILD_DIR"+cd "$BUILD_DIR"++emcmake cmake .. -DES_BUILD_WEB=ON -DES_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release+emmake make -j$(sysctl -n hw.ncpu)++echo ""+echo "Build complete: $BUILD_DIR/sdk/"+ls -la sdk/++echo ""+echo "Copying to desktop/public/wasm..."+mkdir -p ../desktop/public/wasm+cp -f sdk/esengine.js ../desktop/public/wasm/+cp -f sdk/esengine.wasm ../desktop/public/wasm/+echo "Done!"diff --git a/scripts/rebuild-web.sh b/scripts/rebuild-web.shnew file mode 100755index 000000000..1f9bc9fe1--- /dev/null+++ b/scripts/rebuild-web.sh@@ -0,0 +1,13 @@+#!/bin/bash+set -e++cd "$(dirname "$0")/.."++BUILD_DIR=build-web++if [ -d "$BUILD_DIR" ]; then+ echo "Removing existing build directory..."+ rm -rf "$BUILD_DIR"+fi++exec "$(dirname "$0")/build-web.sh"diff --git a/sdk/package-lock.json b/sdk/package-lock.jsonindex 1f162d4c4..a037110d7 100644--- a/sdk/package-lock.json+++ b/sdk/package-lock.json@@ -1,12 +1,12 @@{"name": "@esengine/sdk",- "version": "0.1.0",+ "version": "0.3.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@esengine/sdk",- "version": "0.1.0",+ "version": "0.3.0","license": "MIT","devDependencies": {"@rollup/plugin-typescript": "^11.1.5",