MCPcopy Index your code
hub / github.com/codeaashu/claude-code / StatsProvider

Function StatsProvider

src/context/stats.tsx:104–156  ·  view source on GitHub ↗
(t0)

Source from the content-addressed store, hash-verified

102 children: React.ReactNode;
103};
104export function StatsProvider(t0) {
105 const $ = _c(7);
106 const {
107 store: externalStore,
108 children
109 } = t0;
110 let t1;
111 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
112 t1 = createStatsStore();
113 $[0] = t1;
114 } else {
115 t1 = $[0];
116 }
117 const internalStore = t1;
118 const store = externalStore ?? internalStore;
119 let t2;
120 let t3;
121 if ($[1] !== store) {
122 t2 = () => {
123 const flush = () => {
124 const metrics = store.getAll();
125 if (Object.keys(metrics).length > 0) {
126 saveCurrentProjectConfig(current => ({
127 ...current,
128 lastSessionMetrics: metrics
129 }));
130 }
131 };
132 process.on("exit", flush);
133 return () => {
134 process.off("exit", flush);
135 };
136 };
137 t3 = [store];
138 $[1] = store;
139 $[2] = t2;
140 $[3] = t3;
141 } else {
142 t2 = $[2];
143 t3 = $[3];
144 }
145 useEffect(t2, t3);
146 let t4;
147 if ($[4] !== children || $[5] !== store) {
148 t4 = <StatsContext.Provider value={store}>{children}</StatsContext.Provider>;
149 $[4] = children;
150 $[5] = store;
151 $[6] = t4;
152 } else {
153 t4 = $[6];
154 }
155 return t4;
156}
157export function useStats() {
158 const store = useContext(StatsContext);
159 if (!store) {

Callers

nothing calls this directly

Calls 3

createStatsStoreFunction · 0.85
onMethod · 0.80
offMethod · 0.80

Tested by

no test coverage detected