Skip to content

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.

feat: add extension registry lock/clear and editor infrastructure improvements

esengine064a12c81233
diff --git a/editor/rollup.config.js b/editor/rollup.config.js
index 8fcdecab8..1d6041dd9 100644
--- a/editor/rollup.config.js
+++ b/editor/rollup.config.js
@@ -13,6 +13,7 @@ export default [
output: {
file: 'dist/index.js',
format: 'es',
+ sourcemap: true,
},
external: ['esengine'],
plugins: [
diff --git a/editor/src/gizmos/GizmoRegistry.ts b/editor/src/gizmos/GizmoRegistry.ts
index c7331b7d6..fa33ff66c 100644
--- a/editor/src/gizmos/GizmoRegistry.ts
+++ b/editor/src/gizmos/GizmoRegistry.ts
@@ -29,11 +29,22 @@ export interface GizmoDescriptor {
}
const gizmos = new Map<string, GizmoDescriptor>();
+const builtinGizmoIds = new Set<string>();
export function registerGizmo(descriptor: GizmoDescriptor): void {
gizmos.set(descriptor.id, descriptor);
}
+export function lockBuiltinGizmos(): void {
+ for (const id of gizmos.keys()) builtinGizmoIds.add(id);
+}
+
+export function clearExtensionGizmos(): void {
+ for (const id of gizmos.keys()) {
+ if (!builtinGizmoIds.has(id)) gizmos.delete(id);
+ }
+}
+
export function getGizmo(id: string): GizmoDescriptor | undefined {
return gizmos.get(id);
}
diff --git a/editor/src/gizmos/index.ts b/editor/src/gizmos/index.ts
index 041917c42..9a928ec29 100644
--- a/editor/src/gizmos/index.ts
+++ b/editor/src/gizmos/index.ts
@@ -4,6 +4,8 @@ export {
registerGizmo,
getGizmo,
getAllGizmos,
+ lockBuiltinGizmos,
+ clearExtensionGizmos,
} from './GizmoRegistry';
export { GizmoManager } from './GizmoManager';
diff --git a/editor/src/index.ts b/editor/src/index.ts
index 23b7f92cc..509a78d70 100644
--- a/editor/src/index.ts
+++ b/editor/src/index.ts
@@ -330,3 +330,35 @@ export {
EditorExportService,
type ExtensionLoaderOptions,
} from './extension';
+
+// =============================================================================
+// SDK Re-exports (for @esengine/editor shim)
+// =============================================================================
+
+export {
+ Draw,
+ BlendMode,
+ type DrawAPI,
+ Geometry,
+ DataType,
+ type GeometryHandle,
+ type GeometryOptions,
+ type VertexAttributeDescriptor,
+ Material,
+ ShaderSources,
+ type ShaderHandle,
+ type MaterialHandle,
+ type MaterialOptions,
+ type UniformValue,
+ PostProcess,
+ Renderer,
+ RenderStage,
+ type RenderTargetHandle,
+ type RenderStats,
+ RenderPipeline,
+ type RenderParams,
+ registerDrawCallback,
+ unregisterDrawCallback,
+ clearDrawCallbacks,
+ type DrawCallback,
+} from 'esengine';
diff --git a/editor/src/launcher/ProjectService.ts b/editor/src/launcher/ProjectService.ts
index d7934bf0c..77ac23e46 100644
--- a/editor/src/launcher/ProjectService.ts
+++ b/editor/src/launcher/ProjectService.ts
@@ -231,18 +231,12 @@ export async function openProject(
return { success: false, error: 'Invalid project file format' };
}
- // Update SDK if needed
const projectDir = projectPath.replace(/\/[^/]+\.esproject$/, '');
const sdkService = new SdkExportService();
- if (await sdkService.needsUpdate(projectDir)) {
- await sdkService.exportToProject(projectDir);
- }
+ await sdkService.exportToProject(projectDir);
- // Update editor types if needed
const editorExportService = new EditorExportService();
- if (await editorExportService.needsUpdate(projectDir)) {
- await editorExportService.exportToProject(projectDir);
- }
+ await editorExportService.exportToProject(projectDir);
// Update recent projects
addRecentProject({
diff --git a/editor/src/menus/MenuRegistry.ts b/editor/src/menus/MenuRegistry.ts
index bf217c194..6c6fc2b5f 100644
--- a/editor/src/menus/MenuRegistry.ts
+++ b/editor/src/menus/MenuRegistry.ts
@@ -26,6 +26,9 @@ export interface StatusbarItemDescriptor {
const menus = new Map<string, MenuDescriptor>();
const menuItems = new Map<string, MenuItemDescriptor[]>();
const statusbarItems = new Map<string, StatusbarItemDescriptor>();
+const builtinMenuIds = new Set<string>();
+const builtinMenuItemIds = new Set<string>();
+const builtinStatusbarIds = new Set<string>();
export function registerMenu(descriptor: MenuDescriptor): void {
menus.set(descriptor.id, descriptor);
@@ -37,6 +40,7 @@ export function registerMenu(descriptor: MenuDescriptor): void {
export function registerMenuItem(item: MenuItemDescriptor): void {
const items = menuItems.get(item.menu);
if (items) {
+ if (items.some(i => i.id === item.id)) return;
items.push(item);
} else {
menuItems.set(item.menu, [item]);
@@ -47,6 +51,26 @@ export function registerStatusbarItem(item: StatusbarItemDescriptor): void {
statusbarItems.set(item.id, item);
}
+export function lockBuiltinMenus(): void {
+ for (const id of menus.keys()) builtinMenuIds.add(id);
+ for (const items of menuItems.values()) {
+ for (const item of items) builtinMenuItemIds.add(item.id);
+ }
+ for (const id of statusbarItems.keys()) builtinStatusbarIds.add(id);
+}
+
+export function clearExtensionMenus(): void {
+ for (const id of menus.keys()) {
+ if (!builtinMenuIds.has(id)) menus.delete(id);
+ }
+ for (const [menuId, items] of menuItems.entries()) {
+ menuItems.set(menuId, items.filter(i => builtinMenuItemIds.has(i.id)));
+ }
+ for (const id of statusbarItems.keys()) {
+ if (!builtinStatusbarIds.has(id)) statusbarItems.delete(id);
+ }
+}
+
export function getAllMenus(): MenuDescriptor[] {
return Array.from(menus.values()).sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
}
diff --git a/editor/src/panels/OutputPanel.ts b/editor/src/panels/OutputPanel.ts
index 9003b72aa..a81235e8b 100644
--- a/editor/src/panels/OutputPanel.ts
+++ b/editor/src/panels/OutputPanel.ts
@@ -4,6 +4,10 @@ import { icons } from '../utils/icons';
export class OutputPanel implements PanelInstance {
private container_: HTMLElement;
private contentEl_: HTMLElement | null = null;
+ private lastText_: string = '';
+ private lastType_: string = '';
+ private lastLine_: HTMLElement | null = null;
+ private repeatCount_ = 0;
constructor(container: HTMLElement) {
this.container_ = container;
@@ -16,16 +20,38 @@ export class OutputPanel implements PanelInstance {
const empty = this.contentEl_.querySelector('.es-output-empty');
if (empty) empty.remove();
+ if (text === this.lastText_ && type === this.lastType_ && this.lastLine_) {
+ this.repeatCount_++;
+ let badge = this.lastLine_.querySelector('.es-output-badge') as HTMLElement;
+ if (!badge) {
+ badge = document.createElement('span');
+ badge.className = 'es-output-badge';
+ this.lastLine_.prepend(badge);
+ }
+ badge.textContent = String(this.repeatCount_);
+ this.contentEl_.scrollTop = this.contentEl_.scrollHeight;
+ return;
+ }
+
+ this.lastText_ = text;
+ this.lastType_ = type;
+ this.repeatCount_ = 1;
+
const line = document.createElement('div');
line.className = `es-output-line es-output-${type}`;
line.textContent = text;
this.contentEl_.appendChild(line);
+ this.lastLine_ = line;
this.contentEl_.scrollTop = this.contentEl_.scrollHeight;
}
clear(): void {
if (!this.contentEl_) return;
this.contentEl_.innerHTML = '<div class="es-output-empty">No output messages</div>';
+ this.lastText_ = '';
+ this.lastType_ = '';
+ this.lastLine_ = null;
+ this.repeatCount_ = 0;
}
dispose(): void {
diff --git a/editor/src/scripting/ScriptLoader.ts b/editor/src/scripting/ScriptLoader.ts
index 69a618f7b..97f0b7c64 100644
--- a/editor/src/scripting/ScriptLoader.ts
+++ b/editor/src/scripting/ScriptLoader.ts
@@ -122,6 +122,7 @@ export class ScriptLoader {
bundle: true,
format: 'esm',
write: false,
+ sourcemap: 'inline',
platform: 'browser',
target: 'es2020',
external: ['esengine'],
@@ -149,14 +150,17 @@ export class ScriptLoader {
console.log('ScriptLoader: Scripts compiled successfully');
this.onCompileSuccess_?.();
return true;
- } catch (err) {
+ } catch (err: any) {
console.error('ScriptLoader: Compilation failed:', err);
- const errors: CompileError[] = [{
- file: 'unknown',
- line: 0,
- column: 0,
- message: String(err),
- }];
+ const esbuildErrors = err?.errors as esbuild.Message[] | undefined;
+ const errors: CompileError[] = esbuildErrors?.length
+ ? esbuildErrors.map(e => ({
+ file: e.location?.file || 'unknown',
+ line: e.location?.line || 0,
+ column: e.location?.column || 0,
+ message: e.text,
+ }))
+ : [{ file: 'unknown', line: 0, column: 0, message: String(err) }];
this.onCompileError_?.(errors);
return false;
}
diff --git a/editor/src/scripting/types.ts b/editor/src/scripting/types.ts
index d59e30e46..371390a49 100644
--- a/editor/src/scripting/types.ts
+++ b/editor/src/scripting/types.ts
@@ -54,6 +54,7 @@ export interface NativeFS {
getSdkWasmJs(): Promise<string>;
getSdkWasmDts(): Promise<string>;
getEditorDts(): Promise<string>;
+ toAssetUrl?(path: string): string;
}
// =============================================================================
diff --git a/editor/src/styles/editor.css b/editor/src/styles/editor.css
index 0859aaa95..bb74f02a2 100644
--- a/editor/src/styles/editor.css
+++ b/editor/src/styles/editor.css
@@ -3508,6 +3508,23 @@ svg {
word-break: break-all;
}
+.es-output-badge {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ min-width: 18px;
+ height: 16px;
+ padding: 0 5px;
+ margin-right: 6px;
+ border-radius: 8px;
+ background: var(--es-accent);
+ color: #fff;
+ font-size: 10px;
+ font-weight: 600;
+ line-height: 1;
+ vertical-align: middle;
+}
+
.es-output-command {
color: var(--es-accent);
font-weight: 500;
diff --git a/editor/src/types/ProjectTypes.ts b/editor/src/types/ProjectTypes.ts
index 06d951999..2f6d081ea 100644
--- a/editor/src/types/ProjectTypes.ts
+++ b/editor/src/types/ProjectTypes.ts
@@ -67,4 +67,4 @@ export const PROJECT_TEMPLATES: ProjectTemplateInfo[] = [
export const PROJECT_FILE_EXTENSION = '.esproject';
export const SCENE_FILE_EXTENSION = '.esscene';
export const ENGINE_VERSION = '0.1.0';
-export const SDK_VERSION = '0.3.0';
+export const SDK_VERSION = '0.4.0';