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: add timeline MCP tools, fix custom event rendering and selection
esengine0a43eafa9307
diff --git a/desktop/src-tauri/src/bridge_server.rs b/desktop/src-tauri/src/bridge_server.rsindex bb4215204..db43e086f 100644--- a/desktop/src-tauri/src/bridge_server.rs+++ b/desktop/src-tauri/src/bridge_server.rs@@ -317,6 +317,18 @@ fn parse_request(("POST", "/action/redo") => {Ok(("redo".into(), json!({})))}+ ("GET", "/timeline/data") => {+ let uuid = query_params.get("uuid").cloned();+ let path = query_params.get("path").cloned();+ let mut p = json!({});+ if let Some(u) = uuid { p["uuid"] = json!(u); }+ if let Some(pa) = path { p["path"] = json!(pa); }+ Ok(("getTimelineData".into(), p))+ }+ ("POST", "/timeline/update") => {+ let body = read_json_body(reader)?;+ Ok(("updateTimelineData".into(), body))+ }("GET", "/assets/meta") => {let uuid = query_params.get("uuid").cloned();let path = query_params.get("path").cloned();diff --git a/editor/src/bridge/McpBridge.ts b/editor/src/bridge/McpBridge.tsindex dcbb43887..3ba4dac25 100644--- a/editor/src/bridge/McpBridge.ts+++ b/editor/src/bridge/McpBridge.ts@@ -134,6 +134,8 @@ export class McpBridge {case 'openScene': return this.openScene_(params.path as string);case 'instantiatePrefab': return this.instantiatePrefab_(params);case 'createScript': return this.createScript_(params);+ case 'getTimelineData': return this.getTimelineData_(params);+ case 'updateTimelineData': return this.updateTimelineData_(params);case 'getAssetMeta': return this.getAssetMeta_(params);case 'updateAssetMeta': return this.updateAssetMeta_(params);case 'ensureAssetMeta': return this.ensureAssetMeta_(params);@@ -744,6 +746,68 @@ export class McpBridge {return { ok: true, path: filePath };}+ // =========================================================================+ // Timeline+ // =========================================================================++ private async getTimelineData_(params: Record<string, unknown>): Promise<unknown> {+ const fs = getEditorContext().fs;+ if (!fs) throw new Error('File system not available');+ if (!this.projectPath_) throw new Error('No project path');++ const projectDir = this.projectPath_.replace(/\/[^/]+$/, '');+ const ref = params.path as string | undefined ?? params.uuid as string | undefined;+ if (!ref) throw new Error('path or uuid is required');++ const db = getAssetDatabase();+ const relativePath = this.resolveAssetPath_(ref, db);+ const absPath = `${projectDir}/${relativePath}`;++ const content = await fs.readFile(absPath);+ if (!content) throw new Error(`Timeline file not found: ${relativePath}`);+ return JSON.parse(content);+ }++ private async updateTimelineData_(params: Record<string, unknown>): Promise<unknown> {+ const fs = getEditorContext().fs;+ if (!fs) throw new Error('File system not available');+ if (!this.projectPath_) throw new Error('No project path');++ const projectDir = this.projectPath_.replace(/\/[^/]+$/, '');+ const ref = params.path as string | undefined ?? params.uuid as string | undefined;+ if (!ref) throw new Error('path or uuid is required');++ const db = getAssetDatabase();+ const relativePath = this.resolveAssetPath_(ref, db);+ const absPath = `${projectDir}/${relativePath}`;++ const content = await fs.readFile(absPath);+ if (!content) throw new Error(`Timeline file not found: ${relativePath}`);+ const data = JSON.parse(content) as Record<string, unknown>;++ if (params.tracks !== undefined) data.tracks = params.tracks;+ if (params.duration !== undefined) data.duration = params.duration;+ if (params.wrapMode !== undefined) data.wrapMode = params.wrapMode;++ await fs.writeFile(absPath, JSON.stringify(data, null, 2));++ // Re-select to trigger timeline panel reload+ const store = getEditorStore();+ const selectedId = [...store.selectedEntities][0];+ if (selectedId != null) {+ store.selectEntity(null);+ store.selectEntity(selectedId);+ }+ getSharedRenderContext().requestRender();+ return { ok: true };+ }++ private resolveAssetPath_(ref: string, db: ReturnType<typeof getAssetDatabase>): string {+ const entry = db.getEntry(ref) ?? db.getEntryByPath(ref);+ if (entry) return entry.path;+ return ref;+ }+// =========================================================================// Asset Meta// =========================================================================diff --git a/editor/src/panels/timeline/TimelineAddTrackWizard.ts b/editor/src/panels/timeline/TimelineAddTrackWizard.tsindex 176af174b..ac6fb449c 100644--- a/editor/src/panels/timeline/TimelineAddTrackWizard.ts+++ b/editor/src/panels/timeline/TimelineAddTrackWizard.ts@@ -298,7 +298,7 @@ export class TimelineAddTrackWizard {case 'marker':return { type: 'marker', name: 'Markers', markers: [] };case 'customEvent':- return { type: 'customEvent', name: 'Custom Events', customEvents: [] };+ return { type: 'customEvent', name: 'Custom Events', events: [] };default:return { type, name: type };}diff --git a/editor/src/panels/timeline/TimelineKeyframeArea.ts b/editor/src/panels/timeline/TimelineKeyframeArea.tsindex 8842ffe51..9e0c9f206 100644--- a/editor/src/panels/timeline/TimelineKeyframeArea.ts+++ b/editor/src/panels/timeline/TimelineKeyframeArea.ts@@ -13,6 +13,8 @@ import {BatchDeleteKeyframesCommand,PasteKeyframesCommand,} from './TimelineCommands';+import { showInputDialog } from '../../ui/InputDialog';+import { showObjectDialog } from '../../ui/dialog';import {AddSpineClipCommand,MoveSpineClipCommand,@@ -31,6 +33,8 @@ import {AddCustomEventCommand,MoveCustomEventCommand,DeleteCustomEventCommand,+ RenameCustomEventCommand,+ EditCustomEventPayloadCommand,MoveSpriteAnimStartCommand,} from './TimelineTrackCommands';@@ -97,17 +101,56 @@ export interface TimelineAssetData {duration: number;}+export interface TimelineKeyframe {+ time: number;+ value: number;+ inTangent?: number;+ outTangent?: number;+ interpolation?: string;+}++export interface TimelineChannel {+ property: string;+ keyframes: TimelineKeyframe[];+}++export interface TimelineSpineClip {+ start: number;+ duration: number;+ animation: string;+}++export interface TimelineAudioEvent {+ time: number;+ clip: string;+}++export interface TimelineCustomEvent {+ time: number;+ name: string;+ payload: Record<string, unknown>;+}++export interface TimelineActivationRange {+ start: number;+ end: number;+}++export interface TimelineMarker {+ time: number;+ name: string;+}+export interface TimelineTrackData {type: string;name: string;childPath?: string;component?: string;- channels?: { property: string; keyframes: { time: number; value: number; inTangent?: number; outTangent?: number; interpolation?: string }[] }[];- clips?: { start: number; duration: number; animation: string }[];- events?: { time: number; clip: string }[];- ranges?: { start: number; end: number }[];- markers?: { time: number; name: string }[];- customEvents?: { time: number; name: string; payload: Record<string, unknown> }[];+ channels?: TimelineChannel[];+ clips?: TimelineSpineClip[];+ events?: (TimelineAudioEvent | TimelineCustomEvent)[];+ ranges?: TimelineActivationRange[];+ markers?: TimelineMarker[];clip?: string;startTime?: number;}@@ -154,6 +197,7 @@ export class TimelineKeyframeArea {private unsub_: (() => void) | null = null;private resizeObserver_: ResizeObserver | null = null;private selectedKeyframes_: Map<string, KeyframeHit> = new Map();+ private selectedNpItem_: { type: string; trackIndex: number; itemIndex: number } | null = null;private onSelectionChange_: KeyframeSelectionCallback | null = null;private rubberBand_: { startX: number; startY: number; endX: number; endY: number } | null = null;private clipboard_: { channelIndex: number; relativeTime: number; value: number; inTangent: number; outTangent: number }[] = [];@@ -199,9 +243,23 @@ export class TimelineKeyframeArea {private clearSelection(): void {this.selectedKeyframes_.clear();+ this.selectedNpItem_ = null;this.notifySelectionChange();}+ private selectNpItem(npHit: { type: string; hit: SpineClipHit | AudioEventHit | ActivationRangeHit | MarkerHit | CustomEventHit | SpriteAnimHit }): void {+ this.selectedKeyframes_.clear();+ const hit = npHit.hit;+ let itemIndex = -1;+ if ('clipIndex' in hit) itemIndex = hit.clipIndex;+ else if ('eventIndex' in hit) itemIndex = hit.eventIndex;+ else if ('rangeIndex' in hit) itemIndex = hit.rangeIndex;+ else if ('markerIndex' in hit) itemIndex = hit.markerIndex;+ const trackIndex = hit.trackIndex;+ this.selectedNpItem_ = { type: npHit.type, trackIndex, itemIndex };+ this.draw();+ }+private selectOnly(hit: KeyframeHit): void {this.selectedKeyframes_.clear();this.selectedKeyframes_.set(kfKey(hit.trackIndex, hit.channelIndex, hit.keyframeIndex), hit);@@ -458,30 +516,47 @@ export class TimelineKeyframeArea {break;case 'marker':- this.drawMarkers(ctx, assetTrack.markers ?? [], y);+ this.drawMarkers(ctx, assetTrack.markers ?? [], y, track.index);break;case 'customEvent':- this.drawCustomEvents(ctx, assetTrack.customEvents ?? [], y);+ this.drawCustomEvents(ctx, (assetTrack.events ?? []) as TimelineCustomEvent[], y, track.index);break;}}+ private isNpItemSelected(type: string, trackIndex: number, itemIndex: number): boolean {+ const sel = this.selectedNpItem_;+ return sel != null && sel.type === type && sel.trackIndex === trackIndex && sel.itemIndex === itemIndex;+ }+private drawCustomEvents(ctx: CanvasRenderingContext2D,- events: { time: number; name: string }[],+ events: TimelineCustomEvent[],y: number,+ trackIndex: number,): void {- for (const event of events) {+ for (let i = 0; i < events.length; i++) {+ const event = events[i];const x = this.state_.timeToX(event.time);- ctx.fillStyle = CUSTOM_EVENT_COLOR;+ const selected = this.isNpItemSelected('customEvent', trackIndex, i);++ ctx.fillStyle = selected ? KEYFRAME_SELECTED : CUSTOM_EVENT_COLOR;ctx.fillRect(x - 1, y + 2, 3, TRACK_HEIGHT - 4);ctx.beginPath();ctx.arc(x, y + 6, 4, 0, Math.PI * 2);ctx.fill();- ctx.fillStyle = '#cccccc';+ if (selected) {+ ctx.strokeStyle = '#ffffff';+ ctx.lineWidth = 1.5;+ ctx.beginPath();+ ctx.arc(x, y + 6, 5.5, 0, Math.PI * 2);+ ctx.stroke();+ }++ ctx.fillStyle = selected ? '#ffffff' : '#cccccc';ctx.font = '9px monospace';ctx.textAlign = 'left';ctx.fillText(event.name, x + 6, y + TRACK_HEIGHT / 2 + 3);@@ -492,10 +567,14 @@ export class TimelineKeyframeArea {ctx: CanvasRenderingContext2D,markers: { time: number; name: string }[],y: number,+ trackIndex: number,): void {- for (const marker of markers) {+ for (let i = 0; i < markers.length; i++) {+ const marker = markers[i];const x = this.state_.timeToX(marker.time);- ctx.fillStyle = MARKER_COLOR;+ const selected = this.isNpItemSelected('marker', trackIndex, i);++ ctx.fillStyle = selected ? KEYFRAME_SELECTED : MARKER_COLOR;ctx.fillRect(x - 1, y + 2, 3, TRACK_HEIGHT - 4);ctx.beginPath();@@ -505,7 +584,18 @@ export class TimelineKeyframeArea {ctx.closePath();ctx.fill();- ctx.fillStyle = '#cccccc';+ if (selected) {+ ctx.strokeStyle = '#ffffff';+ ctx.lineWidth = 1.5;+ ctx.beginPath();+ ctx.moveTo(x - 6.5, y + 1);+ ctx.lineTo(x + 6.5, y + 1);+ ctx.lineTo(x, y + 9.5);+ ctx.closePath();+ ctx.stroke();+ }++ ctx.fillStyle = selected ? '#ffffff' : '#cccccc';ctx.font = '9px monospace';ctx.textAlign = 'left';ctx.fillText(marker.name, x + 6, y + TRACK_HEIGHT / 2 + 3);@@ -852,10 +942,10 @@ export class TimelineKeyframeArea {private hitTestCustomEvent(x: number, trackIndex: number): CustomEventHit | null {if (!this.assetData_) return null;const track = this.assetData_.tracks[trackIndex];- if (!track || track.type !== 'customEvent' || !track.customEvents) return null;+ if (!track || track.type !== 'customEvent' || !track.events) return null;- for (let i = 0; i < track.customEvents.length; i++) {- const ex = this.state_.timeToX(track.customEvents[i].time);+ for (let i = 0; i < track.events.length; i++) {+ const ex = this.state_.timeToX(track.events[i].time);if (Math.abs(x - ex) <= KEYFRAME_HIT_RADIUS) {return { trackIndex, eventIndex: i };}@@ -1042,6 +1132,7 @@ export class TimelineKeyframeArea {const npHit = this.hitTestNonPropertyTrack(x, y);if (npHit) {this.clearSelection();+ this.selectNpItem(npHit);this.canvas_.focus();if (npHit.type === 'spine') {this.startSpineClipDrag(e, rect, npHit.hit as SpineClipHit);@@ -1241,8 +1332,8 @@ export class TimelineKeyframeArea {private startCustomEventDrag(_e: MouseEvent, rect: DOMRect, hit: CustomEventHit): void {if (!this.assetData_ || !this.host_) return;const track = this.assetData_.tracks[hit.trackIndex];- if (!track?.customEvents) return;- const event = track.customEvents[hit.eventIndex];+ if (!track?.events) return;+ const event = track.events[hit.eventIndex];if (!event) return;const oldTime = event.time;@@ -1684,6 +1775,7 @@ export class TimelineKeyframeArea {});menu.appendChild(deleteItem);} else if (npHit) {+ this.selectNpItem(npHit);this.buildNonPropertyContextMenu(menu, npHit);} else if (trackInfo) {const assetTrack = this.assetData_.tracks[trackInfo.trackIndex];@@ -1815,10 +1907,60 @@ export class TimelineKeyframeArea {menu.appendChild(item);} else if (npHit.type === 'customEvent') {const hit = npHit.hit as CustomEventHit;- const item = document.createElement('div');- item.className = 'es-timeline-dropdown-item';- item.textContent = 'Delete Event';- item.addEventListener('click', () => {+ const track = this.assetData_!.tracks[hit.trackIndex];+ const events = (track?.events ?? []) as TimelineCustomEvent[];+ const ev = events[hit.eventIndex];++ const renameItem = document.createElement('div');+ renameItem.className = 'es-timeline-dropdown-item';+ renameItem.textContent = 'Rename';+ renameItem.addEventListener('click', async () => {+ menu.remove();+ if (!ev) return;+ const newName = await showInputDialog({+ title: 'Rename Event',+ defaultValue: ev.name,+ placeholder: 'Event name',+ });+ if (newName != null && newName !== ev.name) {+ const cmd = new RenameCustomEventCommand(+ this.assetData_!, hit.trackIndex, hit.eventIndex,+ ev.name, newName,+ () => this.host_!.onAssetDataChanged(),+ );+ this.host_!.executeCommand(cmd);+ }+ });+ menu.appendChild(renameItem);++ const payloadItem = document.createElement('div');+ payloadItem.className = 'es-timeline-dropdown-item';+ payloadItem.textContent = 'Edit Payload';+ payloadItem.addEventListener('click', async () => {+ menu.remove();+ if (!ev) return;+ const newPayload = await showObjectDialog({+ title: `Edit Payload — ${ev.name}`,+ value: ev.payload ?? {},+ });+ if (newPayload == null) return;+ const cmd = new EditCustomEventPayloadCommand(+ this.assetData_!, hit.trackIndex, hit.eventIndex,+ { ...ev.payload }, newPayload,+ () => this.host_!.onAssetDataChanged(),+ );+ this.host_!.executeCommand(cmd);+ });+ menu.appendChild(payloadItem);++ const sep = document.createElement('div');+ sep.className = 'es-timeline-dropdown-separator';+ menu.appendChild(sep);++ const deleteItem = document.createElement('div');+ deleteItem.className = 'es-timeline-dropdown-item';+ deleteItem.textContent = 'Delete Event';+ deleteItem.addEventListener('click', () => {menu.remove();const cmd = new DeleteCustomEventCommand(this.assetData_!, hit.trackIndex, hit.eventIndex,@@ -1826,7 +1968,7 @@ export class TimelineKeyframeArea {);this.host_!.executeCommand(cmd);});- menu.appendChild(item);+ menu.appendChild(deleteItem);}}diff --git a/editor/src/panels/timeline/TimelinePanel.ts b/editor/src/panels/timeline/TimelinePanel.tsindex 11112f65c..f2b996603 100644--- a/editor/src/panels/timeline/TimelinePanel.ts+++ b/editor/src/panels/timeline/TimelinePanel.ts@@ -64,6 +64,7 @@ export class TimelinePanel implements PanelInstance {this.applyScrubPreview();}));+ this.onSelectionOrSceneChanged();this.updateEmptyState();const sceneService = getSceneService();if (sceneService) {diff --git a/editor/src/panels/timeline/TimelineTrackCommands.ts b/editor/src/panels/timeline/TimelineTrackCommands.tsindex 386e99354..6bde41c18 100644--- a/editor/src/panels/timeline/TimelineTrackCommands.ts+++ b/editor/src/panels/timeline/TimelineTrackCommands.ts@@ -62,8 +62,8 @@ interface CustomEventData {function getCustomEvents(data: TimelineAssetData, trackIndex: number): CustomEventData[] | null {const track = data.tracks[trackIndex];if (!track || track.type !== 'customEvent') return null;- if (!track.customEvents) track.customEvents = [];- return track.customEvents as CustomEventData[];+ if (!track.events) track.events = [];+ return track.events as CustomEventData[];}// =============================================================================@@ -786,6 +786,70 @@ export class DeleteCustomEventCommand extends BaseCommand {}}+export class RenameCustomEventCommand extends BaseCommand {+ readonly type = 'timeline_rename_custom_event';+ readonly description = 'Rename custom event';++ constructor(+ private data_: TimelineAssetData,+ private trackIndex_: number,+ private eventIndex_: number,+ private oldName_: string,+ private newName_: string,+ private onChanged_: () => void,+ ) {+ super();+ }++ execute(): void {+ const events = getCustomEvents(this.data_, this.trackIndex_);+ if (!events) return;+ const ev = events[this.eventIndex_];+ if (ev) ev.name = this.newName_;+ this.onChanged_();+ }++ undo(): void {+ const events = getCustomEvents(this.data_, this.trackIndex_);+ if (!events) return;+ const ev = events[this.eventIndex_];+ if (ev) ev.name = this.oldName_;+ this.onChanged_();+ }+}++export class EditCustomEventPayloadCommand extends BaseCommand {+ readonly type = 'timeline_edit_custom_event_payload';+ readonly description = 'Edit custom event payload';++ constructor(+ private data_: TimelineAssetData,+ private trackIndex_: number,+ private eventIndex_: number,+ private oldPayload_: Record<string, unknown>,+ private newPayload_: Record<string, unknown>,+ private onChanged_: () => void,+ ) {+ super();+ }++ execute(): void {+ const events = getCustomEvents(this.data_, this.trackIndex_);+ if (!events) return;+ const ev = events[this.eventIndex_];+ if (ev) ev.payload = { ...this.newPayload_ };+ this.onChanged_();+ }++ undo(): void {+ const events = getCustomEvents(this.data_, this.trackIndex_);+ if (!events) return;+ const ev = events[this.eventIndex_];+ if (ev) ev.payload = { ...this.oldPayload_ };+ this.onChanged_();+ }+}+// =============================================================================// SpriteAnim Commands// =============================================================================diff --git a/editor/src/styles/dialogs.css b/editor/src/styles/dialogs.cssindex 143b50432..94a37f29b 100644--- a/editor/src/styles/dialogs.css+++ b/editor/src/styles/dialogs.css@@ -1366,3 +1366,68 @@cursor: pointer;accent-color: var(--es-accent-gold);}++.es-object-editor {+ min-width: 360px;+}++.es-object-editor-list {+ display: flex;+ flex-direction: column;+ gap: 6px;+ margin-bottom: 8px;+ max-height: 300px;+ overflow-y: auto;+}++.es-object-editor-row {+ display: flex;+ gap: 6px;+ align-items: center;+}++.es-object-editor-key {+ flex: 2;+ min-width: 0;+}++.es-object-editor-value {+ flex: 3;+ min-width: 0;+}++.es-object-editor-remove {+ flex-shrink: 0;+ width: 24px;+ height: 24px;+ border: none;+ background: transparent;+ color: var(--es-text-secondary);+ font-size: 16px;+ cursor: pointer;+ border-radius: 4px;+ display: flex;+ align-items: center;+ justify-content: center;+}++.es-object-editor-remove:hover {+ background: var(--es-bg-tertiary);+ color: var(--es-danger, #e06c75);+}++.es-object-editor-add {+ border: 1px dashed var(--es-border);+ background: transparent;+ color: var(--es-text-secondary);+ padding: 4px 12px;+ cursor: pointer;+ border-radius: 4px;+ font-size: 12px;+ width: 100%;+}++.es-object-editor-add:hover {+ border-color: var(--es-accent);+ color: var(--es-accent);+}diff --git a/editor/src/styles/timeline.css b/editor/src/styles/timeline.cssindex fff5e18d5..b743c885f 100644--- a/editor/src/styles/timeline.css+++ b/editor/src/styles/timeline.css@@ -147,6 +147,7 @@flex-shrink: 0;border-right: 1px solid var(--es-border);overflow-y: auto;+ padding-top: 24px;background: var(--es-bg-primary);}@@ -333,6 +334,12 @@pointer-events: none;}+.es-timeline-dropdown-separator {+ height: 1px;+ background: var(--es-border);+ margin: 4px 0;+}+.es-timeline-dropdown-back {color: var(--es-text-secondary);font-size: 11px;diff --git a/editor/src/ui/dialog/index.ts b/editor/src/ui/dialog/index.tsindex cfc197715..2118a3858 100644--- a/editor/src/ui/dialog/index.ts+++ b/editor/src/ui/dialog/index.ts@@ -4,7 +4,8 @@*/export { Dialog } from './Dialog';-export { showDialog, showInputDialog, showConfirmDialog, showAlertDialog } from './presets';+export { showDialog, showInputDialog, showObjectDialog, showConfirmDialog, showAlertDialog } from './presets';+export type { ObjectDialogOptions } from './presets';export type {DialogRole,DialogButton,diff --git a/editor/src/ui/dialog/presets.ts b/editor/src/ui/dialog/presets.tsindex 9063920e1..a3edb7750 100644--- a/editor/src/ui/dialog/presets.ts+++ b/editor/src/ui/dialog/presets.ts@@ -115,6 +115,117 @@ export function showConfirmDialog(options: ConfirmDialogOptions): Promise<boolea});}+export interface ObjectDialogOptions {+ title: string;+ value: Record<string, unknown>;+ confirmText?: string;+ cancelText?: string;+}++export function showObjectDialog(options: ObjectDialogOptions): Promise<Record<string, unknown> | null> {+ return new Promise((resolve) => {+ const content = document.createElement('div');+ content.className = 'es-object-editor';++ const rows: { keyInput: HTMLInputElement; valueInput: HTMLInputElement; row: HTMLElement }[] = [];++ const addRow = (key = '', value = ''): void => {+ const row = document.createElement('div');+ row.className = 'es-object-editor-row';++ const keyInput = document.createElement('input');+ keyInput.type = 'text';+ keyInput.className = 'es-dialog-input es-object-editor-key';+ keyInput.placeholder = 'key';+ keyInput.value = key;++ const valueInput = document.createElement('input');+ valueInput.type = 'text';+ valueInput.className = 'es-dialog-input es-object-editor-value';+ valueInput.placeholder = 'value';+ valueInput.value = value;++ const removeBtn = document.createElement('button');+ removeBtn.className = 'es-object-editor-remove';+ removeBtn.textContent = '\u00d7';+ removeBtn.addEventListener('click', () => {+ row.remove();+ const idx = rows.findIndex(r => r.row === row);+ if (idx >= 0) rows.splice(idx, 1);+ });++ row.appendChild(keyInput);+ row.appendChild(valueInput);+ row.appendChild(removeBtn);+ listEl.appendChild(row);+ rows.push({ keyInput, valueInput, row });+ };++ const listEl = document.createElement('div');+ listEl.className = 'es-object-editor-list';+ content.appendChild(listEl);++ for (const [k, v] of Object.entries(options.value)) {+ addRow(k, typeof v === 'string' ? v : JSON.stringify(v));+ }++ const addBtn = document.createElement('button');+ addBtn.className = 'es-object-editor-add';+ addBtn.textContent = '+ Add Field';+ addBtn.addEventListener('click', () => addRow());+ content.appendChild(addBtn);++ const errorEl = document.createElement('div');+ errorEl.className = 'es-dialog-error';+ errorEl.style.display = 'none';+ content.appendChild(errorEl);++ let dialog: Dialog;++ const collect = (): Record<string, unknown> | null => {+ const result: Record<string, unknown> = {};+ for (const { keyInput, valueInput } of rows) {+ const k = keyInput.value.trim();+ if (!k) continue;+ const raw = valueInput.value.trim();+ try {+ result[k] = JSON.parse(raw);+ } catch {+ result[k] = raw;+ }+ }+ return result;+ };++ const submit = (): boolean => {+ const result = collect();+ dialog.close({ action: 'confirm', data: result });+ return true;+ };++ dialog = new Dialog({+ title: options.title,+ content,+ width: 420,+ buttons: [+ { label: options.cancelText ?? 'Cancel', role: 'cancel' },+ { label: options.confirmText ?? 'Confirm', role: 'confirm', primary: true, onClick: () => submit() },+ ],+ closeOnEscape: true,+ });++ let resultData: Record<string, unknown> | null = null;+ dialog.open().then((result) => {+ if (result.action === 'confirm') {+ resultData = result.data ?? collect();+ resolve(resultData);+ } else {+ resolve(null);+ }+ }).catch(() => resolve(null));+ });+}+export function showAlertDialog(options: AlertDialogOptions): Promise<void> {return new Promise((resolve) => {const typeClass = options.type ? `es-dialog-${options.type}` : undefined;diff --git a/tools/mcp-server/src/tools/state.ts b/tools/mcp-server/src/tools/state.tsindex 56f4709d0..a6ff0c22c 100644--- a/tools/mcp-server/src/tools/state.ts+++ b/tools/mcp-server/src/tools/state.ts@@ -92,6 +92,36 @@ export function registerStateTools(},);+ server.tool(+ 'get_timeline_data',+ 'Get timeline asset data (tracks, duration, wrapMode)',+ {+ uuid: z.string().optional().describe('Timeline asset UUID'),+ path: z.string().optional().describe('Timeline asset relative path'),+ },+ async (args: { uuid?: string; path?: string }) => {+ const params = args.uuid ? `uuid=${args.uuid}` : `path=${encodeURIComponent(args.path!)}`;+ const result = await bridge.get(`/timeline/data?${params}`);+ return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };+ },+ );++ server.tool(+ 'update_timeline_data',+ 'Update timeline asset: add/modify tracks, keyframes, markers, events, duration',+ {+ uuid: z.string().optional().describe('Timeline asset UUID'),+ path: z.string().optional().describe('Timeline asset relative path'),+ tracks: z.array(z.record(z.unknown())).optional().describe('Full tracks array to replace'),+ duration: z.number().optional().describe('Timeline duration in seconds'),+ wrapMode: z.string().optional().describe('Wrap mode: once, loop, pingPong'),+ },+ async (args: { uuid?: string; path?: string; tracks?: Record<string, unknown>[]; duration?: number; wrapMode?: string }) => {+ const result = await bridge.post('/timeline/update', args);+ return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };+ },+ );+server.tool('get_asset_meta','Get full asset meta: UUID, importer settings, labels, address, group, platform overrides',