(changed: GraphModule[], removed: string[])
| 2285 | } catch {} |
| 2286 | } |
| 2287 | function emitDelta(changed: GraphModule[], removed: string[]) { |
| 2288 | if (!wss) return; |
| 2289 | // Record this version's txn batch order |
| 2290 | try { |
| 2291 | const changedIds = changed.map((m) => m.id); |
| 2292 | if (changedIds.length) { |
| 2293 | const ordered = computeTxnOrderForChanged(changedIds); |
| 2294 | txnBatches.set(graphVersion, ordered); |
| 2295 | // Keep only the last ~20 versions |
| 2296 | if (txnBatches.size > 20) { |
| 2297 | const drop = Array.from(txnBatches.keys()) |
| 2298 | .sort((a, b) => a - b) |
| 2299 | .slice(0, txnBatches.size - 20); |
| 2300 | for (const k of drop) txnBatches.delete(k); |
| 2301 | } |
| 2302 | } |
| 2303 | } catch {} |
| 2304 | const payload = { |
| 2305 | type: 'ns:hmr-delta', |
| 2306 | baseVersion: graphVersion - 1, |
| 2307 | newVersion: graphVersion, |
| 2308 | changed: changed.map((m) => ({ id: m.id, deps: m.deps, hash: m.hash })), |
| 2309 | removed, |
| 2310 | }; |
| 2311 | const json = JSON.stringify(payload); |
| 2312 | wss.clients.forEach((c) => { |
| 2313 | try { |
| 2314 | c.send(json); |
| 2315 | } catch {} |
| 2316 | }); |
| 2317 | } |
| 2318 | function upsertGraphModule(rawId: string, code: string, deps: string[]) { |
| 2319 | const id = normalizeGraphId(rawId); |
| 2320 | const normDeps = deps |
no test coverage detected