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
feat(editor): offer a game's own actions in the palettes, without running its code
yhh2739d3501f6e
diff --git a/desktop/electron/extractSchemas.ts b/desktop/electron/extractSchemas.tsindex 7ac41fc65..eb06b08d5 100644--- a/desktop/electron/extractSchemas.ts+++ b/desktop/electron/extractSchemas.ts@@ -81,12 +81,36 @@ export interface SerializedFieldMeta {label?: string;}+/**+ * A project-registered action, as the editor's palettes need it: the name, and+ * (when it declared them) the parameters that decide which controls to render.+ * The editor's own realm never runs project code, so this artifact is the only+ * way a game's `registerAction('game.startRun', …)` can appear in a dropdown.+ */+export interface ProjectActionSchema {+ name: string;+ /** Declared parameters, verbatim from the registry (see sdk registry.ts). */+ params?: unknown[];+ /** Separator of the canonical string form, when not the default ':'. */+ separator?: string;+}++/** The whole artifact: what the editor knows about a project's declarations. */+export interface SchemasArtifact {+ components: ComponentSchema[];+ actions: ProjectActionSchema[];+ conditions: string[];+}+export interface ExtractSchemasResult {ok: boolean;/** Absolute path to the written schemas.json, or null on failure. */outputPath: string | null;- /** The extracted schemas (also written to outputPath). */+ /** The extracted component schemas (also written to outputPath). */schemas: ComponentSchema[];+ /** The project's own registered actions / conditions (same artifact). */+ actions: ProjectActionSchema[];+ conditions: string[];errors: string[];warnings: string[];}@@ -117,13 +141,15 @@ function esengineAnchor(): Plugin {}/** Write the schemas artifact and return its absolute path. */-function writeSchemas(root: string, schemas: ComponentSchema[]): string {+function writeSchemas(root: string, artifact: SchemasArtifact): string {const outputPath = path.join(root, CACHE_DIR, OUTPUT);mkdirSync(path.dirname(outputPath), { recursive: true });- writeFileSync(outputPath, JSON.stringify(schemas, null, 2) + '\n');+ writeFileSync(outputPath, JSON.stringify(artifact, null, 2) + '\n');return outputPath;}+const EMPTY: SchemasArtifact = { components: [], actions: [], conditions: [] };+/*** Extract the project's component schemas from `<root>/<entry>` (project-relative,* default `src/components.ts`) → `<root>/.esengine/cache/schemas.json`. Never@@ -140,20 +166,38 @@ export async function extractProjectSchemas(const declPath = path.join(root, opts?.entry ?? DEFAULT_DECL_ENTRY);if (!existsSync(declPath)) {if (opts?.required) {- return { ok: false, outputPath: null, schemas: [], errors: [`declaration entry not found: ${declPath}`], warnings: [] };+ return {+ ok: false, outputPath: null, schemas: [], actions: [], conditions: [],+ errors: [`declaration entry not found: ${declPath}`], warnings: [],+ };}- return { ok: true, outputPath: writeSchemas(root, []), schemas: [], errors: [], warnings: [] };+ return { ok: true, outputPath: writeSchemas(root, EMPTY), schemas: [], actions: [], conditions: [], errors: [], warnings: [] };}// Generated entry: install a fresh context FIRST (top-level, so it runs before- // any project code), then defer the declaration's `defineComponent` side- // effects to a dynamic import inside __extract() and hand back the registry.+ // any project code), then defer the declaration's side effects to a dynamic+ // import inside __extract() and hand back what it declared.+ //+ // Actions come from the SAME module for the same reason components do: a+ // `registerAction` IS a declaration, and this is the one project module the+ // editor may evaluate. The registry is diffed around the import so only the+ // project's own names are reported — the engine's builtins register when their+ // plugins build, which never happens here, but a diff keeps that an invariant+ // rather than a coincidence.const entry =- `import { AppContext, setDefaultContext, getUserComponents } from 'esengine';\n` ++ `import { AppContext, setDefaultContext, getUserComponents, aiRegistry } from 'esengine';\n` +`setDefaultContext(new AppContext());\n` +`export async function __extract() {\n` ++ ` const before = new Set(aiRegistry.actionNames());\n` ++ ` const beforeConds = new Set(aiRegistry.conditionNames());\n` +` await import(${JSON.stringify(declPath)});\n` +- ` return getUserComponents();\n` ++ ` const actions = aiRegistry.actionNames().filter((n) => !before.has(n)).map((name) => ({\n` ++ ` name,\n` ++ ` params: aiRegistry.getActionParams(name),\n` ++ ` separator: aiRegistry.getActionSeparator(name),\n` ++ ` }));\n` ++ ` const conditions = aiRegistry.conditionNames().filter((n) => !beforeConds.has(n));\n` ++ ` return { components: getUserComponents(), actions, conditions };\n` +`}\n`;const tmp = mkdtempSync(path.join(tmpdir(), 'estella-schema-'));@@ -175,19 +219,40 @@ export async function extractProjectSchemas(});warnings.push(...result.warnings.map((w) => w.text));- const mod: { __extract(): Promise<Map<string, unknown>> } = await import(pathToFileURL(bundlePath).href);- const registry = await mod.__extract();- const schemas = [...registry.values()]+ interface Extracted {+ components: Map<string, unknown>;+ actions: ProjectActionSchema[];+ conditions: string[];+ }+ const mod: { __extract(): Promise<Extracted> } = await import(pathToFileURL(bundlePath).href);+ const declared = await mod.__extract();+ // Deterministic output throughout — the artifact is compared byte-wise by+ // the incremental cache and read by humans in diffs.+ const schemas = [...declared.components.values()].map(toSchema)- .sort((a, b) => a.name.localeCompare(b.name)); // deterministic output+ .sort((a, b) => a.name.localeCompare(b.name));+ const actions = declared.actions+ .map((a) => normalizeAction(a))+ .sort((a, b) => a.name.localeCompare(b.name));+ const conditions = [...declared.conditions].sort();- return { ok: true, outputPath: writeSchemas(root, schemas), schemas, errors: [], warnings };+ return {+ ok: true,+ outputPath: writeSchemas(root, { components: schemas, actions, conditions }),+ schemas,+ actions,+ conditions,+ errors: [],+ warnings,+ };} catch (err) {const e = err as { errors?: { text: string }[]; warnings?: { text: string }[]; message?: string };return {ok: false,outputPath: null,schemas: [],+ actions: [],+ conditions: [],errors: e.errors?.map((x) => x.text) ?? [String(e.message ?? err)],warnings: e.warnings?.map((x) => x.text) ?? warnings,};@@ -196,6 +261,14 @@ export async function extractProjectSchemas(}}+/** Drop the fields that carry no information, so the artifact stays readable. */+function normalizeAction(a: ProjectActionSchema): ProjectActionSchema {+ const out: ProjectActionSchema = { name: a.name };+ if (a.params && a.params.length) out.params = a.params;+ if (a.separator && a.separator !== ':') out.separator = a.separator;+ return out;+}+/** A user ComponentDef carries the field metadata; see sdk component.ts. */interface UserComponentDef {_name: string;diff --git a/desktop/src/ai/actionCatalog.ts b/desktop/src/ai/actionCatalog.tsnew file mode 100644index 000000000..3324d56ed--- /dev/null+++ b/desktop/src/ai/actionCatalog.ts@@ -0,0 +1,86 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file actionCatalog.ts+ * @brief The action/condition vocabulary the editor can offer, from BOTH+ * sources: the live `aiRegistry` (engine builtins, registered when the+ * edit realm's plugins built) and the open project's own registrations.+ *+ * The editor's main realm never executes project code, so a game's+ * `registerAction('game.startRun', …)` cannot be in the live registry — it+ * arrives as an artifact instead (`.esengine/cache/schemas.json`, written by the+ * same pure-node extractor that already reports the project's components:+ * schema-as-artifact, applied to actions).+ *+ * Everything that offers a name — the FSM state hooks, the BT leaves, an event+ * wire — asks HERE rather than the registry directly, so all three see one+ * vocabulary. A name in neither source is still legal to type: the palettes have+ * always allowed free text, because a game may register more at runtime.+ */+import { aiRegistry } from 'esengine';+import type { AiParamDef } from 'esengine';++/** A project action as serialized in `schemas.json` (see electron/extractSchemas.ts). */+export interface ProjectActionSchema {+ name: string;+ params?: AiParamDef[];+ separator?: string;+}++const projectActions = new Map<string, ProjectActionSchema>();+let projectConditions: string[] = [];++const listeners = new Set<() => void>();+let revision = 0;++/** Subscribe to catalog changes (project open / re-extract), for useSyncExternalStore. */+export const subscribeActionCatalog = (fn: () => void): (() => void) => {+ listeners.add(fn);+ return () => { listeners.delete(fn); };+};+export const getActionCatalogRevision = (): number => revision;++/** Replace the project half of the catalog. Notifies subscribers. */+export function setProjectActions(actions: readonly ProjectActionSchema[], conditions: readonly string[]): void {+ projectActions.clear();+ for (const a of actions) projectActions.set(a.name, a);+ projectConditions = [...conditions];+ revision++;+ for (const l of listeners) l();+}++/** Every offerable action name — engine builtins first, then the project's. */+export function actionNames(): string[] {+ const names = aiRegistry.actionNames();+ const seen = new Set(names);+ for (const name of projectActions.keys()) if (!seen.has(name)) names.push(name);+ return names;+}++export function conditionNames(): string[] {+ const names = aiRegistry.conditionNames();+ const seen = new Set(names);+ for (const name of projectConditions) if (!seen.has(name)) names.push(name);+ return names;+}++/** Whether the catalog knows `name` at all (an unknown name is still authorable). */+export function isKnownAction(name: string): boolean {+ return aiRegistry.hasAction(name) || projectActions.has(name);+}++/**+ * The parameters `name` declares. The live registry wins: if the edit realm has+ * the action, its declaration is first-hand, and the artifact could be one+ * extract behind.+ */+export function actionParams(name: string): readonly AiParamDef[] {+ if (aiRegistry.hasAction(name)) return aiRegistry.getActionParams(name);+ return projectActions.get(name)?.params ?? [];+}++/** The separator joining `name`'s parameters in the canonical string form. */+export function actionSeparator(name: string): string {+ if (aiRegistry.hasAction(name)) return aiRegistry.getActionSeparator(name);+ return projectActions.get(name)?.separator ?? ':';+}diff --git a/desktop/src/components/aiSuggest.ts b/desktop/src/components/aiSuggest.tsindex e36a245f9..9d3645e81 100644--- a/desktop/src/components/aiSuggest.ts+++ b/desktop/src/components/aiSuggest.ts@@ -8,7 +8,7 @@* registry) so they are bilingual via the editor's own i18n — the* same display-side-label precedent as the asset importer.*/-import { aiRegistry } from 'esengine';+import { actionNames, conditionNames } from '@/ai/actionCatalog';import { t } from '@/i18n';import type { SuggestItem } from './SuggestInput';@@ -30,12 +30,12 @@ const BUILTIN_DESC: Record<string, () => string> = {const decorate = (names: string[]): SuggestItem[] =>names.map((value) => ({ value, desc: BUILTIN_DESC[value]?.() }));-/** Action-name suggestions (FSM state hooks, BT action nodes). */+/** Action-name suggestions (FSM state hooks, BT action nodes, event wires). */export function aiActionItems(): SuggestItem[] {- return decorate(aiRegistry.actionNames());+ return decorate(actionNames());}-/** Condition-name suggestions (FSM transitions, BT condition nodes). */+/** Condition-name suggestions (FSM transitions, BT condition nodes, wire guards). */export function aiConditionItems(): SuggestItem[] {- return decorate(aiRegistry.conditionNames());+ return decorate(conditionNames());}diff --git a/desktop/src/events/EventBindingSection.tsx b/desktop/src/events/EventBindingSection.tsxindex ba3329ba0..25055f6b6 100644--- a/desktop/src/events/EventBindingSection.tsx+++ b/desktop/src/events/EventBindingSection.tsx@@ -28,6 +28,7 @@ import { Select } from '@/components/Select';import { SuggestInput } from '@/components/SuggestInput';import { aiActionItems, aiConditionItems } from '@/components/aiSuggest';import { aiParamOptions } from '@/ai/paramOptions';+import { actionParams, actionSeparator, subscribeActionCatalog, getActionCatalogRevision } from '@/ai/actionCatalog';import { SceneStore } from '@/engine/SceneStore';import { SceneCommands } from '@/engine/SceneCommands';import { prettyLabel } from '@/engine/schema';@@ -35,7 +36,7 @@ import { readEventRows, resolveTargetName, sceneEntityNames } from '@/events/eveimport { useInspectorCollapse, isSectionCollapsed } from '@/store/inspectorCollapse';import { t } from '@/i18n';import type { EntityId } from '@/types';-import { UIEventType, aiRegistry, parseActionArg } from 'esengine';+import { UIEventType, parseActionArg } from 'esengine';import type { AiParamDef, AiParamValue, EventBindingRow } from 'esengine';const SECTION_KEY = '__events';@@ -46,6 +47,9 @@ const SELF = '';export function EventBindingSection({ entityId, interactive }: { entityId: EntityId; interactive: boolean }) {useSyncExternalStore(SceneStore.subscribe, SceneStore.getRevision);+ // The project's own actions arrive with the schemas artifact, after open —+ // re-render then, so their parameter controls appear without a reselect.+ useSyncExternalStore(subscribeActionCatalog, getActionCatalogRevision);const collapseExplicit = useInspectorCollapse((s) => s.explicit);const toggleCollapse = useInspectorCollapse((s) => s.toggle);const collapsed = isSectionCollapsed(collapseExplicit, SECTION_KEY);@@ -137,10 +141,10 @@ function EventRow({// What the chosen action takes. A row authored before the action declared its// parameters still shows them: the canonical string parses into the same// record the runtime would build (registry.ts owns that projection).- const defs = aiRegistry.getActionParams(row.action);+ const defs = actionParams(row.action);const values: Record<string, AiParamValue> = row.params && Object.keys(row.params).length? { ...row.params }- : parseActionArg(row.arg, defs, aiRegistry.getActionSeparator(row.action));+ : parseActionArg(row.arg, defs, actionSeparator(row.action));// An authored value the built-in list doesn't know (a widget's own event, or// an entity renamed since) still has to be selectable — append it rather thandiff --git a/desktop/src/main.tsx b/desktop/src/main.tsxindex 05fa8d9a4..2a3869d5f 100644--- a/desktop/src/main.tsx+++ b/desktop/src/main.tsx@@ -46,7 +46,8 @@ import { dockApi } from './layout/dockApi';import { EditorControlSurface } from './engine/EditorSession';import { SceneModel } from './engine/SceneModel';import { EngineHost } from './engine/EngineHost';-import { Particle, aiRegistry, getComponent } from 'esengine';+import { Particle, getComponent } from 'esengine';+import { actionNames, actionParams, conditionNames } from '@/ai/actionCatalog';import { applyFxPreview, initFxPreviewEditRestart } from './engine/fxPreview';import { commands } from './commands/registry';import { ENTITY_SOURCES, sourceById, createFromSource, type TileGridConfig } from './engine/entitySources';@@ -129,10 +130,14 @@ if (new URLSearchParams(location.search).has('automation')) {const particle = EngineHost.getResource(Particle);return rt != null && particle ? particle.getAliveCount(rt) : -1;},- /** The names the action/condition palettes offer in THIS realm — the one- * vocabulary `.esfsm` hooks, `.esbt` leaves and EventBinding rows share.- * Empty means the palettes fall back to free text (nothing registered). */- aiVocabulary: () => ({ actions: aiRegistry.actionNames(), conditions: aiRegistry.conditionNames() }),+ /** The names the action/condition palettes offer — the one vocabulary+ * `.esfsm` hooks, `.esbt` leaves and EventBinding rows share: the edit+ * realm's own registrations plus the open project's (schemas artifact). */+ aiVocabulary: () => ({+ actions: actionNames(),+ conditions: conditionNames(),+ params: Object.fromEntries(actionNames().map((n) => [n, actionParams(n).map((p) => p.name)])),+ }),/** Dispatch any registered editor command by id (the UI's own channel). */runCommand: (id: string) => commands.run(id),/** Save the open scene to disk (the toolbar Save, awaitable). */diff --git a/desktop/src/project/ProjectStore.ts b/desktop/src/project/ProjectStore.tsindex e7ff9cd49..08f23be4f 100644--- a/desktop/src/project/ProjectStore.ts+++ b/desktop/src/project/ProjectStore.ts@@ -18,6 +18,7 @@ import { Boxes } from 'lucide-react';import { spritePrefab, setCanvasDesignSeed, setProjectCameraFit, type EntitySource } from '@/engine/entitySources';import { setPrefabBaseResolver } from '@/engine/SceneQuery';import { setUserSchemas, userSchema, setBitmaskSource, setEnumSource, type UserComponentSchema } from '@/engine/schema';+import { setProjectActions, type ProjectActionSchema } from '@/ai/actionCatalog';import { setAssetRefProblemResolver } from '@/engine/EditorControlSurface';import { installSpineSync, type SpineTransport } from '@/engine/spineSync';import { SceneStore } from '@/engine/SceneStore';@@ -365,9 +366,17 @@ class ProjectStoreImpl {private async loadUserSchemas(): Promise<void> {try {const json = await window.estella.fs.read(`${WORKSPACE_DIR}/cache/schemas.json`);- setUserSchemas(JSON.parse(json) as UserComponentSchema[]);+ const parsed = JSON.parse(json) as+ | UserComponentSchema[]+ | { components?: UserComponentSchema[]; actions?: ProjectActionSchema[]; conditions?: string[] };+ // The artifact grew from a bare component array into `{components, actions,+ // conditions}`; a cache written by an older editor still reads fine.+ const artifact = Array.isArray(parsed) ? { components: parsed } : parsed;+ setUserSchemas(artifact.components ?? []);+ setProjectActions(artifact.actions ?? [], artifact.conditions ?? []);} catch {setUserSchemas([]);+ setProjectActions([], []);}}diff --git a/desktop/tests/action-catalog.test.ts b/desktop/tests/action-catalog.test.tsnew file mode 100644index 000000000..75fc81f8c--- /dev/null+++ b/desktop/tests/action-catalog.test.ts@@ -0,0 +1,80 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file The editor's action vocabulary: the live registry (engine builtins the+ * edit realm registered) merged with the open project's artifact, so the+ * FSM/BT palettes and the Events section all offer one list.+ */+import { describe, it, expect, beforeEach } from 'vitest';+import { aiRegistry } from 'esengine';+import {+ actionNames,+ conditionNames,+ actionParams,+ actionSeparator,+ isKnownAction,+ setProjectActions,+ subscribeActionCatalog,+ getActionCatalogRevision,+} from '@/ai/actionCatalog';++beforeEach(() => {+ aiRegistry.clear();+ setProjectActions([], []);+});++describe('actionCatalog', () => {+ it('offers the live registry and the project artifact as one list', () => {+ aiRegistry.registerAction('timeline.play', () => {});+ setProjectActions([{ name: 'game.startRun' }], ['game.isBoss']);++ expect(actionNames()).toEqual(['timeline.play', 'game.startRun']);+ expect(conditionNames()).toEqual(['game.isBoss']);+ });++ it('does not list a name twice when both halves have it', () => {+ aiRegistry.registerAction('game.startRun', () => {});+ setProjectActions([{ name: 'game.startRun' }], []);++ expect(actionNames()).toEqual(['game.startRun']);+ });++ it('serves a project action\'s declared parameters', () => {+ setProjectActions(+ [{ name: 'game.award', params: [{ name: 'kind', type: 'string' }], separator: '=' }],+ [],+ );++ expect(actionParams('game.award')).toEqual([{ name: 'kind', type: 'string' }]);+ expect(actionSeparator('game.award')).toBe('=');+ expect(isKnownAction('game.award')).toBe(true);+ });++ it('prefers the live registry over the artifact — the artifact can be one extract behind', () => {+ aiRegistry.registerAction('game.award', {+ params: [{ name: 'fresh', type: 'string' }],+ run: () => {},+ });+ setProjectActions([{ name: 'game.award', params: [{ name: 'stale', type: 'string' }] }], []);++ expect(actionParams('game.award').map((p) => p.name)).toEqual(['fresh']);+ });++ it('an unknown name has no parameters and the default separator (still authorable)', () => {+ expect(actionParams('nope')).toEqual([]);+ expect(actionSeparator('nope')).toBe(':');+ expect(isKnownAction('nope')).toBe(false);+ });++ it('notifies subscribers when the project half changes', () => {+ let hits = 0;+ const off = subscribeActionCatalog(() => { hits++; });+ const before = getActionCatalogRevision();++ setProjectActions([{ name: 'game.x' }], []);++ expect(hits).toBe(1);+ expect(getActionCatalogRevision()).toBeGreaterThan(before);+ off();+ });+});diff --git a/desktop/tests/extract-schemas.test.ts b/desktop/tests/extract-schemas.test.tsindex 9bb84d342..0bbe38d68 100644--- a/desktop/tests/extract-schemas.test.ts+++ b/desktop/tests/extract-schemas.test.ts@@ -12,7 +12,7 @@ import { describe, it, expect, beforeAll, afterAll } from 'vitest';import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync, existsSync } from 'node:fs';import { tmpdir } from 'node:os';import path from 'node:path';-import { extractProjectSchemas, type ComponentSchema } from '../electron/extractSchemas';+import { extractProjectSchemas, type ComponentSchema, type SchemasArtifact } from '../electron/extractSchemas';let root: string;@@ -98,8 +98,10 @@ describe('extractProjectSchemas (P2)', () => {it('the written JSON matches the returned schemas (the artifact is the source of truth)', async () => {const res = await extractProjectSchemas(root);- const onDisk = JSON.parse(readFileSync(res.outputPath!, 'utf8')) as ComponentSchema[];- expect(onDisk).toEqual(res.schemas);+ const onDisk = JSON.parse(readFileSync(res.outputPath!, 'utf8')) as SchemasArtifact;+ expect(onDisk.components).toEqual(res.schemas);+ expect(onDisk.actions).toEqual(res.actions);+ expect(onDisk.conditions).toEqual(res.conditions);});it('treats a missing DEFAULT declaration as a component-less project (empty artifact, ok)', async () => {@@ -109,7 +111,7 @@ describe('extractProjectSchemas (P2)', () => {expect(res.ok).toBe(true);expect(res.schemas).toEqual([]);expect(res.outputPath).toBe(path.join(empty, '.esengine/cache/schemas.json'));- expect(JSON.parse(readFileSync(res.outputPath!, 'utf8'))).toEqual([]);+ expect(JSON.parse(readFileSync(res.outputPath!, 'utf8'))).toEqual({ components: [], actions: [], conditions: [] });} finally {rmSync(empty, { recursive: true, force: true });}@@ -144,4 +146,57 @@ describe('extractProjectSchemas (P2)', () => {rmSync(proj, { recursive: true, force: true });}});++ // The palettes can only offer a game's own action names if they reach the+ // editor as data — the main realm never runs project code.+ describe('the project\'s registered actions', () => {+ let proj: string;++ beforeAll(() => {+ proj = mkdtempSync(path.join(tmpdir(), 'estella-schema-actions-'));+ mkdirSync(path.join(proj, 'src'), { recursive: true });+ writeFileSync(+ path.join(proj, 'src', 'components.ts'),+ `import { defineComponent, registerAction, registerCondition } from 'esengine';\n` ++ `export const Score = defineComponent('Score', { points: 0 });\n` ++ `registerAction('game.startRun', () => {});\n` ++ `registerAction('game.award', {\n` ++ ` params: [{ name: 'kind', type: 'enum', options: [{ label: 'Coin', value: 'coin' }] }, { name: 'amount', type: 'number' }],\n` ++ ` run: () => {},\n` ++ `});\n` ++ `registerCondition('game.isBoss', () => false);\n`,+ );+ });+ afterAll(() => rmSync(proj, { recursive: true, force: true }));++ it('reports them with their declared parameters', async () => {+ const res = await extractProjectSchemas(proj);+ expect(res.ok).toBe(true);+ expect(res.actions.map((a) => a.name)).toEqual(['game.award', 'game.startRun']); // sorted+ expect(res.conditions).toEqual(['game.isBoss']);++ const award = res.actions.find((a) => a.name === 'game.award')!;+ expect(award.params).toEqual([+ { name: 'kind', type: 'enum', options: [{ label: 'Coin', value: 'coin' }] },+ { name: 'amount', type: 'number' },+ ]);+ // A parameterless action carries no empty arrays / default separator.+ expect(res.actions.find((a) => a.name === 'game.startRun')).toEqual({ name: 'game.startRun' });+ });++ it('reports the components alongside them, in one artifact', async () => {+ const res = await extractProjectSchemas(proj);+ expect(res.schemas.map((s) => s.name)).toEqual(['Score']);+ const onDisk = JSON.parse(readFileSync(res.outputPath!, 'utf8')) as SchemasArtifact;+ expect(onDisk.components.map((c) => c.name)).toEqual(['Score']);+ expect(onDisk.actions.map((a) => a.name)).toEqual(['game.award', 'game.startRun']);+ });++ it('reports only the PROJECT\'s names — engine builtins are the editor\'s own half', async () => {+ const res = await extractProjectSchemas(proj);+ for (const engineOwned of ['timeline.play', 'ui.setPage', 'fsm.fire']) {+ expect(res.actions.map((a) => a.name)).not.toContain(engineOwned);+ }+ });+ });});