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
refactor(plugin-api): the plugin type surface is an engine-side package
esengine1b66560adde1
diff --git a/VERSIONING.md b/VERSIONING.mdindex 2b2dc803d..a1eef832a 100644--- a/VERSIONING.md+++ b/VERSIONING.md@@ -39,7 +39,7 @@ private fields, and anything marked `@internal` or `@experimental`.## The Editor Plugin APIThe editor's plugin API — `@estella/editor-api`, the shapes in-`desktop/src/plugins/types.ts` that the editor writes into your project as+`editor-api/index.ts` that the editor writes into your project as`.esengine/plugins/.types/editor-api.d.ts` — is **not** one of the four surfacesabove. It is **experimental**, and it is not covered by the MAJOR-line promise:it will keep changing after 1.0.diff --git a/desktop/electron/main.ts b/desktop/electron/main.tsindex 45a7cece1..1bec7060b 100644--- a/desktop/electron/main.ts+++ b/desktop/electron/main.ts@@ -1499,7 +1499,7 @@ function pluginsRootFor(scope: 'project' | 'user'): string {// Scaffold a plugin — manifest, entry, tsconfig, and the typings sidecar the// tsconfig points at. The renderer supplies `editorVersion` and `apiTypes` rather// than main reading them: the renderer holds the constant that ENFORCES the-// `engines.editor` check and the types.ts text the editor is itself typed by, so+// `engines.editor` check and the editor-api text the editor is itself typed by, so// what gets written can never disagree with what gets checked.ipcMain.handle('plugins:scaffold', async (_e, scope: 'project' | 'user', opts: ScaffoldPluginOptions) => {try {diff --git a/desktop/electron/pluginScaffold.ts b/desktop/electron/pluginScaffold.tsindex e3b6c4944..f5446d3a5 100644--- a/desktop/electron/pluginScaffold.ts+++ b/desktop/electron/pluginScaffold.ts@@ -44,7 +44,7 @@ export interface ScaffoldPluginOptions {/** The running editor's version — what `engines.editor` is pinned to. */editorVersion: string;/**- * Text of the plugin API typings (`src/plugins/types.ts`). Written as the scope's+ * Text of the plugin API typings (`editor-api/index.ts`). Written as the scope's* `.types/editor-api.d.ts` sidecar so the generated tsconfig resolves on the first* open — including for a user-scoped plugin, which lives outside the project the* renderer's type sync can reach.diff --git a/desktop/package.json b/desktop/package.jsonindex 08a0df643..5ef39171b 100644--- a/desktop/package.json+++ b/desktop/package.json@@ -3,7 +3,7 @@"version": "0.55.0","private": true,"license": "Apache-2.0",- "description": "Estella Editor — visual scene editor for the Estella 2D WASM engine",+ "description": "Estella Editor \u2014 visual scene editor for the Estella 2D WASM engine","author": "ESEngine Team","type": "module","main": "dist-electron/main.js",@@ -93,6 +93,7 @@"zustand": "^5.0.14"},"devDependencies": {+ "@estella/editor-api": "workspace:*","@fontsource/inter": "^5.2.8","@fontsource/jetbrains-mono": "^5.2.8","@types/node": "^25.9.3",diff --git a/desktop/src/components/NewPluginDialog.tsx b/desktop/src/components/NewPluginDialog.tsxindex 99aa981be..51ad498e7 100644--- a/desktop/src/components/NewPluginDialog.tsx+++ b/desktop/src/components/NewPluginDialog.tsx@@ -29,7 +29,7 @@ import { Toasts } from '@/store/Toasts';import { version as EDITOR_VERSION } from '../../package.json';// The same text init.ts writes as the project's typings sidecar — see types.ts,// which is import-free precisely so it can double as the shipped `.d.ts`.-import editorApiTypes from '@/plugins/types.ts?raw';+import editorApiTypes from '../../../editor-api/index.ts?raw';import { t, type MsgKey } from '@/i18n';type Scope = 'project' | 'user';diff --git a/desktop/src/engine/automationGate.ts b/desktop/src/engine/automationGate.tsindex 5ddd8c045..ad9b3d81f 100644--- a/desktop/src/engine/automationGate.ts+++ b/desktop/src/engine/automationGate.ts@@ -8,7 +8,7 @@* The hook (`window.__estellaEditor`) is the UNCURATED door: project, asset,* play, document and command operations, next to the scene surface. Plugin code* shares that realm and is deliberately handed a curated subset instead- * (src/plugins/types.ts), so publishing the hook unconditionally would quietly+ * (editor-api/index.ts), so publishing the hook unconditionally would quietly* widen what a plugin can reach. It is therefore published only while a driver* is actually authorized.*diff --git a/desktop/src/panels/Details.tsx b/desktop/src/panels/Details.tsxindex 9376ee027..6c79140b7 100644--- a/desktop/src/panels/Details.tsx+++ b/desktop/src/panels/Details.tsx@@ -70,7 +70,7 @@ import type { SceneData, InputMapAsset, ActionType, Binding, LocaleTableAsset, Pimport { modelAddableComponentEntries, subscribeSchemas, getSchemaRevision, boxGroupsFor, isRequiredEmpty, inspectorFields, type BoxGroupDef } from '@/engine/schema';import { inspectorRegistry, buildContributedSection, isInfoRow } from '@/plugins/inspector';import { localizePlugin } from '@/plugins/localize';-import type { AssetInspectorContribution, ComponentInspectorContribution } from '@/plugins/types';+import type { AssetInspectorContribution, ComponentInspectorContribution } from '@estella/editor-api';import * as imap from '@/project/inputMapDoc';import * as ldoc from '@/project/localeTableDoc';import { buildImporterComponent, applyImporterEdit } from '@/project/assetImporter';diff --git a/desktop/src/plugins/PluginHost.ts b/desktop/src/plugins/PluginHost.tsindex 100f24f2e..144c7b8bf 100644--- a/desktop/src/plugins/PluginHost.ts+++ b/desktop/src/plugins/PluginHost.ts@@ -46,7 +46,7 @@ import type { Owner } from '@/contrib/ContributionRegistry';import { resolveLocalized, satisfiesEditorRange, type PluginManifest } from './manifest';import { evaluatePlugin } from './loader';import { buildPluginContext, type BuiltContext, type PluginContribution } from './context';-import type { EditorPlugin } from './types';+import type { EditorPlugin } from '@estella/editor-api';/** Where a plugin sits in its lifecycle — what the Plugins panel shows. */export type PluginPhase =diff --git a/desktop/src/plugins/PluginOverlays.tsx b/desktop/src/plugins/PluginOverlays.tsxindex 5145e7b32..d54a76b20 100644--- a/desktop/src/plugins/PluginOverlays.tsx+++ b/desktop/src/plugins/PluginOverlays.tsx@@ -18,7 +18,7 @@ import { useEffect, useRef, useSyncExternalStore } from 'react';import { activeMode } from '@/mode/activeMode';import { PluginHost } from './PluginHost';import { overlayRegistry, createOverlayGraphics, type OverlayPrimitive } from './overlays';-import type { GizmoStyle } from './types';+import type { GizmoStyle } from '@estella/editor-api';const SVG_NS = 'http://www.w3.org/2000/svg';diff --git a/desktop/src/plugins/agentTools.ts b/desktop/src/plugins/agentTools.tsindex 9092b42a3..1fa94d3fc 100644--- a/desktop/src/plugins/agentTools.ts+++ b/desktop/src/plugins/agentTools.ts@@ -23,7 +23,7 @@*/import { ContributionRegistry, type Owner, type Disposable } from '@/contrib/ContributionRegistry';import { isWireToolName, toolNamespace } from '@/agent/toolName';-import type { AgentToolContribution } from './types';+import type { AgentToolContribution } from '@estella/editor-api';/** The registry keys by `id`; a tool's id IS its name — the model addresses it* by that and nothing else, so a second identifier could only disagree. */diff --git a/desktop/src/plugins/api.ts b/desktop/src/plugins/api.tsindex af48a563b..b827fac02 100644--- a/desktop/src/plugins/api.ts+++ b/desktop/src/plugins/api.ts@@ -11,9 +11,9 @@* implementation that stops matching what authors were promised is a compile error* rather than a runtime surprise in someone else's plugin.*/-import type * as Api from './types';+import type * as Api from '@estella/editor-api';-export type * from './types';+export type * from '@estella/editor-api';export const definePlugin: typeof Api.definePlugin = (plugin) => plugin;diff --git a/desktop/src/plugins/context.ts b/desktop/src/plugins/context.tsindex b958970d5..9f95d799f 100644--- a/desktop/src/plugins/context.ts+++ b/desktop/src/plugins/context.ts@@ -50,7 +50,7 @@ import type {EditorPlugin, EditorProjectApi, EditorSceneApi, EntityTemplateContribution, FieldValue,InspectorContribution, OverlayContribution, PanelContribution, PluginContext,PluginFs, SettingContribution, ToolContribution, PointerInput as PluginPointerInput,-} from './types';+} from '@estella/editor-api';/** Per-plugin persisted state, kept out of the project (it's a user preference). */const stateKey = (id: string): string => `estella.plugin.state.${id}`;diff --git a/desktop/src/plugins/contextMenus.ts b/desktop/src/plugins/contextMenus.tsindex 2a1be5e23..45cc13546 100644--- a/desktop/src/plugins/contextMenus.ts+++ b/desktop/src/plugins/contextMenus.ts@@ -13,7 +13,7 @@import { ContributionRegistry, type Disposable, type Owner } from '@/contrib/ContributionRegistry';import { localizePlugin } from './localize';import type { MenuItem } from '@/components/Menu';-import type { ContextMenuContribution, ContextMenuLocation, ContextMenuTarget } from './types';+import type { ContextMenuContribution, ContextMenuLocation, ContextMenuTarget } from '@estella/editor-api';const contrib = new ContributionRegistry<ContextMenuContribution>('context menu item');diff --git a/desktop/src/plugins/init.ts b/desktop/src/plugins/init.tsindex 29b1c44cb..830718c7d 100644--- a/desktop/src/plugins/init.ts+++ b/desktop/src/plugins/init.ts@@ -18,7 +18,7 @@ import { PluginHost } from './PluginHost';// precisely so it doubles as the `.d.ts` plugin authors compile against — shipping// the same file the editor itself is typed by means the two can never disagree,// and there is no package to publish or copy to go stale.-import editorApiTypes from './types.ts?raw';+import editorApiTypes from '../../../editor-api/index.ts?raw';let currentRoot: string | null = null;let inited = false;diff --git a/desktop/src/plugins/inspector.ts b/desktop/src/plugins/inspector.tsindex 5ff336a1c..e6623065b 100644--- a/desktop/src/plugins/inspector.ts+++ b/desktop/src/plugins/inspector.ts@@ -20,7 +20,7 @@ import type { InspectorComponent, InspectorField } from '@/types';import type {AssetInspectorContribution, ComponentInspectorContribution, InspectorContribution,InspectorSectionBuilder, LocalizedString,-} from './types';+} from '@estella/editor-api';const contrib = new ContributionRegistry<InspectorContribution>('inspector section');diff --git a/desktop/src/plugins/loader.ts b/desktop/src/plugins/loader.tsindex 23ecbf17d..793f72bda 100644--- a/desktop/src/plugins/loader.ts+++ b/desktop/src/plugins/loader.ts@@ -26,7 +26,7 @@ import * as ReactDOMClient from 'react-dom/client';import * as ReactJsxRuntime from 'react/jsx-runtime';import * as esengine from 'esengine';import * as editorApi from './api';-import type { EditorPlugin } from './types';+import type { EditorPlugin } from '@estella/editor-api';/*** The modules a plugin may import. A bare specifier outside this set is a loaddiff --git a/desktop/src/plugins/localize.ts b/desktop/src/plugins/localize.tsindex f8df04066..99f59fa14 100644--- a/desktop/src/plugins/localize.ts+++ b/desktop/src/plugins/localize.ts@@ -10,7 +10,7 @@* inspector, and the menus all resolve identically.*/import { editorLocale } from '@/i18n';-import type { LocalizedString } from './types';+import type { LocalizedString } from '@estella/editor-api';/** Resolve for the current editor locale, falling back to `en`, then any value. */export function localizePlugin(value: LocalizedString | undefined): string {diff --git a/desktop/src/plugins/manifest.ts b/desktop/src/plugins/manifest.tsindex 3803bb2d0..03bd50ee1 100644--- a/desktop/src/plugins/manifest.ts+++ b/desktop/src/plugins/manifest.ts@@ -15,7 +15,7 @@// LocalizedString is owned by the public type surface (types.ts) — one spelling// for the manifest and for every contribution a plugin registers.-import type { LocalizedString } from './types';+import type { LocalizedString } from '@estella/editor-api';export type { LocalizedString };diff --git a/desktop/src/plugins/overlays.ts b/desktop/src/plugins/overlays.tsindex 8aeb054bc..8d8f6bfe0 100644--- a/desktop/src/plugins/overlays.ts+++ b/desktop/src/plugins/overlays.ts@@ -18,7 +18,7 @@import { ViewportController } from '@/engine/ViewportController';import { EngineHost } from '@/engine/EngineHost';import { ContributionRegistry, type Disposable, type Owner } from '@/contrib/ContributionRegistry';-import type { GizmoStyle, OverlayContribution, OverlayGraphics, Vec2 } from './types';+import type { GizmoStyle, OverlayContribution, OverlayGraphics, Vec2 } from '@estella/editor-api';/** A collected primitive, already projected to overlay CSS pixels. */export type OverlayPrimitive =diff --git a/desktop/tests/agent-plugin-tools.test.ts b/desktop/tests/agent-plugin-tools.test.tsindex 7a71a241f..a71bc2f84 100644--- a/desktop/tests/agent-plugin-tools.test.ts+++ b/desktop/tests/agent-plugin-tools.test.ts@@ -16,7 +16,7 @@ import { fileURLToPath } from 'node:url';import { agentTools, type ContributedTool } from '../electron/agent/kernel';import { agentToolProblem } from '../src/plugins/agentTools';import { isWireToolName } from '../src/agent/toolName';-import type { AgentToolContribution } from '../src/plugins/types';+import type { AgentToolContribution } from '@estella/editor-api';const tool = (over: Partial<ContributedTool> = {}): ContributedTool => ({name: 'acme_bake',diff --git a/desktop/tests/plugin-api-surface.test.ts b/desktop/tests/plugin-api-surface.test.tsindex c35f97631..86d98d37f 100644--- a/desktop/tests/plugin-api-surface.test.ts+++ b/desktop/tests/plugin-api-surface.test.ts@@ -18,7 +18,7 @@ import { fileURLToPath } from 'node:url';import * as api from '@/plugins/api';import { importsAnotherModule } from '../../tools/lib/moduleImports.mjs';-const TYPES_FILE = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../src/plugins/types.ts');+const TYPES_FILE = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../editor-api/index.ts');const source = readFileSync(TYPES_FILE, 'utf8');describe('plugin API surface', () => {diff --git a/desktop/tests/plugin-contributions.test.ts b/desktop/tests/plugin-contributions.test.tsindex c586e6ad5..99bd80351 100644--- a/desktop/tests/plugin-contributions.test.ts+++ b/desktop/tests/plugin-contributions.test.ts@@ -19,7 +19,7 @@ import { toolRegistry } from '@/tools/toolRegistry';import { useEditorStore } from '@/store/editorStore';import { useTilemapPaint } from '@/store/tilemapPaintStore';import type { OverlayPrimitive } from '@/plugins/overlays';-import type { LocalizedString, OverlayGraphics, Vec2 } from '@/plugins/types';+import type { LocalizedString, OverlayGraphics, Vec2 } from '@estella/editor-api';const PLUGIN = 'plugin:acme';const id = (v: LocalizedString) => (typeof v === 'string' ? v : v.en);diff --git a/desktop/tests/plugin-inventory.test.ts b/desktop/tests/plugin-inventory.test.tsindex 2d586cfa6..a28d7cda0 100644--- a/desktop/tests/plugin-inventory.test.ts+++ b/desktop/tests/plugin-inventory.test.ts@@ -15,7 +15,7 @@import { describe, it, expect, afterEach } from 'vitest';import { buildPluginContext, type ContributionKind } from '@/plugins/context';import type { PluginManifest } from '@/plugins/manifest';-import type { PluginContext } from '@/plugins/types';+import type { PluginContext } from '@estella/editor-api';const MANIFEST: PluginManifest = {id: 'acme.tools',diff --git a/desktop/tsconfig.json b/desktop/tsconfig.jsonindex e05667e86..a9722c0fa 100644--- a/desktop/tsconfig.json+++ b/desktop/tsconfig.json@@ -21,7 +21,8 @@"verbatimModuleSyntax": true,"paths": {- "@/*": ["./src/*"]+ "@/*": ["./src/*"],+ "@estella/editor-api": ["../editor-api/index.ts"]}},"include": ["src", "electron", "tests", "vite.config.ts"]diff --git a/desktop/src/plugins/types.ts b/editor-api/index.tssimilarity index 99%rename from desktop/src/plugins/types.tsrename to editor-api/index.tsindex edd356539..d81283dcb 100644--- a/desktop/src/plugins/types.ts+++ b/editor-api/index.ts@@ -1,7 +1,7 @@// SPDX-License-Identifier: Apache-2.0// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team/**- * @file types.ts — THE public type surface of the editor plugin API.+ * @file index.ts — THE public type surface of the editor plugin API.** Deliberately SELF-CONTAINED (types only, zero imports): the editor copies this* file's text verbatim into a project's `.esengine/plugins/.types/editor-api.d.ts`,diff --git a/editor-api/package.json b/editor-api/package.jsonnew file mode 100644index 000000000..ca4a959de--- /dev/null+++ b/editor-api/package.json@@ -0,0 +1,14 @@+{+ "name": "@estella/editor-api",+ "version": "0.55.0",+ "private": true,+ "license": "Apache-2.0",+ "description": "Public type surface of the Estella editor plugin API",+ "type": "module",+ "types": "./index.ts",+ "exports": {+ ".": {+ "types": "./index.ts"+ }+ }+}diff --git a/plugins/audio-mixer/tsconfig.json b/plugins/audio-mixer/tsconfig.jsonindex 72a0a96ce..f10c2b660 100644--- a/plugins/audio-mixer/tsconfig.json+++ b/plugins/audio-mixer/tsconfig.json@@ -7,7 +7,7 @@"jsx": "react-jsx","noEmit": true,"skipLibCheck": true,- "paths": { "@estella/editor-api": ["../../desktop/src/plugins/types.ts"] }+ "paths": { "@estella/editor-api": ["../../editor-api/index.ts"] }},"include": ["src", "tests"]}diff --git a/plugins/ldtk/tsconfig.json b/plugins/ldtk/tsconfig.jsonindex 1e3cb400b..8d9fe045b 100644--- a/plugins/ldtk/tsconfig.json+++ b/plugins/ldtk/tsconfig.json@@ -7,7 +7,7 @@"noEmit": true,"skipLibCheck": true,"types": ["vitest/globals"],- "paths": { "@estella/editor-api": ["../../desktop/src/plugins/types.ts"] }+ "paths": { "@estella/editor-api": ["../../editor-api/index.ts"] }},"include": ["src", "tests"]}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 476f0d653..a2efc2f02 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -79,6 +79,9 @@ importers:specifier: ^5.0.14version: 5.0.14(@types/[email protected])([email protected])devDependencies:+ '@estella/editor-api':+ specifier: workspace:*+ version: link:../editor-api'@fontsource/inter':specifier: ^5.2.8version: 5.2.8@@ -119,6 +122,8 @@ importers:specifier: ^2.1.0version: 2.1.9(@types/[email protected])(@vitest/[email protected])([email protected])([email protected])([email protected])([email protected])+ editor-api: {}+pipeline:dependencies:draco3dgltf:diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex ddc1b1ad8..8912c87d9 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -2,6 +2,7 @@ packages:- 'sdk'- 'pipeline'- 'desktop'+ - 'editor-api'- 'plugins/*'onlyBuiltDependencies:- esbuilddiff --git a/tools/check-plugin-api-contract.mjs b/tools/check-plugin-api-contract.mjsindex e958919e1..b19f639d3 100644--- a/tools/check-plugin-api-contract.mjs+++ b/tools/check-plugin-api-contract.mjs@@ -35,7 +35,7 @@ const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');*/const SURFACES = {typings: {- path: 'desktop/src/plugins/types.ts',+ path: 'editor-api/index.ts',who: 'the plugin author, in the .d.ts the editor writes into their project',from: /^ \* STABILITY:/m,to: /^ \*\/$/m,diff --git a/tools/releaseGate.mjs b/tools/releaseGate.mjsindex 3714dd12d..abd310444 100644--- a/tools/releaseGate.mjs+++ b/tools/releaseGate.mjs@@ -200,7 +200,7 @@ export const CRITERIA = [// the contract". What fails a release is not the answer but its absence from// one of the places somebody acts on it.answeredBy: 'node tools/check-plugin-api-contract.mjs',- needs: ['tools/check-plugin-api-contract.mjs', 'desktop/src/plugins/types.ts'],+ needs: ['tools/check-plugin-api-contract.mjs', 'editor-api/index.ts'],},{id: 'every-subsystem-has-a-verdict',