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(sdk): unify subsystem runtime access — Res(Spine), Res(Tilemaps), public UI composition

yhh8c8403543056
diff --git a/sdk/src/core-content.ts b/sdk/src/core-content.ts
index 0c6398124..87b7281e1 100644
--- a/sdk/src/core-content.ts
+++ b/sdk/src/core-content.ts
@@ -311,6 +311,7 @@ export {
Tilemap,
TilemapLayer,
TilemapAPI,
+ Tilemaps,
initTilemapAPI,
shutdownTilemapAPI,
TilemapPlugin,
diff --git a/sdk/src/core-ui.ts b/sdk/src/core-ui.ts
index de97988e1..155ecabbe 100644
--- a/sdk/src/core-ui.ts
+++ b/sdk/src/core-ui.ts
@@ -87,3 +87,58 @@ export {
type ThemeTokens,
type ThemeColors,
} from './ui';
+
+// ─── UI code-composition surface ─────────────────────────────────────────────
+// Promoted so UI can be built in code, not just authored in the editor:
+// flexbox config, dimension helpers, node/visual/text builders, and the widget
+// factories.
+export {
+ // Dimensions
+ px,
+ percent,
+ auto,
+ isAuto,
+ DimensionUnit,
+ type Dimension,
+ // UINode layout enums
+ UIPositionType,
+ AlignSelf,
+ // Flex container
+ FlexContainer,
+ FlexDirection,
+ FlexWrap,
+ JustifyContent,
+ AlignItems,
+ AlignContent,
+ type FlexContainerData,
+ // Builders
+ buildUINode,
+ buildUIVisual,
+ buildText,
+ spawnUIEntity,
+ setUIVisible,
+ type UINodeInit,
+ type UIVisualInit,
+ type TextInit,
+ type UIEntityInit,
+ // Widget factories
+ createButton,
+ setButtonState,
+ type ButtonOptions,
+ type ButtonStateVisual,
+ createToggle,
+ type ToggleOptions,
+ type ToggleHandle,
+ createSlider,
+ type SliderOptions,
+ type SliderHandle,
+ createProgress,
+ type ProgressOptions,
+ type ProgressHandle,
+ createDialog,
+ type DialogOptions,
+ type DialogHandle,
+ createDropdown,
+ type DropdownOptions,
+ type DropdownHandle,
+} from './ui';
diff --git a/sdk/src/spine/SpinePlugin.ts b/sdk/src/spine/SpinePlugin.ts
index de1685cd3..3d1d896fd 100644
--- a/sdk/src/spine/SpinePlugin.ts
+++ b/sdk/src/spine/SpinePlugin.ts
@@ -30,6 +30,13 @@ export interface SpineEventsData {
export const SpineEvents = defineResource<SpineEventsData>({ events: [] }, 'SpineEvents');
+/**
+ * Public runtime spine API. Present once the app has a {@link SpineManager}
+ * (a realm with the spine side-module). Read it with `Res(Spine)` to control
+ * playback — `setAnimation` / `setSkin` / `setMixDuration` / `getAnimations` / etc.
+ */
+export const Spine = defineResource<SpineManager>(null!, 'Spine');
+
const SPINE_TYPE_MAP: Record<number, SpineEventType | null> = {
0: 'start',
1: 'interrupt',
@@ -60,6 +67,7 @@ export class SpinePlugin implements Plugin {
this.spineManager_ = manager;
if (this.app_) {
const app = this.app_;
+ app.insertResource(Spine, manager);
const pipeline = app.pipeline;
pipeline?.addPreFlushCallback((registry) => {
manager.submitMeshes(registry._cpp);
@@ -87,6 +95,10 @@ export class SpinePlugin implements Plugin {
app.insertResource(SpineEvents, { events: [] });
+ if (this.spineManager_) {
+ app.insertResource(Spine, this.spineManager_);
+ }
+
this.despawnUnsub_ = app.world.onDespawn((entity: Entity) => {
this.spineManager_?.removeEntity(entity);
});
diff --git a/sdk/src/spine/index.ts b/sdk/src/spine/index.ts
index 9b9a7acf9..edd795b8a 100644
--- a/sdk/src/spine/index.ts
+++ b/sdk/src/spine/index.ts
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
-export { SpinePlugin, SpineEvents } from './SpinePlugin';
+export { SpinePlugin, SpineEvents, Spine } from './SpinePlugin';
export type { SpineEvent, SpineEventType, SpineEventsData } from './SpinePlugin';
export { SpineManager } from './SpineManager';
export type { SpineVersion } from './SpineManager';
diff --git a/sdk/src/tilemap/index.ts b/sdk/src/tilemap/index.ts
index 1341ae94a..d472981e6 100644
--- a/sdk/src/tilemap/index.ts
+++ b/sdk/src/tilemap/index.ts
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
export { Tilemap, TilemapLayer, type TilemapData, type TilemapLayerData } from './components';
-export { TilemapAPI, initTilemapAPI, shutdownTilemapAPI } from './tilemapAPI';
+export { TilemapAPI, Tilemaps, initTilemapAPI, shutdownTilemapAPI } from './tilemapAPI';
export { TilemapPlugin, tilemapPlugin } from './tilemapPlugin';
export {
parseTiledMap, parseTmjJson, loadTiledMap, loadTiledCollisionObjects,
diff --git a/sdk/src/tilemap/tilemapAPI.ts b/sdk/src/tilemap/tilemapAPI.ts
index e858c32d5..08b582f5e 100644
--- a/sdk/src/tilemap/tilemapAPI.ts
+++ b/sdk/src/tilemap/tilemapAPI.ts
@@ -3,6 +3,7 @@
import type { ESEngineModule } from '../wasm';
import { withMalloc } from '../wasmScratch';
import { CoreApiBridge } from '../CoreApiBridge';
+import { defineResource } from '../resource';
interface TilemapModule {
tilemap_initLayer(entity: number, width: number, height: number,
@@ -274,3 +275,10 @@ export const TilemapAPI = {
return module_?.tilemap_importChunks?.(entity, encoded) ?? false;
},
};
+
+/**
+ * Public runtime tilemap API as a resource, so it is reached the same way as
+ * the other subsystems — read it with `Res(Tilemaps)`. Wraps the
+ * {@link TilemapAPI} singleton (still exported for direct use).
+ */
+export const Tilemaps = defineResource<typeof TilemapAPI>(TilemapAPI, 'Tilemaps');