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.

refactor(ui): delete TS mirrors and plugins for removed components

esengine6df47c171aaa
diff --git a/sdk/src/core.ts b/sdk/src/core.ts
index 45b3bfa6b..3357e0d5d 100644
--- a/sdk/src/core.ts
+++ b/sdk/src/core.ts
@@ -353,11 +353,8 @@ export {
ItemPool,
LinearLayout,
GridLayout,
- FanLayout,
LinearLayoutProvider,
GridLayoutProvider,
- FanLayoutProvider,
- computeFanPositions,
collectionGetItemEntity,
collectionRefreshItems,
collectionRefreshItem,
@@ -370,7 +367,6 @@ export {
type CollectionLayoutResult,
type LinearLayoutData,
type GridLayoutData,
- type FanLayoutData,
intersectRects,
invertMatrix4,
screenToWorld,
@@ -379,8 +375,6 @@ export {
quaternionToAngle2D,
Interactable,
UIInteraction,
- Selectable,
- type SelectableData,
AnimOverride,
Button,
ButtonState,
diff --git a/sdk/src/ui/FanLayoutPlugin.ts b/sdk/src/ui/FanLayoutPlugin.ts
deleted file mode 100644
index 2be6bb271..000000000
--- a/sdk/src/ui/FanLayoutPlugin.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import type { App, Plugin } from '../app';
-import { registerComponent } from '../component';
-import { FanLayout } from './layouts/FanLayout';
-import { PluginName } from '../systemLabels';
-
-export class FanLayoutPlugin implements Plugin {
- name = PluginName.FanLayout;
-
- build(_app: App): void {
- registerComponent('FanLayout', FanLayout);
- }
-}
-
-export const fanLayoutPlugin = new FanLayoutPlugin();
diff --git a/sdk/src/ui/LayoutGroup.ts b/sdk/src/ui/LayoutGroup.ts
deleted file mode 100644
index 1e44eb2de..000000000
--- a/sdk/src/ui/LayoutGroup.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { defineBuiltin } from '../component';
-import type { Padding } from '../wasm.generated';
-
-export const LayoutDirection = {
- Horizontal: 0,
- Vertical: 1,
-} as const;
-
-export type LayoutDirection = (typeof LayoutDirection)[keyof typeof LayoutDirection];
-
-export const ChildAlignment = {
- Start: 0,
- Center: 1,
- End: 2,
-} as const;
-
-export type ChildAlignment = (typeof ChildAlignment)[keyof typeof ChildAlignment];
-
-export interface LayoutGroupData {
- direction: number;
- spacing: number;
- padding: Padding;
- childAlignment: number;
- reverseOrder: boolean;
-}
-
-export const LayoutGroup = defineBuiltin<LayoutGroupData>('LayoutGroup', {
- direction: LayoutDirection.Horizontal,
- spacing: 0,
- padding: { left: 0, top: 0, right: 0, bottom: 0 },
- childAlignment: ChildAlignment.Start,
- reverseOrder: false,
-});
diff --git a/sdk/src/ui/LayoutGroupPlugin.ts b/sdk/src/ui/LayoutGroupPlugin.ts
deleted file mode 100644
index 9e8960b38..000000000
--- a/sdk/src/ui/LayoutGroupPlugin.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import type { App, Plugin } from '../app';
-import { registerComponent } from '../component';
-import { LayoutGroup } from './LayoutGroup';
-import { PluginName } from '../systemLabels';
-
-export class LayoutGroupPlugin implements Plugin {
- name = PluginName.LayoutGroup;
- dependencies = [PluginName.UILayout];
-
- build(_app: App): void {
- registerComponent('LayoutGroup', LayoutGroup);
- }
-}
-
-export const layoutGroupPlugin = new LayoutGroupPlugin();
diff --git a/sdk/src/ui/Selectable.ts b/sdk/src/ui/Selectable.ts
deleted file mode 100644
index c6eb67468..000000000
--- a/sdk/src/ui/Selectable.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { defineBuiltin } from '../component';
-
-export interface SelectableData {
- selected: boolean;
- group: number;
-}
-
-export const Selectable = defineBuiltin<SelectableData>('Selectable', {
- selected: false,
- group: 0,
-});
diff --git a/sdk/src/ui/SelectablePlugin.ts b/sdk/src/ui/SelectablePlugin.ts
deleted file mode 100644
index d0a1894de..000000000
--- a/sdk/src/ui/SelectablePlugin.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import type { App, Plugin } from '../app';
-import { defineSystem, Schedule } from '../system';
-import { Res } from '../resource';
-import type { Entity } from '../types';
-import { playModeOnly } from '../env';
-import { Interactable } from './Interactable';
-import { UIInteraction, type UIInteractionData } from './UIInteraction';
-import { Selectable, type SelectableData } from './Selectable';
-import { UIEvents, UIEventQueue } from './UIEvents';
-import { PluginName } from '../systemLabels';
-
-export class SelectablePlugin implements Plugin {
- name = PluginName.Selectable;
- dependencies = [PluginName.UIInteraction];
-
- build(app: App): void {
- const world = app.world;
-
- app.addSystemToSchedule(Schedule.Update, defineSystem(
- [Res(UIEvents)],
- (uiEvents: UIEventQueue) => {
- const entities = world.getEntitiesWithComponents([Selectable, Interactable]);
-
- for (const entity of entities) {
- if (!world.valid(entity)) continue;
- if (!world.has(entity, UIInteraction)) continue;
-
- const interaction = world.get(entity, UIInteraction) as UIInteractionData;
- if (!interaction.justPressed) continue;
-
- const selectable = world.get(entity, Selectable) as SelectableData;
- const newSelected = !selectable.selected;
-
- if (newSelected && selectable.group !== 0) {
- for (const other of entities) {
- if (other === entity || !world.valid(other)) continue;
- const otherSel = world.get(other, Selectable) as SelectableData;
- if (otherSel.group === selectable.group && otherSel.selected) {
- otherSel.selected = false;
- world.insert(other, Selectable, otherSel);
- uiEvents.emit(other, 'deselect');
- break;
- }
- }
- }
-
- selectable.selected = newSelected;
- world.insert(entity, Selectable, selectable);
- uiEvents.emit(entity, newSelected ? 'select' : 'deselect');
- }
- },
- { name: 'SelectableSystem' },
- ), { runIf: playModeOnly });
- }
-}
-
-export const selectablePlugin = new SelectablePlugin();
diff --git a/sdk/src/ui/index.ts b/sdk/src/ui/index.ts
index 542871e54..938a689d6 100644
--- a/sdk/src/ui/index.ts
+++ b/sdk/src/ui/index.ts
@@ -308,19 +308,6 @@ export {
dropdownPlugin,
} from './DropdownPlugin';
-// LayoutGroup Component (C++ backed)
-export {
- LayoutGroup,
- LayoutDirection,
- ChildAlignment,
- type LayoutGroupData,
-} from './LayoutGroup';
-
-export {
- LayoutGroupPlugin,
- layoutGroupPlugin,
-} from './LayoutGroupPlugin';
-
// FlexContainer Component
export {
FlexContainer,
@@ -497,18 +484,12 @@ export {
export { LinearLayout, type LinearLayoutData } from './layouts/LinearLayout';
export { GridLayout, type GridLayoutData } from './layouts/GridLayout';
-export { FanLayout, type FanLayoutData } from './layouts/FanLayout';
export { LinearLayoutProvider } from './layouts/LinearLayoutProvider';
export { GridLayoutProvider } from './layouts/GridLayoutProvider';
-export { FanLayoutProvider, computeFanPositions } from './layouts/FanLayoutProvider';
-export { FanLayoutPlugin, fanLayoutPlugin } from './FanLayoutPlugin';
export { LinearLayoutPlugin, linearLayoutPlugin } from './LinearLayoutPlugin';
export { GridLayoutPlugin, gridLayoutPlugin } from './GridLayoutPlugin';
-export { Selectable, type SelectableData } from './Selectable';
-export { SelectablePlugin, selectablePlugin } from './SelectablePlugin';
-
export const AnimOverride = {
POS_X: 1,
POS_Y: 2,
diff --git a/sdk/src/uiPlugins.ts b/sdk/src/uiPlugins.ts
index e5d5e54e1..dec51bdf7 100644
--- a/sdk/src/uiPlugins.ts
+++ b/sdk/src/uiPlugins.ts
@@ -15,10 +15,7 @@ import { dropdownPlugin } from './ui/DropdownPlugin';
import { uiRenderOrderPlugin } from './ui/UIRenderOrderPlugin';
import { stateMachinePlugin } from './ui/StateMachinePlugin';
import { dataBindingPlugin } from './ui/DataBindingPlugin';
-import { layoutGroupPlugin } from './ui/LayoutGroupPlugin';
import { collectionViewPlugin } from './ui/CollectionViewPlugin';
-import { fanLayoutPlugin } from './ui/FanLayoutPlugin';
-import { selectablePlugin } from './ui/SelectablePlugin';
import { linearLayoutPlugin } from './ui/LinearLayoutPlugin';
import { gridLayoutPlugin } from './ui/GridLayoutPlugin';
import type { Plugin } from './app';
@@ -30,7 +27,7 @@ export const uiPlugins: Plugin[] = [
uiInteractionPlugin, dragPlugin, scrollViewPlugin, sliderPlugin,
togglePlugin, textInputPlugin, stateMachinePlugin,
focusPlugin, safeAreaPlugin, dropdownPlugin,
- layoutGroupPlugin, collectionViewPlugin,
- fanLayoutPlugin, selectablePlugin, linearLayoutPlugin, gridLayoutPlugin,
+ collectionViewPlugin,
+ linearLayoutPlugin, gridLayoutPlugin,
uiRenderOrderPlugin,
];