清理调试日志
This commit is contained in:
@@ -36,7 +36,6 @@ export function EntityInspector({ entityStore: _entityStore, messageHub }: Entit
|
|||||||
const handleEntityDetails = (event: Event) => {
|
const handleEntityDetails = (event: Event) => {
|
||||||
const customEvent = event as CustomEvent;
|
const customEvent = event as CustomEvent;
|
||||||
const details = customEvent.detail;
|
const details = customEvent.detail;
|
||||||
console.log('[EntityInspector] Received entity details:', details);
|
|
||||||
setRemoteEntityDetails(details);
|
setRemoteEntityDetails(details);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -61,9 +60,7 @@ export function EntityInspector({ entityStore: _entityStore, messageHub }: Entit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Attempting to create component:', componentName);
|
|
||||||
const component = componentRegistry.createInstance(componentName);
|
const component = componentRegistry.createInstance(componentName);
|
||||||
console.log('Created component:', component);
|
|
||||||
|
|
||||||
if (component) {
|
if (component) {
|
||||||
selectedEntity.addComponent(component);
|
selectedEntity.addComponent(component);
|
||||||
|
|||||||
@@ -48,19 +48,14 @@ export function SceneHierarchy({ entityStore, messageHub }: SceneHierarchyProps)
|
|||||||
const profilerService = (window as any).__PROFILER_SERVICE__ as ProfilerService | undefined;
|
const profilerService = (window as any).__PROFILER_SERVICE__ as ProfilerService | undefined;
|
||||||
|
|
||||||
if (!profilerService) {
|
if (!profilerService) {
|
||||||
console.warn('[SceneHierarchy] ProfilerService not available');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[SceneHierarchy] Subscribing to ProfilerService');
|
|
||||||
|
|
||||||
const unsubscribe = profilerService.subscribe((data) => {
|
const unsubscribe = profilerService.subscribe((data) => {
|
||||||
const connected = profilerService.isConnected();
|
const connected = profilerService.isConnected();
|
||||||
console.log('[SceneHierarchy] Received data, connected:', connected, 'entities:', data.entities?.length || 0);
|
|
||||||
setIsRemoteConnected(connected);
|
setIsRemoteConnected(connected);
|
||||||
|
|
||||||
if (connected && data.entities && data.entities.length > 0) {
|
if (connected && data.entities && data.entities.length > 0) {
|
||||||
console.log('[SceneHierarchy] Setting remote entities:', data.entities);
|
|
||||||
setRemoteEntities(data.entities);
|
setRemoteEntities(data.entities);
|
||||||
} else {
|
} else {
|
||||||
setRemoteEntities([]);
|
setRemoteEntities([]);
|
||||||
|
|||||||
@@ -125,8 +125,7 @@ export class ProfilerService {
|
|||||||
private async startServer(): Promise<void> {
|
private async startServer(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const port = parseInt(this.wsPort);
|
const port = parseInt(this.wsPort);
|
||||||
const result = await invoke<string>('start_profiler_server', { port });
|
await invoke<string>('start_profiler_server', { port });
|
||||||
console.log('[ProfilerService]', result);
|
|
||||||
this.isServerRunning = true;
|
this.isServerRunning = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[ProfilerService] Failed to start server:', error);
|
console.error('[ProfilerService] Failed to start server:', error);
|
||||||
@@ -137,16 +136,13 @@ export class ProfilerService {
|
|||||||
if (this.ws) return;
|
if (this.ws) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log(`[ProfilerService] Connecting to ws://localhost:${this.wsPort}`);
|
|
||||||
const ws = new WebSocket(`ws://localhost:${this.wsPort}`);
|
const ws = new WebSocket(`ws://localhost:${this.wsPort}`);
|
||||||
|
|
||||||
ws.onopen = () => {
|
ws.onopen = () => {
|
||||||
console.log('[ProfilerService] Connected to profiler server');
|
|
||||||
this.notifyListeners(this.createEmptyData());
|
this.notifyListeners(this.createEmptyData());
|
||||||
};
|
};
|
||||||
|
|
||||||
ws.onclose = () => {
|
ws.onclose = () => {
|
||||||
console.log('[ProfilerService] Disconnected from profiler server');
|
|
||||||
this.ws = null;
|
this.ws = null;
|
||||||
|
|
||||||
// 如果服务器还在运行,尝试重连
|
// 如果服务器还在运行,尝试重连
|
||||||
@@ -186,7 +182,6 @@ export class ProfilerService {
|
|||||||
|
|
||||||
public requestEntityDetails(entityId: number): void {
|
public requestEntityDetails(entityId: number): void {
|
||||||
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
||||||
console.warn('[ProfilerService] Cannot request entity details: WebSocket not connected');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +191,6 @@ export class ProfilerService {
|
|||||||
requestId: `entity_details_${entityId}_${Date.now()}`,
|
requestId: `entity_details_${entityId}_${Date.now()}`,
|
||||||
entityId
|
entityId
|
||||||
};
|
};
|
||||||
console.log('[ProfilerService] Requesting entity details:', request);
|
|
||||||
this.ws.send(JSON.stringify(request));
|
this.ws.send(JSON.stringify(request));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[ProfilerService] Failed to request entity details:', error);
|
console.error('[ProfilerService] Failed to request entity details:', error);
|
||||||
@@ -251,7 +245,6 @@ export class ProfilerService {
|
|||||||
|
|
||||||
private requestRawEntityList(): void {
|
private requestRawEntityList(): void {
|
||||||
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
||||||
console.warn('[ProfilerService] Cannot request entity list: WebSocket not connected');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +253,6 @@ export class ProfilerService {
|
|||||||
type: 'get_raw_entity_list',
|
type: 'get_raw_entity_list',
|
||||||
requestId: `entity_list_${Date.now()}`
|
requestId: `entity_list_${Date.now()}`
|
||||||
};
|
};
|
||||||
console.log('[ProfilerService] Requesting entity list:', request);
|
|
||||||
this.ws.send(JSON.stringify(request));
|
this.ws.send(JSON.stringify(request));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[ProfilerService] Failed to request entity list:', error);
|
console.error('[ProfilerService] Failed to request entity list:', error);
|
||||||
@@ -269,12 +261,9 @@ export class ProfilerService {
|
|||||||
|
|
||||||
private handleRawEntityListResponse(data: any): void {
|
private handleRawEntityListResponse(data: any): void {
|
||||||
if (!data || !Array.isArray(data)) {
|
if (!data || !Array.isArray(data)) {
|
||||||
console.warn('[ProfilerService] Invalid raw entity list response:', data);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[ProfilerService] Received raw entity list, count:', data.length);
|
|
||||||
|
|
||||||
const entities: RemoteEntity[] = data.map((e: any) => ({
|
const entities: RemoteEntity[] = data.map((e: any) => ({
|
||||||
id: e.id,
|
id: e.id,
|
||||||
name: e.name || `Entity ${e.id}`,
|
name: e.name || `Entity ${e.id}`,
|
||||||
@@ -298,12 +287,9 @@ export class ProfilerService {
|
|||||||
|
|
||||||
private handleEntityDetailsResponse(data: any): void {
|
private handleEntityDetailsResponse(data: any): void {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
console.warn('[ProfilerService] Invalid entity details response:', data);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[ProfilerService] Received entity details:', data);
|
|
||||||
|
|
||||||
const entityDetails: RemoteEntityDetails = {
|
const entityDetails: RemoteEntityDetails = {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
name: data.name || `Entity ${data.id}`,
|
name: data.name || `Entity ${data.id}`,
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ export class ComponentLoaderService implements IService {
|
|||||||
componentInfos: ComponentFileInfo[],
|
componentInfos: ComponentFileInfo[],
|
||||||
modulePathTransform?: (filePath: string) => string
|
modulePathTransform?: (filePath: string) => string
|
||||||
): Promise<LoadedComponentInfo[]> {
|
): Promise<LoadedComponentInfo[]> {
|
||||||
logger.info(`Loading ${componentInfos.length} components`);
|
|
||||||
|
|
||||||
const loadedComponents: LoadedComponentInfo[] = [];
|
const loadedComponents: LoadedComponentInfo[] = [];
|
||||||
|
|
||||||
for (const componentInfo of componentInfos) {
|
for (const componentInfo of componentInfos) {
|
||||||
@@ -48,7 +46,6 @@ export class ComponentLoaderService implements IService {
|
|||||||
components: loadedComponents
|
components: loadedComponents
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info(`Successfully loaded ${loadedComponents.length} components`);
|
|
||||||
return loadedComponents;
|
return loadedComponents;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,20 +63,15 @@ export class ComponentLoaderService implements IService {
|
|||||||
|
|
||||||
if (modulePathTransform) {
|
if (modulePathTransform) {
|
||||||
const modulePath = modulePathTransform(componentInfo.path);
|
const modulePath = modulePathTransform(componentInfo.path);
|
||||||
logger.info(`Attempting to load component from: ${modulePath}`);
|
|
||||||
logger.info(`Looking for export: ${componentInfo.className}`);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const module = await import(/* @vite-ignore */ modulePath);
|
const module = await import(/* @vite-ignore */ modulePath);
|
||||||
logger.info(`Module loaded, exports:`, Object.keys(module));
|
|
||||||
|
|
||||||
componentClass = module[componentInfo.className] || module.default;
|
componentClass = module[componentInfo.className] || module.default;
|
||||||
|
|
||||||
if (!componentClass) {
|
if (!componentClass) {
|
||||||
logger.warn(`Component class ${componentInfo.className} not found in module exports`);
|
logger.warn(`Component class ${componentInfo.className} not found in module exports`);
|
||||||
logger.warn(`Available exports: ${Object.keys(module).join(', ')}`);
|
logger.warn(`Available exports: ${Object.keys(module).join(', ')}`);
|
||||||
} else {
|
|
||||||
logger.info(`Successfully loaded component class: ${componentInfo.className}`);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(`Failed to import component module: ${modulePath}`, error);
|
logger.error(`Failed to import component module: ${modulePath}`, error);
|
||||||
@@ -108,8 +100,6 @@ export class ComponentLoaderService implements IService {
|
|||||||
|
|
||||||
this.loadedComponents.set(componentInfo.path, loadedInfo);
|
this.loadedComponents.set(componentInfo.path, loadedInfo);
|
||||||
|
|
||||||
logger.info(`Component ${componentClass ? 'loaded' : 'metadata registered'}: ${componentInfo.className}`);
|
|
||||||
|
|
||||||
return loadedInfo;
|
return loadedInfo;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(`Failed to load component: ${componentInfo.fileName}`, error);
|
logger.error(`Failed to load component: ${componentInfo.fileName}`, error);
|
||||||
@@ -131,7 +121,6 @@ export class ComponentLoaderService implements IService {
|
|||||||
this.componentRegistry.unregister(loadedComponent.fileInfo.className);
|
this.componentRegistry.unregister(loadedComponent.fileInfo.className);
|
||||||
this.loadedComponents.delete(filePath);
|
this.loadedComponents.delete(filePath);
|
||||||
|
|
||||||
logger.info(`Component unloaded: ${loadedComponent.fileInfo.className}`);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +128,6 @@ export class ComponentLoaderService implements IService {
|
|||||||
for (const [filePath] of this.loadedComponents) {
|
for (const [filePath] of this.loadedComponents) {
|
||||||
this.unloadComponent(filePath);
|
this.unloadComponent(filePath);
|
||||||
}
|
}
|
||||||
logger.info('Cleared all loaded components');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private convertToModulePath(filePath: string): string {
|
private convertToModulePath(filePath: string): string {
|
||||||
@@ -148,6 +136,5 @@ export class ComponentLoaderService implements IService {
|
|||||||
|
|
||||||
public dispose(): void {
|
public dispose(): void {
|
||||||
this.clearLoadedComponents();
|
this.clearLoadedComponents();
|
||||||
logger.info('ComponentLoaderService disposed');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user