@0x1f320.sh/why-did-you-render-mcp 1.0.0-dev.2 → 1.0.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.cjs +28 -8
- package/dist/client/index.js +28 -8
- package/dist/server/index.js +4 -5
- package/package.json +1 -1
package/dist/client/index.cjs
CHANGED
|
@@ -75,17 +75,37 @@ function buildOptions(opts) {
|
|
|
75
75
|
if (ws?.readyState === WebSocket.OPEN) ws.send(JSON.stringify(msg));
|
|
76
76
|
else queue.push(msg);
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
let pendingBatch = null;
|
|
79
|
+
let flushScheduled = false;
|
|
80
|
+
function flushBatch() {
|
|
81
|
+
flushScheduled = false;
|
|
82
|
+
if (!pendingBatch || pendingBatch.reports.length === 0) return;
|
|
79
83
|
send({
|
|
80
|
-
type: "render",
|
|
84
|
+
type: "render-batch",
|
|
81
85
|
projectId,
|
|
82
|
-
commitId,
|
|
83
|
-
payload:
|
|
84
|
-
displayName: info.displayName,
|
|
85
|
-
reason: sanitizeReason(info.reason),
|
|
86
|
-
hookName: info.hookName
|
|
87
|
-
}
|
|
86
|
+
commitId: pendingBatch.commitId,
|
|
87
|
+
payload: pendingBatch.reports
|
|
88
88
|
});
|
|
89
|
+
pendingBatch = null;
|
|
90
|
+
}
|
|
91
|
+
return { notifier(info) {
|
|
92
|
+
const report = {
|
|
93
|
+
displayName: info.displayName,
|
|
94
|
+
reason: sanitizeReason(info.reason),
|
|
95
|
+
hookName: info.hookName
|
|
96
|
+
};
|
|
97
|
+
if (pendingBatch && pendingBatch.commitId === commitId) pendingBatch.reports.push(report);
|
|
98
|
+
else {
|
|
99
|
+
if (pendingBatch) flushBatch();
|
|
100
|
+
pendingBatch = {
|
|
101
|
+
commitId,
|
|
102
|
+
reports: [report]
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
if (!flushScheduled) {
|
|
106
|
+
flushScheduled = true;
|
|
107
|
+
queueMicrotask(flushBatch);
|
|
108
|
+
}
|
|
89
109
|
} };
|
|
90
110
|
}
|
|
91
111
|
//#endregion
|
package/dist/client/index.js
CHANGED
|
@@ -74,17 +74,37 @@ function buildOptions(opts) {
|
|
|
74
74
|
if (ws?.readyState === WebSocket.OPEN) ws.send(JSON.stringify(msg));
|
|
75
75
|
else queue.push(msg);
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
let pendingBatch = null;
|
|
78
|
+
let flushScheduled = false;
|
|
79
|
+
function flushBatch() {
|
|
80
|
+
flushScheduled = false;
|
|
81
|
+
if (!pendingBatch || pendingBatch.reports.length === 0) return;
|
|
78
82
|
send({
|
|
79
|
-
type: "render",
|
|
83
|
+
type: "render-batch",
|
|
80
84
|
projectId,
|
|
81
|
-
commitId,
|
|
82
|
-
payload:
|
|
83
|
-
displayName: info.displayName,
|
|
84
|
-
reason: sanitizeReason(info.reason),
|
|
85
|
-
hookName: info.hookName
|
|
86
|
-
}
|
|
85
|
+
commitId: pendingBatch.commitId,
|
|
86
|
+
payload: pendingBatch.reports
|
|
87
87
|
});
|
|
88
|
+
pendingBatch = null;
|
|
89
|
+
}
|
|
90
|
+
return { notifier(info) {
|
|
91
|
+
const report = {
|
|
92
|
+
displayName: info.displayName,
|
|
93
|
+
reason: sanitizeReason(info.reason),
|
|
94
|
+
hookName: info.hookName
|
|
95
|
+
};
|
|
96
|
+
if (pendingBatch && pendingBatch.commitId === commitId) pendingBatch.reports.push(report);
|
|
97
|
+
else {
|
|
98
|
+
if (pendingBatch) flushBatch();
|
|
99
|
+
pendingBatch = {
|
|
100
|
+
commitId,
|
|
101
|
+
reports: [report]
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
if (!flushScheduled) {
|
|
105
|
+
flushScheduled = true;
|
|
106
|
+
queueMicrotask(flushBatch);
|
|
107
|
+
}
|
|
88
108
|
} };
|
|
89
109
|
}
|
|
90
110
|
//#endregion
|
package/dist/server/index.js
CHANGED
|
@@ -344,11 +344,10 @@ function createWsServer(port) {
|
|
|
344
344
|
ws.on("message", (raw) => {
|
|
345
345
|
try {
|
|
346
346
|
const msg = JSON.parse(String(raw));
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
347
|
+
const projectId = msg.projectId ?? "default";
|
|
348
|
+
heartbeat.setProjectId(ws, projectId);
|
|
349
|
+
if (msg.type === "render") store.addRender(msg.payload, projectId, msg.commitId);
|
|
350
|
+
else if (msg.type === "render-batch") for (const report of msg.payload) store.addRender(report, projectId, msg.commitId);
|
|
352
351
|
} catch {
|
|
353
352
|
console.error("[wdyr-mcp] invalid message received");
|
|
354
353
|
}
|
package/package.json
CHANGED