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 floating build progress panel UI
esengine111149181ebe
diff --git a/editor/src/builder/BuildProgressPanel.ts b/editor/src/builder/BuildProgressPanel.tsnew file mode 100644index 000000000..81f424dee--- /dev/null+++ b/editor/src/builder/BuildProgressPanel.ts@@ -0,0 +1,284 @@+/**+ * @file BuildProgressPanel.ts+ * @brief Floating build progress panel UI+ */++import {+ BuildProgress,+ BuildProgressReporter,+ BuildPhase,+ BuildLogEntry,+ formatDuration,+} from './BuildProgress';++// =============================================================================+// Types+// =============================================================================++export type CancelCallback = () => void;++// =============================================================================+// Phase Display Names+// =============================================================================++const PHASE_DISPLAY_NAMES: Record<BuildPhase, string> = {+ preparing: 'Preparing',+ compiling: 'Compiling Scripts',+ processing_assets: 'Processing Assets',+ assembling: 'Assembling',+ writing: 'Writing Output',+ completed: 'Completed',+ failed: 'Failed',+};++const LOG_LEVEL_CLASSES: Record<string, string> = {+ info: 'progress-log-info',+ warn: 'progress-log-warn',+ error: 'progress-log-error',+ debug: 'progress-log-debug',+};++// =============================================================================+// BuildProgressPanel Class+// =============================================================================++export class BuildProgressPanel {+ private container_: HTMLDivElement | null = null;+ private progressBar_: HTMLDivElement | null = null;+ private progressText_: HTMLDivElement | null = null;+ private phaseText_: HTMLDivElement | null = null;+ private taskText_: HTMLDivElement | null = null;+ private timeText_: HTMLDivElement | null = null;+ private logContainer_: HTMLDivElement | null = null;+ private cancelBtn_: HTMLButtonElement | null = null;+ private closeBtn_: HTMLButtonElement | null = null;++ private reporter_: BuildProgressReporter | null = null;+ private unsubscribe_: (() => void) | null = null;+ private onCancel_: CancelCallback | null = null;+ private autoScrollLogs_ = true;++ show(reporter: BuildProgressReporter, onCancel?: CancelCallback): void {+ this.reporter_ = reporter;+ this.onCancel_ = onCancel ?? null;++ if (!this.container_) {+ this.createPanel();+ }++ this.container_!.style.display = 'flex';+ this.updateCancelButton(true);++ this.unsubscribe_ = reporter.onProgress((progress) => {+ this.updateProgress(progress);+ });+ }++ hide(): void {+ if (this.container_) {+ this.container_.style.display = 'none';+ }+ this.cleanup();+ }++ destroy(): void {+ this.cleanup();+ if (this.container_ && this.container_.parentNode) {+ this.container_.parentNode.removeChild(this.container_);+ }+ this.container_ = null;+ }++ private cleanup(): void {+ if (this.unsubscribe_) {+ this.unsubscribe_();+ this.unsubscribe_ = null;+ }+ this.reporter_ = null;+ this.onCancel_ = null;+ }++ private createPanel(): void {+ this.container_ = document.createElement('div');+ this.container_.className = 'build-progress-panel';++ const header = document.createElement('div');+ header.className = 'build-progress-header';++ const title = document.createElement('div');+ title.className = 'build-progress-title';+ title.textContent = 'Building...';++ this.closeBtn_ = document.createElement('button');+ this.closeBtn_.className = 'build-progress-close';+ this.closeBtn_.innerHTML = '×';+ this.closeBtn_.onclick = () => this.hide();++ header.appendChild(title);+ header.appendChild(this.closeBtn_);++ const phaseSection = document.createElement('div');+ phaseSection.className = 'build-progress-phase-section';++ this.phaseText_ = document.createElement('div');+ this.phaseText_.className = 'build-progress-phase';++ this.timeText_ = document.createElement('div');+ this.timeText_.className = 'build-progress-time';++ phaseSection.appendChild(this.phaseText_);+ phaseSection.appendChild(this.timeText_);++ const progressSection = document.createElement('div');+ progressSection.className = 'build-progress-bar-section';++ const progressTrack = document.createElement('div');+ progressTrack.className = 'build-progress-bar-track';++ this.progressBar_ = document.createElement('div');+ this.progressBar_.className = 'build-progress-bar-fill';++ progressTrack.appendChild(this.progressBar_);++ this.progressText_ = document.createElement('div');+ this.progressText_.className = 'build-progress-percent';+ this.progressText_.textContent = '0%';++ progressSection.appendChild(progressTrack);+ progressSection.appendChild(this.progressText_);++ this.taskText_ = document.createElement('div');+ this.taskText_.className = 'build-progress-task';++ this.logContainer_ = document.createElement('div');+ this.logContainer_.className = 'build-progress-logs';+ this.logContainer_.onscroll = () => {+ const el = this.logContainer_!;+ const atBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 20;+ this.autoScrollLogs_ = atBottom;+ };++ const footer = document.createElement('div');+ footer.className = 'build-progress-footer';++ this.cancelBtn_ = document.createElement('button');+ this.cancelBtn_.className = 'build-progress-cancel-btn';+ this.cancelBtn_.textContent = 'Cancel';+ this.cancelBtn_.onclick = () => this.handleCancel();++ footer.appendChild(this.cancelBtn_);++ this.container_.appendChild(header);+ this.container_.appendChild(phaseSection);+ this.container_.appendChild(progressSection);+ this.container_.appendChild(this.taskText_);+ this.container_.appendChild(this.logContainer_);+ this.container_.appendChild(footer);++ document.body.appendChild(this.container_);+ }++ private updateProgress(progress: BuildProgress): void {+ if (!this.container_) return;++ this.progressBar_!.style.width = `${progress.overallProgress}%`;+ this.progressText_!.textContent = `${progress.overallProgress}%`;++ this.phaseText_!.textContent = PHASE_DISPLAY_NAMES[progress.phase];+ this.taskText_!.textContent = progress.currentTask;++ const elapsed = Date.now() - progress.startTime;+ let timeText = `Elapsed: ${formatDuration(elapsed)}`;+ if (progress.estimatedTimeRemaining !== undefined && progress.estimatedTimeRemaining > 0) {+ timeText += ` · ~${formatDuration(progress.estimatedTimeRemaining)} remaining`;+ }+ this.timeText_!.textContent = timeText;++ this.updateLogs(progress.logs);++ if (progress.phase === 'completed') {+ this.phaseText_!.classList.add('build-progress-success');+ this.updateCancelButton(false);+ } else if (progress.phase === 'failed') {+ this.phaseText_!.classList.add('build-progress-error');+ this.progressBar_!.classList.add('build-progress-bar-error');+ this.updateCancelButton(false);+ } else {+ this.phaseText_!.classList.remove('build-progress-success', 'build-progress-error');+ this.progressBar_!.classList.remove('build-progress-bar-error');+ }+ }++ private updateLogs(logs: BuildLogEntry[]): void {+ if (!this.logContainer_) return;++ const currentCount = this.logContainer_.children.length;+ const newLogs = logs.slice(currentCount);++ for (const entry of newLogs) {+ const line = document.createElement('div');+ line.className = `build-progress-log-line ${LOG_LEVEL_CLASSES[entry.level] || ''}`;++ const time = new Date(entry.timestamp).toLocaleTimeString();+ line.innerHTML = `<span class="log-time">[${time}]</span> ${this.escapeHtml(entry.message)}`;++ this.logContainer_.appendChild(line);+ }++ if (this.autoScrollLogs_ && newLogs.length > 0) {+ this.logContainer_.scrollTop = this.logContainer_.scrollHeight;+ }+ }++ private escapeHtml(text: string): string {+ const div = document.createElement('div');+ div.textContent = text;+ return div.innerHTML;+ }++ private updateCancelButton(canCancel: boolean): void {+ if (this.cancelBtn_) {+ this.cancelBtn_.disabled = !canCancel;+ this.cancelBtn_.textContent = canCancel ? 'Cancel' : 'Close';+ this.cancelBtn_.onclick = canCancel+ ? () => this.handleCancel()+ : () => this.hide();+ }+ }++ private handleCancel(): void {+ if (this.onCancel_) {+ this.onCancel_();+ }+ }++ isVisible(): boolean {+ return this.container_?.style.display === 'flex';+ }+}++// =============================================================================+// Singleton Instance+// =============================================================================++let panelInstance: BuildProgressPanel | null = null;++export function getBuildProgressPanel(): BuildProgressPanel {+ if (!panelInstance) {+ panelInstance = new BuildProgressPanel();+ }+ return panelInstance;+}++export function showBuildProgress(+ reporter: BuildProgressReporter,+ onCancel?: CancelCallback+): void {+ getBuildProgressPanel().show(reporter, onCancel);+}++export function hideBuildProgress(): void {+ if (panelInstance) {+ panelInstance.hide();+ }+}diff --git a/editor/src/builder/index.ts b/editor/src/builder/index.tsindex a1b0c42de..a83e82757 100644--- a/editor/src/builder/index.ts+++ b/editor/src/builder/index.ts@@ -10,6 +10,7 @@ export { WeChatBuilder } from './WeChatBuilder';export { BuildCache, type BuildCacheData, type FileHash, type FileChangeResult } from './BuildCache';export { BuildProgressReporter, formatDuration, formatSize, type BuildProgress, type BuildLogEntry, type BuildPhase, type LogLevel } from './BuildProgress';+export { BuildProgressPanel, getBuildProgressPanel, showBuildProgress, hideBuildProgress, type CancelCallback } from './BuildProgressPanel';export { BuildConfigService, getBuildConfigService, initBuildConfigService, type BuildSettingsFile } from './BuildConfigService';export { BuildPipeline, createTask, createPlayableTasks, type BuildTask, type TaskResult, type PipelineResult } from './BuildPipeline';export { BuildConfigIO, downloadConfigsAsFile, uploadConfigsFromFile, type ExportedConfig, type ImportResult } from './BuildConfigIO';diff --git a/editor/src/styles/editor.css b/editor/src/styles/editor.cssindex 445d082d3..b9471121d 100644--- a/editor/src/styles/editor.css+++ b/editor/src/styles/editor.css@@ -3468,3 +3468,194 @@ svg {font-size: 11px;color: var(--es-text-secondary);}++/* =============================================================================+ * Build Progress Panel+ * ============================================================================= */++.build-progress-panel {+ position: fixed;+ bottom: 20px;+ right: 20px;+ width: 420px;+ max-height: 400px;+ background: var(--es-bg-secondary);+ border: 1px solid var(--es-border);+ border-radius: 8px;+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);+ display: none;+ flex-direction: column;+ z-index: 10000;+ overflow: hidden;+}++.build-progress-header {+ display: flex;+ justify-content: space-between;+ align-items: center;+ padding: 12px 16px;+ background: var(--es-bg-tertiary);+ border-bottom: 1px solid var(--es-border);+}++.build-progress-title {+ font-size: 13px;+ font-weight: 500;+ color: var(--es-text-primary);+}++.build-progress-close {+ background: none;+ border: none;+ color: var(--es-text-secondary);+ font-size: 18px;+ line-height: 1;+ cursor: pointer;+ padding: 0 4px;+}++.build-progress-close:hover {+ color: var(--es-text-primary);+}++.build-progress-phase-section {+ display: flex;+ justify-content: space-between;+ align-items: center;+ padding: 12px 16px 8px;+}++.build-progress-phase {+ font-size: 14px;+ font-weight: 500;+ color: var(--es-accent);+}++.build-progress-phase.build-progress-success {+ color: var(--es-success);+}++.build-progress-phase.build-progress-error {+ color: var(--es-danger);+}++.build-progress-time {+ font-size: 11px;+ color: var(--es-text-secondary);+}++.build-progress-bar-section {+ display: flex;+ align-items: center;+ gap: 12px;+ padding: 0 16px 8px;+}++.build-progress-bar-track {+ flex: 1;+ height: 6px;+ background: var(--es-bg-tertiary);+ border-radius: 3px;+ overflow: hidden;+}++.build-progress-bar-fill {+ height: 100%;+ background: var(--es-accent);+ border-radius: 3px;+ transition: width 0.2s ease;+ width: 0%;+}++.build-progress-bar-fill.build-progress-bar-error {+ background: var(--es-danger);+}++.build-progress-percent {+ font-size: 12px;+ font-weight: 500;+ color: var(--es-text-primary);+ min-width: 36px;+ text-align: right;+}++.build-progress-task {+ padding: 0 16px 12px;+ font-size: 11px;+ color: var(--es-text-secondary);+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}++.build-progress-logs {+ flex: 1;+ min-height: 120px;+ max-height: 180px;+ overflow-y: auto;+ background: var(--es-bg-primary);+ margin: 0 12px;+ border-radius: 4px;+ font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;+ font-size: 11px;+ line-height: 1.5;+}++.build-progress-log-line {+ padding: 2px 8px;+ color: var(--es-text-secondary);+ border-bottom: 1px solid var(--es-bg-secondary);+}++.build-progress-log-line:last-child {+ border-bottom: none;+}++.build-progress-log-line .log-time {+ color: var(--es-text-secondary);+ opacity: 0.6;+ margin-right: 4px;+}++.build-progress-log-line.progress-log-info {+ color: var(--es-text-primary);+}++.build-progress-log-line.progress-log-warn {+ color: #e6a700;+}++.build-progress-log-line.progress-log-error {+ color: var(--es-danger);+}++.build-progress-log-line.progress-log-debug {+ color: var(--es-text-secondary);+ opacity: 0.7;+}++.build-progress-footer {+ display: flex;+ justify-content: flex-end;+ padding: 12px 16px;+ border-top: 1px solid var(--es-border);+}++.build-progress-cancel-btn {+ padding: 6px 16px;+ background: var(--es-bg-tertiary);+ border: 1px solid var(--es-border);+ border-radius: 4px;+ color: var(--es-text-primary);+ font-size: 12px;+ cursor: pointer;+}++.build-progress-cancel-btn:hover:not(:disabled) {+ background: var(--es-bg-hover);+}++.build-progress-cancel-btn:disabled {+ opacity: 0.5;+ cursor: default;+}