You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

29 lines
927 B

import type { AssetManager } from "@/core/AssetManager";
import { UiList } from "@/ui-core/UiList";
import { UiPanel } from "@/ui-core/UiPanel";
export class AssetWidget {
readonly element: HTMLDivElement;
private readonly list = new UiList();
private readonly assetManager: AssetManager;
constructor(assetManager: AssetManager) {
this.assetManager = assetManager;
const panel = new UiPanel("Assets");
panel.append(this.list.element);
this.element = panel.element;
this.render();
}
render(): void {
const snapshot = this.assetManager.getInspectorSnapshot();
const bundles = Object.entries(snapshot.bundles);
const sessions = Object.keys(snapshot.sessions);
const items = [
`sessions: ${sessions.length}`,
`bundles: ${bundles.length}`,
...bundles.slice(0, 5).map(([name, meta]) => `${name}: ref=${meta.refCount}`),
];
this.list.setItems(items);
}
}