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.

chore: sync SDK dist files

esenginec67d66d5af94
diff --git a/desktop/public/sdk/cjs/index.wechat.js b/desktop/public/sdk/cjs/index.wechat.js
index 3030a5e76..7a1754f9c 100644
--- a/desktop/public/sdk/cjs/index.wechat.js
+++ b/desktop/public/sdk/cjs/index.wechat.js
@@ -483,16 +483,37 @@ function createComponentDef(name, defaults) {
}
};
}
+function getComponentRegistry() {
+ if (typeof window === 'undefined')
+ return new Map();
+ return (window.__esengine_componentRegistry ?? (window.__esengine_componentRegistry = new Map()));
+}
function defineComponent(name, defaults) {
+ const registry = getComponentRegistry();
+ const existing = registry.get(name);
+ if (existing)
+ return existing;
const def = createComponentDef(name, defaults);
+ registry.set(name, def);
registerToEditor(name, defaults, false);
return def;
}
function defineTag(name) {
+ const registry = getComponentRegistry();
+ const existing = registry.get(name);
+ if (existing)
+ return existing;
const def = createComponentDef(name, {});
+ registry.set(name, def);
registerToEditor(name, {}, true);
return def;
}
+function getUserComponent(name) {
+ return getComponentRegistry().get(name);
+}
+function clearUserComponents() {
+ getComponentRegistry().clear();
+}
function registerToEditor(name, defaults, isTag) {
if (typeof window !== 'undefined' && window.__esengine_registerComponent) {
window.__esengine_registerComponent(name, defaults, isTag);
@@ -591,10 +612,12 @@ const builtinComponents = {
SpineAnimation,
};
function getComponentDefaults(typeName) {
- const component = builtinComponents[typeName];
- if (component) {
- return { ...component._default };
- }
+ const builtin = builtinComponents[typeName];
+ if (builtin)
+ return { ...builtin._default };
+ const userComp = getUserComponent(typeName);
+ if (userComp)
+ return { ...userComp._default };
return null;
}
@@ -958,6 +981,23 @@ function defineSystem(params, fn, options) {
};
}
// =============================================================================
+// Global System Registration
+// =============================================================================
+function getPendingSystems() {
+ if (typeof window === 'undefined')
+ return [];
+ return (window.__esengine_pendingSystems ?? (window.__esengine_pendingSystems = []));
+}
+function addSystem(system) {
+ getPendingSystems().push({ schedule: Schedule.Update, system });
+}
+function addStartupSystem(system) {
+ getPendingSystems().push({ schedule: Schedule.Startup, system });
+}
+function addSystemToSchedule(schedule, system) {
+ getPendingSystems().push({ schedule, system });
+}
+// =============================================================================
// System Runner
// =============================================================================
class SystemRunner {
@@ -2954,6 +2994,17 @@ function createWebApp(module, options) {
app.addPlugin(textPlugin);
return app;
}
+function flushPendingSystems(app) {
+ if (typeof window === 'undefined')
+ return;
+ const pending = window.__esengine_pendingSystems;
+ if (!pending || pending.length === 0)
+ return;
+ for (const entry of pending) {
+ app.addSystemToSchedule(entry.schedule, entry.system);
+ }
+ pending.length = 0;
+}
// =============================================================================
// View-Projection Computation
// =============================================================================
@@ -3264,8 +3315,16 @@ function loadComponent(world, entity, compData) {
case 'UIRect':
world.insert(entity, UIRect, data);
break;
- default:
- console.warn(`Unknown component type: ${compData.type}`);
+ default: {
+ const userComp = getUserComponent(compData.type);
+ if (userComp) {
+ world.insert(entity, userComp, data);
+ }
+ else {
+ console.warn(`Unknown component type: ${compData.type}`);
+ }
+ break;
+ }
}
}
function updateCameraAspectRatio(world, aspectRatio) {
@@ -4179,5 +4238,5 @@ function isRuntime() {
initWeChatPlatform();
setPlatform(wechatAdapter);
-export { App, AssetPlugin, AssetServer, Assets, AsyncCache, BlendMode, Camera, Canvas, Children, Commands, CommandsInstance, DataType, Draw, EntityCommands, Geometry, INVALID_ENTITY, INVALID_TEXTURE, Input, LocalTransform, Material, MaterialLoader, Mut, Parent, PostProcess, PreviewPlugin, Query, QueryInstance, RenderPipeline, RenderStage, Renderer, Res, ResMut, Schedule, ShaderSources, SpineAnimation, SpineController, Sprite, SystemRunner, Text, TextAlign, TextOverflow, TextPlugin, TextRenderer, TextVerticalAlign, Time, UIRect, Velocity, World, WorldTransform, assetPlugin, clearDrawCallbacks, color, createSpineController, createWebApp, defineComponent, defineResource, defineSystem, defineTag, getComponentDefaults, getPlatform, getPlatformType, initDrawAPI, initGeometryAPI, initMaterialAPI, initPostProcessAPI, initRendererAPI, isBuiltinComponent, isEditor, isPlatformInitialized, isRuntime, isWeChat, isWeb, loadComponent, loadSceneData, loadSceneWithAssets, platformFetch, platformFileExists, platformInstantiateWasm, platformReadFile, platformReadTextFile, quat, registerDrawCallback, registerMaterialCallback, setEditorMode, shutdownDrawAPI, shutdownGeometryAPI, shutdownMaterialAPI, shutdownPostProcessAPI, shutdownRendererAPI, textPlugin, unregisterDrawCallback, updateCameraAspectRatio, vec2, vec3, vec4, wxFileExists, wxFileExistsSync, wxGetImagePixels, wxLoadImage, wxLoadImagePixels, wxReadFile, wxReadTextFile, wxWriteFile };
+export { App, AssetPlugin, AssetServer, Assets, AsyncCache, BlendMode, Camera, Canvas, Children, Commands, CommandsInstance, DataType, Draw, EntityCommands, Geometry, INVALID_ENTITY, INVALID_TEXTURE, Input, LocalTransform, Material, MaterialLoader, Mut, Parent, PostProcess, PreviewPlugin, Query, QueryInstance, RenderPipeline, RenderStage, Renderer, Res, ResMut, Schedule, ShaderSources, SpineAnimation, SpineController, Sprite, SystemRunner, Text, TextAlign, TextOverflow, TextPlugin, TextRenderer, TextVerticalAlign, Time, UIRect, Velocity, World, WorldTransform, addStartupSystem, addSystem, addSystemToSchedule, assetPlugin, clearDrawCallbacks, clearUserComponents, color, createSpineController, createWebApp, defineComponent, defineResource, defineSystem, defineTag, flushPendingSystems, getComponentDefaults, getPlatform, getPlatformType, getUserComponent, initDrawAPI, initGeometryAPI, initMaterialAPI, initPostProcessAPI, initRendererAPI, isBuiltinComponent, isEditor, isPlatformInitialized, isRuntime, isWeChat, isWeb, loadComponent, loadSceneData, loadSceneWithAssets, platformFetch, platformFileExists, platformInstantiateWasm, platformReadFile, platformReadTextFile, quat, registerDrawCallback, registerMaterialCallback, setEditorMode, shutdownDrawAPI, shutdownGeometryAPI, shutdownMaterialAPI, shutdownPostProcessAPI, shutdownRendererAPI, textPlugin, unregisterDrawCallback, updateCameraAspectRatio, vec2, vec3, vec4, wxFileExists, wxFileExistsSync, wxGetImagePixels, wxLoadImage, wxLoadImagePixels, wxReadFile, wxReadTextFile, wxWriteFile };
//# sourceMappingURL=index.wechat.js.map
diff --git a/desktop/public/sdk/esm/esengine.d.ts b/desktop/public/sdk/esm/esengine.d.ts
index b50e4ba13..733db4c3c 100644
--- a/desktop/public/sdk/esm/esengine.d.ts
+++ b/desktop/public/sdk/esm/esengine.d.ts
@@ -48,6 +48,8 @@ interface ComponentDef<T> {
}
declare function defineComponent<T extends object>(name: string, defaults: T): ComponentDef<T>;
declare function defineTag(name: string): ComponentDef<{}>;
+declare function getUserComponent(name: string): ComponentDef<any> | undefined;
+declare function clearUserComponents(): void;
interface BuiltinComponentDef<T> {
readonly _id: symbol;
readonly _name: string;
@@ -500,6 +502,9 @@ interface SystemDef {
declare function defineSystem<P extends readonly SystemParam[]>(params: [...P], fn: (...args: InferParams<P>) => void, options?: {
name?: string;
}): SystemDef;
+declare function addSystem(system: SystemDef): void;
+declare function addStartupSystem(system: SystemDef): void;
+declare function addSystemToSchedule(schedule: Schedule, system: SystemDef): void;
declare class SystemRunner {
private readonly world_;
private readonly resources_;
@@ -550,6 +555,7 @@ interface WebAppOptions {
glContextHandle?: number;
}
declare function createWebApp(module: ESEngineModule, options?: WebAppOptions): App;
+declare function flushPendingSystems(app: App): void;
declare enum TextAlign {
Left = 0,
@@ -1676,5 +1682,5 @@ declare function setEditorMode(active: boolean): void;
declare function isEditor(): boolean;
declare function isRuntime(): boolean;
-export { App, AssetPlugin, AssetServer, Assets, AsyncCache, BlendMode, Camera, Canvas, Children, Commands, CommandsInstance, DataType, Draw, EntityCommands, Geometry, INVALID_ENTITY, INVALID_TEXTURE, Input, LocalTransform, Material, MaterialLoader, Mut, Parent, PostProcess, PreviewPlugin, Query, QueryInstance, RenderPipeline, RenderStage, Renderer, Res, ResMut, ResMutInstance, Schedule, ShaderSources, SpineAnimation, SpineController, Sprite, SystemRunner, Text, TextAlign, TextOverflow, TextPlugin, TextRenderer, TextVerticalAlign, Time, UIRect, Velocity, World, WorldTransform, assetPlugin, clearDrawCallbacks, color, createSpineController, createWebApp, defineComponent, defineResource, defineSystem, defineTag, getComponentDefaults, getPlatform, getPlatformType, initDrawAPI, initGeometryAPI, initMaterialAPI, initPostProcessAPI, initRendererAPI, isBuiltinComponent, isEditor, isPlatformInitialized, isRuntime, isWeChat, isWeb, loadComponent, loadSceneData, loadSceneWithAssets, platformFetch, platformFileExists, platformInstantiateWasm, platformReadFile, platformReadTextFile, quat, registerDrawCallback, registerMaterialCallback, setEditorMode, shutdownDrawAPI, shutdownGeometryAPI, shutdownMaterialAPI, shutdownPostProcessAPI, shutdownRendererAPI, textPlugin, unregisterDrawCallback, updateCameraAspectRatio, vec2, vec3, vec4 };
+export { App, AssetPlugin, AssetServer, Assets, AsyncCache, BlendMode, Camera, Canvas, Children, Commands, CommandsInstance, DataType, Draw, EntityCommands, Geometry, INVALID_ENTITY, INVALID_TEXTURE, Input, LocalTransform, Material, MaterialLoader, Mut, Parent, PostProcess, PreviewPlugin, Query, QueryInstance, RenderPipeline, RenderStage, Renderer, Res, ResMut, ResMutInstance, Schedule, ShaderSources, SpineAnimation, SpineController, Sprite, SystemRunner, Text, TextAlign, TextOverflow, TextPlugin, TextRenderer, TextVerticalAlign, Time, UIRect, Velocity, World, WorldTransform, addStartupSystem, addSystem, addSystemToSchedule, assetPlugin, clearDrawCallbacks, clearUserComponents, color, createSpineController, createWebApp, defineComponent, defineResource, defineSystem, defineTag, flushPendingSystems, getComponentDefaults, getPlatform, getPlatformType, getUserComponent, initDrawAPI, initGeometryAPI, initMaterialAPI, initPostProcessAPI, initRendererAPI, isBuiltinComponent, isEditor, isPlatformInitialized, isRuntime, isWeChat, isWeb, loadComponent, loadSceneData, loadSceneWithAssets, platformFetch, platformFileExists, platformInstantiateWasm, platformReadFile, platformReadTextFile, quat, registerDrawCallback, registerMaterialCallback, setEditorMode, shutdownDrawAPI, shutdownGeometryAPI, shutdownMaterialAPI, shutdownPostProcessAPI, shutdownRendererAPI, textPlugin, unregisterDrawCallback, updateCameraAspectRatio, vec2, vec3, vec4 };
export type { AnyComponentDef, AssetBundle, AssetManifest, AssetsData, BuiltinComponentDef, CameraData, CanvasData, ChildrenData, Color, CommandsDescriptor, ComponentData, ComponentDef, CppRegistry, CppResourceManager, DrawAPI, DrawCallback, ESEngineModule, Entity, FileLoadOptions, GeometryHandle, GeometryOptions, InferParam, InferParams, InputState, LoadedMaterial, LocalTransformData, MaterialAssetData, MaterialHandle, MaterialOptions, MutWrapper, ParentData, PlatformAdapter, PlatformRequestOptions, PlatformResponse, PlatformType, Plugin, Quat, QueryDescriptor, QueryResult, RenderParams, RenderStats, RenderTargetHandle, ResDescriptor, ResMutDescriptor, ResourceDef, SceneComponentData, SceneData, SceneEntityData, SceneLoadOptions, ShaderHandle, ShaderLoader, SliceBorder, SpineAnimationData, SpineDescriptor, SpineEvent, SpineEventCallback, SpineEventType, SpineLoadResult, SpriteData, SystemDef, SystemParam, TextData, TextRenderResult, TextureHandle, TextureInfo, TimeData, TrackEntryInfo, UIRectData, UniformValue, Vec2, Vec3, Vec4, VelocityData, VertexAttributeDescriptor, WebAppOptions, WorldTransformData };
diff --git a/desktop/public/sdk/esm/esengine.js b/desktop/public/sdk/esm/esengine.js
index 797cde8b0..23a390767 100644
--- a/desktop/public/sdk/esm/esengine.js
+++ b/desktop/public/sdk/esm/esengine.js
@@ -173,16 +173,37 @@ function createComponentDef(name, defaults) {
}
};
}
+function getComponentRegistry() {
+ if (typeof window === 'undefined')
+ return new Map();
+ return (window.__esengine_componentRegistry ?? (window.__esengine_componentRegistry = new Map()));
+}
function defineComponent(name, defaults) {
+ const registry = getComponentRegistry();
+ const existing = registry.get(name);
+ if (existing)
+ return existing;
const def = createComponentDef(name, defaults);
+ registry.set(name, def);
registerToEditor(name, defaults, false);
return def;
}
function defineTag(name) {
+ const registry = getComponentRegistry();
+ const existing = registry.get(name);
+ if (existing)
+ return existing;
const def = createComponentDef(name, {});
+ registry.set(name, def);
registerToEditor(name, {}, true);
return def;
}
+function getUserComponent(name) {
+ return getComponentRegistry().get(name);
+}
+function clearUserComponents() {
+ getComponentRegistry().clear();
+}
function registerToEditor(name, defaults, isTag) {
if (typeof window !== 'undefined' && window.__esengine_registerComponent) {
window.__esengine_registerComponent(name, defaults, isTag);
@@ -281,10 +302,12 @@ const builtinComponents = {
SpineAnimation,
};
function getComponentDefaults(typeName) {
- const component = builtinComponents[typeName];
- if (component) {
- return { ...component._default };
- }
+ const builtin = builtinComponents[typeName];
+ if (builtin)
+ return { ...builtin._default };
+ const userComp = getUserComponent(typeName);
+ if (userComp)
+ return { ...userComp._default };
return null;
}
@@ -648,6 +671,23 @@ function defineSystem(params, fn, options) {
};
}
// =============================================================================
+// Global System Registration
+// =============================================================================
+function getPendingSystems() {
+ if (typeof window === 'undefined')
+ return [];
+ return (window.__esengine_pendingSystems ?? (window.__esengine_pendingSystems = []));
+}
+function addSystem(system) {
+ getPendingSystems().push({ schedule: Schedule.Update, system });
+}
+function addStartupSystem(system) {
+ getPendingSystems().push({ schedule: Schedule.Startup, system });
+}
+function addSystemToSchedule(schedule, system) {
+ getPendingSystems().push({ schedule, system });
+}
+// =============================================================================
// System Runner
// =============================================================================
class SystemRunner {
@@ -2644,6 +2684,17 @@ function createWebApp(module, options) {
app.addPlugin(textPlugin);
return app;
}
+function flushPendingSystems(app) {
+ if (typeof window === 'undefined')
+ return;
+ const pending = window.__esengine_pendingSystems;
+ if (!pending || pending.length === 0)
+ return;
+ for (const entry of pending) {
+ app.addSystemToSchedule(entry.schedule, entry.system);
+ }
+ pending.length = 0;
+}
// =============================================================================
// View-Projection Computation
// =============================================================================
@@ -2954,8 +3005,16 @@ function loadComponent(world, entity, compData) {
case 'UIRect':
world.insert(entity, UIRect, data);
break;
- default:
- console.warn(`Unknown component type: ${compData.type}`);
+ default: {
+ const userComp = getUserComponent(compData.type);
+ if (userComp) {
+ world.insert(entity, userComp, data);
+ }
+ else {
+ console.warn(`Unknown component type: ${compData.type}`);
+ }
+ break;
+ }
}
}
function updateCameraAspectRatio(world, aspectRatio) {
@@ -3868,5 +3927,5 @@ function isRuntime() {
// Initialize Web platform
setPlatform(webAdapter);
-export { App, AssetPlugin, AssetServer, Assets, AsyncCache, BlendMode, Camera, Canvas, Children, Commands, CommandsInstance, DataType, Draw, EntityCommands, Geometry, INVALID_ENTITY, INVALID_TEXTURE, Input, LocalTransform, Material, MaterialLoader, Mut, Parent, PostProcess, PreviewPlugin, Query, QueryInstance, RenderPipeline, RenderStage, Renderer, Res, ResMut, Schedule, ShaderSources, SpineAnimation, SpineController, Sprite, SystemRunner, Text, TextAlign, TextOverflow, TextPlugin, TextRenderer, TextVerticalAlign, Time, UIRect, Velocity, World, WorldTransform, assetPlugin, clearDrawCallbacks, color, createSpineController, createWebApp, defineComponent, defineResource, defineSystem, defineTag, getComponentDefaults, getPlatform, getPlatformType, initDrawAPI, initGeometryAPI, initMaterialAPI, initPostProcessAPI, initRendererAPI, isBuiltinComponent, isEditor, isPlatformInitialized, isRuntime, isWeChat, isWeb, loadComponent, loadSceneData, loadSceneWithAssets, platformFetch, platformFileExists, platformInstantiateWasm, platformReadFile, platformReadTextFile, quat, registerDrawCallback, registerMaterialCallback, setEditorMode, shutdownDrawAPI, shutdownGeometryAPI, shutdownMaterialAPI, shutdownPostProcessAPI, shutdownRendererAPI, textPlugin, unregisterDrawCallback, updateCameraAspectRatio, vec2, vec3, vec4 };
+export { App, AssetPlugin, AssetServer, Assets, AsyncCache, BlendMode, Camera, Canvas, Children, Commands, CommandsInstance, DataType, Draw, EntityCommands, Geometry, INVALID_ENTITY, INVALID_TEXTURE, Input, LocalTransform, Material, MaterialLoader, Mut, Parent, PostProcess, PreviewPlugin, Query, QueryInstance, RenderPipeline, RenderStage, Renderer, Res, ResMut, Schedule, ShaderSources, SpineAnimation, SpineController, Sprite, SystemRunner, Text, TextAlign, TextOverflow, TextPlugin, TextRenderer, TextVerticalAlign, Time, UIRect, Velocity, World, WorldTransform, addStartupSystem, addSystem, addSystemToSchedule, assetPlugin, clearDrawCallbacks, clearUserComponents, color, createSpineController, createWebApp, defineComponent, defineResource, defineSystem, defineTag, flushPendingSystems, getComponentDefaults, getPlatform, getPlatformType, getUserComponent, initDrawAPI, initGeometryAPI, initMaterialAPI, initPostProcessAPI, initRendererAPI, isBuiltinComponent, isEditor, isPlatformInitialized, isRuntime, isWeChat, isWeb, loadComponent, loadSceneData, loadSceneWithAssets, platformFetch, platformFileExists, platformInstantiateWasm, platformReadFile, platformReadTextFile, quat, registerDrawCallback, registerMaterialCallback, setEditorMode, shutdownDrawAPI, shutdownGeometryAPI, shutdownMaterialAPI, shutdownPostProcessAPI, shutdownRendererAPI, textPlugin, unregisterDrawCallback, updateCameraAspectRatio, vec2, vec3, vec4 };
//# sourceMappingURL=index.js.map