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
fix(project): every module a project can refuse is one a build can detect
esengine5aafe58954bb
diff --git a/desktop b/desktopindex aaf6a8998..7e24a9479 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit aaf6a8998298097c58659adca0b12c173ba4f7ff+Subproject commit 7e24a9479346049c4e898380c190a32742f723dcdiff --git a/pipeline/src/project/targetSupport.ts b/pipeline/src/project/targetSupport.tsindex 84c00f050..a0e66601e 100644--- a/pipeline/src/project/targetSupport.ts+++ b/pipeline/src/project/targetSupport.ts@@ -26,7 +26,9 @@import { NATIVE_PLATFORMS, type ExportPlatform } from './platforms';/** An engine subsystem a build target may lack. */-export type Subsystem = 'text' | 'tilemap' | 'particles' | 'postprocess' | 'physics' | 'spine' | 'video' | 'ai' | 'replication' | 'gameplay';+export type Subsystem =+ | 'text' | 'tilemap' | 'particles' | 'postprocess' | 'physics' | 'physics3d'+ | 'spine' | 'dragonbones' | 'video' | 'ai' | 'logic' | 'replication' | 'gameplay';/*** The authored vocabulary that puts a subsystem in use: a scene or prefab@@ -44,7 +46,14 @@ export const SUBSYSTEM_COMPONENTS: Readonly<Record<Subsystem, readonly string[]>'PolygonCollider2D', 'ChainCollider2D', 'OneWayPlatform2D', 'CharacterController2D','HingeJoint2D', 'DistanceJoint2D', 'SliderJoint2D', 'FixedJoint2D', 'WheelJoint2D', 'MotorJoint2D',],+ physics3d: [+ 'RigidBody3D', 'BoxCollider3D', 'SphereCollider3D', 'CapsuleCollider3D',+ 'MeshCollider3D', 'ConvexCollider3D', 'CharacterController3D',+ 'HingeJoint3D', 'DistanceJoint3D', 'SliderJoint3D', 'FixedJoint3D', 'PointJoint3D',+ ],spine: ['SpineAnimation'],+ dragonbones: ['DragonBonesAnimation'],+ logic: ['ScriptGraphAgent'],video: ['Video'],ai: ['NavAgent', 'NavArea', 'NavLink', 'NavObstacle', 'NavVolume',@@ -63,7 +72,10 @@ export const SUBSYSTEM_LABEL: Readonly<Record<Subsystem, string>> = {particles: 'Particles',postprocess: 'Post-processing',physics: 'Physics (Box2D)',+ physics3d: 'Physics (3D)',spine: 'Spine animation',+ dragonbones: 'DragonBones animation',+ logic: 'Script graphs',video: 'Video',ai: 'Gameplay AI',replication: 'Replication',@@ -82,7 +94,10 @@ export const SUBSYSTEM_INSTALL: Readonly<Record<Subsystem, string>> = {postprocess: 'base',tilemap: 'esengine/tilemap',physics: 'esengine/physics',+ physics3d: 'esengine/physics3d',spine: 'esengine/spine',+ dragonbones: 'esengine/dragonbones',+ logic: 'esengine/logic',video: 'whole-entry',ai: 'esengine/ai',replication: 'esengine/replication',@@ -132,6 +147,18 @@ const COMPONENT_SUBSYSTEM: ReadonlyMap<string, Subsystem> = new Map(.flatMap(([subsystem, names]) => names.map((name) => [name, subsystem] as const)),);+/**+ * The `esengine/` module a component belongs to, or null for one the base engine+ * always carries. What the Add Component menu asks before offering a component a+ * project has refused — the same table the export refuses a build by.+ */+export function moduleOfComponent(name: string): string | null {+ const subsystem = COMPONENT_SUBSYSTEM.get(name);+ if (subsystem === undefined) return null;+ const install = SUBSYSTEM_INSTALL[subsystem];+ return install === 'base' || install === 'whole-entry' ? null : install;+}+/*** Collect the subsystems a scene / prefab document puts in use. Pure, and shape-* agnostic: it walks for the serialized `type` vocabulary, so nested entities,diff --git a/pipeline/tests/engine-installs.test.ts b/pipeline/tests/engine-installs.test.tsindex 0fbddc78e..ab01ffcf6 100644--- a/pipeline/tests/engine-installs.test.ts+++ b/pipeline/tests/engine-installs.test.ts@@ -10,8 +10,8 @@*/import { describe, it, expect } from 'vitest';import { engineInstalls, moduleChoices } from '../src/bundle/engineInstalls';-import { ESENGINE_SUBPATHS } from '../src/bundle/esengineResolve';-import { SUBSYSTEM_INSTALL, type Subsystem } from '../src/project/targetSupport';+import { ENGINE_MODULES, ESENGINE_SUBPATHS } from '../src/bundle/engineSubpaths';+import { SUBSYSTEM_COMPONENTS, SUBSYSTEM_INSTALL, type Subsystem } from '../src/project/targetSupport';describe('the engine modules a package installs', () => {it('takes a subsystem from the components its content authored', () => {@@ -165,3 +165,27 @@ describe('what a project said, read off its manifest', () => {expect(moduleChoices({ physics: { enabled: false } })).toEqual({});});});++/**+ * A module a project can refuse has to be one the build can SEE being used.+ *+ * The refusal is enforced by detection, so a module with no authored vocabulary+ * would be excluded silently and ship a package missing it — the outcome the+ * refusal exists to prevent. Three modules were in that state.+ */+describe('every module a project can refuse', () => {+ it('has authored vocabulary the build can detect it by', () => {+ const byComponent = new Set(+ (Object.entries(SUBSYSTEM_INSTALL) as [Subsystem, string][])+ .filter(([s, install]) => install.startsWith('esengine/')+ && SUBSYSTEM_COMPONENTS[s].length > 0)+ .map(([, install]) => install),+ );+ // Detection also reads asset extensions, which is how a script graph is+ // found; asked through engineInstalls so this cannot read a stale copy.+ for (const ext of ['.esgraph', '.esfsm', '.esbt']) {+ for (const s of engineInstalls({ assetPaths: [`x${ext}`] }).subpaths) byComponent.add(s);+ }+ expect(ENGINE_MODULES.filter((m) => !byComponent.has(m))).toEqual([]);+ });+});