Files
codegraph/__tests__/fixtures/factory-closure-ts/src/ui/panel.ts
T
Colby McHenry d49265043c test(explore): add the factory-closure fixture and its selection probe (CG-27)
A file whose top-level symbol spans almost all of it — createFoo() returning
an object of closures — is how Svelte 5 rune stores, React custom-hook modules,
IIFE module-pattern JS and Zustand's create((set,get)=>({…})) are all written.
probe-factory-closure.mjs measures what such a file DELIVERS from within: which
inner symbols' definitions reach the agent, not how many bytes did.
2026-08-06 13:58:36 -05:00

44 lines
1.2 KiB
TypeScript

import type { DashboardStore } from '../stores/dashboard-store';
import type { FilterSpec } from '../stores/types';
import { medianOf } from '../lib/metrics';
/** The dashboard panel — the only consumer of the store's closures. */
export function mountPanel(store: DashboardStore, dashboardId: string) {
let disposed = false;
const unsubscribe = store.subscribe((state) => {
if (disposed) return;
render(state.widgets.length, state.sampleCount, state.loading);
});
async function boot(): Promise<void> {
await store.loadWidgets(dashboardId);
await store.refreshMetrics();
store.reconcileLayout();
}
function search(text: string): void {
const specs: FilterSpec[] = text.trim().length === 0
? []
: [{ field: 'title', op: 'contains', value: text.trim() }];
store.applyFilter(specs);
}
function download(): string {
return store.exportCsv();
}
function render(widgetCount: number, sampleCount: number, loading: boolean): void {
void widgetCount;
void sampleCount;
void loading;
}
function dispose(): void {
disposed = true;
unsubscribe();
}
return { boot, search, download, dispose, median: medianOf };
}